• 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 <cstdint>
21 #include <string>
22 #include <vector>
23 
24 namespace perfetto {
25 
26 namespace trace_processor {
27 class TraceProcessor;
28 }
29 
30 namespace profiling {
31 class Symbolizer;
32 }
33 
34 namespace trace_to_text {
35 
36 enum class ProfileType {
37   kHeapProfile,
38   kJavaHeapProfile,
39   kPerfProfile,
40 };
41 
42 struct SerializedProfile {
43   ProfileType profile_type;
44   uint64_t pid;
45   std::string serialized;
46   // non-empty if profile_type == kHeapProfile
47   std::string heap_name;
48 };
49 
50 enum class ConversionMode { kHeapProfile, kPerfProfile, kJavaHeapProfile };
51 
52 enum class ConversionFlags : uint64_t {
53   kNone = 0,
54   // Suffix frame names with additional information. Current annotations are
55   // specific to apps running within the Android runtime, and include
56   // information such as whether the given frame was interpreted / executed
57   // under JIT / etc.
58   kAnnotateFrames = 1
59 };
60 
61 bool TraceToPprof(trace_processor::TraceProcessor* tp,
62                   std::vector<SerializedProfile>* output,
63                   ConversionMode mode = ConversionMode::kHeapProfile,
64                   uint64_t flags = 0,
65                   uint64_t pid = 0,
66                   const std::vector<uint64_t>& timestamps = {});
67 
68 }  // namespace trace_to_text
69 }  // namespace perfetto
70 
71 #endif  // INCLUDE_PERFETTO_PROFILING_PPROF_BUILDER_H_
72