1 /*
2  * Copyright (C) 2021 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_PERFETTO_SQL_INTRINSICS_TABLE_FUNCTIONS_FLAMEGRAPH_CONSTRUCTION_ALGORITHMS_H_
18 #define SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_TABLE_FUNCTIONS_FLAMEGRAPH_CONSTRUCTION_ALGORITHMS_H_
19 
20 #include <cstdint>
21 #include <memory>
22 #include <optional>
23 #include <string>
24 #include <vector>
25 
26 #include "src/trace_processor/db/column/types.h"
27 #include "src/trace_processor/storage/trace_storage.h"
28 #include "src/trace_processor/tables/profiler_tables_py.h"
29 
30 namespace perfetto::trace_processor {
31 
32 // Represents a time boundary for a column.
33 struct TimeConstraints {
34   FilterOp op;
35   int64_t value;
36 };
37 
38 std::unique_ptr<tables::ExperimentalFlamegraphTable> BuildHeapProfileFlamegraph(
39     TraceStorage* storage,
40     UniquePid upid,
41     int64_t timestamp);
42 
43 std::unique_ptr<tables::ExperimentalFlamegraphTable>
44 BuildNativeCallStackSamplingFlamegraph(
45     TraceStorage* storage,
46     std::optional<UniquePid> upid,
47     std::optional<std::string> upid_group,
48     const std::vector<TimeConstraints>& time_constraints);
49 
50 }  // namespace perfetto::trace_processor
51 
52 #endif  // SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_TABLE_FUNCTIONS_FLAMEGRAPH_CONSTRUCTION_ALGORITHMS_H_
53