1 /* 2 * Copyright (C) 2020 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 SRC_TRACE_PROCESSOR_DYNAMIC_EXPERIMENTAL_FLAMEGRAPH_GENERATOR_H_ 18 #define SRC_TRACE_PROCESSOR_DYNAMIC_EXPERIMENTAL_FLAMEGRAPH_GENERATOR_H_ 19 20 #include "src/trace_processor/importers/proto/flamegraph_construction_algorithms.h" 21 #include "src/trace_processor/sqlite/db_sqlite_table.h" 22 23 #include "src/trace_processor/storage/trace_storage.h" 24 25 namespace perfetto { 26 namespace trace_processor { 27 28 class TraceProcessorContext; 29 30 class ExperimentalFlamegraphGenerator 31 : public DbSqliteTable::DynamicTableGenerator { 32 public: 33 enum class ProfileType { kGraph, kNative, kPerf }; 34 35 struct InputValues { 36 ProfileType profile_type; 37 int64_t ts; 38 std::vector<TimeConstraints> time_constraints; 39 base::Optional<UniquePid> upid; 40 base::Optional<std::string> upid_group; 41 std::string focus_str; 42 }; 43 44 explicit ExperimentalFlamegraphGenerator(TraceProcessorContext* context); 45 virtual ~ExperimentalFlamegraphGenerator() override; 46 47 Table::Schema CreateSchema() override; 48 std::string TableName() override; 49 uint32_t EstimateRowCount() override; 50 base::Status ValidateConstraints(const QueryConstraints&) override; 51 base::Status ComputeTable(const std::vector<Constraint>& cs, 52 const std::vector<Order>& ob, 53 const BitVector& cols_used, 54 std::unique_ptr<Table>& table_return) override; 55 56 private: 57 TraceProcessorContext* context_ = nullptr; 58 }; 59 60 } // namespace trace_processor 61 } // namespace perfetto 62 63 #endif // SRC_TRACE_PROCESSOR_DYNAMIC_EXPERIMENTAL_FLAMEGRAPH_GENERATOR_H_ 64