• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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_OPERATORS_ETM_DECODE_TRACE_VTABLE_H_
18 #define SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_OPERATORS_ETM_DECODE_TRACE_VTABLE_H_
19 
20 #include <memory>
21 
22 #include "src/trace_processor/sqlite/bindings/sqlite_module.h"
23 
24 namespace perfetto::trace_processor {
25 class TraceStorage;
26 namespace etm {
27 
28 struct EtmDecodeTraceVtable : sqlite::Module<EtmDecodeTraceVtable> {
29   using Context = TraceStorage;
30   struct Vtab : sqlite::Module<EtmDecodeTraceVtable>::Vtab {
VtabEtmDecodeTraceVtable::Vtab31     explicit Vtab(TraceStorage* in_storage) : storage(in_storage) {}
32     TraceStorage* storage;
33   };
34   class Cursor;
35   static constexpr auto kType = kEponymousOnly;
36   static constexpr bool kSupportsWrites = false;
37   static constexpr bool kDoesOverloadFunctions = false;
38 
39   static int Connect(sqlite3*,
40                      void*,
41                      int,
42                      const char* const*,
43                      sqlite3_vtab**,
44                      char**);
45   static int Disconnect(sqlite3_vtab*);
46 
47   static int BestIndex(sqlite3_vtab*, sqlite3_index_info*);
48 
49   static int Open(sqlite3_vtab*, sqlite3_vtab_cursor**);
50   static int Close(sqlite3_vtab_cursor*);
51 
52   static int Filter(sqlite3_vtab_cursor*,
53                     int,
54                     const char*,
55                     int,
56                     sqlite3_value**);
57   static int Next(sqlite3_vtab_cursor*);
58   static int Eof(sqlite3_vtab_cursor*);
59   static int Column(sqlite3_vtab_cursor*, sqlite3_context*, int);
60   static int Rowid(sqlite3_vtab_cursor*, sqlite_int64*);
61 
62   // This needs to happen at the end as it depends on the functions
63   // defined above.
64   static constexpr sqlite3_module kModule = CreateModule();
65 };
66 
67 }  // namespace etm
68 }  // namespace perfetto::trace_processor
69 
70 #endif  // SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_OPERATORS_ETM_DECODE_TRACE_VTABLE_H_
71