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