aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorDavid Yen <dyen@chromium.org>2016-04-08 04:37:45 +0200
committerJochen Eisinger <jochen@chromium.org>2016-04-08 04:37:45 +0200
commitb0e5f262334e9a4d9e083d0daf430be2202f0152 (patch)
tree6047c3863e0f4babeaa71da9497ec3ef8031f3cc /src/tools
parentRemove unreferenced local variable which breaks build. (diff)
downloadbreakpad-b0e5f262334e9a4d9e083d0daf430be2202f0152.tar.xz
Added an option (-i) to have dump_syms output header information only.
It is often helpful to check if a particular symbol file dumped by dump_syms actually matches a version of a binary file we have. The symbol output contains an ID which can be used to see if it matches the binary file. Unfortunately, this ID is internally calculated and not a standard hash of the binary file. Being able to output the header information only will allow users to determine whether their symbol file is up to date or not. R=jochen@chromium.org BUG=561447 Review URL: https://codereview.chromium.org/1864823002 . Patch from David Yen <dyen@chromium.org>.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/linux/dump_syms/dump_syms.cc28
-rw-r--r--src/tools/mac/dump_syms/dump_syms_tool.cc13
2 files changed, 30 insertions, 11 deletions
diff --git a/src/tools/linux/dump_syms/dump_syms.cc b/src/tools/linux/dump_syms/dump_syms.cc
index c51ae8cd..84953172 100644
--- a/src/tools/linux/dump_syms/dump_syms.cc
+++ b/src/tools/linux/dump_syms/dump_syms.cc
@@ -39,11 +39,13 @@
#include "common/linux/dump_symbols.h"
using google_breakpad::WriteSymbolFile;
+using google_breakpad::WriteSymbolFileHeader;
int usage(const char* self) {
fprintf(stderr, "Usage: %s [OPTION] <binary-with-debugging-info> "
"[directories-for-debug-file]\n\n", self);
fprintf(stderr, "Options:\n");
+ fprintf(stderr, " -i: Output module header information only.\n");
fprintf(stderr, " -c Do not generate CFI section\n");
fprintf(stderr, " -r Do not handle inter-compilation unit references\n");
fprintf(stderr, " -v Print all warnings to stderr\n");
@@ -53,27 +55,29 @@ int usage(const char* self) {
int main(int argc, char **argv) {
if (argc < 2)
return usage(argv[0]);
-
+ bool header_only = false;
bool cfi = true;
bool handle_inter_cu_refs = true;
bool log_to_stderr = false;
int arg_index = 1;
while (arg_index < argc && strlen(argv[arg_index]) > 0 &&
argv[arg_index][0] == '-') {
- if (strcmp("-c", argv[arg_index]) == 0) {
+ if (strcmp("-i", argv[arg_index]) == 0) {
+ header_only = true;
+ } else if (strcmp("-c", argv[arg_index]) == 0) {
cfi = false;
} else if (strcmp("-r", argv[arg_index]) == 0) {
handle_inter_cu_refs = false;
} else if (strcmp("-v", argv[arg_index]) == 0) {
log_to_stderr = true;
} else {
+ printf("2.4 %s\n", argv[arg_index]);
return usage(argv[0]);
}
++arg_index;
}
if (arg_index == argc)
return usage(argv[0]);
-
// Save stderr so it can be used below.
FILE* saved_stderr = fdopen(dup(fileno(stderr)), "w");
if (!log_to_stderr) {
@@ -82,7 +86,6 @@ int main(int argc, char **argv) {
// Add this brace section to silence gcc warnings.
}
}
-
const char* binary;
std::vector<string> debug_dirs;
binary = argv[arg_index];
@@ -92,11 +95,18 @@ int main(int argc, char **argv) {
debug_dirs.push_back(argv[debug_dir_index]);
}
- SymbolData symbol_data = cfi ? ALL_SYMBOL_DATA : NO_CFI;
- google_breakpad::DumpOptions options(symbol_data, handle_inter_cu_refs);
- if (!WriteSymbolFile(binary, debug_dirs, options, std::cout)) {
- fprintf(saved_stderr, "Failed to write symbol file.\n");
- return 1;
+ if (header_only) {
+ if (!WriteSymbolFileHeader(binary, std::cout)) {
+ fprintf(saved_stderr, "Failed to process file.\n");
+ return 1;
+ }
+ } else {
+ SymbolData symbol_data = cfi ? ALL_SYMBOL_DATA : NO_CFI;
+ google_breakpad::DumpOptions options(symbol_data, handle_inter_cu_refs);
+ if (!WriteSymbolFile(binary, debug_dirs, options, std::cout)) {
+ fprintf(saved_stderr, "Failed to write symbol file.\n");
+ return 1;
+ }
}
return 0;
diff --git a/src/tools/mac/dump_syms/dump_syms_tool.cc b/src/tools/mac/dump_syms/dump_syms_tool.cc
index 54f29226..6f68457b 100644
--- a/src/tools/mac/dump_syms/dump_syms_tool.cc
+++ b/src/tools/mac/dump_syms/dump_syms_tool.cc
@@ -51,11 +51,13 @@ using std::vector;
struct Options {
Options()
- : srcPath(), dsymPath(), arch(), cfi(true), handle_inter_cu_refs(true) {}
+ : srcPath(), dsymPath(), arch(), header_only(false),
+ cfi(true), handle_inter_cu_refs(true) {}
string srcPath;
string dsymPath;
const NXArchInfo *arch;
+ bool header_only;
bool cfi;
bool handle_inter_cu_refs;
};
@@ -151,6 +153,9 @@ static bool Start(const Options &options) {
}
}
+ if (options.header_only)
+ return dump_symbols.WriteSymbolFileHeader(std::cout);
+
// Read the primary file into a Breakpad Module.
Module* module = NULL;
if (!dump_symbols.ReadSymbolData(&module))
@@ -189,6 +194,7 @@ static void Usage(int argc, const char *argv[]) {
fprintf(stderr, "Output a Breakpad symbol file from a Mach-o file.\n");
fprintf(stderr, "Usage: %s [-a ARCHITECTURE] [-c] [-g dSYM path] "
"<Mach-o file>\n", argv[0]);
+ fprintf(stderr, "\t-i: Output module header information only.\n");
fprintf(stderr, "\t-a: Architecture type [default: native, or whatever is\n");
fprintf(stderr, "\t in the file, if it contains only one architecture]\n");
fprintf(stderr, "\t-g: Debug symbol file (dSYM) to dump in addition to the "
@@ -204,8 +210,11 @@ static void SetupOptions(int argc, const char *argv[], Options *options) {
extern int optind;
signed char ch;
- while ((ch = getopt(argc, (char * const *)argv, "a:g:chr?")) != -1) {
+ while ((ch = getopt(argc, (char * const *)argv, "ia:g:chr?")) != -1) {
switch (ch) {
+ case 'i':
+ options->header_only = true;
+ break;
case 'a': {
const NXArchInfo *arch_info =
google_breakpad::BreakpadGetArchInfoFromName(optarg);