OLD | NEW |
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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 public DwarfCUToModule::LineToModuleHandler { | 309 public DwarfCUToModule::LineToModuleHandler { |
310 public: | 310 public: |
311 // Create a line-to-module converter using BYTE_READER. | 311 // Create a line-to-module converter using BYTE_READER. |
312 DumperLineToModule(dwarf2reader::ByteReader *byte_reader) | 312 DumperLineToModule(dwarf2reader::ByteReader *byte_reader) |
313 : byte_reader_(byte_reader) { } | 313 : byte_reader_(byte_reader) { } |
314 | 314 |
315 void StartCompilationUnit(const string& compilation_dir) { | 315 void StartCompilationUnit(const string& compilation_dir) { |
316 compilation_dir_ = compilation_dir; | 316 compilation_dir_ = compilation_dir; |
317 } | 317 } |
318 | 318 |
319 void ReadProgram(const char *program, uint64 length, | 319 void ReadProgram(const uint8_t *program, uint64 length, |
320 Module *module, vector<Module::Line> *lines) { | 320 Module *module, vector<Module::Line> *lines) { |
321 DwarfLineToModule handler(module, compilation_dir_, lines); | 321 DwarfLineToModule handler(module, compilation_dir_, lines); |
322 dwarf2reader::LineInfo parser(program, length, byte_reader_, &handler); | 322 dwarf2reader::LineInfo parser(program, length, byte_reader_, &handler); |
323 parser.Start(); | 323 parser.Start(); |
324 } | 324 } |
325 private: | 325 private: |
326 string compilation_dir_; | 326 string compilation_dir_; |
327 dwarf2reader::ByteReader *byte_reader_; // WEAK | 327 dwarf2reader::ByteReader *byte_reader_; // WEAK |
328 }; | 328 }; |
329 | 329 |
330 bool DumpSymbols::ReadDwarf(google_breakpad::Module *module, | 330 bool DumpSymbols::ReadDwarf(google_breakpad::Module *module, |
331 const mach_o::Reader &macho_reader, | 331 const mach_o::Reader &macho_reader, |
332 const mach_o::SectionMap &dwarf_sections, | 332 const mach_o::SectionMap &dwarf_sections, |
333 bool handle_inter_cu_refs) const { | 333 bool handle_inter_cu_refs) const { |
334 // Build a byte reader of the appropriate endianness. | 334 // Build a byte reader of the appropriate endianness. |
335 ByteReader byte_reader(macho_reader.big_endian() | 335 ByteReader byte_reader(macho_reader.big_endian() |
336 ? dwarf2reader::ENDIANNESS_BIG | 336 ? dwarf2reader::ENDIANNESS_BIG |
337 : dwarf2reader::ENDIANNESS_LITTLE); | 337 : dwarf2reader::ENDIANNESS_LITTLE); |
338 | 338 |
339 // Construct a context for this file. | 339 // Construct a context for this file. |
340 DwarfCUToModule::FileContext file_context(selected_object_name_, | 340 DwarfCUToModule::FileContext file_context(selected_object_name_, |
341 module, | 341 module, |
342 handle_inter_cu_refs); | 342 handle_inter_cu_refs); |
343 | 343 |
344 // Build a dwarf2reader::SectionMap from our mach_o::SectionMap. | 344 // Build a dwarf2reader::SectionMap from our mach_o::SectionMap. |
345 for (mach_o::SectionMap::const_iterator it = dwarf_sections.begin(); | 345 for (mach_o::SectionMap::const_iterator it = dwarf_sections.begin(); |
346 it != dwarf_sections.end(); ++it) { | 346 it != dwarf_sections.end(); ++it) { |
347 file_context.AddSectionToSectionMap( | 347 file_context.AddSectionToSectionMap( |
348 it->first, | 348 it->first, |
349 reinterpret_cast<const char *>(it->second.contents.start), | 349 it->second.contents.start, |
350 it->second.contents.Size()); | 350 it->second.contents.Size()); |
351 } | 351 } |
352 | 352 |
353 // Find the __debug_info section. | 353 // Find the __debug_info section. |
354 dwarf2reader::SectionMap::const_iterator debug_info_entry = | 354 dwarf2reader::SectionMap::const_iterator debug_info_entry = |
355 file_context.section_map().find("__debug_info"); | 355 file_context.section_map().find("__debug_info"); |
356 assert(debug_info_entry != file_context.section_map().end()); | 356 assert(debug_info_entry != file_context.section_map().end()); |
357 const std::pair<const char*, uint64>& debug_info_section = | 357 const std::pair<const uint8_t *, uint64>& debug_info_section = |
358 debug_info_entry->second; | 358 debug_info_entry->second; |
359 // There had better be a __debug_info section! | 359 // There had better be a __debug_info section! |
360 if (!debug_info_section.first) { | 360 if (!debug_info_section.first) { |
361 fprintf(stderr, "%s: __DWARF segment of file has no __debug_info section\n", | 361 fprintf(stderr, "%s: __DWARF segment of file has no __debug_info section\n", |
362 selected_object_name_.c_str()); | 362 selected_object_name_.c_str()); |
363 return false; | 363 return false; |
364 } | 364 } |
365 | 365 |
366 // Build a line-to-module loader for the root handler to use. | 366 // Build a line-to-module loader for the root handler to use. |
367 DumperLineToModule line_to_module(&byte_reader); | 367 DumperLineToModule line_to_module(&byte_reader); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 fprintf(stderr, "architecture '%s'", arch->name); | 417 fprintf(stderr, "architecture '%s'", arch->name); |
418 else | 418 else |
419 fprintf(stderr, "architecture %d,%d", | 419 fprintf(stderr, "architecture %d,%d", |
420 macho_reader.cpu_type(), macho_reader.cpu_subtype()); | 420 macho_reader.cpu_type(), macho_reader.cpu_subtype()); |
421 fprintf(stderr, " to Breakpad symbol file: no register name table\n"); | 421 fprintf(stderr, " to Breakpad symbol file: no register name table\n"); |
422 return false; | 422 return false; |
423 } | 423 } |
424 } | 424 } |
425 | 425 |
426 // Find the call frame information and its size. | 426 // Find the call frame information and its size. |
427 const char *cfi = reinterpret_cast<const char *>(section.contents.start); | 427 const uint8_t *cfi = section.contents.start; |
428 size_t cfi_size = section.contents.Size(); | 428 size_t cfi_size = section.contents.Size(); |
429 | 429 |
430 // Plug together the parser, handler, and their entourages. | 430 // Plug together the parser, handler, and their entourages. |
431 DwarfCFIToModule::Reporter module_reporter(selected_object_name_, | 431 DwarfCFIToModule::Reporter module_reporter(selected_object_name_, |
432 section.section_name); | 432 section.section_name); |
433 DwarfCFIToModule handler(module, register_names, &module_reporter); | 433 DwarfCFIToModule handler(module, register_names, &module_reporter); |
434 dwarf2reader::ByteReader byte_reader(macho_reader.big_endian() ? | 434 dwarf2reader::ByteReader byte_reader(macho_reader.big_endian() ? |
435 dwarf2reader::ENDIANNESS_BIG : | 435 dwarf2reader::ENDIANNESS_BIG : |
436 dwarf2reader::ENDIANNESS_LITTLE); | 436 dwarf2reader::ENDIANNESS_LITTLE); |
437 byte_reader.SetAddressSize(macho_reader.bits_64() ? 8 : 4); | 437 byte_reader.SetAddressSize(macho_reader.bits_64() ? 8 : 4); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 if (ReadSymbolData(&module) && module) { | 617 if (ReadSymbolData(&module) && module) { |
618 bool res = module->Write(stream, symbol_data_); | 618 bool res = module->Write(stream, symbol_data_); |
619 delete module; | 619 delete module; |
620 return res; | 620 return res; |
621 } | 621 } |
622 | 622 |
623 return false; | 623 return false; |
624 } | 624 } |
625 | 625 |
626 } // namespace google_breakpad | 626 } // namespace google_breakpad |
OLD | NEW |