Index: snapshot/mac/mach_o_image_annotations_reader.cc |
diff --git a/snapshot/mac/mach_o_image_annotations_reader.cc b/snapshot/mac/mach_o_image_annotations_reader.cc |
index b95e8559263d4bb85ef450e770b1d666a87a27b1..12550937fb1c54f6eda9f1f6e4250c55b23d4d4e 100644 |
--- a/snapshot/mac/mach_o_image_annotations_reader.cc |
+++ b/snapshot/mac/mach_o_image_annotations_reader.cc |
@@ -22,7 +22,6 @@ |
#include "client/simple_string_dictionary.h" |
#include "snapshot/mac/mach_o_image_reader.h" |
#include "snapshot/mac/process_reader.h" |
-#include "snapshot/mac/process_types.h" |
#include "util/mach/task_memory.h" |
#include "util/stdlib/strnlen.h" |
@@ -55,6 +54,38 @@ std::map<std::string, std::string> MachOImageAnnotationsReader::SimpleMap() |
return simple_map_annotations; |
} |
+bool MachOImageAnnotationsReader::GetCrashpadInfo( |
+ process_types::CrashpadInfo* crashpad_info) const { |
+ mach_vm_address_t crashpad_info_address; |
+ const process_types::section* crashpad_info_section = |
+ image_reader_->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 << " in " << name_; |
+ return false; |
+ } |
+ |
+ if (!crashpad_info->Read(process_reader_, crashpad_info_address)) { |
+ LOG(WARNING) << "could not read crashpad info from " << name_; |
+ 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 in " << name_; |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
void MachOImageAnnotationsReader::ReadCrashReporterClientAnnotations( |
std::vector<std::string>* vector_annotations) const { |
mach_vm_address_t crash_info_address; |
@@ -138,31 +169,8 @@ void MachOImageAnnotationsReader::ReadDyldErrorStringAnnotation( |
void MachOImageAnnotationsReader::ReadCrashpadSimpleAnnotations( |
std::map<std::string, std::string>* simple_map_annotations) const { |
- mach_vm_address_t crashpad_info_address; |
- const process_types::section* crashpad_info_section = |
- image_reader_->GetSectionByName( |
- SEG_DATA, "__crashpad_info", &crashpad_info_address); |
- if (!crashpad_info_section) { |
- return; |
- } |
- |
process_types::CrashpadInfo crashpad_info; |
- if (crashpad_info_section->size < |
- crashpad_info.ExpectedSize(process_reader_)) { |
- LOG(WARNING) << "small crashpad info section size " |
- << crashpad_info_section->size << " in " << name_; |
- return; |
- } |
- |
- if (!crashpad_info.Read(process_reader_, crashpad_info_address)) { |
- LOG(WARNING) << "could not read crashpad info from " << name_; |
- return; |
- } |
- |
- if (crashpad_info.signature != CrashpadInfo::kSignature || |
- crashpad_info.size != crashpad_info_section->size || |
- crashpad_info.version < 1) { |
- LOG(WARNING) << "unexpected crashpad info data in " << name_; |
+ if (!GetCrashpadInfo(&crashpad_info)) { |
return; |
} |