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_PROFILER_STACK_SAMPLING_PROFILER_H_ | 5 #ifndef BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ |
6 #define BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ | 6 #define BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // The results of the profiling are passed to the completed callback and consist | 57 // The results of the profiling are passed to the completed callback and consist |
58 // of a vector of CallStackProfiles. Each CallStackProfile corresponds to a | 58 // of a vector of CallStackProfiles. Each CallStackProfile corresponds to a |
59 // burst as specified in SamplingParams and contains a set of Samples and | 59 // burst as specified in SamplingParams and contains a set of Samples and |
60 // Modules. One Sample corresponds to a single recorded stack, and the Modules | 60 // Modules. One Sample corresponds to a single recorded stack, and the Modules |
61 // record those modules associated with the recorded stack frames. | 61 // record those modules associated with the recorded stack frames. |
62 class BASE_EXPORT StackSamplingProfiler { | 62 class BASE_EXPORT StackSamplingProfiler { |
63 public: | 63 public: |
64 // Module represents the module (DLL or exe) corresponding to a stack frame. | 64 // Module represents the module (DLL or exe) corresponding to a stack frame. |
65 struct BASE_EXPORT Module { | 65 struct BASE_EXPORT Module { |
66 Module(); | 66 Module(); |
67 Module(const void* base_address, const std::string& id, | 67 Module(uintptr_t base_address, |
| 68 const std::string& id, |
68 const FilePath& filename); | 69 const FilePath& filename); |
69 ~Module(); | 70 ~Module(); |
70 | 71 |
71 // Points to the base address of the module. | 72 // Points to the base address of the module. |
72 const void* base_address; | 73 uintptr_t base_address; |
73 | 74 |
74 // An opaque binary string that uniquely identifies a particular program | 75 // An opaque binary string that uniquely identifies a particular program |
75 // version with high probability. This is parsed from headers of the loaded | 76 // version with high probability. This is parsed from headers of the loaded |
76 // module. | 77 // module. |
77 // For binaries generated by GNU tools: | 78 // For binaries generated by GNU tools: |
78 // Contents of the .note.gnu.build-id field. | 79 // Contents of the .note.gnu.build-id field. |
79 // On Windows: | 80 // On Windows: |
80 // GUID + AGE in the debug image headers of a module. | 81 // GUID + AGE in the debug image headers of a module. |
81 std::string id; | 82 std::string id; |
82 | 83 |
83 // The filename of the module. | 84 // The filename of the module. |
84 FilePath filename; | 85 FilePath filename; |
85 }; | 86 }; |
86 | 87 |
87 // Frame represents an individual sampled stack frame with module information. | 88 // Frame represents an individual sampled stack frame with module information. |
88 struct BASE_EXPORT Frame { | 89 struct BASE_EXPORT Frame { |
89 // Identifies an unknown module. | 90 // Identifies an unknown module. |
90 static const size_t kUnknownModuleIndex = static_cast<size_t>(-1); | 91 static const size_t kUnknownModuleIndex = static_cast<size_t>(-1); |
91 | 92 |
92 Frame(const void* instruction_pointer, size_t module_index); | 93 Frame(uintptr_t instruction_pointer, size_t module_index); |
93 ~Frame(); | 94 ~Frame(); |
94 | 95 |
| 96 // Default constructor to satisfy IPC macros. Do not use explicitly. |
| 97 Frame(); |
| 98 |
95 // The sampled instruction pointer within the function. | 99 // The sampled instruction pointer within the function. |
96 const void* instruction_pointer; | 100 uintptr_t instruction_pointer; |
97 | 101 |
98 // Index of the module in CallStackProfile::modules. We don't represent | 102 // Index of the module in CallStackProfile::modules. We don't represent |
99 // module state directly here to save space. | 103 // module state directly here to save space. |
100 size_t module_index; | 104 size_t module_index; |
101 }; | 105 }; |
102 | 106 |
103 // Sample represents a set of stack frames. | 107 // Sample represents a set of stack frames. |
104 using Sample = std::vector<Frame>; | 108 using Sample = std::vector<Frame>; |
105 | 109 |
106 // CallStackProfile represents a set of samples. | 110 // CallStackProfile represents a set of samples. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // The metrics provider code wants to put Samples in a map and compare them, | 237 // The metrics provider code wants to put Samples in a map and compare them, |
234 // which requires us to define a few operators. | 238 // which requires us to define a few operators. |
235 BASE_EXPORT bool operator==(const StackSamplingProfiler::Frame& a, | 239 BASE_EXPORT bool operator==(const StackSamplingProfiler::Frame& a, |
236 const StackSamplingProfiler::Frame& b); | 240 const StackSamplingProfiler::Frame& b); |
237 BASE_EXPORT bool operator<(const StackSamplingProfiler::Frame& a, | 241 BASE_EXPORT bool operator<(const StackSamplingProfiler::Frame& a, |
238 const StackSamplingProfiler::Frame& b); | 242 const StackSamplingProfiler::Frame& b); |
239 | 243 |
240 } // namespace base | 244 } // namespace base |
241 | 245 |
242 #endif // BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ | 246 #endif // BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ |
OLD | NEW |