mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-25 18:47:35 +00:00
Full crash report on windows.
This commit is contained in:
+27
-10
@@ -13,6 +13,7 @@
|
|||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#if WINDOWS
|
#if WINDOWS
|
||||||
#define popen _popen
|
#define popen _popen
|
||||||
@@ -26,7 +27,7 @@ void SendCrashReport(const std::string &crash_report)
|
|||||||
// "http://localhost:3010/api/v1/server-crash-report", // development
|
// "http://localhost:3010/api/v1/server-crash-report", // development
|
||||||
};
|
};
|
||||||
|
|
||||||
auto config = EQEmuConfig::get();
|
auto config = EQEmuConfig::get();
|
||||||
for (auto &e: endpoints) {
|
for (auto &e: endpoints) {
|
||||||
uri u(e);
|
uri u(e);
|
||||||
|
|
||||||
@@ -103,27 +104,30 @@ public:
|
|||||||
EQEmuStackWalker(DWORD dwProcessId, HANDLE hProcess) : StackWalker(dwProcessId, hProcess) { }
|
EQEmuStackWalker(DWORD dwProcessId, HANDLE hProcess) : StackWalker(dwProcessId, hProcess) { }
|
||||||
virtual void OnOutput(LPCSTR szText) {
|
virtual void OnOutput(LPCSTR szText) {
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
for(int i = 0; i < 4096; ++i) {
|
for (int i = 0; i < 4096; ++i) {
|
||||||
if(szText[i] == 0) {
|
if (szText[i] == 0) {
|
||||||
buffer[i] = '\0';
|
buffer[i] = '\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(szText[i] == '\n' || szText[i] == '\r') {
|
if (szText[i] == '\n' || szText[i] == '\r') {
|
||||||
buffer[i] = ' ';
|
buffer[i] = ' ';
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
buffer[i] = szText[i];
|
buffer[i] = szText[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RuleB(Analytics, CrashReporting)) {
|
std::string line = buffer;
|
||||||
std::string crash_report = buffer;
|
_lines.push_back(line);
|
||||||
SendCrashReport(crash_report);
|
|
||||||
}
|
|
||||||
|
|
||||||
Log(Logs::General, Logs::Crash, buffer);
|
Log(Logs::General, Logs::Crash, buffer);
|
||||||
StackWalker::OnOutput(szText);
|
StackWalker::OnOutput(szText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<std::string>& const GetLines() { return _lines; }
|
||||||
|
private:
|
||||||
|
std::vector<std::string> _lines;
|
||||||
};
|
};
|
||||||
|
|
||||||
LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
|
LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
|
||||||
@@ -197,7 +201,20 @@ LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
|
|||||||
|
|
||||||
if(EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode)
|
if(EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode)
|
||||||
{
|
{
|
||||||
EQEmuStackWalker sw; sw.ShowCallstack(GetCurrentThread(), ExceptionInfo->ContextRecord);
|
EQEmuStackWalker sw;
|
||||||
|
sw.ShowCallstack(GetCurrentThread(), ExceptionInfo->ContextRecord);
|
||||||
|
|
||||||
|
if (RuleB(Analytics, CrashReporting)) {
|
||||||
|
std::string crash_report;
|
||||||
|
auto& lines = sw.GetLines();
|
||||||
|
|
||||||
|
for (auto& line : lines) {
|
||||||
|
crash_report += line;
|
||||||
|
crash_report += "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
SendCrashReport(crash_report);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXCEPTION_EXECUTE_HANDLER;
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
|
|||||||
Reference in New Issue
Block a user