1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Breakpad integration

Provide your own breakpad and point cmake at it.

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
mkdir breakpad && cd breakpad
../depot_tools/fetch breakpad # edit the script to use python2
cd src
LDFLAGS="-m32" CXXFLAGS="-m32" CFLAGS="-m32" CPPFLAGS="-m32" ./configure
LDFLAGS="-m32" CXXFLAGS="-m32" CFLAGS="-m32" CPPFLAGS="-m32" make -j 8

Run cmake on openrct2:
cd openrct2
vim CMakeLists.txt # provide your path to breakpad
mkdir build && cd build
cmake ../ -DWITH_BREAKPAD=ON
make -j 8
./openrct2 # open a game, select "about openrct2", crash
This commit is contained in:
Michał Janiszewski
2016-04-03 22:41:24 +02:00
parent 8494eb9ff3
commit e28de49a34
4 changed files with 56 additions and 3 deletions

View File

@@ -143,6 +143,16 @@ if (STATIC)
endif (WIN32) endif (WIN32)
endif () endif ()
option(WITH_BREAKPAD "Enable breakpad")
if (WITH_BREAKPAD)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_BREAKPAD")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BREAKPAD")
set(BREAKPAD_DIR "/home/janisozaur/workspace/breakpad/src")
set(BREAKPAD_INCLUDE_DIR "${BREAKPAD_DIR}/src")
set(BREAKPAD_LIBRARY_DIR "${BREAKPAD_DIR}/src/client/linux")
set(BREAKPAD_LIBS breakpad_client pthread)
endif (WITH_BREAKPAD)
# find and include SDL2 # find and include SDL2
PKG_CHECK_MODULES(SDL2 REQUIRED sdl2 SDL2_ttf) PKG_CHECK_MODULES(SDL2 REQUIRED sdl2 SDL2_ttf)
if (STATIC) if (STATIC)
@@ -180,9 +190,9 @@ if (UNIX)
set(DLLIB dl) set(DLLIB dl)
endif (UNIX) endif (UNIX)
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS} ${LIBCURL_INCLUDE_DIRS} ${JANSSON_INCLUDE_DIRS} ${SPEEX_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS} ${LIBCURL_INCLUDE_DIRS} ${JANSSON_INCLUDE_DIRS} ${SPEEX_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${BREAKPAD_INCLUDE_DIR})
LINK_DIRECTORIES(${SDL2_LIBRARY_DIRS} ${JANSSON_LIBRARY_DIRS} ${LIBCURL_LIBRARY_DIRS} ${PNG_LIBRARY_DIRS} ${ZLIB_LIBRARY_DIRS}) LINK_DIRECTORIES(${SDL2_LIBRARY_DIRS} ${JANSSON_LIBRARY_DIRS} ${LIBCURL_LIBRARY_DIRS} ${PNG_LIBRARY_DIRS} ${ZLIB_LIBRARY_DIRS} ${BREAKPAD_LIBRARY_DIR})
if (WIN32) if (WIN32)
# build as library for now, replace with add_executable # build as library for now, replace with add_executable
@@ -215,7 +225,7 @@ endif (UNIX AND NOT APPLE)
# libopenrct2.dll -> openrct2.dll # libopenrct2.dll -> openrct2.dll
set_target_properties(${PROJECT} PROPERTIES PREFIX "") set_target_properties(${PROJECT} PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2LIBS} ${HTTPLIBS} ${NETWORKLIBS} ${SPEEX_LIBRARIES} ${DLLIB} ${REQUIREDLIBS}) TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2LIBS} ${HTTPLIBS} ${NETWORKLIBS} ${SPEEX_LIBRARIES} ${DLLIB} ${REQUIREDLIBS} ${BREAKPAD_LIBS})
if (APPLE OR STATIC) if (APPLE OR STATIC)
FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c) FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c)

View File

@@ -39,6 +39,7 @@
#include "util/sawyercoding.h" #include "util/sawyercoding.h"
#include "util/util.h" #include "util/util.h"
#include "world/mapgen.h" #include "world/mapgen.h"
#include "platform/breakpad.h"
#if defined(__unix__) #if defined(__unix__)
#include <sys/mman.h> #include <sys/mman.h>
@@ -263,6 +264,12 @@ bool openrct2_initialise()
*/ */
void openrct2_launch() void openrct2_launch()
{ {
#ifdef USE_BREAKPAD
CExceptionHandler eh;
// never free
eh = newCExceptionHandlerSimple();
#endif // USE_BREAKPAD
if (openrct2_initialise()) { if (openrct2_initialise()) {
RCT2_GLOBAL(RCT2_ADDRESS_RUN_INTRO_TICK_PART, uint8) = 0; RCT2_GLOBAL(RCT2_ADDRESS_RUN_INTRO_TICK_PART, uint8) = 0;
if((gOpenRCT2StartupAction == STARTUP_ACTION_TITLE) && gConfigGeneral.play_intro) if((gOpenRCT2StartupAction == STARTUP_ACTION_TITLE) && gConfigGeneral.play_intro)

19
src/platform/breakpad.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include "breakpad.h"
#ifdef USE_BREAKPAD
#include "client/linux/handler/exception_handler.h"
#include <stdio.h>
static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* context, bool succeeded) {
printf("Dump path: %s\n", descriptor.path());
return succeeded;
}
extern "C" CExceptionHandler newCExceptionHandlerSimple(void)
{
printf("init Simple breakpad\n");
google_breakpad::MinidumpDescriptor descriptor("/tmp");
//google_breakpad::ExceptionHandler eh(descriptor, NULL, dumpCallback, NULL, true, -1);
return reinterpret_cast<void*>(new google_breakpad::ExceptionHandler(descriptor, NULL, dumpCallback, NULL, true, -1));
}
#endif // USE_BREAKPAD

17
src/platform/breakpad.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef _OPENRCT2_BREAKPAD_
#define _OPENRCT2_BREAKPAD_
#ifdef USE_BREAKPAD
typedef void* CExceptionHandler;
#ifdef __cplusplus
extern "C"
{
#endif
CExceptionHandler newCExceptionHandlerSimple(void);
#ifdef __cplusplus
}
#endif
#endif // USE_BREAKPAD
#endif /* _OPENRCT2_BREAKPAD_ */