gpt4 book ai didi

c - 如何获得更详细的回溯

转载 作者:IT王子 更新时间:2023-10-29 00:19:37 25 4
gpt4 key购买 nike

<分区>

我正在尝试在我的 C++ 程序终止时打印回溯。函数打印回溯如下;

   void print_backtrace(void){

void *tracePtrs[10];
size_t count;

count = backtrace(tracePtrs, 10);

char** funcNames = backtrace_symbols(tracePtrs, count);

for (int i = 0; i < count; i++)
syslog(LOG_INFO,"%s\n", funcNames[i]);

free(funcNames);

}

它给出了这样的输出;

   desktop program: Received SIGSEGV signal, last error is : Success
desktop program: ./program() [0x422225]
desktop program: ./program() [0x422371]
desktop program: /lib/libc.so.6(+0x33af0) [0x7f0710f75af0]
desktop program: /lib/libc.so.6(+0x12a08e) [0x7f071106c08e]
desktop program: ./program() [0x428895]
desktop program: /lib/libc.so.6(__libc_start_main+0xfd) [0x7f0710f60c4d]
desktop program: ./program() [0x4082c9]

有没有办法通过函数名称和行获得更详细的回溯,例如 gdb 输出?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com