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