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

Side by Side Diff: src/tools/mac/dump_syms/dump_syms_tool.cc

Issue 1340543002: Fix Mac Breakpad host tools to build in Linux cross-compile (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: Move mac-headers to mac_headers Created 5 years, 3 months 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
OLDNEW
1 // -*- mode: c++ -*- 1 // -*- mode: c++ -*-
2 2
3 // Copyright (c) 2011, Google Inc. 3 // Copyright (c) 2011, Google Inc.
4 // All rights reserved. 4 // All rights reserved.
5 // 5 //
6 // Redistribution and use in source and binary forms, with or without 6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are 7 // modification, are permitted provided that the following conditions are
8 // met: 8 // met:
9 // 9 //
10 // * Redistributions of source code must retain the above copyright 10 // * Redistributions of source code must retain the above copyright
(...skipping 11 matching lines...) Expand all
22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 31
32 // dump_syms_tool.mm: Command line tool that uses the DumpSymbols class. 32 // dump_syms_tool.cc: Command line tool that uses the DumpSymbols class.
33 // TODO(waylonis): accept stdin 33 // TODO(waylonis): accept stdin
34 34
35 #include <mach-o/arch.h> 35 #include <mach-o/arch.h>
36 #include <unistd.h> 36 #include <unistd.h>
37 37
38 #include <algorithm>
38 #include <iostream> 39 #include <iostream>
39 #include <vector> 40 #include <vector>
40 41
41 #include "common/mac/dump_syms.h" 42 #include "common/mac/dump_syms.h"
42 #include "common/mac/arch_utilities.h" 43 #include "common/mac/arch_utilities.h"
43 #include "common/mac/macho_utilities.h" 44 #include "common/mac/macho_utilities.h"
44 #include "common/scoped_ptr.h" 45 #include "common/scoped_ptr.h"
45 46
46 using google_breakpad::DumpSymbols; 47 using google_breakpad::DumpSymbols;
47 using google_breakpad::Module; 48 using google_breakpad::Module;
48 using google_breakpad::scoped_ptr; 49 using google_breakpad::scoped_ptr;
49 using std::vector; 50 using std::vector;
50 51
51 struct Options { 52 struct Options {
52 Options() 53 Options()
53 : srcPath(), dsymPath(), arch(), cfi(true), handle_inter_cu_refs(true) {} 54 : srcPath(), dsymPath(), arch(), cfi(true), handle_inter_cu_refs(true) {}
54 NSString *srcPath; 55
55 NSString *dsymPath; 56 string srcPath;
57 string dsymPath;
56 const NXArchInfo *arch; 58 const NXArchInfo *arch;
57 bool cfi; 59 bool cfi;
58 bool handle_inter_cu_refs; 60 bool handle_inter_cu_refs;
59 }; 61 };
60 62
61 static bool StackFrameEntryComparator(const Module::StackFrameEntry* a, 63 static bool StackFrameEntryComparator(const Module::StackFrameEntry* a,
62 const Module::StackFrameEntry* b) { 64 const Module::StackFrameEntry* b) {
63 return a->address < b->address; 65 return a->address < b->address;
64 } 66 }
65 67
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 DumpSymbols dump_symbols(symbol_data, options.handle_inter_cu_refs); 109 DumpSymbols dump_symbols(symbol_data, options.handle_inter_cu_refs);
108 110
109 // For x86_64 binaries, the CFI data is in the __TEXT,__eh_frame of the 111 // For x86_64 binaries, the CFI data is in the __TEXT,__eh_frame of the
110 // Mach-O file, which is not copied into the dSYM. Whereas in i386, the CFI 112 // Mach-O file, which is not copied into the dSYM. Whereas in i386, the CFI
111 // data is in the __DWARF,__debug_frame section, which is moved into the 113 // data is in the __DWARF,__debug_frame section, which is moved into the
112 // dSYM. Therefore, to get x86_64 CFI data, dump_syms needs to look at both 114 // dSYM. Therefore, to get x86_64 CFI data, dump_syms needs to look at both
113 // the dSYM and the Mach-O file. If both paths are present and CFI was 115 // the dSYM and the Mach-O file. If both paths are present and CFI was
114 // requested, then consider the Module as "split" and dump all the debug data 116 // requested, then consider the Module as "split" and dump all the debug data
115 // from the primary debug info file, the dSYM, and then dump additional CFI 117 // from the primary debug info file, the dSYM, and then dump additional CFI
116 // data from the source Mach-O file. 118 // data from the source Mach-O file.
117 bool split_module = options.dsymPath && options.srcPath && options.cfi; 119 bool split_module =
118 NSString* primary_file = split_module ? options.dsymPath : options.srcPath; 120 !options.dsymPath.empty() && !options.srcPath.empty() && options.cfi;
121 const string& primary_file =
122 split_module ? options.dsymPath : options.srcPath;
119 123
120 if (!dump_symbols.Read(primary_file)) 124 if (!dump_symbols.Read(primary_file))
121 return false; 125 return false;
122 126
123 if (options.arch) { 127 if (options.arch) {
124 if (!dump_symbols.SetArchitecture(options.arch->cputype, 128 if (!dump_symbols.SetArchitecture(options.arch->cputype,
125 options.arch->cpusubtype)) { 129 options.arch->cpusubtype)) {
126 fprintf(stderr, "%s: no architecture '%s' is present in file.\n", 130 fprintf(stderr, "%s: no architecture '%s' is present in file.\n",
127 [primary_file fileSystemRepresentation], options.arch->name); 131 primary_file.c_str(), options.arch->name);
128 size_t available_size; 132 size_t available_size;
129 const SuperFatArch *available = 133 const SuperFatArch *available =
130 dump_symbols.AvailableArchitectures(&available_size); 134 dump_symbols.AvailableArchitectures(&available_size);
131 if (available_size == 1) 135 if (available_size == 1)
132 fprintf(stderr, "the file's architecture is: "); 136 fprintf(stderr, "the file's architecture is: ");
133 else 137 else
134 fprintf(stderr, "architectures present in the file are:\n"); 138 fprintf(stderr, "architectures present in the file are:\n");
135 for (size_t i = 0; i < available_size; i++) { 139 for (size_t i = 0; i < available_size; i++) {
136 const SuperFatArch *arch = &available[i]; 140 const SuperFatArch *arch = &available[i];
137 const NXArchInfo *arch_info = 141 const NXArchInfo *arch_info =
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 google_breakpad::BreakpadGetArchInfoFromName(optarg); 211 google_breakpad::BreakpadGetArchInfoFromName(optarg);
208 if (!arch_info) { 212 if (!arch_info) {
209 fprintf(stderr, "%s: Invalid architecture: %s\n", argv[0], optarg); 213 fprintf(stderr, "%s: Invalid architecture: %s\n", argv[0], optarg);
210 Usage(argc, argv); 214 Usage(argc, argv);
211 exit(1); 215 exit(1);
212 } 216 }
213 options->arch = arch_info; 217 options->arch = arch_info;
214 break; 218 break;
215 } 219 }
216 case 'g': 220 case 'g':
217 options->dsymPath = [[NSFileManager defaultManager] 221 options->dsymPath = optarg;
218 stringWithFileSystemRepresentation:optarg length:strlen(optarg)];
219 break; 222 break;
220 case 'c': 223 case 'c':
221 options->cfi = false; 224 options->cfi = false;
222 break; 225 break;
223 case 'r': 226 case 'r':
224 options->handle_inter_cu_refs = false; 227 options->handle_inter_cu_refs = false;
225 break; 228 break;
226 case '?': 229 case '?':
227 case 'h': 230 case 'h':
228 Usage(argc, argv); 231 Usage(argc, argv);
229 exit(0); 232 exit(0);
230 break; 233 break;
231 } 234 }
232 } 235 }
233 236
234 if ((argc - optind) != 1) { 237 if ((argc - optind) != 1) {
235 fprintf(stderr, "Must specify Mach-o file\n"); 238 fprintf(stderr, "Must specify Mach-o file\n");
236 Usage(argc, argv); 239 Usage(argc, argv);
237 exit(1); 240 exit(1);
238 } 241 }
239 242
240 options->srcPath = [[NSFileManager defaultManager] 243 options->srcPath = argv[optind];
241 stringWithFileSystemRepresentation:argv[optind]
242 length:strlen(argv[optind])];
243 } 244 }
244 245
245 //============================================================================= 246 //=============================================================================
246 int main (int argc, const char * argv[]) { 247 int main (int argc, const char * argv[]) {
247 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
248 Options options; 248 Options options;
249 bool result; 249 bool result;
250 250
251 SetupOptions(argc, argv, &options); 251 SetupOptions(argc, argv, &options);
252 result = Start(options); 252 result = Start(options);
253 253
254 [pool release];
255
256 return !result; 254 return !result;
257 } 255 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698