#define BT_BUF_SIZE 4096
void PrintBackTrace() {
int j, nptrs;
void *buffer[BT_BUF_SIZE];
char **strings;
nptrs = backtrace(buffer, BT_BUF_SIZE);
strings = backtrace_symbols(buffer, nptrs);
if (strings == NULL) {
return;
}
for (j = 0; j < nptrs; j++)
printf("[backtrace] %s\n", strings[j]);
free(strings);
}
[DEMO] 打印backtrace
于 2023-02-20 16:58:39 首次发布