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

Unified Diff: minidump/minidump_thread_writer.cc

Issue 693933002: Add MinidumpThreadListWriter::InitializeFromSnapshot() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@minidump_init_from_snapshot_context_new
Patch Set: Address review feedback Created 6 years, 1 month 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
« no previous file with comments | « minidump/minidump_thread_writer.h ('k') | minidump/minidump_thread_writer_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: minidump/minidump_thread_writer.cc
diff --git a/minidump/minidump_thread_writer.cc b/minidump/minidump_thread_writer.cc
index efca1bda3e49512b36f7b772784b59de8ae3ac5b..814473d086a66fc18a2a4ed196947c290a386103 100644
--- a/minidump/minidump_thread_writer.cc
+++ b/minidump/minidump_thread_writer.cc
@@ -19,6 +19,8 @@
#include "base/logging.h"
#include "minidump/minidump_context_writer.h"
#include "minidump/minidump_memory_writer.h"
+#include "snapshot/memory_snapshot.h"
+#include "snapshot/thread_snapshot.h"
#include "util/file/file_writer.h"
#include "util/numeric/safe_assignment.h"
@@ -31,6 +33,33 @@ MinidumpThreadWriter::MinidumpThreadWriter()
MinidumpThreadWriter::~MinidumpThreadWriter() {
}
+void MinidumpThreadWriter::InitializeFromSnapshot(
+ const ThreadSnapshot* thread_snapshot,
+ const MinidumpThreadIDMap* thread_id_map) {
+ DCHECK_EQ(state(), kStateMutable);
+ DCHECK(!stack_);
+ DCHECK(!context_);
+
+ auto thread_id_it = thread_id_map->find(thread_snapshot->ThreadID());
+ DCHECK(thread_id_it != thread_id_map->end());
+ SetThreadID(thread_id_it->second);
+
+ SetSuspendCount(thread_snapshot->SuspendCount());
+ SetPriority(thread_snapshot->Priority());
+ SetTEB(thread_snapshot->ThreadSpecificDataAddress());
+
+ const MemorySnapshot* stack_snapshot = thread_snapshot->Stack();
+ if (stack_snapshot && stack_snapshot->Size() > 0) {
+ scoped_ptr<MinidumpMemoryWriter> stack =
+ MinidumpMemoryWriter::CreateFromSnapshot(stack_snapshot);
+ SetStack(stack.Pass());
+ }
+
+ scoped_ptr<MinidumpContextWriter> context =
+ MinidumpContextWriter::CreateFromSnapshot(thread_snapshot->Context());
+ SetContext(context.Pass());
+}
+
const MINIDUMP_THREAD* MinidumpThreadWriter::MinidumpThread() const {
DCHECK_EQ(state(), kStateWritable);
@@ -108,6 +137,21 @@ MinidumpThreadListWriter::MinidumpThreadListWriter()
MinidumpThreadListWriter::~MinidumpThreadListWriter() {
}
+void MinidumpThreadListWriter::InitializeFromSnapshot(
+ const std::vector<const ThreadSnapshot*>& thread_snapshots,
+ MinidumpThreadIDMap* thread_id_map) {
+ DCHECK_EQ(state(), kStateMutable);
+ DCHECK(threads_.empty());
+
+ BuildMinidumpThreadIDMap(thread_snapshots, thread_id_map);
+
+ for (const ThreadSnapshot* thread_snapshot : thread_snapshots) {
+ auto thread = make_scoped_ptr(new MinidumpThreadWriter());
+ thread->InitializeFromSnapshot(thread_snapshot, thread_id_map);
+ AddThread(thread.Pass());
+ }
+}
+
void MinidumpThreadListWriter::SetMemoryListWriter(
MinidumpMemoryListWriter* memory_list_writer) {
DCHECK_EQ(state(), kStateMutable);
« no previous file with comments | « minidump/minidump_thread_writer.h ('k') | minidump/minidump_thread_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698