• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef INCLUDE_PERFETTO_PROFILING_PPROF_BUILDER_H_
18 #define INCLUDE_PERFETTO_PROFILING_PPROF_BUILDER_H_
19 
20 #include <string>
21 #include <vector>
22 
23 namespace perfetto {
24 
25 namespace trace_processor {
26 class TraceProcessor;
27 }
28 
29 namespace profiling {
30 class Symbolizer;
31 }
32 
33 namespace trace_to_text {
34 
35 enum class ProfileType {
36   kHeapProfile,
37   kPerfProfile,
38 };
39 
40 struct SerializedProfile {
41   ProfileType profile_type;
42   uint64_t pid;
43   std::string serialized;
44   // non-empty if profile_type == kHeapProfile
45   std::string heap_name;
46 };
47 
48 enum class ConversionMode { kHeapProfile, kPerfProfile };
49 
50 enum class ConversionFlags : uint64_t {
51   kNone = 0,
52   // Suffix frame names with additional information. Current annotations are
53   // specific to apps running within the Android runtime, and include
54   // information such as whether the given frame was interpreted / executed
55   // under JIT / etc.
56   kAnnotateFrames = 1
57 };
58 
59 bool TraceToPprof(trace_processor::TraceProcessor* tp,
60                   std::vector<SerializedProfile>* output,
61                   ConversionMode mode = ConversionMode::kHeapProfile,
62                   uint64_t flags = 0,
63                   uint64_t pid = 0,
64                   const std::vector<uint64_t>& timestamps = {});
65 
66 }  // namespace trace_to_text
67 }  // namespace perfetto
68 
69 #endif  // INCLUDE_PERFETTO_PROFILING_PPROF_BUILDER_H_
70