diff --git a/Modules/BreakpadCrashReporting/CMakeLists.txt b/Modules/BreakpadCrashReporting/CMakeLists.txt index 5e609c435d..3acecde186 100644 --- a/Modules/BreakpadCrashReporting/CMakeLists.txt +++ b/Modules/BreakpadCrashReporting/CMakeLists.txt @@ -1,33 +1,36 @@ # TODOs # LATER nicer separation of Linux/Window/.. code # OK test should check existence of dump file # - find nice script to use linux symbol writer tool dump_.. on all relevant libraries # - update documentation # OK check buildtype (O2/-g/..) in cmake # OK use the same library structure in "our" cmake script as google uses in their build # OK otherwise we cannot switch between custom-built versions of breakpad and our superbuild version # [optional] add install step to our Breakpad build if(MITK_USE_Breakpad) # from top-level CMakeLists.txt find_package(Breakpad) if (NOT Breakpad_FOUND) message(FATAL_ERROR "MITK_USE_Breakpad was set but Breakpad build cannot be found. Plaese check CMake cache variables regarding Breakpad") endif() MITK_CREATE_MODULE(BreakpadCrashReporting INTERNAL_INCLUDE_DIRS ${Breakpad_INCLUDE_DIR} ADDITIONAL_LIBS ${Breakpad_LIBRARIES} FORCE_STATIC ) if(CMAKE_SYSTEM MATCHES "Windows") add_executable(CrashReportingServer mitkCrashReportingServer.cpp) target_link_libraries(CrashReportingServer ${ALL_LIBRARIES} BreakpadCrashReporting) MITK_INSTALL(TARGETS CrashReportingServer) endif() + if(CMAKE_SYSTEM MATCHES "Linux") + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ProduceBreakpadSymbols.sh.in ${MITK_CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ProduceBreakpadSymbols.sh) + endif() add_subdirectory(Testing) endif(MITK_USE_Breakpad) diff --git a/Modules/BreakpadCrashReporting/ProduceBreakpadSymbols.sh.in b/Modules/BreakpadCrashReporting/ProduceBreakpadSymbols.sh.in new file mode 100755 index 0000000000..4b8f168cf8 --- /dev/null +++ b/Modules/BreakpadCrashReporting/ProduceBreakpadSymbols.sh.in @@ -0,0 +1,34 @@ +#!/bin/bash +# +# This script can be used to convert the debugging symbols of binaries to text-format symbol files. +# This needs to be done so that Breakpad can produce useful stack traces. +# The script takes as argument the path to the binary for which the symbols should be converted. +# +# To produce the stack trace use the application @Breakpad_DIR@/minidump_stackwalk +# For further details have a look at the offical documentation of google breakpad: https://code.google.com/p/google-breakpad/wiki/LinuxStarterGuide + +# path to binary +BINARY_PATH=$1 + +# path to dump_sys +DUMPSYMS=@Breakpad_DIR@/dump_syms + +# output path +OUTPUT=@MITK_CMAKE_RUNTIME_OUTPUT_DIRECTORY@/CrashDumps + +# if output folder does not exist yet +mkdir -p $OUTPUT + +OUTPUTFILEPATH=$OUTPUT/symbols.sym + +$DUMPSYMS $BINARY_PATH > $OUTPUTFILEPATH + +HASH=$(head -n1 $OUTPUTFILEPATH | awk '{ print $4 }' ) +echo $HASH + +EXENAME=$(head -n1 $OUTPUTFILEPATH | awk '{ print $5 }' ) +echo $EXENAME + +mkdir -p $OUTPUT/./symbols/$EXENAME/$HASH +mv $OUTPUTFILEPATH $OUTPUT/./symbols/$EXENAME/$HASH +