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

Unified Diff: snapshot/minidump/module_snapshot_minidump.cc

Issue 972383002: snapshot: Add a minimal ModuleSnapshotMinidump and accessor from ProcessSnapshotMinidump (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: snapshot/minidump/module_snapshot_minidump.cc
diff --git a/snapshot/minidump/module_snapshot_minidump.cc b/snapshot/minidump/module_snapshot_minidump.cc
new file mode 100644
index 0000000000000000000000000000000000000000..354f3f130ed0a1abe43de01141967d7628ad3b1d
--- /dev/null
+++ b/snapshot/minidump/module_snapshot_minidump.cc
@@ -0,0 +1,170 @@
+// Copyright 2014 The Crashpad Authors. All rights reserved.
Robert Sesek 2015/03/04 01:52:25 2015
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "snapshot/minidump/module_snapshot_minidump.h"
+
+#include "minidump/minidump_extensions.h"
+#include "snapshot/minidump/minidump_simple_string_dictionary_reader.h"
+#include "snapshot/minidump/minidump_string_list_reader.h"
+
+namespace crashpad {
+namespace internal {
+
+ModuleSnapshotMinidump::ModuleSnapshotMinidump()
+ : ModuleSnapshot(),
+ minidump_module_(),
+ annotations_vector_(),
+ annotations_simple_map_(),
+ initialized_() {
+}
+
+ModuleSnapshotMinidump::~ModuleSnapshotMinidump() {
+}
+
+bool ModuleSnapshotMinidump::Initialize(
+ FileReaderInterface* file_reader,
+ RVA minidump_module_rva,
+ const MINIDUMP_LOCATION_DESCRIPTOR*
+ minidump_module_crashpad_info_location) {
+ INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
+
+ if (!file_reader->SeekSet(minidump_module_rva)) {
+ return false;
+ }
+
+ if (!file_reader->ReadExactly(&minidump_module_, sizeof(minidump_module_))) {
+ return false;
+ }
+
+ InitializeModuleCrashpadInfo(file_reader,
+ minidump_module_crashpad_info_location);
+
+ INITIALIZATION_STATE_SET_VALID(initialized_);
+ return true;
+}
+
+std::string ModuleSnapshotMinidump::Name() const {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+ NOTREACHED();
Robert Sesek 2015/03/04 01:52:25 Are these going to be implemented eventually? If s
Mark Mentovai 2015/03/04 16:24:24 Robert Sesek wrote:
Robert Sesek 2015/03/04 17:06:25 OK. Are these methods going to be implemented at s
Mark Mentovai 2015/03/04 17:10:21 Robert Sesek wrote:
Robert Sesek 2015/03/04 17:14:00 Yeah TODO would probably be good (w/ associated bu
+ return std::string();
+}
+
+uint64_t ModuleSnapshotMinidump::Address() const {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+ NOTREACHED();
+ return 0;
+}
+
+uint64_t ModuleSnapshotMinidump::Size() const {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+ NOTREACHED();
+ return 0;
+}
+
+time_t ModuleSnapshotMinidump::Timestamp() const {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+ NOTREACHED();
+ return 0;
+}
+
+void ModuleSnapshotMinidump::FileVersion(uint16_t* version_0,
+ uint16_t* version_1,
+ uint16_t* version_2,
+ uint16_t* version_3) const {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+ NOTREACHED();
+ *version_0 = 0;
+ *version_1 = 0;
+ *version_2 = 0;
+ *version_3 = 0;
+}
+
+void ModuleSnapshotMinidump::SourceVersion(uint16_t* version_0,
+ uint16_t* version_1,
+ uint16_t* version_2,
+ uint16_t* version_3) const {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+ NOTREACHED();
+ *version_0 = 0;
+ *version_1 = 0;
+ *version_2 = 0;
+ *version_3 = 0;
+}
+
+ModuleSnapshot::ModuleType ModuleSnapshotMinidump::GetModuleType() const {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+ NOTREACHED();
+ return kModuleTypeUnknown;
+}
+
+void ModuleSnapshotMinidump::UUID(crashpad::UUID* uuid) const {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+ NOTREACHED();
+ *uuid = crashpad::UUID();
+}
+
+std::vector<std::string> ModuleSnapshotMinidump::AnnotationsVector() const {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+ return annotations_vector_;
+}
+
+std::map<std::string, std::string>
+ModuleSnapshotMinidump::AnnotationsSimpleMap() const {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+ return annotations_simple_map_;
+}
+
+void ModuleSnapshotMinidump::InitializeModuleCrashpadInfo(
+ FileReaderInterface* file_reader,
+ const MINIDUMP_LOCATION_DESCRIPTOR*
+ minidump_module_crashpad_info_location) {
+ if (!minidump_module_crashpad_info_location ||
+ minidump_module_crashpad_info_location->Rva == 0) {
+ return;
+ }
+
+ MinidumpModuleCrashpadInfo minidump_module_crashpad_info;
+ if (minidump_module_crashpad_info_location->DataSize <
+ sizeof(minidump_module_crashpad_info)) {
Robert Sesek 2015/03/04 01:52:25 nit: indent +4
+ LOG(ERROR) << "minidump_module_crashpad_info size mismatch";
+ return;
+ }
+
+ if (!file_reader->SeekSet(minidump_module_crashpad_info_location->Rva)) {
+ return;
+ }
+
+ if (!file_reader->ReadExactly(&minidump_module_crashpad_info,
+ sizeof(minidump_module_crashpad_info))) {
+ return;
+ }
+
+ if (minidump_module_crashpad_info.version !=
+ MinidumpModuleCrashpadInfo::kVersion) {
+ LOG(ERROR) << "minidump_module_crashpad_info version mismatch";
+ return;
+ }
+
+ ReadMinidumpStringList(file_reader,
Robert Sesek 2015/03/04 01:52:25 What if these functions return false? There's no w
Mark Mentovai 2015/03/04 16:24:24 Robert Sesek wrote:
+ minidump_module_crashpad_info.list_annotations,
+ &annotations_vector_);
+
+ ReadMinidumpSimpleStringDictionary(
+ file_reader,
+ minidump_module_crashpad_info.simple_annotations,
+ &annotations_simple_map_);
+}
+
+} // namespace internal
+} // namespace crashpad

Powered by Google App Engine
This is Rietveld 408576698