上一页 1 2 3 4 5 6 7 ··· 17 下一页
摘要: CURL? 嗯,说来话长了~~~~ 这东西现在已经是苹果机上内置的命令行工具之一了,可见其魅力之一斑 1) 二话不说,先从这里开始吧! curl http://www.yahoo.com 回车之后,www.yahoo.com 的html就稀里哗啦地显示在屏幕上了~~~~~ 2) 嗯,要想把读过来页面存下来,是不是要这样呢? curl http://www.yahoo.com > page.html... 阅读全文
posted @ 2011-07-18 19:55 napoleon_liu 阅读(298) 评论(0) 推荐(0) 编辑
摘要: pstack.sh 改进版本#!/bin/bashif (( $# < 1 )) ; then echo "usage: `basename $0` pid" 1>&2 exit 1fi if [[ ! -r /proc/$1 ]] ; then echo "Process $1 not found." 1>&2 exit 1fi (gdb -quiet -nx /proc/$1/exe -p $1 <<EOFdefine my_dump_all_stackx \$pcbtendthread apply al 阅读全文
posted @ 2011-06-30 18:39 napoleon_liu 阅读(388) 评论(1) 推荐(0) 编辑
摘要: #!/bin/bash if (( $# < 1 )) then echo "usage: `basename $0` pid" 1>&2 exit 1 fiif [[ ! -r /proc/$1 ]] then echo "Process $1 not found." 1>&2 exit 1 fibacktrace="bt" if [[ -d /proc/$1/task ]] then if [[ `ls /proc/$1/task 2>/dev/null | wc -l` > 1 ]] 阅读全文
posted @ 2011-06-28 19:52 napoleon_liu 阅读(1035) 评论(1) 推荐(0) 编辑
摘要: 文章出处:http://www.limodev.cn/blog作者联系方式:李先静 <xianjimli at hotmail dot com> 我 已经写过两篇关于gdbserver调试共享库的BLOG了:第一篇解决了调试共享库的难题,让调试共享库成为可能,但是使用起来很麻烦。第二篇做了点改 进,通过一个脚本文件计算偏移量,使用起来稍微方便一点。几年过去了,gdbserver还是不支持调试共享库... 阅读全文
posted @ 2011-06-27 23:20 napoleon_liu 阅读(1880) 评论(1) 推荐(0) 编辑
摘要: Linux支持共享库已经有悠久的历史了,不再是什么新概念了。大家都知道如何编译、连接以及动态加载(dlopen/dlsym/dlclose) 共享库。但是,可能很多人,甚至包括一些高手,对共享库相关的一些环境变量认识模糊。当然,不知道这些环境变量,也可以用共享库,但是,若知道它们,可能就会用得更好。下面介绍一些常用的环境变量,希望对家有所帮助: LD_LIBRARY_PATH 这个环境变量是大家最... 阅读全文
posted @ 2011-06-27 23:10 napoleon_liu 阅读(1802) 评论(0) 推荐(0) 编辑
摘要: mtrace 可以用来检查内存泄漏。 它利用__malloc_hook机制,记录每一个内存分配的调用,在利用gcc的__builtin_return_address 获得函数的调用地址, 生成log文件。最后通过 程序中的调试信息和日志文件找出发生内存泄漏的函数。记住程序编译时要带上调试信息,不然只有地址了。利用LD_PRELOAD机制, 我们可以不需要修改程序就可以跟踪内存泄漏的问题。mtrace.so.cpp#include <mcheck.h> #include <stdlib.h> static void init() __attribute__((constr 阅读全文
posted @ 2011-06-02 10:21 napoleon_liu 阅读(954) 评论(0) 推荐(0) 编辑
摘要: 配置文件读取程序 conf.h#ifndef CONF_H_INCLUDE__#define CONF_H_INCLUDE__#include <string>#include <map>#include <sstream>#include <stdio.h>#include <stdlib.h>#include <string.h>#define CONF_BLANK_SEP "\t\v\r\n "class Conf { public: static std::string right_trim(s 阅读全文
posted @ 2011-05-16 18:30 napoleon_liu 阅读(706) 评论(0) 推荐(0) 编辑
摘要: #ifndef FILE_LOCK_H_INCLUDE_#define FILE_LOCK_H_INCLUDE_#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>class FileLock { public: explicit FileLock(int file_des) { m_file_des = file_des; } FileLock() { m_file_des = -1; } void attach(int fd) { m_ 阅读全文
posted @ 2011-05-13 18:34 napoleon_liu 阅读(551) 评论(2) 推荐(0) 编辑
摘要: 日志是程序的基本功能。有开源的log4j 到 c++的 log4cpp。 很多公司的项目也有自己的日志库。 log4cpp 这类日志库,实现了分离的线程和自己的缓存,这样可以最大化的减小 写日志模块被阻塞,这在一些不能阻塞的场景下是有意义。但是我们的应用很少需要这么高的要求,只要能打印日志,并控制大小就可以。所以我先实现了个轮转的日志。 就是打印满一个文件,就换新文件,并给老文件编号. 比如 my.log; my.log.1 ; my.log.2rotate_log.hpp#ifndef ROTATE_LOG_INC#define ROTATE_LOG_INC#include <sys/ 阅读全文
posted @ 2011-05-13 14:29 napoleon_liu 阅读(815) 评论(0) 推荐(0) 编辑
摘要: vim 写程序没有tags很麻烦, 如果你在一个新项目下,那更是麻烦。本脚本, 利用 gcc 的 -MMD选项生成文件依赖, 这样可以利用工程的makefile来生成 cscope和tags。 真是太强了。gen_cscope_tag.sh 内容如下:#!/bin/bashtarget="$*"is_gen_all=1;CSCOPE_DIR=.cscopeTAGS_DIR=.tagsCFLAGS+=-MMD make $targetexport CFLAGSfunction get_dep_files(){ sed -r -e 's/\s+/\n/g' | 阅读全文
posted @ 2011-05-06 19:36 napoleon_liu 阅读(2060) 评论(0) 推荐(1) 编辑
上一页 1 2 3 4 5 6 7 ··· 17 下一页