diff --git a/CHANGELOG b/CHANGELOG index ce038d2150..39c3538908 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,10 @@ Unreleased: SDK: * +v36.1 - 2023-07-06: + Trace Processor: + * Fix compile on Windows. + v36.0 - 2023-07-05: Tracing service and probes: * Fixed unnecessary reads of thread files /proc when scraping process names. diff --git a/src/trace_processor/db/query_executor_unittest.cc b/src/trace_processor/db/query_executor_unittest.cc index d8b79d786b..5152920348 100644 --- a/src/trace_processor/db/query_executor_unittest.cc +++ b/src/trace_processor/db/query_executor_unittest.cc @@ -445,6 +445,7 @@ TEST(QueryExecutor, StringBinarySearchIsNull) { ASSERT_EQ(res.Get(0), 2u); } +#if !PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) TEST(QueryExecutor, StringBinarySearchRegex) { StringPool pool; std::vector strings{"cheese", "pasta", "pizza", @@ -502,6 +503,7 @@ TEST(QueryExecutor, StringBinarySearchRegexWithNum) { ASSERT_EQ(res.size(), 0u); } +#endif } // namespace } // namespace trace_processor diff --git a/src/trace_processor/db/storage/string_storage.cc b/src/trace_processor/db/storage/string_storage.cc index 2a31652420..d0f7b3eede 100644 --- a/src/trace_processor/db/storage/string_storage.cc +++ b/src/trace_processor/db/storage/string_storage.cc @@ -95,8 +95,6 @@ struct GlobFullStringPool { std::vector matches_; }; -#if !PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) - struct Regex { bool operator()(StringPool::Id rhs, regex::Regex& pattern) const { return rhs != StringPool::Id::Null() && @@ -122,8 +120,6 @@ struct RegexFullStringPool { std::vector matches_; }; -#endif - struct IsNull { bool operator()(StringPool::Id rhs, StringPool::Id) const { return rhs == StringPool::Id::Null(); @@ -216,31 +212,25 @@ RangeOrBitVector StringStorage::Search(FilterOp op, GlobFullStringPool{string_pool_, matcher}, builder); break; } - case FilterOp::kRegex: - if constexpr (regex::IsRegexSupported()) { - base::StatusOr regex = - regex::Regex::Create(sql_val.AsString()); - if (!regex.status().ok()) { - break; - } - - // For very big string pools (or small ranges) or pools with large - // strings run a standard regex function. - if (range.size() < string_pool_->size() || - string_pool_->HasLargeString()) { - utils::LinearSearchWithComparator(std::move(regex.value()), start, - Regex{string_pool_}, builder); - break; - } - - utils::LinearSearchWithComparator( - StringPool::Id::Null(), start, - RegexFullStringPool{string_pool_, regex.value()}, builder); + case FilterOp::kRegex: { + // Caller should ensure that the regex is valid. + base::StatusOr regex = + regex::Regex::Create(sql_val.AsString()); + PERFETTO_CHECK(regex.status().ok()); + + // For very big string pools (or small ranges) or pools with large + // strings run a standard regex function. + if (range.size() < string_pool_->size() || + string_pool_->HasLargeString()) { + utils::LinearSearchWithComparator(std::move(regex.value()), start, + Regex{string_pool_}, builder); break; - } else { - PERFETTO_DFATAL("Regex not supported"); } - + utils::LinearSearchWithComparator( + StringPool::Id::Null(), start, + RegexFullStringPool{string_pool_, regex.value()}, builder); + break; + } case FilterOp::kIsNull: utils::LinearSearchWithComparator(val, start, IsNull(), builder); break; @@ -312,15 +302,13 @@ RangeOrBitVector StringStorage::IndexSearch(FilterOp op, Glob{string_pool_}, builder); break; } - case FilterOp::kRegex: - PERFETTO_CHECK(regex::IsRegexSupported()); - if constexpr (regex::IsRegexSupported()) { - base::StatusOr regex = - regex::Regex::Create(sql_val.AsString()); - utils::IndexSearchWithComparator(std::move(regex.value()), start, - indices, Regex{string_pool_}, builder); - } + case FilterOp::kRegex: { + base::StatusOr regex = + regex::Regex::Create(sql_val.AsString()); + utils::IndexSearchWithComparator(std::move(regex.value()), start, indices, + Regex{string_pool_}, builder); break; + } case FilterOp::kIsNull: utils::IndexSearchWithComparator(val, start, indices, IsNull(), builder); break; diff --git a/src/trace_processor/db/storage/string_storage_unittest.cc b/src/trace_processor/db/storage/string_storage_unittest.cc index ab3d7d8257..1c0f1ef2b5 100644 --- a/src/trace_processor/db/storage/string_storage_unittest.cc +++ b/src/trace_processor/db/storage/string_storage_unittest.cc @@ -194,6 +194,7 @@ TEST(StringStorageUnittest, LinearSearchGlob) { ASSERT_EQ(bv.CountSetBits(), 3u); } +#if !PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) TEST(StringStorageUnittest, LinearSearchRegex) { std::vector strings{"cheese", "pasta", "pizza", "pierogi", "onion", "fries"}; @@ -229,6 +230,7 @@ TEST(StringStorageUnittest, LinearSearchRegexMalformed) { ASSERT_EQ(bv.CountSetBits(), 0u); } +#endif TEST(StringStorageUnittest, IndexSearchEq) { std::vector strings{"cheese", "pasta", "pizza", diff --git a/src/trace_processor/util/regex.h b/src/trace_processor/util/regex.h index d64a83665b..120e4c9682 100644 --- a/src/trace_processor/util/regex.h +++ b/src/trace_processor/util/regex.h @@ -18,6 +18,7 @@ #define SRC_TRACE_PROCESSOR_UTIL_REGEX_H_ #include +#include "perfetto/base/compiler.h" #include "perfetto/ext/base/scoped_file.h" #include "perfetto/ext/base/status_or.h" @@ -69,6 +70,7 @@ class Regex { } return Regex(std::move(regex)); #else + base::ignore_result(pattern); PERFETTO_FATAL("Windows regex is not supported."); #endif } @@ -79,6 +81,7 @@ class Regex { PERFETTO_CHECK(regex_); return regexec(®ex_.value(), s, 0, nullptr, 0) == 0; #else + base::ignore_result(s); PERFETTO_FATAL("Windows regex is not supported."); #endif }