ianlancetaylor / libbacktrace

A C library that may be linked into a C/C++ program to produce symbolic backtraces
Other
944 stars 220 forks source link

Unlike GDB, LLVM ORC generated functions are not resolved #121

Open paniq opened 4 months ago

paniq commented 4 months ago

Enthusiastically I plugged libbacktrace into our LLVM JIT hosted language, only to discover that unlike GDB, it can't resolve functions generated by LLVM at runtime. Here's an example output; backtrace_print vs gdb bt:

0x7fffe2db50c4 ???
        ???:0
0x7fffe2db5034 ???
        ???:0
0x7ffff2e08fe3 ???
        ???:0
0x7fffea9c90ba ???
        ???:0
0x7fffea9c3ff8 ???
        ???:0
0x7fffea9c2089 ???
        ???:0
0x7ffff370090a _ZN6scopes8try_mainEv
        ../src/boot.cpp:353
0x7ffff3700a1e _ZN6scopes8run_mainEv
        ../src/boot.cpp:382
0x7ffff28b2d8f __libc_start_call_main
        ../sysdeps/nptl/libc_start_call_main.h:58
0x7ffff28b2e3f __libc_start_main_impl
        ../csu/libc-start.c:392
0x401074 ???
        ???:0
0xffffffffffffffff ???
        ???:0

Thread 1 "scopes" received signal SIGABRT, Aborted.
__pthread_kill_implementation (no_tid=0, signo=6, threadid=140737262092736) at ./nptl/pthread_kill.c:44
44      ./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737262092736) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140737262092736) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=140737262092736, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007ffff28cb476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007ffff28b17f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007fffe2db50ea in /redacted/scopes/testing/compiler/test_backtrace.sc:1 ()
    at /redacted/scopes/testing/compiler/test_backtrace.sc:14
#6  0x00007fffe2db5035 in /redacted/scopes/testing/compiler/test_backtrace.sc:1 ()
    at /redacted/scopes/testing/compiler/test_backtrace.sc:1
#7  0x00007ffff2e08fe4 in exec-module () at /redacted/scopes/lib/scopes/core.sc:5216
#8  0x00007fffea9c90bb in load-module () at /redacted/scopes/lib/scopes/core.sc:5322
#9  0x00007fffea9c3ff9 in run-main () at /redacted/scopes/lib/scopes/core.sc:11654
#10 0x00007fffea9c208a in /redacted/scopes/lib/scopes/core.sc:11420 ()
    at /redacted/scopes/lib/scopes/core.sc:11664
#11 0x00007ffff370090b in scopes::try_main () at ../src/boot.cpp:353
#12 0x00007ffff3700a1f in scopes::run_main () at ../src/boot.cpp:382
#13 0x00007ffff28b2d90 in __libc_start_call_main (main=main@entry=0x401150 <main(int, char**)>, argc=argc@entry=2, 
    argv=argv@entry=0x7fffffffd788) at ../sysdeps/nptl/libc_start_call_main.h:58
#14 0x00007ffff28b2e40 in __libc_start_main_impl (main=0x401150 <main(int, char**)>, argc=2, argv=0x7fffffffd788, 
    init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd778) at ../csu/libc-start.c:392
#15 0x0000000000401075 in _start ()
ianlancetaylor commented 4 months ago

Do you know how gdb is able to find that information? Do you know of any documentation? Thanks.