2014年4月24日

被strncpy搞糊涂的snprintf

摘要: 摘自man文档: The strncpy() function is similar, except that at most n bytes of src are copied. Warning: If there is no null byte among the first n bytes of src, the string placed in dest will not benull-t... 阅读全文

posted @ 2014-04-24 15:45 techsunny 阅读(316) 评论(0) 推荐(0) 编辑

利用backtrace跟踪程序的调用堆栈

摘要: 通过backtrace()函数可以获得当前的程序堆栈地址. 提供一个指针数组, backtrace()函数会把调用堆栈的地址填到里面.#include int backtrace(void **buffer, int size);为了跟踪动态库, 需要给gcc添加-rdynamic参数. 另外, 为了看到函数名, 行号等调试信息, 还要添加-g参数.-rdynamic参数的涵义:This inst... 阅读全文

posted @ 2014-04-24 15:31 techsunny 阅读(2961) 评论(0) 推荐(1) 编辑

导航