stacktrace
stacktrace copied to clipboard
Stack symbolization depends on where the source files resides
For some reasons I started to use stacktrace library injecting the source files to my project. And it turned out that the result depends on how to build the project.
/project
---/stacktrace
--- backtrace.cpp
--- from_exception.cpp
--- CMakeLists.txt which add_library(stacktrace backtrace.cpp from_exception.cpp)
test.cpp
CMakeLists.txt
And I build two versions of executable:
- add_executable(ver1 test.cpp stacktrace/backtrace.cpp stacktrace/from_exception.cpp)
- add_executable(ver2 test.cpp) + target_link_libraries(ver2 stacktrace)
The ver1 shows stack as
0# foo() in /opt/test
1# main in /opt/test
2# 0x00007FE22EAA8D90 in /lib/x86_64-linux-gnu/libc.so.6
3# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
4# _start in /opt/test
The ver2 show stack as
0# 0x000055FEA0E2D528 in /opt/test
1# 0x000055FEA0E2CA13 in /opt/test
2# 0x00007F11801E7D90 in /lib/x86_64-linux-gnu/libc.so.6
3# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
4# 0x000055FEA0E2C905 in /opt/test
Can you help me to understand what's going on?
Code for reproduction is here I use clang-17 and libc++