Add INLINE and INLINE_ORIGIN records on Windows dump_syms

This adds INLINE and INLINE_ORIGIN records on Window dump_syms. It also
adds more LINE records that represents the inner most callsite line info
inside a function.

Bug: chromium:1190878
Change-Id: I15c2044709f8ca831b03a453910d036f749452c6
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3133606
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
This commit is contained in:
Zequan Wu
2022-01-04 16:03:22 -08:00
committed by Joshua Peraza
parent 634a7b3fad
commit 10afee3916
3 changed files with 482 additions and 60 deletions

View File

@@ -38,30 +38,55 @@
#include "common/windows/pdb_source_line_writer.h"
#include "common/windows/pe_source_line_writer.h"
using std::wstring;
using google_breakpad::PDBSourceLineWriter;
using google_breakpad::PESourceLineWriter;
using std::unique_ptr;
using std::wstring;
int usage(const wchar_t* self) {
fprintf(stderr, "Usage: %ws [--pe] [--i] <file.[pdb|exe|dll]>\n", self);
fprintf(stderr, "Options:\n");
fprintf(stderr,
"--pe:\tRead debugging information from PE file and do "
"not attempt to locate matching PDB file.\n"
"\tThis is only supported for PE32+ (64 bit) PE files.\n");
fprintf(stderr,
"--i:\tOutput INLINE/INLINE_ORIGIN record\n"
"\tThis cannot be used with [--pe].\n");
return 1;
}
int wmain(int argc, wchar_t** argv) {
bool success;
if (argc == 2) {
PDBSourceLineWriter pdb_writer;
if (!pdb_writer.Open(wstring(argv[1]), PDBSourceLineWriter::ANY_FILE)) {
bool success = false;
bool pe = false;
bool handle_inline = false;
int arg_index = 1;
while (arg_index < argc && wcslen(argv[arg_index]) > 0 &&
wcsncmp(L"--", argv[arg_index], 2) == 0) {
if (wcscmp(L"--pe", argv[arg_index]) == 0) {
pe = true;
} else if (wcscmp(L"--i", argv[arg_index]) == 0) {
handle_inline = true;
}
++arg_index;
}
if ((pe && handle_inline) || arg_index == argc) {
usage(argv[0]);
return 1;
}
wchar_t* file_path = argv[arg_index];
if (pe) {
PESourceLineWriter pe_writer(file_path);
success = pe_writer.WriteSymbols(stdout);
} else {
PDBSourceLineWriter pdb_writer(handle_inline);
if (!pdb_writer.Open(wstring(file_path), PDBSourceLineWriter::ANY_FILE)) {
fprintf(stderr, "Open failed.\n");
return 1;
}
success = pdb_writer.WriteSymbols(stdout);
} else if (argc == 3 && wcscmp(argv[1], L"--pe") == 0) {
PESourceLineWriter pe_writer(argv[2]);
success = pe_writer.WriteSymbols(stdout);
} else {
fprintf(stderr, "Usage: %ws [--pe] <file.[pdb|exe|dll]>\n", argv[0]);
fprintf(stderr, "Options:\n");
fprintf(stderr, "--pe:\tRead debugging information from PE file and do "
"not attempt to locate matching PDB file.\n"
"\tThis is only supported for PE32+ (64 bit) PE files.\n");
return 1;
}
if (!success) {