mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-06-21 13:41:45 +00:00
Add breakpad to server
This commit is contained in:
parent
df3886168f
commit
a6467c9c47
4 changed files with 71 additions and 0 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "extern/breakpad"]
|
||||||
|
path = extern/breakpad
|
||||||
|
url = https://chromium.googlesource.com/breakpad/breakpad
|
|
@ -1,6 +1,20 @@
|
||||||
project(tes3mp-server)
|
project(tes3mp-server)
|
||||||
|
|
||||||
option(BUILD_WITH_PAWN "Enable Pawn language" OFF)
|
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)
|
if(BUILD_WITH_PAWN)
|
||||||
|
|
||||||
add_subdirectory(amx)
|
add_subdirectory(amx)
|
||||||
|
@ -90,6 +104,7 @@ target_link_libraries(tes3mp-server
|
||||||
components
|
components
|
||||||
${Terra_LIBRARY}
|
${Terra_LIBRARY}
|
||||||
${Pawn_LIBRARY}
|
${Pawn_LIBRARY}
|
||||||
|
${Breakpad_Library}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
#include <components/openmw-mp/Version.hpp>
|
#include <components/openmw-mp/Version.hpp>
|
||||||
|
|
||||||
|
#ifdef ENABLE_BREAKPAD
|
||||||
|
#include <handler/exception_handler.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
|
||||||
|
@ -47,6 +51,51 @@ void printVersion(string version, int protocol)
|
||||||
cout << "------------------------------------------------------------" << endl;
|
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)
|
std::string loadSettings (Settings::Manager & settings)
|
||||||
{
|
{
|
||||||
Files::ConfigurationManager mCfgMgr;
|
Files::ConfigurationManager mCfgMgr;
|
||||||
|
@ -102,6 +151,8 @@ int main(int argc, char *argv[])
|
||||||
Settings::Manager mgr;
|
Settings::Manager mgr;
|
||||||
Files::ConfigurationManager cfgMgr;
|
Files::ConfigurationManager cfgMgr;
|
||||||
|
|
||||||
|
breakpad(boost::filesystem::path(cfgMgr.getLogPath()).c_str());
|
||||||
|
|
||||||
loadSettings(mgr);
|
loadSettings(mgr);
|
||||||
|
|
||||||
int logLevel = mgr.getInt("loglevel", "General");
|
int logLevel = mgr.getInt("loglevel", "General");
|
||||||
|
@ -206,5 +257,6 @@ int main(int argc, char *argv[])
|
||||||
std::cout.rdbuf(cout_rdbuf);
|
std::cout.rdbuf(cout_rdbuf);
|
||||||
std::cerr.rdbuf(cerr_rdbuf);
|
std::cerr.rdbuf(cerr_rdbuf);
|
||||||
|
|
||||||
|
breakpad_close();
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
1
extern/breakpad
vendored
Submodule
1
extern/breakpad
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit e6d1c032baa222d8a8dc87813e9067199ec0266d
|
Loading…
Reference in a new issue