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

Unified Diff: base/trace_event/heap_profiler_stack_frame_deduplicator.cc

Issue 1839503002: [tracing] Add native allocation tracing mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WalkStackFrames (wants frame pointers) Created 4 years, 9 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: 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 95685250cd23a9dd42e61ebc43e41cfb622f244d..401da3ff6641408e488ed4e4631611452cdb6f80 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>
@@ -16,16 +17,19 @@
namespace base {
namespace trace_event {
-StackFrameDeduplicator::FrameNode::FrameNode(StackFrame frame,
+StackFrameDeduplicator::FrameNode::FrameNode(StackFrameType frame_type,
+ StackFrame frame,
int parent_frame_index)
- : frame(frame), parent_frame_index(parent_frame_index) {}
+ : frame_type(frame_type), frame(frame),
+ parent_frame_index(parent_frame_index) {}
StackFrameDeduplicator::FrameNode::FrameNode(const FrameNode& other) = default;
StackFrameDeduplicator::FrameNode::~FrameNode() {}
StackFrameDeduplicator::StackFrameDeduplicator() {}
StackFrameDeduplicator::~StackFrameDeduplicator() {}
-int StackFrameDeduplicator::Insert(const StackFrame* beginFrame,
+int StackFrameDeduplicator::Insert(StackFrameType frame_type,
+ const StackFrame* beginFrame,
const StackFrame* endFrame) {
int frame_index = -1;
std::map<StackFrame, int>* nodes = &roots_;
@@ -38,7 +42,7 @@ int StackFrameDeduplicator::Insert(const StackFrame* beginFrame,
if (node == nodes->end()) {
// There is no tree node for this frame yet, create it. The parent node
// is the node associated with the previous frame.
- FrameNode frame_node(frame, frame_index);
+ FrameNode frame_node(frame_type, frame, frame_index);
// The new frame node will be appended, so its index is the current size
// of the vector.
@@ -78,7 +82,18 @@ void StackFrameDeduplicator::AppendAsTraceFormat(std::string* out) const {
out->append(stringify_buffer);
scoped_ptr<TracedValue> frame_node_value(new TracedValue);
- frame_node_value->SetString("name", frame_node->frame);
+ switch (frame_node->frame_type) {
+ case STACK_FRAME_TYPE_SYMBOL:
+ frame_node_value->SetString(
+ "name", static_cast<const char*>(frame_node->frame));
+ break;
+ case STACK_FRAME_TYPE_PC:
+ SStringPrintf(&stringify_buffer,
+ "pc:%" PRIxPTR,
+ reinterpret_cast<uintptr_t>(frame_node->frame));
+ 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);

Powered by Google App Engine
This is Rietveld 408576698