Skip to content

Commit

Permalink
Fix backtrace
Browse files Browse the repository at this point in the history
  • Loading branch information
IonAgorria committed Mar 27, 2024
1 parent a39da5c commit 518707f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
39 changes: 26 additions & 13 deletions Source/XTool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,47 @@ ELSE()
SET(OPTION_DISABLE_STACKTRACE ON)
ELSE()
#https://www.boost.org/doc/libs/1_78_0/doc/html/stacktrace/configuration_and_build.html
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS})
IF(MSVC_CL_BUILD)
#Use WinDbg for MSVC
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS})

macro(setup_backtrace)
MESSAGE("Stacktrace: Using Backtrace")
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_BACKTRACE)
if(Backtrace_INCLUDE_DIRS)
include_directories(${Backtrace_INCLUDE_DIRS})
endif()
if(Backtrace_INCLUDE_DIR)
include_directories(${Backtrace_INCLUDE_DIR})
endif()
if(NOT Backtrace_LIBRARIES)
message("Backtrace_LIBRARIES not filled, using builtin")
set(Backtrace_LIBRARIES -lbacktrace)
endif()
SET(XTool_LINK_LIBS ${XTool_LINK_LIBS} ${Backtrace_LIBRARIES})
endmacro()
macro(setup_windbg)
MESSAGE("Stacktrace: Using WinDbg")
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_WINDBG)
SET(XTool_LINK_LIBS ${XTool_LINK_LIBS} ole32 dbgeng)
endmacro()

IF(MSVC_CL_BUILD)
#Use WinDbg for MSVC
setup_windbg()
ELSEIF(PERIMETER_WINDOWS)
#Use Backtrace if available in Msys/Mingw, else WinDbg
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${PREFER_STATIC_LIBRARY_SUFFIXES})
FIND_PACKAGE(Backtrace)
IF(Backtrace_FOUND AND OPTION_USE_BACKTRACE)
MESSAGE("Stacktrace: Using Backtrace")
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_BACKTRACE)
SET(XTool_LINK_LIBS ${XTool_LINK_LIBS} ${Backtrace_LIBRARIES})
setup_backtrace()
ELSE()
MESSAGE("Stacktrace: Using WinDbg")
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_WINDBG)
SET(XTool_LINK_LIBS ${XTool_LINK_LIBS} ole32 dbgeng)
setup_windbg()
ENDIF()
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${PREFER_DYNAMIC_LIBRARY_SUFFIXES})
ELSE()
#Use ADDR2LINE in POSIX unless Backtrace is wanted
FIND_PACKAGE(Backtrace)
IF(Backtrace_FOUND AND OPTION_USE_BACKTRACE)
MESSAGE("Stacktrace: Using Backtrace")
INCLUDE_DIRECTORIES(${Backtrace_INCLUDE_DIR} ${Backtrace_INCLUDE_DIRS})
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_BACKTRACE)
SET(XTool_LINK_LIBS ${XTool_LINK_LIBS} ${Backtrace_LIBRARIES})
setup_backtrace()
ELSE()
MESSAGE("Stacktrace: Using Addr2Line")
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_ADDR2LINE)
Expand Down
3 changes: 2 additions & 1 deletion perimeter.nix
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ in pkgs.stdenv.mkDerivation {
# Build / Runtime dependencies
buildInputs = with (if flag_static then pkgs.pkgsStatic else pkgs); [
zlib
libbacktrace
boost
ffmpeg
SDL2
Expand Down Expand Up @@ -133,4 +134,4 @@ in pkgs.stdenv.mkDerivation {

# fixup phase
dontStrip = true;
}
}

0 comments on commit 518707f

Please sign in to comment.