xref: /aosp_15_r20/external/cronet/base/profiler/frame.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1*6777b538SAndroid Build Coastguard Worker // Copyright 2019 The Chromium Authors
2*6777b538SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*6777b538SAndroid Build Coastguard Worker // found in the LICENSE file.
4*6777b538SAndroid Build Coastguard Worker 
5*6777b538SAndroid Build Coastguard Worker #ifndef BASE_PROFILER_FRAME_H_
6*6777b538SAndroid Build Coastguard Worker #define BASE_PROFILER_FRAME_H_
7*6777b538SAndroid Build Coastguard Worker 
8*6777b538SAndroid Build Coastguard Worker #include "base/base_export.h"
9*6777b538SAndroid Build Coastguard Worker #include "base/memory/raw_ptr_exclusion.h"
10*6777b538SAndroid Build Coastguard Worker #include "base/profiler/module_cache.h"
11*6777b538SAndroid Build Coastguard Worker 
12*6777b538SAndroid Build Coastguard Worker namespace base {
13*6777b538SAndroid Build Coastguard Worker 
14*6777b538SAndroid Build Coastguard Worker // Frame represents an individual sampled stack frame with full module
15*6777b538SAndroid Build Coastguard Worker // information.
16*6777b538SAndroid Build Coastguard Worker struct BASE_EXPORT Frame {
17*6777b538SAndroid Build Coastguard Worker   Frame(uintptr_t instruction_pointer, const ModuleCache::Module* module);
18*6777b538SAndroid Build Coastguard Worker 
19*6777b538SAndroid Build Coastguard Worker   // TODO(crbug.com/1371105): For prototype use by Android arm browser main
20*6777b538SAndroid Build Coastguard Worker   // thread profiling for tracing only. Update once we have a full design
21*6777b538SAndroid Build Coastguard Worker   // for function name upload.
22*6777b538SAndroid Build Coastguard Worker   Frame(uintptr_t instruction_pointer,
23*6777b538SAndroid Build Coastguard Worker         const ModuleCache::Module* module,
24*6777b538SAndroid Build Coastguard Worker         std::string function_name);
25*6777b538SAndroid Build Coastguard Worker   ~Frame();
26*6777b538SAndroid Build Coastguard Worker 
27*6777b538SAndroid Build Coastguard Worker   // The sampled instruction pointer within the function.
28*6777b538SAndroid Build Coastguard Worker   uintptr_t instruction_pointer;
29*6777b538SAndroid Build Coastguard Worker 
30*6777b538SAndroid Build Coastguard Worker   // The module information.
31*6777b538SAndroid Build Coastguard Worker   // `module` is not a raw_ptr<...> because it is used with gmock Field() that
32*6777b538SAndroid Build Coastguard Worker   // expects a raw pointer in V8UnwinderTest.UnwindThroughV8Frames.
33*6777b538SAndroid Build Coastguard Worker   RAW_PTR_EXCLUSION const ModuleCache::Module* module;
34*6777b538SAndroid Build Coastguard Worker 
35*6777b538SAndroid Build Coastguard Worker   // This serves as a temporary way to pass function names from libunwindstack
36*6777b538SAndroid Build Coastguard Worker   // unwinder to tracing profiler. Not used by any other unwinder.
37*6777b538SAndroid Build Coastguard Worker   // TODO(crbug.com/1371105): For prototype use by Android arm browser main
38*6777b538SAndroid Build Coastguard Worker   // thread profiling for tracing only. Update once we have a full design
39*6777b538SAndroid Build Coastguard Worker   // for function name upload.
40*6777b538SAndroid Build Coastguard Worker   std::string function_name;
41*6777b538SAndroid Build Coastguard Worker };
42*6777b538SAndroid Build Coastguard Worker 
43*6777b538SAndroid Build Coastguard Worker }  // namespace base
44*6777b538SAndroid Build Coastguard Worker 
45*6777b538SAndroid Build Coastguard Worker #endif  // BASE_PROFILER_FRAME_H_
46