From 34c3899c0cb28a22404380b0626bbfe872dcf6b4 Mon Sep 17 00:00:00 2001 From: Zhanglong Xia Date: Sat, 17 Jun 2023 04:01:34 +0800 Subject: [PATCH] [build] add -rdynamic to the linker flags (#1909) 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 ------------------ --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index df7c2302289..4fefd2798b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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")