diff options
author | Lalit Maganti <lalitm@google.com> | 2024-05-13 12:34:38 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-05-13 12:34:38 +0000 |
commit | 314796c1f920daf390861f68d9349414acbb478a (patch) | |
tree | 32bb76c1dc324b287d518681fd1abe3622b700b9 | |
parent | 99ead97a359f6bde7db6edd9cdf28e2b2d57e8fc (diff) | |
parent | 8ff526265cce05bf0c6b8737fb0e484d81d595b8 (diff) | |
download | perfetto-314796c1f920daf390861f68d9349414acbb478a.tar.gz |
Merge "tp: fix compile of sqlite modules in MSVC" into main
12 files changed, 84 insertions, 49 deletions
diff --git a/include/perfetto/base/logging.h b/include/perfetto/base/logging.h index 7730c32cb..a882e2ebe 100644 --- a/include/perfetto/base/logging.h +++ b/include/perfetto/base/logging.h @@ -148,8 +148,8 @@ inline void MaybeSerializeLastLogsForCrashReporting() {} __LINE__, ##__VA_ARGS__); \ } while (0) #elif defined(PERFETTO_DISABLE_LOG) -#define PERFETTO_XLOG(level, fmt, ...) ::perfetto::base::ignore_result(level, \ - fmt, ##__VA_ARGS__) +#define PERFETTO_XLOG(level, fmt, ...) \ + ::perfetto::base::ignore_result(level, fmt, ##__VA_ARGS__) #else #define PERFETTO_XLOG(level, fmt, ...) \ ::perfetto::base::LogMessage(level, ::perfetto::base::Basename(__FILE__), \ diff --git a/src/trace_processor/perfetto_sql/engine/runtime_table_function.h b/src/trace_processor/perfetto_sql/engine/runtime_table_function.h index 37abd2a59..b3a7b5bec 100644 --- a/src/trace_processor/perfetto_sql/engine/runtime_table_function.h +++ b/src/trace_processor/perfetto_sql/engine/runtime_table_function.h @@ -117,6 +117,10 @@ struct RuntimeTableFunctionModule static int Eof(sqlite3_vtab_cursor*); static int Column(sqlite3_vtab_cursor*, sqlite3_context*, int); static int Rowid(sqlite3_vtab_cursor*, sqlite_int64*); + + // This needs to happen at the end as it depends on the functions + // defined above. + static constexpr sqlite3_module kModule = CreateModule(); }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/perfetto_sql/engine/table_pointer_module.h b/src/trace_processor/perfetto_sql/engine/table_pointer_module.h index bd15c90c6..6cb4f59f1 100644 --- a/src/trace_processor/perfetto_sql/engine/table_pointer_module.h +++ b/src/trace_processor/perfetto_sql/engine/table_pointer_module.h @@ -103,6 +103,10 @@ struct TablePointerModule : sqlite::Module<TablePointerModule> { const char*, FindFunctionFn**, void**); + + // This needs to happen at the end as it depends on the functions + // defined above. + static constexpr sqlite3_module kModule = CreateModule(); }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/perfetto_sql/intrinsics/operators/counter_mipmap_operator.h b/src/trace_processor/perfetto_sql/intrinsics/operators/counter_mipmap_operator.h index 1b0897cc0..7c1337bda 100644 --- a/src/trace_processor/perfetto_sql/intrinsics/operators/counter_mipmap_operator.h +++ b/src/trace_processor/perfetto_sql/intrinsics/operators/counter_mipmap_operator.h @@ -120,6 +120,10 @@ struct CounterMipmapOperator : sqlite::Module<CounterMipmapOperator> { static int Eof(sqlite3_vtab_cursor*); static int Column(sqlite3_vtab_cursor*, sqlite3_context*, int); static int Rowid(sqlite3_vtab_cursor*, sqlite_int64*); + + // This needs to happen at the end as it depends on the functions + // defined above. + static constexpr sqlite3_module kModule = CreateModule(); }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/perfetto_sql/intrinsics/operators/slice_mipmap_operator.h b/src/trace_processor/perfetto_sql/intrinsics/operators/slice_mipmap_operator.h index 329122582..e74e96011 100644 --- a/src/trace_processor/perfetto_sql/intrinsics/operators/slice_mipmap_operator.h +++ b/src/trace_processor/perfetto_sql/intrinsics/operators/slice_mipmap_operator.h @@ -121,6 +121,10 @@ struct SliceMipmapOperator : sqlite::Module<SliceMipmapOperator> { static int Eof(sqlite3_vtab_cursor*); static int Column(sqlite3_vtab_cursor*, sqlite3_context*, int); static int Rowid(sqlite3_vtab_cursor*, sqlite_int64*); + + // This needs to happen at the end as it depends on the functions + // defined above. + static constexpr sqlite3_module kModule = CreateModule(); }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/perfetto_sql/intrinsics/operators/span_join_operator.h b/src/trace_processor/perfetto_sql/intrinsics/operators/span_join_operator.h index 18f389f21..565222372 100644 --- a/src/trace_processor/perfetto_sql/intrinsics/operators/span_join_operator.h +++ b/src/trace_processor/perfetto_sql/intrinsics/operators/span_join_operator.h @@ -469,6 +469,10 @@ struct SpanJoinOperatorModule : public sqlite::Module<SpanJoinOperatorModule> { const char*, FindFunctionFn**, void**); + + // This needs to happen at the end as it depends on the functions + // defined above. + static constexpr sqlite3_module kModule = CreateModule(); }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/perfetto_sql/intrinsics/operators/window_operator.cc b/src/trace_processor/perfetto_sql/intrinsics/operators/window_operator.cc index 3092af184..fc1949759 100644 --- a/src/trace_processor/perfetto_sql/intrinsics/operators/window_operator.cc +++ b/src/trace_processor/perfetto_sql/intrinsics/operators/window_operator.cc @@ -42,6 +42,16 @@ constexpr char kSchema[] = R"( )"; } +enum Column { + kRowId = 0, + kQuantum = 1, + kWindowStart = 2, + kWindowDur = 3, + kTs = 4, + kDuration = 5, + kQuantumTs = 6 +}; + int WindowOperatorModule::Create(sqlite3* db, void* raw_ctx, int argc, diff --git a/src/trace_processor/perfetto_sql/intrinsics/operators/window_operator.h b/src/trace_processor/perfetto_sql/intrinsics/operators/window_operator.h index f7cf8054c..3b79e9201 100644 --- a/src/trace_processor/perfetto_sql/intrinsics/operators/window_operator.h +++ b/src/trace_processor/perfetto_sql/intrinsics/operators/window_operator.h @@ -63,15 +63,6 @@ struct WindowOperatorModule : sqlite::Module<WindowOperatorModule> { FilterType filter_type = FilterType::kReturnAll; }; - enum Column { - kRowId = 0, - kQuantum = 1, - kWindowStart = 2, - kWindowDur = 3, - kTs = 4, - kDuration = 5, - kQuantumTs = 6 - }; static constexpr auto kType = kCreateOnly; static constexpr bool kDoesOverloadFunctions = false; @@ -108,6 +99,10 @@ struct WindowOperatorModule : sqlite::Module<WindowOperatorModule> { static int Rowid(sqlite3_vtab_cursor*, sqlite_int64*); static int Update(sqlite3_vtab*, int, sqlite3_value**, sqlite_int64*); + + // This needs to happen at the end as it depends on the functions + // defined above. + static constexpr sqlite3_module kModule = CreateModule(); }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/sqlite/bindings/sqlite_module.h b/src/trace_processor/sqlite/bindings/sqlite_module.h index 61bcb7bd0..ed3b8a651 100644 --- a/src/trace_processor/sqlite/bindings/sqlite_module.h +++ b/src/trace_processor/sqlite/bindings/sqlite_module.h @@ -19,6 +19,8 @@ #include <sqlite3.h> +#include "perfetto/base/logging.h" + namespace perfetto::trace_processor::sqlite { // Prototype for a virtual table (vtab) module which can be registered with @@ -48,44 +50,6 @@ struct Module { // Setting this to true requires that the |FindFunction| function is defined. static constexpr bool kDoesOverloadFunctions = true; - // sqlite3_module object corresponding to the module. Used to pass information - // about this module to SQLite. - // - // Note: this has to be defined here to allow referencing the functions - // defined above. - static constexpr sqlite3_module kModule = []() { - sqlite3_module module{}; - module.xBestIndex = &Impl::BestIndex; - module.xOpen = &Impl::Open; - module.xClose = &Impl::Close; - module.xFilter = &Impl::Filter; - module.xNext = &Impl::Next; - module.xEof = &Impl::Eof; - module.xColumn = &Impl::Column; - module.xRowid = &Impl::Rowid; - if constexpr (Impl::kType == kCreateOnly) { - module.xCreate = &Impl::Create; - module.xDestroy = &Impl::Destroy; - module.xConnect = &Impl::Connect; - module.xDisconnect = &Impl::Disconnect; - } else { - module.xCreate = nullptr; - module.xDestroy = [](sqlite3_vtab*) -> int { - __builtin_trap(); - __builtin_unreachable(); - }; - module.xConnect = &Impl::Connect; - module.xDisconnect = &Impl::Disconnect; - } - if constexpr (Impl::kSupportsWrites) { - module.xUpdate = &Impl::Update; - } - if constexpr (Impl::kDoesOverloadFunctions) { - module.xFindFunction = &Impl::FindFunction; - } - return module; - }(); - // Specifies the type of context for the module. Implementations should define // this type to match the context type which is expected to be passed into // |sqlite3_create_module|. @@ -228,6 +192,40 @@ struct Module { static auto GetCursor(sqlite3_vtab_cursor* cursor) { return static_cast<typename Impl::Cursor*>(cursor); } + + // Returns sqlite3_module object corresponding to the module. Used to pass + // information about this module to SQLite. + static constexpr sqlite3_module CreateModule() { + sqlite3_module module{}; + module.xBestIndex = &Impl::BestIndex; + module.xOpen = &Impl::Open; + module.xClose = &Impl::Close; + module.xFilter = &Impl::Filter; + module.xNext = &Impl::Next; + module.xEof = &Impl::Eof; + module.xColumn = &Impl::Column; + module.xRowid = &Impl::Rowid; + if constexpr (Impl::kType == kCreateOnly) { + module.xCreate = &Impl::Create; + module.xDestroy = &Impl::Destroy; + module.xConnect = &Impl::Connect; + module.xDisconnect = &Impl::Disconnect; + } else { + module.xCreate = nullptr; + module.xDestroy = [](sqlite3_vtab*) -> int { + PERFETTO_FATAL("Should not be reachable"); + }; + module.xConnect = &Impl::Connect; + module.xDisconnect = &Impl::Disconnect; + } + if constexpr (Impl::kSupportsWrites) { + module.xUpdate = &Impl::Update; + } + if constexpr (Impl::kDoesOverloadFunctions) { + module.xFindFunction = &Impl::FindFunction; + } + return module; + } }; } // namespace perfetto::trace_processor::sqlite diff --git a/src/trace_processor/sqlite/db_sqlite_table.h b/src/trace_processor/sqlite/db_sqlite_table.h index a94cbe693..1085e39dd 100644 --- a/src/trace_processor/sqlite/db_sqlite_table.h +++ b/src/trace_processor/sqlite/db_sqlite_table.h @@ -158,6 +158,10 @@ struct DbSqliteModule : public sqlite::Module<DbSqliteModule> { sqlite3_index_info* info, const std::vector<int>&, const std::vector<int>&); + + // This needs to happen at the end as it depends on the functions + // defined above. + static constexpr sqlite3_module kModule = CreateModule(); }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/sqlite/sql_stats_table.h b/src/trace_processor/sqlite/sql_stats_table.h index 45d5b145c..caacb89d0 100644 --- a/src/trace_processor/sqlite/sql_stats_table.h +++ b/src/trace_processor/sqlite/sql_stats_table.h @@ -71,6 +71,10 @@ struct SqlStatsModule : sqlite::Module<SqlStatsModule> { static int Eof(sqlite3_vtab_cursor*); static int Column(sqlite3_vtab_cursor*, sqlite3_context*, int); static int Rowid(sqlite3_vtab_cursor*, sqlite_int64*); + + // This needs to happen at the end as it depends on the functions + // defined above. + static constexpr sqlite3_module kModule = CreateModule(); }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/sqlite/stats_table.h b/src/trace_processor/sqlite/stats_table.h index bff7ae808..f9b499626 100644 --- a/src/trace_processor/sqlite/stats_table.h +++ b/src/trace_processor/sqlite/stats_table.h @@ -65,6 +65,10 @@ struct StatsModule : sqlite::Module<StatsModule> { static int Eof(sqlite3_vtab_cursor*); static int Column(sqlite3_vtab_cursor*, sqlite3_context*, int); static int Rowid(sqlite3_vtab_cursor*, sqlite_int64*); + + // This needs to happen at the end as it depends on the functions + // defined above. + static constexpr sqlite3_module kModule = CreateModule(); }; } // namespace perfetto::trace_processor |