]> sigrok.org Git - pulseview.git/commitdiff
Add stacktrace support
authorWolfram Sang <redacted>
Fri, 17 Apr 2020 13:43:27 +0000 (15:43 +0200)
committerUwe Hermann <redacted>
Sat, 2 May 2020 21:41:52 +0000 (23:41 +0200)
Use backtrace when available, otherwise the basic stacktracer.

This fixes bug #1150.

Signed-off-by: Wolfram Sang <redacted>
CMakeLists.txt

index ecaf6694234e8ce9c0b049b3814cb28644908a49..e157e7dbe934cc96c3f75a4b9b94d6cf94d7a3a3 100644 (file)
@@ -123,6 +123,14 @@ if(ENABLE_TESTS)
 endif()
 
 if(ENABLE_STACKTRACE)
+       include(FindBacktrace)
+       if (Backtrace_FOUND)
+               set(_Boost_STACKTRACE_BACKTRACE_HEADERS "boost/stacktrace.hpp")
+               list(APPEND BOOSTCOMPS stacktrace_backtrace)
+       else()
+               set(_Boost_STACKTRACE_BASIC_HEADERS     "boost/stacktrace.hpp")
+               list(APPEND BOOSTCOMPS stacktrace_basic)
+       endif()
        find_package(Boost 1.65.1 COMPONENTS ${BOOSTCOMPS} REQUIRED)
 else()
        find_package(Boost 1.55 COMPONENTS ${BOOSTCOMPS} REQUIRED)
@@ -465,7 +473,10 @@ if(ENABLE_SIGNALS)
 endif()
 
 if(ENABLE_STACKTRACE)
-       add_definitions(-DENABLE_STACKTRACE)
+       add_definitions(-DENABLE_STACKTRACE -no-pie -fno-pie)
+       if (Backtrace_FOUND)
+               add_definitions(-DBOOST_STACKTRACE_USE_BACKTRACE)
+       endif()
 endif()
 
 #===============================================================================
@@ -520,8 +531,8 @@ if(WIN32)
 endif()
 
 if(ENABLE_STACKTRACE)
-       # Needed to resolve dladdr.
-       list(APPEND PULSEVIEW_LINK_LIBS "-ldl")
+       list(APPEND PULSEVIEW_LINK_LIBS ${CMAKE_DL_LIBS} ${Backtrace_LIBRARIES})
+       link_libraries("-no-pie -fno-pie")
 endif()
 
 if(ANDROID)