Skip to content

Commit

Permalink
Added callstack on crash for windows (linux shortly ...)
Browse files Browse the repository at this point in the history
  • Loading branch information
TLeonardUK committed Mar 24, 2024
1 parent 27dbe2a commit 771bf47
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ MessageHandleResult DS2_BloodstainManager::Handle_RequestGetDeadingGhost(GameCli
// Doesn't exist, no go.
else
{
WarningS(Client->GetName().c_str(), "Failed to retrieve bloodstain '%i'", Request->bloodstain_id());
WarningS(Client->GetName().c_str(), "Failed to retrieve bloodstain '%u'", Request->bloodstain_id());
}

DS2_Frpg2RequestMessage::RequestGetDeadingGhostResponse Response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ MessageHandleResult DS3_BloodstainManager::Handle_RequestGetDeadingGhost(GameCli
// Doesn't exist, no go.
else
{
WarningS(Client->GetName().c_str(), "Failed to retrieve bloodstain '%i', returning empty ghost data.", Request->bloodstain_id());
WarningS(Client->GetName().c_str(), "Failed to retrieve bloodstain '%u', returning empty ghost data.", Request->bloodstain_id());
}

DS3_Frpg2RequestMessage::RequestGetDeadingGhostResponse Response;
Expand Down
2 changes: 1 addition & 1 deletion Source/Server/Server/Database/ServerDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ bool ServerDatabase::RunStatement(const std::string& sql, const std::vector<Data
sqlite3_stmt* statement = nullptr;
if (int result = sqlite3_prepare_v2(db_handle, sql.c_str(), (int)sql.length(), &statement, nullptr); result != SQLITE_OK)
{
Error("sqlite3_prepare_v2 failed with error: %s", sqlite3_errstr(result));
Error("sqlite3_prepare_v2 (%s) failed with error: %s", sql.c_str(), sqlite3_errstr(result));
return false;
}
for (int i = 0; i < Values.size(); i++)
Expand Down
20 changes: 20 additions & 0 deletions Source/Shared/Platform/Win32/Win32Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,30 @@ struct Win32CtrlSignalHandler

} gWin32CtrlSignalHandler;

LONG WINAPI ExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo)
{
Log("================== Crash Log ==================");

std::unique_ptr<Callstack> Stack = CaptureCallstack(1);
for (auto& Frame : Stack->Frames)
{
Log("0x%016p %-30s %s@%zi",
Frame.Address,
Frame.Function.empty() ? "<unknown>" : Frame.Function.c_str(),
Frame.Filename.empty() ? "<unknown>" : Frame.Filename.c_str(),
Frame.Line
);
}

return EXCEPTION_CONTINUE_SEARCH;
}

bool PlatformInit()
{
LoadSymbols();

SetUnhandledExceptionFilter(ExceptionHandler);

WSADATA wsaData;
if (int Result = WSAStartup(MAKEWORD(2, 2), &wsaData); Result != 0)
{
Expand Down

0 comments on commit 771bf47

Please sign in to comment.