remove libunwind
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <libunwind.h>
|
// #include <libunwind.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
void customFunction1(int n);
|
void customFunction1(int n);
|
||||||
@@ -7,38 +7,38 @@ void customFunction2(int n);
|
|||||||
void customFunction3(int n);
|
void customFunction3(int n);
|
||||||
|
|
||||||
// Call this function to get a backtrace.
|
// Call this function to get a backtrace.
|
||||||
void backtrace() {
|
// void backtrace() {
|
||||||
unw_cursor_t cursor;
|
// unw_cursor_t cursor;
|
||||||
unw_context_t context;
|
// unw_context_t context;
|
||||||
|
|
||||||
// Initialize cursor to current frame for local unwinding.
|
// // Initialize cursor to current frame for local unwinding.
|
||||||
unw_getcontext(&context);
|
// unw_getcontext(&context);
|
||||||
unw_init_local(&cursor, &context);
|
// unw_init_local(&cursor, &context);
|
||||||
|
|
||||||
// Unwind frames one by one, going up the frame stack.
|
// // Unwind frames one by one, going up the frame stack.
|
||||||
while (unw_step(&cursor) > 0) {
|
// while (unw_step(&cursor) > 0) {
|
||||||
unw_word_t offset, pc;
|
// unw_word_t offset, pc;
|
||||||
unw_get_reg(&cursor, UNW_REG_IP, &pc);
|
// unw_get_reg(&cursor, UNW_REG_IP, &pc);
|
||||||
if (pc == 0) {
|
// if (pc == 0) {
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
printf("0x%lx:", pc);
|
// printf("0x%lx:", pc);
|
||||||
|
|
||||||
char sym[256];
|
// char sym[256];
|
||||||
if (unw_get_proc_name(&cursor, sym, sizeof(sym), &offset) == 0) {
|
// if (unw_get_proc_name(&cursor, sym, sizeof(sym), &offset) == 0) {
|
||||||
printf(" (%s+0x%lx)\n", sym, offset);
|
// printf(" (%s+0x%lx)\n", sym, offset);
|
||||||
} else {
|
// } else {
|
||||||
printf(" -- error: unable to obtain symbol name for this frame\n");
|
// printf(" -- error: unable to obtain symbol name for this frame\n");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
void customFunction1(int n) {
|
void customFunction1(int n) {
|
||||||
if(n <= 0) {
|
if(n <= 0) {
|
||||||
printf("End of recursion\n");
|
printf("End of recursion\n");
|
||||||
// output backtrace
|
// output backtrace
|
||||||
printf("pid: %d\n", getpid());
|
printf("pid: %d\n", getpid());
|
||||||
backtrace();
|
// backtrace();
|
||||||
while (1) {
|
while (1) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
} // never return, keep stack
|
} // never return, keep stack
|
||||||
|
|||||||
Reference in New Issue
Block a user