Questions tagged «backtrace»


5
如何使backtrace()/ backtrace_symbols()打印函数名称?
特定于Linux,backtrace()并backtrace_symbols()允许您生成程序的调用跟踪。但是,它仅打印函数地址,而不显示我程序的名称。如何使它们也打印函数名称?我试着编译程序-g以及-ggdb。下面的测试用例仅显示以下内容: 回溯------------ ./a.out()[0x8048616] ./a.out()[0x8048623] /lib/libc.so.6(__libc_start_main+0xf3)[0x4a937413] ./a.out()[0x8048421] ---------------------- 我希望前2个项目也显示函数名称,foo并且main 码: #include <execinfo.h> #include <string.h> #include <errno.h> #include <unistd.h> #include <stdlib.h> static void full_write(int fd, const char *buf, size_t len) { while (len > 0) { ssize_t ret = write(fd, buf, len); if ((ret == -1) && (errno != EINTR)) break; buf …
90 c  linux  debugging  backtrace 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.