OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #include "snapshot/minidump/module_snapshot_minidump.h" |
| 16 |
| 17 #include "minidump/minidump_extensions.h" |
| 18 #include "snapshot/minidump/minidump_simple_string_dictionary_reader.h" |
| 19 #include "snapshot/minidump/minidump_string_list_reader.h" |
| 20 |
| 21 namespace crashpad { |
| 22 namespace internal { |
| 23 |
| 24 ModuleSnapshotMinidump::ModuleSnapshotMinidump() |
| 25 : ModuleSnapshot(), |
| 26 minidump_module_(), |
| 27 annotations_vector_(), |
| 28 annotations_simple_map_(), |
| 29 initialized_() { |
| 30 } |
| 31 |
| 32 ModuleSnapshotMinidump::~ModuleSnapshotMinidump() { |
| 33 } |
| 34 |
| 35 bool ModuleSnapshotMinidump::Initialize( |
| 36 FileReaderInterface* file_reader, |
| 37 RVA minidump_module_rva, |
| 38 const MINIDUMP_LOCATION_DESCRIPTOR* |
| 39 minidump_module_crashpad_info_location) { |
| 40 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); |
| 41 |
| 42 if (!file_reader->SeekSet(minidump_module_rva)) { |
| 43 return false; |
| 44 } |
| 45 |
| 46 if (!file_reader->ReadExactly(&minidump_module_, sizeof(minidump_module_))) { |
| 47 return false; |
| 48 } |
| 49 |
| 50 if (!InitializeModuleCrashpadInfo(file_reader, |
| 51 minidump_module_crashpad_info_location)) { |
| 52 return false; |
| 53 } |
| 54 |
| 55 INITIALIZATION_STATE_SET_VALID(initialized_); |
| 56 return true; |
| 57 } |
| 58 |
| 59 std::string ModuleSnapshotMinidump::Name() const { |
| 60 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 61 NOTREACHED(); // https://code.google.com/p/crashpad/issues/detail?id=10 |
| 62 return std::string(); |
| 63 } |
| 64 |
| 65 uint64_t ModuleSnapshotMinidump::Address() const { |
| 66 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 67 NOTREACHED(); // https://code.google.com/p/crashpad/issues/detail?id=10 |
| 68 return 0; |
| 69 } |
| 70 |
| 71 uint64_t ModuleSnapshotMinidump::Size() const { |
| 72 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 73 NOTREACHED(); // https://code.google.com/p/crashpad/issues/detail?id=10 |
| 74 return 0; |
| 75 } |
| 76 |
| 77 time_t ModuleSnapshotMinidump::Timestamp() const { |
| 78 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 79 NOTREACHED(); // https://code.google.com/p/crashpad/issues/detail?id=10 |
| 80 return 0; |
| 81 } |
| 82 |
| 83 void ModuleSnapshotMinidump::FileVersion(uint16_t* version_0, |
| 84 uint16_t* version_1, |
| 85 uint16_t* version_2, |
| 86 uint16_t* version_3) const { |
| 87 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 88 NOTREACHED(); // https://code.google.com/p/crashpad/issues/detail?id=10 |
| 89 *version_0 = 0; |
| 90 *version_1 = 0; |
| 91 *version_2 = 0; |
| 92 *version_3 = 0; |
| 93 } |
| 94 |
| 95 void ModuleSnapshotMinidump::SourceVersion(uint16_t* version_0, |
| 96 uint16_t* version_1, |
| 97 uint16_t* version_2, |
| 98 uint16_t* version_3) const { |
| 99 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 100 NOTREACHED(); // https://code.google.com/p/crashpad/issues/detail?id=10 |
| 101 *version_0 = 0; |
| 102 *version_1 = 0; |
| 103 *version_2 = 0; |
| 104 *version_3 = 0; |
| 105 } |
| 106 |
| 107 ModuleSnapshot::ModuleType ModuleSnapshotMinidump::GetModuleType() const { |
| 108 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 109 NOTREACHED(); // https://code.google.com/p/crashpad/issues/detail?id=10 |
| 110 return kModuleTypeUnknown; |
| 111 } |
| 112 |
| 113 void ModuleSnapshotMinidump::UUID(crashpad::UUID* uuid) const { |
| 114 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 115 NOTREACHED(); // https://code.google.com/p/crashpad/issues/detail?id=10 |
| 116 *uuid = crashpad::UUID(); |
| 117 } |
| 118 |
| 119 std::vector<std::string> ModuleSnapshotMinidump::AnnotationsVector() const { |
| 120 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 121 return annotations_vector_; |
| 122 } |
| 123 |
| 124 std::map<std::string, std::string> |
| 125 ModuleSnapshotMinidump::AnnotationsSimpleMap() const { |
| 126 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 127 return annotations_simple_map_; |
| 128 } |
| 129 |
| 130 bool ModuleSnapshotMinidump::InitializeModuleCrashpadInfo( |
| 131 FileReaderInterface* file_reader, |
| 132 const MINIDUMP_LOCATION_DESCRIPTOR* |
| 133 minidump_module_crashpad_info_location) { |
| 134 if (!minidump_module_crashpad_info_location || |
| 135 minidump_module_crashpad_info_location->Rva == 0) { |
| 136 return true; |
| 137 } |
| 138 |
| 139 MinidumpModuleCrashpadInfo minidump_module_crashpad_info; |
| 140 if (minidump_module_crashpad_info_location->DataSize < |
| 141 sizeof(minidump_module_crashpad_info)) { |
| 142 LOG(ERROR) << "minidump_module_crashpad_info size mismatch"; |
| 143 return false; |
| 144 } |
| 145 |
| 146 if (!file_reader->SeekSet(minidump_module_crashpad_info_location->Rva)) { |
| 147 return false; |
| 148 } |
| 149 |
| 150 if (!file_reader->ReadExactly(&minidump_module_crashpad_info, |
| 151 sizeof(minidump_module_crashpad_info))) { |
| 152 return false; |
| 153 } |
| 154 |
| 155 if (minidump_module_crashpad_info.version != |
| 156 MinidumpModuleCrashpadInfo::kVersion) { |
| 157 LOG(ERROR) << "minidump_module_crashpad_info version mismatch"; |
| 158 return false; |
| 159 } |
| 160 |
| 161 if (!ReadMinidumpStringList(file_reader, |
| 162 minidump_module_crashpad_info.list_annotations, |
| 163 &annotations_vector_)) { |
| 164 return false; |
| 165 } |
| 166 |
| 167 return ReadMinidumpSimpleStringDictionary( |
| 168 file_reader, |
| 169 minidump_module_crashpad_info.simple_annotations, |
| 170 &annotations_simple_map_); |
| 171 } |
| 172 |
| 173 } // namespace internal |
| 174 } // namespace crashpad |
OLD | NEW |