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(const void* base_address, const std::string& id, |
Mike Wittman
2015/08/31 21:42:00
The |base_address| parameter should use the same t
sydli
2015/09/01 00:29:59
Done.
| |
68 const FilePath& filename); | 68 const FilePath& filename); |
69 ~Module(); | 69 ~Module(); |
70 | 70 |
71 // Points to the base address of the module. | 71 // Points to the base address of the module. |
72 const void* base_address; | 72 uintptr_t base_address; |
Mike Wittman
2015/08/31 20:57:57
I'd prefer to keep the const void* type for this a
erikchen
2015/08/31 21:15:17
The type of this member should not be dependent on
Mike Wittman
2015/08/31 21:42:00
Debuggability of the code is always a relevant con
sydli
2015/09/01 00:29:59
Okay; I split this into a separate CL:
https://cod
Mike Wittman
2015/09/01 00:41:57
The const void* => uintptr_t change should be pret
| |
73 | 73 |
74 // An opaque binary string that uniquely identifies a particular program | 74 // An opaque binary string that uniquely identifies a particular program |
75 // version with high probability. This is parsed from headers of the loaded | 75 // version with high probability. This is parsed from headers of the loaded |
76 // module. | 76 // module. |
77 // For binaries generated by GNU tools: | 77 // For binaries generated by GNU tools: |
78 // Contents of the .note.gnu.build-id field. | 78 // Contents of the .note.gnu.build-id field. |
79 // On Windows: | 79 // On Windows: |
80 // GUID + AGE in the debug image headers of a module. | 80 // GUID + AGE in the debug image headers of a module. |
81 std::string id; | 81 std::string id; |
82 | 82 |
83 // The filename of the module. | 83 // The filename of the module. |
84 FilePath filename; | 84 FilePath filename; |
85 }; | 85 }; |
86 | 86 |
87 // Frame represents an individual sampled stack frame with module information. | 87 // Frame represents an individual sampled stack frame with module information. |
88 struct BASE_EXPORT Frame { | 88 struct BASE_EXPORT Frame { |
89 // Identifies an unknown module. | 89 // Identifies an unknown module. |
90 static const size_t kUnknownModuleIndex = static_cast<size_t>(-1); | 90 static const size_t kUnknownModuleIndex = static_cast<size_t>(-1); |
91 | 91 |
92 Frame(); | |
92 Frame(const void* instruction_pointer, size_t module_index); | 93 Frame(const void* instruction_pointer, size_t module_index); |
Mike Wittman
2015/08/31 21:42:00
Similarly, the |instruction_pointer| parameter sho
sydli
2015/09/01 00:29:59
Done.
| |
93 ~Frame(); | 94 ~Frame(); |
94 | 95 |
95 // The sampled instruction pointer within the function. | 96 // The sampled instruction pointer within the function. |
96 const void* instruction_pointer; | 97 uintptr_t instruction_pointer; |
97 | 98 |
98 // Index of the module in CallStackProfile::modules. We don't represent | 99 // Index of the module in CallStackProfile::modules. We don't represent |
99 // module state directly here to save space. | 100 // module state directly here to save space. |
100 size_t module_index; | 101 size_t module_index; |
101 }; | 102 }; |
102 | 103 |
103 // Sample represents a set of stack frames. | 104 // Sample represents a set of stack frames. |
104 using Sample = std::vector<Frame>; | 105 using Sample = std::vector<Frame>; |
105 | 106 |
106 // CallStackProfile represents a set of samples. | 107 // 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, | 234 // The metrics provider code wants to put Samples in a map and compare them, |
234 // which requires us to define a few operators. | 235 // which requires us to define a few operators. |
235 BASE_EXPORT bool operator==(const StackSamplingProfiler::Frame& a, | 236 BASE_EXPORT bool operator==(const StackSamplingProfiler::Frame& a, |
236 const StackSamplingProfiler::Frame& b); | 237 const StackSamplingProfiler::Frame& b); |
237 BASE_EXPORT bool operator<(const StackSamplingProfiler::Frame& a, | 238 BASE_EXPORT bool operator<(const StackSamplingProfiler::Frame& a, |
238 const StackSamplingProfiler::Frame& b); | 239 const StackSamplingProfiler::Frame& b); |
239 | 240 |
240 } // namespace base | 241 } // namespace base |
241 | 242 |
242 #endif // BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ | 243 #endif // BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ |
OLD | NEW |