Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.

Commit d988b6c

Browse files
richardlaurnchamberlain
authored andcommitted
Fix fprintf calls on Windows
pSymbol->Address is ULONG64 but fprintf's %p format on x86 expects 32-bits. Fixes #26 PR-URL: #27 Reviewed-By: Richard Chamberlain <richard_chamberlain@uk.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: George Adams <george.adams@uk.ibm.com>
1 parent 95a046e commit d988b6c

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

src/node_report.cc

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -598,21 +598,20 @@ void PrintNativeStack(FILE* fp) {
598598
pSymbol->MaxNameLen = MAX_SYM_NAME;
599599

600600
if (SymFromAddr(hProcess, dwAddress, &dwOffset64, pSymbol)) {
601-
DWORD dwOffset = 0;
602-
IMAGEHLP_LINE64 line;
603-
line.SizeOfStruct = sizeof(line);
604-
if (SymGetLineFromAddr64(hProcess, dwAddress, &dwOffset, &line)) {
605-
fprintf(fp, "%2d: [pc=0x%p] %s [+%d] in %s: line: %lu\n", i, pSymbol->Address, pSymbol->Name, dwOffset, line.FileName, line.LineNumber);
606-
} else {
607-
// SymGetLineFromAddr64() failed, just print the address and symbol
608-
if (dwOffset64 <= 32) { // sanity check
609-
fprintf(fp, "%2d: [pc=0x%p] %s [+%d]\n", i, pSymbol->Address, pSymbol->Name, dwOffset64);
610-
} else {
611-
fprintf(fp, "%2d: [pc=0x%p]\n", i, pSymbol->Address);
612-
}
613-
}
601+
DWORD dwOffset = 0;
602+
IMAGEHLP_LINE64 line;
603+
line.SizeOfStruct = sizeof(line);
604+
if (SymGetLineFromAddr64(hProcess, dwAddress, &dwOffset, &line)) {
605+
fprintf(fp, "%2d: [pc=0x%p] %s [+%d] in %s: line: %lu\n", i,
606+
reinterpret_cast<void*>(pSymbol->Address), pSymbol->Name,
607+
dwOffset, line.FileName, line.LineNumber);
608+
} else {
609+
fprintf(fp, "%2d: [pc=0x%p] %s [+%lld]\n", i,
610+
reinterpret_cast<void*>(pSymbol->Address), pSymbol->Name,
611+
dwOffset64);
612+
}
614613
} else { // SymFromAddr() failed, just print the address
615-
fprintf(fp, "%2d: [pc=0x%p]\n", i, pSymbol->Address);
614+
fprintf(fp, "%2d: [pc=0x%p]\n", i, reinterpret_cast<void*>(dwAddress));
616615
}
617616
}
618617
}

0 commit comments

Comments
 (0)