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); |