Skip to content

Commit

Permalink
[build] add -rdynamic to the linker flags (#1909)
Browse files Browse the repository at this point in the history
When the otbr-agent is crashed, the platform will output the backtrace
info. Without the "-rdynamic" flags, the backtrace info only contains
the address of the backtrace functions. This commit adds the "-rdynamic"
flags to linker flags to make the backtrace module to be able to parse
the function name from the function address.

Example of the backtrace ouput after adding -rdynamic flag:

[C] Platform------: ------------------ BEGINNING OF CRASH -------------
[C] Platform------: *** FATAL ERROR: Caught signal: 8 (Floating point exception)
[C] Platform------: # 0: ./build/otbr/src/agent/otbr-agent(+0x18b89d) [0x55b56df0b89d]
[C] Platform------: # 1: ./build/otbr/src/agent/otbr-agent(+0x18b9c8) [0x55b56df0b9c8]
[C] Platform------: # 2: /lib/x86_64-linux-gnu/libc.so.6(+0x3bf90) [0x7f1f84c5af90]
[C] Platform------: # 3: ./build/otbr/src/agent/otbr-agent otbr::Ncp::ControllerOpenThread::Init()+0x146 [0x6dfd4dda]
[C] Platform------: # 4: ./build/otbr/src/agent/otbr-agent otbr::Application::Init()+0x1e [0x6decbfbc]
[C] Platform------: # 5: ./build/otbr/src/agent/otbr-agent(+0x14d97d) [0x55b56decd97d]
[C] Platform------: # 6: ./build/otbr/src/agent/otbr-agent main+0x92 [0x6decdb88]
[C] Platform------: # 7: /lib/x86_64-linux-gnu/libc.so.6(+0x2718a) [0x7f1f84c4618a]
[C] Platform------: # 8: /lib/x86_64-linux-gnu/libc.so.6 __libc_start_main+0x85 [0x84c46245]
[C] Platform------: # 9: ./build/otbr/src/agent/otbr-agent _start+0x21 [0x6decbd81]
[C] Platform------: ------------------ END OF CRASH ------------------
  • Loading branch information
zhanglongxia committed Jun 16, 2023
1 parent 1cbc34c commit 34c3899
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ if(NOT CMAKE_CXX_STANDARD)
endif()

set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXE_LINKER_FLAGS "-rdynamic ${CMAKE_EXE_LINKER_FLAGS}")

if (OTBR_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
message(STATUS "Coverage: ON")
Expand Down

0 comments on commit 34c3899

Please sign in to comment.