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_ITERATE_RANGE_VTABLE_H_ 18 #define SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_OPERATORS_ETM_ITERATE_RANGE_VTABLE_H_ 19 20 #include <cstdint> 21 22 #include "src/trace_processor/sqlite/bindings/sqlite_module.h" 23 #include "src/trace_processor/storage/trace_storage.h" 24 25 namespace perfetto::trace_processor::etm { 26 27 struct InstructionRangeSqlValue; 28 29 struct EtmIterateRangeVtable : sqlite::Module<EtmIterateRangeVtable> { 30 using Context = TraceStorage; 31 struct Vtab : sqlite::Module<EtmIterateRangeVtable>::Vtab { 32 TraceStorage* storage; 33 }; 34 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 perfetto::trace_processor::etm 68 69 #endif // SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_OPERATORS_ETM_ITERATE_RANGE_VTABLE_H_ 70