Add an option to not handle DWARF inter-compilation unit references in Linux dump_syms.

This saves a lot of memory for dump_syms.

Review URL: https://breakpad.appspot.com/565002

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1163 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
thestig@chromium.org 2013-04-24 21:18:44 +00:00
parent ae3947e123
commit f7566bd447
7 changed files with 300 additions and 129 deletions

View file

@ -43,33 +43,43 @@ int usage(const char* self) {
"[directories-for-debug-file]\n\n", self);
fprintf(stderr, "Options:\n");
fprintf(stderr, " -c Do not generate CFI section\n");
fprintf(stderr, " -r Do not handle inter-compilation unit references\n");
return 1;
}
int main(int argc, char **argv) {
if (argc < 2 || argc > 4)
if (argc < 2)
return usage(argv[0]);
bool cfi = true;
int binary_index = 1;
if (strcmp("-c", argv[1]) == 0) {
cfi = false;
++binary_index;
bool handle_inter_cu_refs = true;
int arg_index = 1;
while (arg_index < argc && strlen(argv[arg_index]) > 0 &&
argv[arg_index][0] == '-') {
if (strcmp("-c", argv[arg_index]) == 0) {
cfi = false;
} else if (strcmp("-r", argv[arg_index]) == 0) {
handle_inter_cu_refs = false;
} else {
return usage(argv[0]);
}
++arg_index;
}
if (!cfi && argc == 2)
if (arg_index == argc)
return usage(argv[0]);
const char *binary;
const char* binary;
std::vector<string> debug_dirs;
binary = argv[binary_index];
for (int debug_dir_index = binary_index + 1;
binary = argv[arg_index];
for (int debug_dir_index = arg_index + 1;
debug_dir_index < argc;
++debug_dir_index) {
debug_dirs.push_back(argv[debug_dir_index]);
}
SymbolData symbol_data = cfi ? ALL_SYMBOL_DATA : NO_CFI;
if (!WriteSymbolFile(binary, debug_dirs, symbol_data, std::cout)) {
google_breakpad::DumpOptions options(symbol_data, handle_inter_cu_refs);
if (!WriteSymbolFile(binary, debug_dirs, options, std::cout)) {
fprintf(stderr, "Failed to write symbol file.\n");
return 1;
}