Skip to content

Commit

Permalink
Fix fprintf calls on Windows
Browse files Browse the repository at this point in the history
pSymbol->Address is ULONG64 but fprintf's %p format on x86 expects 32-bits.

Fixes nodejs#26
  • Loading branch information
richardlau committed Nov 18, 2016
1 parent ef67b73 commit 45f0b24
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -602,17 +602,23 @@ void PrintNativeStack(FILE* fp) {
IMAGEHLP_LINE64 line;
line.SizeOfStruct = sizeof(line);
if (SymGetLineFromAddr64(hProcess, dwAddress, &dwOffset, &line)) {
fprintf(fp, "%2d: [pc=0x%p] %s [+%d] in %s: line: %lu\n", i, pSymbol->Address, pSymbol->Name, dwOffset, line.FileName, line.LineNumber);
fprintf(fp, "%2d: [pc=0x%p] %s [+%d] in %s: line: %lu\n", i,
reinterpret_cast<void*>(pSymbol->Address), pSymbol->Name,
dwOffset, line.FileName, line.LineNumber);
} else {
// SymGetLineFromAddr64() failed, just print the address and symbol
if (dwOffset64 <= 32) { // sanity check
fprintf(fp, "%2d: [pc=0x%p] %s [+%d]\n", i, pSymbol->Address, pSymbol->Name, dwOffset64);
fprintf(fp, "%2d: [pc=0x%p] %s [+%lld]\n", i,
reinterpret_cast<void*>(pSymbol->Address), pSymbol->Name,
dwOffset64);
} else {
fprintf(fp, "%2d: [pc=0x%p]\n", i, pSymbol->Address);
fprintf(fp, "%2d: [pc=0x%p]\n", i,
reinterpret_cast<void*>(pSymbol->Address));
}
}
} else { // SymFromAddr() failed, just print the address
fprintf(fp, "%2d: [pc=0x%p]\n", i, pSymbol->Address);
fprintf(fp, "%2d: [pc=0x%p]\n", i,
reinterpret_cast<void*>(pSymbol->Address));
}
}
}
Expand Down

0 comments on commit 45f0b24

Please sign in to comment.