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

Side by Side Diff: src/client/linux/minidump_writer/minidump_writer.cc

Issue 1688743002: Switch the Linux minidump writer to use MDCVInfoELF for CV data. (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: Rework to handle arbitrary size build ids Created 4 years, 8 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 // Copyright (c) 2010, Google Inc. 1 // Copyright (c) 2010, 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
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 #include "client/linux/dump_writer_common/thread_info.h" 67 #include "client/linux/dump_writer_common/thread_info.h"
68 #include "client/linux/dump_writer_common/ucontext_reader.h" 68 #include "client/linux/dump_writer_common/ucontext_reader.h"
69 #include "client/linux/handler/exception_handler.h" 69 #include "client/linux/handler/exception_handler.h"
70 #include "client/linux/minidump_writer/cpu_set.h" 70 #include "client/linux/minidump_writer/cpu_set.h"
71 #include "client/linux/minidump_writer/line_reader.h" 71 #include "client/linux/minidump_writer/line_reader.h"
72 #include "client/linux/minidump_writer/linux_dumper.h" 72 #include "client/linux/minidump_writer/linux_dumper.h"
73 #include "client/linux/minidump_writer/linux_ptrace_dumper.h" 73 #include "client/linux/minidump_writer/linux_ptrace_dumper.h"
74 #include "client/linux/minidump_writer/proc_cpuinfo_reader.h" 74 #include "client/linux/minidump_writer/proc_cpuinfo_reader.h"
75 #include "client/minidump_file_writer.h" 75 #include "client/minidump_file_writer.h"
76 #include "common/linux/file_id.h"
76 #include "common/linux/linux_libc_support.h" 77 #include "common/linux/linux_libc_support.h"
77 #include "common/minidump_type_helper.h" 78 #include "common/minidump_type_helper.h"
78 #include "google_breakpad/common/minidump_format.h" 79 #include "google_breakpad/common/minidump_format.h"
79 #include "third_party/lss/linux_syscall_support.h" 80 #include "third_party/lss/linux_syscall_support.h"
80 81
81 namespace { 82 namespace {
82 83
83 using google_breakpad::AppMemoryList; 84 using google_breakpad::AppMemoryList;
85 using google_breakpad::auto_wasteful_vector;
84 using google_breakpad::ExceptionHandler; 86 using google_breakpad::ExceptionHandler;
85 using google_breakpad::CpuSet; 87 using google_breakpad::CpuSet;
88 using google_breakpad::kDefaultBuildIdSize;
86 using google_breakpad::LineReader; 89 using google_breakpad::LineReader;
87 using google_breakpad::LinuxDumper; 90 using google_breakpad::LinuxDumper;
88 using google_breakpad::LinuxPtraceDumper; 91 using google_breakpad::LinuxPtraceDumper;
89 using google_breakpad::MDTypeHelper; 92 using google_breakpad::MDTypeHelper;
90 using google_breakpad::MappingEntry; 93 using google_breakpad::MappingEntry;
91 using google_breakpad::MappingInfo; 94 using google_breakpad::MappingInfo;
92 using google_breakpad::MappingList; 95 using google_breakpad::MappingList;
93 using google_breakpad::MinidumpFileWriter; 96 using google_breakpad::MinidumpFileWriter;
94 using google_breakpad::PageAllocator; 97 using google_breakpad::PageAllocator;
95 using google_breakpad::ProcCpuInfoReader; 98 using google_breakpad::ProcCpuInfoReader;
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 bool FillRawModule(const MappingInfo& mapping, 542 bool FillRawModule(const MappingInfo& mapping,
540 bool member, 543 bool member,
541 unsigned int mapping_id, 544 unsigned int mapping_id,
542 MDRawModule* mod, 545 MDRawModule* mod,
543 const uint8_t* identifier) { 546 const uint8_t* identifier) {
544 my_memset(mod, 0, MD_MODULE_SIZE); 547 my_memset(mod, 0, MD_MODULE_SIZE);
545 548
546 mod->base_of_image = mapping.start_addr; 549 mod->base_of_image = mapping.start_addr;
547 mod->size_of_image = mapping.size; 550 mod->size_of_image = mapping.size;
548 551
549 uint8_t cv_buf[MDCVInfoPDB70_minsize + NAME_MAX]; 552 auto_wasteful_vector<uint8_t, kDefaultBuildIdSize> identifier_bytes(
550 uint8_t* cv_ptr = cv_buf; 553 dumper_->allocator());
551 554
552 const uint32_t cv_signature = MD_CVINFOPDB70_SIGNATURE;
553 my_memcpy(cv_ptr, &cv_signature, sizeof(cv_signature));
554 cv_ptr += sizeof(cv_signature);
555 uint8_t* signature = cv_ptr;
556 cv_ptr += sizeof(MDGUID);
557 if (identifier) { 555 if (identifier) {
558 // GUID was provided by caller. 556 // GUID was provided by caller.
559 my_memcpy(signature, identifier, sizeof(MDGUID)); 557 identifier_bytes.insert(identifier_bytes.end(),
558 identifier,
559 identifier + sizeof(MDGUID));
560 } else { 560 } else {
561 // Note: ElfFileIdentifierForMapping() can manipulate the |mapping.name|. 561 // Note: ElfFileIdentifierForMapping() can manipulate the |mapping.name|.
562 dumper_->ElfFileIdentifierForMapping(mapping, member, 562 dumper_->ElfFileIdentifierForMapping(mapping,
563 mapping_id, signature); 563 member,
564 mapping_id,
565 identifier_bytes);
564 } 566 }
565 my_memset(cv_ptr, 0, sizeof(uint32_t)); // Set age to 0 on Linux. 567
566 cv_ptr += sizeof(uint32_t); 568 if (!identifier_bytes.empty()) {
569 UntypedMDRVA cv(&minidump_writer_);
570 if (!cv.Allocate(MDCVInfoELF_minsize + identifier_bytes.size()))
571 return false;
572
573 const uint32_t cv_signature = MD_CVINFOELF_SIGNATURE;
574 cv.Copy(&cv_signature, sizeof(cv_signature));
575 cv.Copy(cv.position() + sizeof(cv_signature), &identifier_bytes[0],
576 identifier_bytes.size());
577
578 mod->cv_record = cv.location();
579 }
567 580
568 char file_name[NAME_MAX]; 581 char file_name[NAME_MAX];
569 char file_path[NAME_MAX]; 582 char file_path[NAME_MAX];
570 dumper_->GetMappingEffectiveNameAndPath( 583 dumper_->GetMappingEffectiveNameAndPath(
571 mapping, file_path, sizeof(file_path), file_name, sizeof(file_name)); 584 mapping, file_path, sizeof(file_path), file_name, sizeof(file_name));
572 585
573 const size_t file_name_len = my_strlen(file_name);
574 UntypedMDRVA cv(&minidump_writer_);
575 if (!cv.Allocate(MDCVInfoPDB70_minsize + file_name_len + 1))
576 return false;
577
578 // Write pdb_file_name
579 my_memcpy(cv_ptr, file_name, file_name_len + 1);
580 cv.Copy(cv_buf, MDCVInfoPDB70_minsize + file_name_len + 1);
581
582 mod->cv_record = cv.location();
583
584 MDLocationDescriptor ld; 586 MDLocationDescriptor ld;
585 if (!minidump_writer_.WriteString(file_path, my_strlen(file_path), &ld)) 587 if (!minidump_writer_.WriteString(file_path, my_strlen(file_path), &ld))
586 return false; 588 return false;
587 mod->module_name_rva = ld.rva; 589 mod->module_name_rva = ld.rva;
588 return true; 590 return true;
589 } 591 }
590 592
591 bool WriteMemoryListStream(MDRawDirectory* dirent) { 593 bool WriteMemoryListStream(MDRawDirectory* dirent) {
592 TypedMDRVA<uint32_t> list(&minidump_writer_); 594 TypedMDRVA<uint32_t> list(&minidump_writer_);
593 if (memory_blocks_.size()) { 595 if (memory_blocks_.size()) {
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 const MappingList& mappings, 1360 const MappingList& mappings,
1359 const AppMemoryList& appmem, 1361 const AppMemoryList& appmem,
1360 LinuxDumper* dumper) { 1362 LinuxDumper* dumper) {
1361 MinidumpWriter writer(filename, -1, NULL, mappings, appmem, dumper); 1363 MinidumpWriter writer(filename, -1, NULL, mappings, appmem, dumper);
1362 if (!writer.Init()) 1364 if (!writer.Init())
1363 return false; 1365 return false;
1364 return writer.Dump(); 1366 return writer.Dump();
1365 } 1367 }
1366 1368
1367 } // namespace google_breakpad 1369 } // namespace google_breakpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698