| Index: base/trace_event/heap_profiler_stack_frame_deduplicator.cc
|
| diff --git a/base/trace_event/heap_profiler_stack_frame_deduplicator.cc b/base/trace_event/heap_profiler_stack_frame_deduplicator.cc
|
| index 12121937530ff30503e6c6dd0a5f65cc38f4bedc..6305a0a31cc8d1fad250ae4b80646a3d65bf085e 100644
|
| --- a/base/trace_event/heap_profiler_stack_frame_deduplicator.cc
|
| +++ b/base/trace_event/heap_profiler_stack_frame_deduplicator.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "base/trace_event/heap_profiler_stack_frame_deduplicator.h"
|
|
|
| +#include <inttypes.h>
|
| #include <stddef.h>
|
|
|
| #include <string>
|
| @@ -31,7 +32,9 @@ int StackFrameDeduplicator::Insert(const StackFrame* beginFrame,
|
| std::map<StackFrame, int>* nodes = &roots_;
|
|
|
| // Loop through the frames, early out when a frame is null.
|
| - for (const StackFrame* it = beginFrame; it != endFrame && *it; it++) {
|
| + for (const StackFrame* it = beginFrame;
|
| + it != endFrame && !it->empty();
|
| + it++) {
|
| StackFrame frame = *it;
|
|
|
| auto node = nodes->find(frame);
|
| @@ -78,7 +81,25 @@ void StackFrameDeduplicator::AppendAsTraceFormat(std::string* out) const {
|
| out->append(stringify_buffer);
|
|
|
| std::unique_ptr<TracedValue> frame_node_value(new TracedValue);
|
| - frame_node_value->SetString("name", frame_node->frame);
|
| + const StackFrame& frame = frame_node->frame;
|
| + switch (frame.type) {
|
| + case StackFrame::TYPE_SYMBOL:
|
| + frame_node_value->SetString(
|
| + "name", static_cast<const char*>(frame.value));
|
| + break;
|
| + case StackFrame::TYPE_THREAD_NAME:
|
| + SStringPrintf(&stringify_buffer,
|
| + "[Thread: %s]",
|
| + static_cast<const char*>(frame.value));
|
| + frame_node_value->SetString("name", stringify_buffer);
|
| + break;
|
| + case StackFrame::TYPE_PC:
|
| + SStringPrintf(&stringify_buffer,
|
| + "pc:%" PRIxPTR,
|
| + reinterpret_cast<uintptr_t>(frame.value));
|
| + frame_node_value->SetString("name", stringify_buffer);
|
| + break;
|
| + }
|
| if (frame_node->parent_frame_index >= 0) {
|
| SStringPrintf(&stringify_buffer, "%d", frame_node->parent_frame_index);
|
| frame_node_value->SetString("parent", stringify_buffer);
|
|
|