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_EXPERIMENTAL_ANNOTATED_STACK_H_
18 #define SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_TABLE_FUNCTIONS_EXPERIMENTAL_ANNOTATED_STACK_H_
19 
20 #include <cstdint>
21 #include <memory>
22 #include <string>
23 #include <vector>
24 
25 #include "perfetto/ext/base/status_or.h"
26 #include "perfetto/trace_processor/basic_types.h"
27 #include "src/trace_processor/db/table.h"
28 #include "src/trace_processor/perfetto_sql/intrinsics/table_functions/static_table_function.h"
29 
30 namespace perfetto::trace_processor {
31 
32 class TraceProcessorContext;
33 
34 // The "experimental_annotated_callstack" dynamic table.
35 //
36 // Given a leaf callsite id, returns the full callstack (including the leaf),
37 // with optional (currently Android-specific) annotations. A given callsite will
38 // always have the same annotation.
39 class ExperimentalAnnotatedStack : public StaticTableFunction {
40  public:
ExperimentalAnnotatedStack(TraceProcessorContext * context)41   explicit ExperimentalAnnotatedStack(TraceProcessorContext* context)
42       : context_(context) {}
43 
44   Table::Schema CreateSchema() override;
45   std::string TableName() override;
46   uint32_t EstimateRowCount() override;
47   base::StatusOr<std::unique_ptr<Table>> ComputeTable(
48       const std::vector<SqlValue>& arguments) override;
49 
50  private:
51   TraceProcessorContext* context_ = nullptr;
52 };
53 
54 }  // namespace perfetto::trace_processor
55 
56 #endif  // SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_TABLE_FUNCTIONS_EXPERIMENTAL_ANNOTATED_STACK_H_
57