write module file paths in the crash reports' JSON files

This commit is contained in:
myT 2018-12-07 20:48:49 +01:00
parent a49512abde
commit 4e32660946

View file

@ -115,6 +115,9 @@ static void WIN_DumpStackTrace( debug_help_t* debugHelp )
stackFrame.AddrStack.Mode = AddrModeFlat; stackFrame.AddrStack.Mode = AddrModeFlat;
#endif #endif
const HANDLE processHandle = GetCurrentProcess();
const HANDLE threadHandle = GetCurrentThread();
JSONW_BeginNamedArray("stack_trace"); JSONW_BeginNamedArray("stack_trace");
unsigned char buffer[sizeof(IMAGEHLP_SYMBOL64) + BUFFER_SIZE]; unsigned char buffer[sizeof(IMAGEHLP_SYMBOL64) + BUFFER_SIZE];
@ -123,7 +126,7 @@ static void WIN_DumpStackTrace( debug_help_t* debugHelp )
int level = 1; int level = 1;
while (level++ < (MAX_LEVELS + 1)) { while (level++ < (MAX_LEVELS + 1)) {
BOOL result = debugHelp->StackWalk64( BOOL result = debugHelp->StackWalk64(
machineType, GetCurrentProcess(), GetCurrentThread(), &stackFrame, &context, machineType, processHandle, threadHandle, &stackFrame, &context,
NULL, debugHelp->SymFunctionTableAccess64, debugHelp->SymGetModuleBase64, NULL); NULL, debugHelp->SymFunctionTableAccess64, debugHelp->SymGetModuleBase64, NULL);
if (!result || stackFrame.AddrPC.Offset == 0) if (!result || stackFrame.AddrPC.Offset == 0)
break; break;
@ -139,10 +142,15 @@ static void WIN_DumpStackTrace( debug_help_t* debugHelp )
JSONW_HexValue("return_address", stackFrame.AddrReturn.Offset); JSONW_HexValue("return_address", stackFrame.AddrReturn.Offset);
DWORD64 displacement; DWORD64 displacement;
result = debugHelp->SymGetSymFromAddr64(GetCurrentProcess(), stackFrame.AddrPC.Offset, &displacement, symbol); result = debugHelp->SymGetSymFromAddr64(processHandle, stackFrame.AddrPC.Offset, &displacement, symbol);
if (result) if (result)
JSONW_StringValue("name", symbol->Name); JSONW_StringValue("name", symbol->Name);
const DWORD64 moduleBase = debugHelp->SymGetModuleBase64(processHandle, stackFrame.AddrPC.Offset);
char moduleName[MAX_PATH];
if (moduleBase && GetModuleFileNameA((HMODULE)moduleBase, moduleName, sizeof(moduleName)))
JSONW_StringValue("module_name", moduleName);
JSONW_EndObject(); JSONW_EndObject();
} }