Skip to content

Stack symbolization depends on where the source files resides #174

@subbota-a

Description

@subbota-a

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:

  1. add_executable(ver1 test.cpp stacktrace/backtrace.cpp stacktrace/from_exception.cpp)
  2. 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++

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions