Crashlog: Windows: Handle negative address offsets from BFD symbol

This commit is contained in:
Jonathan G Rennison
2022-11-02 22:13:56 +00:00
parent 60ed858707
commit 652d6c8181

View File

@@ -544,9 +544,13 @@ char *CrashLogWindows::AppendDecodedStacktrace(char *buffer, const char *last) c
free(demangled); free(demangled);
#endif #endif
if (symbol_ok && bfd_info.function_addr) { if (symbol_ok && bfd_info.function_addr) {
if (bfd_info.function_addr < frame.AddrPC.Offset) {
buffer += seprintf(buffer, last, " - " OTTD_PRINTF64U, static_cast<DWORD64>(bfd_info.function_addr) - frame.AddrPC.Offset);
} else {
buffer += seprintf(buffer, last, " + " OTTD_PRINTF64U, frame.AddrPC.Offset - static_cast<DWORD64>(bfd_info.function_addr)); buffer += seprintf(buffer, last, " + " OTTD_PRINTF64U, frame.AddrPC.Offset - static_cast<DWORD64>(bfd_info.function_addr));
} }
} }
}
if (bfd_info.file_name != nullptr) { if (bfd_info.file_name != nullptr) {
buffer += seprintf(buffer, last, " (%s:%d)", bfd_info.file_name, bfd_info.line); buffer += seprintf(buffer, last, " (%s:%d)", bfd_info.file_name, bfd_info.line);
} }