xref: /aosp_15_r20/external/perfetto/src/trace_processor/perfetto_sql/intrinsics/functions/stack_functions.h (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1 /*
2  * Copyright (C) 2023 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_FUNCTIONS_STACK_FUNCTIONS_H_
18 #define SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_FUNCTIONS_STACK_FUNCTIONS_H_
19 
20 #include <sqlite3.h>
21 #include <cstddef>
22 #include <cstdint>
23 
24 #include "perfetto/base/status.h"
25 
26 namespace perfetto {
27 namespace trace_processor {
28 
29 class PerfettoSqlEngine;
30 class TraceProcessorContext;
31 
32 // Registers the stack manipulation related functions:
33 //
34 // STACK_FROM_STACK_PROFILE_FRAME(frame_id LONG)
35 // Creates a stack with just the frame referenced by frame_id (reference to the
36 // stack_profile_frame table)
37 //
38 // STACK_FROM_STACK_PROFILE_CALLSITE(callsite_id LONG, [annotate BOOLEAN])
39 // Creates a stack by taking a callsite_id (reference to the
40 // stack_profile_callsite table) and generating a list of frames (by walking the
41 // stack_profile_callsite table)
42 // Optionally annotates frames (annotate param has a default value of false)
43 // *Important*: Annotations might interfere with certain aggregations, as we
44 // will could have a frame that is annotated with different annotations. That
45 // will lead to multiple functions being generated (same name, line etc, but
46 // different annotation).
47 //
48 // CAT_STACKS(root BLOB/STRING, level_1 BLOB/STRING, …, leaf BLOB/STRING)
49 // Creates a Stack by concatenating other Stacks. Also accepts strings for which
50 // it generates a fake Frame
51 //
52 // See protos/perfetto/trace_processor/stack.proto
53 base::Status RegisterStackFunctions(PerfettoSqlEngine* engine,
54                                     TraceProcessorContext* context);
55 
56 }  // namespace trace_processor
57 }  // namespace perfetto
58 
59 #endif  // SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_FUNCTIONS_STACK_FUNCTIONS_H_
60