- added support for google-breakpad in linux

This commit is contained in:
Mark Vejvoda 2013-02-01 02:27:01 +00:00
parent bf71461d78
commit 71d5f24828
4 changed files with 167 additions and 4 deletions

View File

@ -0,0 +1,110 @@
# -*- cmake -*-
# - Find Google BreakPad
# Find the Google BreakPad includes and library
# This module defines
# BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR, where to find exception_handler.h, etc.
# BREAKPAD_EXCEPTION_HANDLER_LIBRARIES, the libraries needed to use Google BreakPad.
# BREAKPAD_EXCEPTION_HANDLER_FOUND, If false, do not try to use Google BreakPad.
# also defined, but not for general use are
# BREAKPAD_EXCEPTION_HANDLER_LIBRARY, where to find the Google BreakPad library.
SET(BREAKPAD_OS "linux")
IF(WIN32)
SET(BREAKPAD_OS "windows")
ENDIF()
FIND_PATH(BREAKPAD_INCLUDE_DIR
#common/breakpad_types.h
client/${BREAKPAD_OS}/handler/exception_handler.h
PATHS
${BREAKPAD_ROOT}/src/
)
IF(NOT GoogleBreakpad_FIND_COMPONENTS)
#SET(GoogleBreakpad_FIND_COMPONENTS common exception_handler client)
SET(GoogleBreakpad_FIND_COMPONENTS client)
ENDIF()
#IF(CMAKE_TRACE)
MESSAGE(STATUS "BREAKPAD_ROOT=${BREAKPAD_ROOT}")
MESSAGE(STATUS "BREAKPAD_INCLUDE_DIR=${BREAKPAD_INCLUDE_DIR}")
#ENDIF(CMAKE_TRACE)
IF(BREAKPAD_INCLUDE_DIR)
SET(BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR ${BREAKPAD_INCLUDE_DIR} ${BREAKPAD_INCLUDE_DIR}/client/${BREAKPAD_OS}/)
SET(BREAKPAD_FOUND TRUE)
FOREACH(COMPONENT ${GoogleBreakpad_FIND_COMPONENTS})
#string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
string(TOLOWER ${COMPONENT} UPPERCOMPONENT)
FIND_LIBRARY(BREAKPAD_${UPPERCOMPONENT}_LIBRARY_RELEASE
NAMES ${COMPONENT} libbreakpad_${COMPONENT}.a libbreakpad${COMPONENT}.a
PATHS
${BREAKPAD_ROOT}/src/client/${BREAKPAD_OS}/Release/lib
${BREAKPAD_INCLUDE_DIR}/src/client/${BREAKPAD_OS}/Release/lib
${BREAKPAD_ROOT}/src/client/${BREAKPAD_OS}/
${BREAKPAD_INCLUDE_DIR}/src/client/${BREAKPAD_OS}/
)
FIND_LIBRARY(BREAKPAD_${UPPERCOMPONENT}_LIBRARY_DEBUG
NAMES ${COMPONENT} libbreakpad_${COMPONENT}.a libbreakpad${COMPONENT}.a
PATHS
${BREAKPAD_ROOT}/src/client/${BREAKPAD_OS}/Debug/lib
${BREAKPAD_INCLUDE_DIR}/src/client/${BREAKPAD_OS}/Debug/lib
${BREAKPAD_ROOT}/src/client/${BREAKPAD_OS}/
${BREAKPAD_INCLUDE_DIR}/src/client/${BREAKPAD_OS}/
)
IF(BREAKPAD_${UPPERCOMPONENT}_LIBRARY_RELEASE OR BREAKPAD_${UPPERCOMPONENT}_LIBRARY_DEBUG)
SET(BREAKPAD_${UPPERCOMPONENT}_FOUND TRUE)
SET(BREAKPAD_${UPPERCOMPONENT}_LIBRARY optimized ${BREAKPAD_${UPPERCOMPONENT}_LIBRARY_RELEASE} debug ${BREAKPAD_${UPPERCOMPONENT}_LIBRARY_DEBUG})
set(BREAKPAD_${UPPERCOMPONENT}_LIBRARY ${BREAKPAD_${UPPERCOMPONENT}_LIBRARY} CACHE FILEPATH "The breakpad ${UPPERCOMPONENT} library")
set(BREAKPAD_EXCEPTION_HANDLER_FOUND TRUE)
set(BREAKPAD_EXCEPTION_HANDLER_LIBRARIES ${BREAKPAD_EXCEPTION_HANDLER_LIBRARIES} ${BREAKPAD_${UPPERCOMPONENT}_LIBRARY_RELEASE})
ELSE()
SET(BREAKPAD_FOUND FALSE)
SET(BREAKPAD_${UPPERCOMPONENT}_FOUND FALSE)
SET(BREAKPAD_${UPPERCOMPONENT}_LIBRARY "${BREAKPAD_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND}")
ENDIF()
# IF(CMAKE_TRACE)
MESSAGE(STATUS "Looking for ${UPPERCOMPONENT}")
MESSAGE(STATUS "BREAKPAD_${UPPERCOMPONENT}_LIBRARY_RELEASE=${BREAKPAD_${UPPERCOMPONENT}_LIBRARY_RELEASE}")
MESSAGE(STATUS "BREAKPAD_INCLUDE_DIR=${BREAKPAD_INCLUDE_DIR}")
# ENDIF(CMAKE_TRACE)
ENDFOREACH(COMPONENT)
ENDIF(BREAKPAD_INCLUDE_DIR)
IF(BREAKPAD_FOUND)
# IF(CMAKE_TRACE)
MESSAGE(STATUS "Looking for dump-symbols in: ${BREAKPAD_INCLUDE_DIR}/tools/${BREAKPAD_OS}/" )
# ENDIF(CMAKE_TRACE)
FIND_PROGRAM(BREAKPAD_DUMPSYMS_EXE
dump_syms NAMES dumpsyms dump_syms.exe
PATHS
ENV
PATH
${BREAKPAD_ROOT}/tools/${BREAKPAD_OS}/binaries
${BREAKPAD_INCLUDE_DIR}/tools/${BREAKPAD_OS}/binaries
${BREAKPAD_ROOT}/tools/${BREAKPAD_OS}/dump_syms
${BREAKPAD_INCLUDE_DIR}/tools/${BREAKPAD_OS}/dump_syms
${BREAKPAD_ROOT}/src/tools/${BREAKPAD_OS}/binaries
${BREAKPAD_INCLUDE_DIR}/src/tools/${BREAKPAD_OS}/binaries
${BREAKPAD_ROOT}/src/tools/${BREAKPAD_OS}/dump_syms
${BREAKPAD_INCLUDE_DIR}/src/tools/${BREAKPAD_OS}/dump_syms
)
# IF(CMAKE_TRACE)
MESSAGE(STATUS "Looking for dump-symbols result: ${BREAKPAD_DUMPSYMS_EXE}" )
# ENDIF(CMAKE_TRACE)
IF(BREAKPAD_DUMPSYMS_EXE)
SET(BREAKPAD_DUMPSYMS_EXE_FOUND TRUE)
ELSE(BREAKPAD_DUMPSYMS_EXE)
SET(BREAKPAD_DUMPSYMS_EXE_FOUND FALSE)
#SET(BREAKPAD_FOUND FALSE)
ENDIF(BREAKPAD_DUMPSYMS_EXE)
ENDIF(BREAKPAD_FOUND)

View File

@ -233,6 +233,17 @@ IF(BUILD_MEGAGLEST)
SET(MG_STREFLOP "streflop")
ENDIF()
find_package( GoogleBreakpad )
if(BREAKPAD_EXCEPTION_HANDLER_FOUND AND BREAKPAD_EXCEPTION_HANDLER_LIBRARIES)
add_definitions(-DHAVE_GOOGLE_BREAKPAD)
include_directories( ${BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR} )
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${BREAKPAD_EXCEPTION_HANDLER_LIBRARIES})
else()
message("** WARNING: Could not find GoogleBreakpad. Disabling GoogleBreakpad support.")
endif()
IF(WIN32)
TARGET_LINK_LIBRARIES(${TARGET_NAME} stdc++ gcc odbc32 wsock32 winspool winmm shell32 comctl32 ctl3d32 advapi32 wsock32 opengl32 glu32 ole32 oleaut32 uuid mingw32 ddraw dsound dxguid ws2_32 iphlpapi wsock32 libogg libvorbis libvorbisfile zlib jpeg libpng xerces-c2_8_0 OpenAL32 libcurl winmm gdi32 opengl32 glu32 SDL SDLmain lua5.1 ${MG_STREFLOP} libmegaglest stdc++ moldname mingwex msvcrt user32 kernel32)
ENDIF()

View File

@ -16,7 +16,7 @@
#endif
#ifdef HAVE_GOOGLE_BREAKPAD
#include "exception_handler.h"
#include "handler/exception_handler.h"
#endif
#include "math_wrapper.h"
@ -1426,9 +1426,17 @@ void setupLogging(Config &config, bool haveSpecialOutputCommandLineOption) {
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 In setting up errorHandlerPtr->set_dump_path...\n");
#if defined(WIN32)
wstring dumpfilepath = utf8_decode(dumpFilePath);
if(SystemFlags::VERBOSE_MODE_ENABLED) wprintf(L"Hooking up google_breakpad::ExceptionHandler to save dmp files to [%s]...\n",dumpfilepath.c_str());
errorHandlerPtr->set_dump_path(dumpfilepath);
#else
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Hooking up google_breakpad::ExceptionHandler to save dmp files to [%s]...\n",dumpFilePath.c_str());
//errorHandlerPtr->set_dump_path(dumpfilepath);
google_breakpad::MinidumpDescriptor descriptor(dumpFilePath);
errorHandlerPtr->set_minidump_descriptor(descriptor);
#endif
}
#endif
@ -5171,6 +5179,7 @@ void handleSIGSEGV(int sig) {
#if defined(HAVE_GOOGLE_BREAKPAD)
#if defined(WIN32)
// Callback when minidump written.
static bool MinidumpCallback(const wchar_t *dump_path,
const wchar_t *minidump_id,
@ -5181,15 +5190,31 @@ static bool MinidumpCallback(const wchar_t *dump_path,
printf("\n======= In MinidumpCallback...\n");
wprintf(L"\n***ERROR details captured:\nCrash minidump folder: %s\nfile: %s.dmp\nSucceeded: %d\n", (dump_path != NULL ? dump_path : L"(null)"),(minidump_id != NULL ? minidump_id : L"(null)"),succeeded);
#ifdef WIN32
wchar_t szBuf[8096];
_snwprintf(szBuf,8096,L"An unhandled error was detected.\n\nA crash dump file has been created in the folder:\n%s\nCrash dump filename is: %s.dmp",dump_path,minidump_id);
MessageBox(NULL, szBuf, L"Unhandled error", MB_OK|MB_SYSTEMMODAL);
return succeeded;
}
#else
// Callback when minidump written.
static bool MinidumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
void* context,
bool succeeded) {
printf("\n======= In MinidumpCallback...\n");
printf("\n***ERROR details captured:\nCrash minidump folder: %s\nfile: %s\nSucceeded: %d\n", descriptor.directory().c_str(),descriptor.path(),succeeded);
char szBuf[8096];
snprintf(szBuf,8096,"An unhandled error was detected.\n\nA crash dump file has been created in the folder:\n%s\nCrash dump filename is: %s.dmp",descriptor.directory().c_str(),descriptor.path());
//MessageBox(NULL, szBuf, "Unhandled error", MB_OK|MB_SYSTEMMODAL);
return succeeded;
}
#endif
return succeeded;
}
#endif
#ifdef WIN32
@ -5238,9 +5263,15 @@ int glestMainWrapper(int argc, char** argv) {
//}
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Hooking up google_breakpad::ExceptionHandler...\n");
#if defined(WIN32)
wstring dumpfilepath = utf8_decode(".");
//google_breakpad::ExceptionHandler handler(dumpfilepath, NULL, MinidumpCallback, NULL, true);
errorHandlerPtr.reset(new google_breakpad::ExceptionHandler(dumpfilepath, NULL, MinidumpCallback, NULL, true));
#else
google_breakpad::MinidumpDescriptor descriptor(".");
errorHandlerPtr.reset(new google_breakpad::ExceptionHandler(descriptor, NULL, MinidumpCallback, NULL, true,-1));
#endif
// ExceptionHandler(const wstring& dump_path,
// FilterCallback filter,
// MinidumpCallback callback,

View File

@ -262,6 +262,17 @@ option(ENABLE_FRIBIDI "Enable FriBIDi support" ON)
message("Could not find FriBiDi. Disabling FriBiDi support.")
endif()
find_package( GoogleBreakpad )
if(BREAKPAD_EXCEPTION_HANDLER_FOUND AND BREAKPAD_EXCEPTION_HANDLER_LIBRARIES)
add_definitions(-DHAVE_GOOGLE_BREAKPAD)
#include_directories( ${BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR} )
#SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${BREAKPAD_EXCEPTION_HANDLER_LIBRARIES})
else()
message("** WARNING: Could not find GoogleBreakpad. Disabling GoogleBreakpad support.")
endif()
#########################################################################################
# megaglest lib