Index: snapshot/mac/mach_o_image_reader.cc |
diff --git a/snapshot/mac/mach_o_image_reader.cc b/snapshot/mac/mach_o_image_reader.cc |
index 26f7138823b4057ee524b313a56ff33eb1a0c828..0f791e1b8ed43574921299d65ec6d2ed7ac6b673 100644 |
--- a/snapshot/mac/mach_o_image_reader.cc |
+++ b/snapshot/mac/mach_o_image_reader.cc |
@@ -23,6 +23,7 @@ |
#include "base/logging.h" |
#include "base/strings/stringprintf.h" |
+#include "client/crashpad_info.h" |
#include "snapshot/mac/mach_o_image_segment_reader.h" |
#include "snapshot/mac/mach_o_image_symbol_table_reader.h" |
#include "snapshot/mac/process_reader.h" |
@@ -454,6 +455,39 @@ void MachOImageReader::UUID(crashpad::UUID* uuid) const { |
memcpy(uuid, &uuid_, sizeof(uuid_)); |
} |
+bool MachOImageReader::GetCrashpadInfo( |
+ process_types::CrashpadInfo* crashpad_info) const { |
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
+ |
+ mach_vm_address_t crashpad_info_address; |
+ const process_types::section* crashpad_info_section = |
+ GetSectionByName(SEG_DATA, "__crashpad_info", &crashpad_info_address); |
+ if (!crashpad_info_section) { |
+ return false; |
+ } |
+ |
+ if (crashpad_info_section->size < |
+ crashpad_info->ExpectedSize(process_reader_)) { |
+ LOG(WARNING) << "small crashpad info section size " |
+ << crashpad_info_section->size << module_info_; |
+ return false; |
+ } |
+ |
+ if (!crashpad_info->Read(process_reader_, crashpad_info_address)) { |
+ LOG(WARNING) << "could not read crashpad info" << module_info_; |
+ return false; |
+ } |
+ |
+ if (crashpad_info->signature != CrashpadInfo::kSignature || |
+ crashpad_info->size != crashpad_info_section->size || |
+ crashpad_info->version < 1) { |
+ LOG(WARNING) << "unexpected crashpad info data" << module_info_; |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
template <typename T> |
bool MachOImageReader::ReadLoadCommand(mach_vm_address_t load_command_address, |
const std::string& load_command_info, |