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

Unified Diff: base/trace_event/heap_profiler_allocation_context.h

Issue 1839503002: [tracing] Add native allocation tracing mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add type to StackFrame; format thread name Created 4 years, 8 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_allocation_context.h
diff --git a/base/trace_event/heap_profiler_allocation_context.h b/base/trace_event/heap_profiler_allocation_context.h
index 8544c78eb2cd34c3f7693fa4063ccdcf85f837a1..ef89ea6e459134414562969df069205f155cd52d 100644
--- a/base/trace_event/heap_profiler_allocation_context.h
+++ b/base/trace_event/heap_profiler_allocation_context.h
@@ -35,10 +35,40 @@ namespace trace_event {
//
// See the design doc (https://goo.gl/4s7v7b) for more details.
-using StackFrame = const char*;
+// TODO: description
Primiano Tucci (use gerrit) 2016/04/07 15:51:56 :)
+struct BASE_EXPORT StackFrame {
+ enum Type {
Primiano Tucci (use gerrit) 2016/04/07 15:51:56 enum class (thanks c++11), so we can get the right
+ TYPE_SYMBOL, // const char* string
Primiano Tucci (use gerrit) 2016/04/07 15:51:56 Is this for the pseudo stack? In this case I think
+ TYPE_THREAD_NAME, // const char* thread name
+ TYPE_PC, // as returned by stack tracing (e.g. by StackTrace)
Primiano Tucci (use gerrit) 2016/04/07 15:51:56 Let's call it explicitly PROGRAM_COUNTER (or NATIV
+ };
+
+ bool empty() const { return value == nullptr; }
+
+ static StackFrame Empty() {
+ return {TYPE_SYMBOL, nullptr};
+ }
+
+ static StackFrame FromSymbol(const void* symbol) {
+ return {TYPE_SYMBOL, symbol};
+ }
+ static StackFrame FromPC(const void* pc) {
+ return {TYPE_PC, pc};
+ }
+ static StackFrame FromThreadName(const char* name) {
+ return {TYPE_THREAD_NAME, name};
+ }
+
+ Type type;
+ const void* value;
+};
+
+bool BASE_EXPORT operator < (const StackFrame& lhs, const StackFrame& rhs);
Primiano Tucci (use gerrit) 2016/04/07 15:51:56 what do we need these operators for?
Dmitry Skiba 2016/04/12 18:22:10 For inserting StackFrame in a map, deduplicator do
+bool BASE_EXPORT operator == (const StackFrame& lhs, const StackFrame& rhs);
+bool BASE_EXPORT operator != (const StackFrame& lhs, const StackFrame& rhs);
struct BASE_EXPORT Backtrace {
- // Unused backtrace frames are filled with nullptr frames. If the stack is
+ // Unused backtrace frames are filled with empty frames. If the stack is
// higher than what can be stored here, the bottom frames are stored. Based
// on the data above, a depth of 12 captures the full stack in the vast
// majority of the cases.
@@ -83,6 +113,11 @@ bool BASE_EXPORT operator==(const AllocationContext& lhs,
namespace BASE_HASH_NAMESPACE {
template <>
+struct BASE_EXPORT hash<base::trace_event::StackFrame>: hash<const void*> {
Primiano Tucci (use gerrit) 2016/04/07 15:51:56 where do we hash StackFrame objects? Don't we keep
Dmitry Skiba 2016/04/12 18:22:10 Just in case someone decides to put it into a hash
+ size_t operator()(const base::trace_event::StackFrame& frame) const;
+};
+
+template <>
struct BASE_EXPORT hash<base::trace_event::Backtrace> {
size_t operator()(const base::trace_event::Backtrace& backtrace) const;
};

Powered by Google App Engine
This is Rietveld 408576698