Add breakpad to server

coverity_scan^2
Koncord 8 years ago
parent df3886168f
commit a6467c9c47

3
.gitmodules vendored

@ -0,0 +1,3 @@
[submodule "extern/breakpad"]
path = extern/breakpad
url = https://chromium.googlesource.com/breakpad/breakpad

@ -1,6 +1,20 @@
project(tes3mp-server)
option(BUILD_WITH_PAWN "Enable Pawn language" OFF)
option(ENABLE_BREAKPAD "Enable Google Breakpad for Crash reporting" OFF)
if(ENABLE_BREAKPAD)
endif(ENABLE_BREAKPAD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_BREAKPAD")
if (UNIX)
set(Breakpad_Headers "${CMAKE_SOURCE_DIR}/extern/breakpad/src/client/linux")
set(Breakpad_Library "${CMAKE_SOURCE_DIR}/extern/breakpad/src/client/linux/libbreakpad_client.a")
elseif(WIN32)
set(Breakpad_Headers "${CMAKE_SOURCE_DIR}/extern/breakpad/src/client/windows")
set(Breakpad_Library "${CMAKE_SOURCE_DIR}/extern/breakpad/src/client/windows/libbreakpad_client.a")
endif (UNIX)
include_directories(${CMAKE_SOURCE_DIR}/extern/breakpad/src ${Breakpad_Headers})
if(BUILD_WITH_PAWN)
add_subdirectory(amx)
@ -90,6 +104,7 @@ target_link_libraries(tes3mp-server
components
${Terra_LIBRARY}
${Pawn_LIBRARY}
${Breakpad_Library}
)
if (UNIX)

@ -17,6 +17,10 @@
#include <boost/filesystem/fstream.hpp>
#include <components/openmw-mp/Version.hpp>
#ifdef ENABLE_BREAKPAD
#include <handler/exception_handler.h>
#endif
using namespace std;
using namespace mwmp;
@ -47,6 +51,51 @@ void printVersion(string version, int protocol)
cout << "------------------------------------------------------------" << endl;
}
#ifdef ENABLE_BREAKPAD
google_breakpad::ExceptionHandler *pHandler = 0;
#if defined(_WIN32)
bool DumpCallback(const char* _dump_dir, const char* _minidump_id, void* context, EXCEPTION_POINTERS* exinfo, MDRawAssertionInfo* assertion, bool success)
#elif defined(__linux)
bool DumpCallback(const google_breakpad::MinidumpDescriptor &md, void *context, bool success)
#endif
{
// NO STACK USE, NO HEAP USE THERE !!!
return success;
}
void breakpad(std::string pathToDump)
{
#ifdef _WIN32
pHandler = new google_breakpad::ExceptionHandler(
pathToDump,
/*FilterCallback*/ 0,
DumpCallback,
/*context*/
0,
true
);
#else
google_breakpad::MinidumpDescriptor md(pathToDump);
pHandler = new google_breakpad::ExceptionHandler(
md,
/*FilterCallback*/ 0,
DumpCallback,
/*context*/ 0,
true,
-1
);
#endif
}
void breakpad_close()
{
delete pHandler;
}
#else
void breakpad(std::string pathToDump){}
void breakpad_close(){}
#endif
std::string loadSettings (Settings::Manager & settings)
{
Files::ConfigurationManager mCfgMgr;
@ -102,6 +151,8 @@ int main(int argc, char *argv[])
Settings::Manager mgr;
Files::ConfigurationManager cfgMgr;
breakpad(boost::filesystem::path(cfgMgr.getLogPath()).c_str());
loadSettings(mgr);
int logLevel = mgr.getInt("loglevel", "General");
@ -206,5 +257,6 @@ int main(int argc, char *argv[])
std::cout.rdbuf(cout_rdbuf);
std::cerr.rdbuf(cerr_rdbuf);
breakpad_close();
return code;
}

1
extern/breakpad vendored

@ -0,0 +1 @@
Subproject commit e6d1c032baa222d8a8dc87813e9067199ec0266d
Loading…
Cancel
Save