Hi, I am relatively new to this library, but find it very nifty to print a callstack on a crash.
I face some issues getting function names printed out on an Arm device I am working on.
First some backstory.
The compilers I am using to crosscompile for the platform are called
arm-openwrt-linux-muslgnueabi-gcc and arm-openwrt-linux-muslgnueabi-g++
I am using libunwind in a version that is bundled with the crosscompile environment. (1.1 or 1.2.1 - both versions are available as zipfiles in the toolchain)
I can choose them and compile programs that link againgst libunwind and I am allowed to execute them on the platform.
My backtrace function is this
void backtrace() {
unw_cursor_t cursor;
unw_context_t context;
// Initialize cursor to current frame for local unwinding.
unw_getcontext(&context);
unw_init_local(&cursor, &context);
// Unwind frames one by one, going up the frame stack.
while (unw_step(&cursor) > 0) {
unw_word_t pc;
unw_word_t offset;
unw_get_reg(&cursor, UNW_REG_IP, &pc);
if (pc == 0) {
break;
}
printf("%010p:", (void*)pc);
char sym[256];
if (unw_get_proc_name(&cursor, sym, sizeof(sym), &offset) == 0) {
printf(" (%s+0x%p)\n", sym, (void*)offset);
} else {
printf(" -- error: unable to obtain symbol name for this frame\n");
}
}
}
I get stacktraces like this: (Always without function names)
0x00016bb0: -- error: unable to obtain symbol name for this frame
0xb6fb9fac: -- error: unable to obtain symbol name for this frame
0x00016950: -- error: unable to obtain symbol name for this frame
0x00014db4: -- error: unable to obtain symbol name for this frame
0xb6f9c4ec: -- error: unable to obtain symbol name for this frame
I have tried a range of compiler flags to change this, but with little luck.
-g -funwind-tables -unwind-tables -fomit-frame-pointer -rdynamic -fasynchronous-unwind-tables -mapcs-frame
What could I be doing wrong? Or are function names just not accessible on ARM?
Kind regards
Jesper