Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: src/tools/linux/dump_syms/dump_syms.cc

Issue 1437763002: dump_syms: add a -v flag (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: address mark's comments Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, Google Inc. 1 // Copyright (c) 2011, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer 11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the 12 // in the documentation and/or other materials provided with the
13 // distribution. 13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its 14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from 15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission. 16 // this software without specific prior written permission.
17 // 17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 #include <paths.h>
30 #include <stdio.h> 31 #include <stdio.h>
32 #include <unistd.h>
31 33
32 #include <cstring> 34 #include <cstring>
33 #include <iostream> 35 #include <iostream>
34 #include <string> 36 #include <string>
35 #include <vector> 37 #include <vector>
36 38
37 #include "common/linux/dump_symbols.h" 39 #include "common/linux/dump_symbols.h"
38 40
39 using google_breakpad::WriteSymbolFile; 41 using google_breakpad::WriteSymbolFile;
40 42
41 int usage(const char* self) { 43 int usage(const char* self) {
42 fprintf(stderr, "Usage: %s [OPTION] <binary-with-debugging-info> " 44 fprintf(stderr, "Usage: %s [OPTION] <binary-with-debugging-info> "
43 "[directories-for-debug-file]\n\n", self); 45 "[directories-for-debug-file]\n\n", self);
44 fprintf(stderr, "Options:\n"); 46 fprintf(stderr, "Options:\n");
45 fprintf(stderr, " -c Do not generate CFI section\n"); 47 fprintf(stderr, " -c Do not generate CFI section\n");
46 fprintf(stderr, " -r Do not handle inter-compilation unit references\n"); 48 fprintf(stderr, " -r Do not handle inter-compilation unit references\n");
49 fprintf(stderr, " -v Print all warnings to stderr\n");
47 return 1; 50 return 1;
48 } 51 }
49 52
50 int main(int argc, char **argv) { 53 int main(int argc, char **argv) {
51 if (argc < 2) 54 if (argc < 2)
52 return usage(argv[0]); 55 return usage(argv[0]);
53 56
54 bool cfi = true; 57 bool cfi = true;
55 bool handle_inter_cu_refs = true; 58 bool handle_inter_cu_refs = true;
59 bool log_to_stderr = false;
56 int arg_index = 1; 60 int arg_index = 1;
57 while (arg_index < argc && strlen(argv[arg_index]) > 0 && 61 while (arg_index < argc && strlen(argv[arg_index]) > 0 &&
58 argv[arg_index][0] == '-') { 62 argv[arg_index][0] == '-') {
59 if (strcmp("-c", argv[arg_index]) == 0) { 63 if (strcmp("-c", argv[arg_index]) == 0) {
60 cfi = false; 64 cfi = false;
61 } else if (strcmp("-r", argv[arg_index]) == 0) { 65 } else if (strcmp("-r", argv[arg_index]) == 0) {
62 handle_inter_cu_refs = false; 66 handle_inter_cu_refs = false;
67 } else if (strcmp("-v", argv[arg_index]) == 0) {
68 log_to_stderr = true;
63 } else { 69 } else {
64 return usage(argv[0]); 70 return usage(argv[0]);
65 } 71 }
66 ++arg_index; 72 ++arg_index;
67 } 73 }
68 if (arg_index == argc) 74 if (arg_index == argc)
69 return usage(argv[0]); 75 return usage(argv[0]);
70 76
77 // Save stderr so it can be used below.
78 FILE* saved_stderr = fdopen(dup(fileno(stderr)), "w");
79 if (!log_to_stderr) {
80 if (freopen(_PATH_DEVNULL, "w", stderr)) {
81 // If it fails, not a lot we can (or should) do.
82 // Add this brace section to silence gcc warnings.
83 }
84 }
85
71 const char* binary; 86 const char* binary;
72 std::vector<string> debug_dirs; 87 std::vector<string> debug_dirs;
73 binary = argv[arg_index]; 88 binary = argv[arg_index];
74 for (int debug_dir_index = arg_index + 1; 89 for (int debug_dir_index = arg_index + 1;
75 debug_dir_index < argc; 90 debug_dir_index < argc;
76 ++debug_dir_index) { 91 ++debug_dir_index) {
77 debug_dirs.push_back(argv[debug_dir_index]); 92 debug_dirs.push_back(argv[debug_dir_index]);
78 } 93 }
79 94
80 SymbolData symbol_data = cfi ? ALL_SYMBOL_DATA : NO_CFI; 95 SymbolData symbol_data = cfi ? ALL_SYMBOL_DATA : NO_CFI;
81 google_breakpad::DumpOptions options(symbol_data, handle_inter_cu_refs); 96 google_breakpad::DumpOptions options(symbol_data, handle_inter_cu_refs);
82 if (!WriteSymbolFile(binary, debug_dirs, options, std::cout)) { 97 if (!WriteSymbolFile(binary, debug_dirs, options, std::cout)) {
83 fprintf(stderr, "Failed to write symbol file.\n"); 98 fprintf(saved_stderr, "Failed to write symbol file.\n");
84 return 1; 99 return 1;
85 } 100 }
86 101
87 return 0; 102 return 0;
88 } 103 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698