OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ | 5 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ |
6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ | 6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 // Represents (pseudo) stack frame. Used in Backtrace class below. | 38 // Represents (pseudo) stack frame. Used in Backtrace class below. |
39 // | 39 // |
40 // Conceptually stack frame is identified by its value, and type is used | 40 // Conceptually stack frame is identified by its value, and type is used |
41 // mostly to properly format the value. Value is expected to be a valid | 41 // mostly to properly format the value. Value is expected to be a valid |
42 // pointer from process' address space. | 42 // pointer from process' address space. |
43 struct BASE_EXPORT StackFrame { | 43 struct BASE_EXPORT StackFrame { |
44 enum class Type { | 44 enum class Type { |
45 TRACE_EVENT_NAME, // const char* string | 45 TRACE_EVENT_NAME, // const char* string |
46 THREAD_NAME, // const char* thread name | 46 THREAD_NAME, // const char* thread name |
| 47 PROGRAM_COUNTER, // as returned by stack tracing (e.g. by StackTrace) |
47 }; | 48 }; |
48 | 49 |
49 static StackFrame FromTraceEventName(const char* name) { | 50 static StackFrame FromTraceEventName(const char* name) { |
50 return {Type::TRACE_EVENT_NAME, name}; | 51 return {Type::TRACE_EVENT_NAME, name}; |
51 } | 52 } |
52 static StackFrame FromThreadName(const char* name) { | 53 static StackFrame FromThreadName(const char* name) { |
53 return {Type::THREAD_NAME, name}; | 54 return {Type::THREAD_NAME, name}; |
54 } | 55 } |
| 56 static StackFrame FromProgramCounter(const void* pc) { |
| 57 return {Type::PROGRAM_COUNTER, pc}; |
| 58 } |
55 | 59 |
56 Type type; | 60 Type type; |
57 const void* value; | 61 const void* value; |
58 }; | 62 }; |
59 | 63 |
60 bool BASE_EXPORT operator < (const StackFrame& lhs, const StackFrame& rhs); | 64 bool BASE_EXPORT operator < (const StackFrame& lhs, const StackFrame& rhs); |
61 bool BASE_EXPORT operator == (const StackFrame& lhs, const StackFrame& rhs); | 65 bool BASE_EXPORT operator == (const StackFrame& lhs, const StackFrame& rhs); |
62 bool BASE_EXPORT operator != (const StackFrame& lhs, const StackFrame& rhs); | 66 bool BASE_EXPORT operator != (const StackFrame& lhs, const StackFrame& rhs); |
63 | 67 |
64 struct BASE_EXPORT Backtrace { | 68 struct BASE_EXPORT Backtrace { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 }; | 128 }; |
125 | 129 |
126 template <> | 130 template <> |
127 struct BASE_EXPORT hash<base::trace_event::AllocationContext> { | 131 struct BASE_EXPORT hash<base::trace_event::AllocationContext> { |
128 size_t operator()(const base::trace_event::AllocationContext& context) const; | 132 size_t operator()(const base::trace_event::AllocationContext& context) const; |
129 }; | 133 }; |
130 | 134 |
131 } // BASE_HASH_NAMESPACE | 135 } // BASE_HASH_NAMESPACE |
132 | 136 |
133 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ | 137 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ |
OLD | NEW |