Merge "Migrate v8 tables to new intrinsics / stdlib convention" into main
diff --git a/bazel/deps.bzl b/bazel/deps.bzl
index a105a63..ee17856 100644
--- a/bazel/deps.bzl
+++ b/bazel/deps.bzl
@@ -35,18 +35,18 @@
     _add_repo_if_not_existing(
         http_archive,
         name = "perfetto_dep_sqlite",
-        url = "https://storage.googleapis.com/perfetto/sqlite-amalgamation-3390200.zip",
-        sha256 = "87775784f8b22d0d0f1d7811870d39feaa7896319c7c20b849a4181c5a50609b",
-        strip_prefix = "sqlite-amalgamation-3390200",
+        url = "https://storage.googleapis.com/perfetto/sqlite-amalgamation-3440200.zip",
+        sha256 = "833be89b53b3be8b40a2e3d5fedb635080e3edb204957244f3d6987c2bb2345f",
+        strip_prefix = "sqlite-amalgamation-3440200",
         build_file = "//bazel:sqlite.BUILD",
     )
 
     _add_repo_if_not_existing(
         http_archive,
         name = "perfetto_dep_sqlite_src",
-        url = "https://storage.googleapis.com/perfetto/sqlite-src-3390200.zip",
-        sha256 = "e933d77000f45f3fbc8605f0050586a3013505a8de9b44032bd00ed72f1586f0",
-        strip_prefix = "sqlite-src-3390200",
+        url = "https://storage.googleapis.com/perfetto/sqlite-src-3440200.zip",
+        sha256 = "73187473feb74509357e8fa6cb9fd67153b2d010d00aeb2fddb6ceeb18abaf27",
+        strip_prefix = "sqlite-src-3440200",
         build_file = "//bazel:sqlite.BUILD",
     )
 
diff --git a/gn/standalone/sanitizers/BUILD.gn b/gn/standalone/sanitizers/BUILD.gn
index 574dcfb..4fef817 100644
--- a/gn/standalone/sanitizers/BUILD.gn
+++ b/gn/standalone/sanitizers/BUILD.gn
@@ -19,8 +19,9 @@
   visibility = [ "*" ]
   if (using_sanitizer) {
     public_configs = [ ":sanitizers_ldflags" ]
+    deps = [ ":ignorelist_copy" ]
     if (is_android && sanitizer_lib != "" && !sanitizer_lib_dir_is_static) {
-      deps = [ ":copy_sanitizer_lib" ]
+      deps += [ ":copy_sanitizer_lib" ]
     }
   }
 }
@@ -32,9 +33,20 @@
   }
 }
 
+# Add a dependency on the ignorelist.txt file to cause rebuilds when
+# the file changes.
+copy("ignorelist_copy") {
+  sources = [ "ignorelist.txt" ]
+  outputs = [ "${target_out_dir}/ignorelist.txt" ]
+}
+
 config("sanitizers_cflags") {
   if (using_sanitizer) {
-    cflags = [ "-fno-omit-frame-pointer" ]
+    ignorelist_path_ = rebase_path("ignorelist.txt", root_build_dir)
+    cflags = [
+      "-fno-omit-frame-pointer",
+      "-fsanitize-ignorelist=$ignorelist_path_",
+    ]
     defines = []
 
     if (is_asan) {
diff --git a/gn/standalone/sanitizers/ignorelist.txt b/gn/standalone/sanitizers/ignorelist.txt
new file mode 100644
index 0000000..8a3d1d1
--- /dev/null
+++ b/gn/standalone/sanitizers/ignorelist.txt
@@ -0,0 +1,4 @@
+# The rules in this file are only applied at compile time.
+[memory]
+fun:vdbeChangeP4Full
+fun:*OpenDiskFile*
diff --git a/src/base/file_utils.cc b/src/base/file_utils.cc
index fba722d..a1fa238 100644
--- a/src/base/file_utils.cc
+++ b/src/base/file_utils.cc
@@ -433,7 +433,7 @@
   static_assert(sizeof(decltype(file_size.QuadPart)) <= sizeof(uint64_t));
   return static_cast<uint64_t>(file_size.QuadPart);
 #else
-  struct stat buf;
+  struct stat buf {};
   if (fstat(fd, &buf) == -1) {
     return std::nullopt;
   }
diff --git a/src/trace_processor/importers/ftrace/ftrace_parser.cc b/src/trace_processor/importers/ftrace/ftrace_parser.cc
index c853c44..475fcfc 100644
--- a/src/trace_processor/importers/ftrace/ftrace_parser.cc
+++ b/src/trace_processor/importers/ftrace/ftrace_parser.cc
@@ -571,6 +571,7 @@
   // buffer ABI not matching the data read out of the kernel (while the trace
   // was being recorded). Reject such traces altogether as we need to make such
   // errors hard to ignore (most likely it's a bug in perfetto or the kernel).
+  using protos::pbzero::FtraceParseStatus;
   auto error_it = evt.ftrace_parse_errors();
   if (error_it) {
     auto dev_flag =
@@ -585,13 +586,26 @@
           "native trace_processor_shell as an accelerator with these flags: "
           "\"trace_processor_shell --httpd --dev --dev-flag "
           "ignore-ftrace-parse-errors=true <trace_file.pb>\". Errors: ";
+      size_t error_count = 0;
       for (; error_it; ++error_it) {
-        msg += protos::pbzero::FtraceParseStatus_Name(
-            static_cast<protos::pbzero::FtraceParseStatus>(*error_it));
+        auto error_code = static_cast<FtraceParseStatus>(*error_it);
+        // Relax the strictness of zero-padded page errors, they're prevalent
+        // but also do not affect the actual ftrace payload.
+        // See b/329396486#comment6, b/204564312#comment20.
+        if (error_code ==
+            FtraceParseStatus::FTRACE_STATUS_ABI_ZERO_DATA_LENGTH) {
+          context_->storage->IncrementStats(
+              stats::ftrace_abi_errors_skipped_zero_data_length);
+          continue;
+        }
+        error_count += 1;
+        msg += protos::pbzero::FtraceParseStatus_Name(error_code);
         msg += ", ";
       }
       msg += "(ERR:ftrace_parse)";  // special marker for UI
-      return base::Status(msg);
+      if (error_count > 0) {
+        return base::Status(msg);
+      }
     }
   }
 
diff --git a/src/trace_processor/metrics/sql/experimental/frame_times.sql b/src/trace_processor/metrics/sql/experimental/frame_times.sql
index 80ad550..a3a73c5 100644
--- a/src/trace_processor/metrics/sql/experimental/frame_times.sql
+++ b/src/trace_processor/metrics/sql/experimental/frame_times.sql
@@ -52,20 +52,26 @@
 
 DROP VIEW IF EXISTS InterestingSegments;
 CREATE PERFETTO VIEW InterestingSegments AS
-SELECT  -- 1) Gestures overlapping interactions.
-  ts_ge AS ts,
-  dur_ge AS dur
-FROM InteractionEventsJoinGestureEvents
-WHERE ts_ge IS NOT NULL
-GROUP BY ts_ge
-UNION ALL
-SELECT  -- 2) Interactions without gestures.
-  ts_ir AS ts,
-  dur_ir AS dur
-FROM InteractionEventsJoinGestureEvents
-WHERE ts_ge IS NULL
-GROUP BY ts_ir
-HAVING COUNT(*) = 1;
+WITH pre_cast AS (
+  SELECT  -- 1) Gestures overlapping interactions.
+    ts_ge AS ts,
+    dur_ge AS dur
+  FROM InteractionEventsJoinGestureEvents
+  WHERE ts_ge IS NOT NULL
+  GROUP BY ts_ge
+  UNION ALL
+  SELECT  -- 2) Interactions without gestures.
+    ts_ir AS ts,
+    dur_ir AS dur
+  FROM InteractionEventsJoinGestureEvents
+  WHERE ts_ge IS NULL
+  GROUP BY ts_ir
+  HAVING COUNT(*) = 1
+)
+SELECT
+  CAST(ts AS BIGINT) AS ts,
+  CAST(dur AS BIGINT) AS dur
+FROM pre_cast;
 
 --------------------------------------------------------------------------------
 -- On ChromeOS, DRM events, if they exist, are the source of truth. Otherwise,
diff --git a/src/trace_processor/storage/stats.h b/src/trace_processor/storage/stats.h
index 7fb6ce0..cedcf0c 100644
--- a/src/trace_processor/storage/stats.h
+++ b/src/trace_processor/storage/stats.h
@@ -72,6 +72,8 @@
   F(ftrace_setup_errors,                  kSingle,  kInfo,     kTrace,         \
        "One or more atrace/ftrace categories were not found or failed to "     \
        "enable. See ftrace_setup_errors in the metadata table for details."),  \
+  F(ftrace_abi_errors_skipped_zero_data_length,                                \
+                                          kSingle,  kInfo,     kAnalysis, ""), \
   F(fuchsia_non_numeric_counters,         kSingle,  kError,    kAnalysis, ""), \
   F(fuchsia_timestamp_overflow,           kSingle,  kError,    kAnalysis, ""), \
   F(fuchsia_invalid_event,                kSingle,  kError,    kAnalysis, ""), \
diff --git a/test/trace_processor/diff_tests/metrics/android/android_boot.out b/test/trace_processor/diff_tests/metrics/android/android_boot.out
index 3d5c172..3bf13cc 100644
--- a/test/trace_processor/diff_tests/metrics/android/android_boot.out
+++ b/test/trace_processor/diff_tests/metrics/android/android_boot.out
@@ -40,7 +40,7 @@
         native_alloc_gc_count: 0
         explicit_gc_count: 0
         alloc_gc_count: 0
-        mb_per_ms_of_gc: 0.8829305684617433
+        mb_per_ms_of_gc: 0.8829305684617432
     }
     post_boot_gc_aggregation {
         total_gc_count: 4
@@ -54,6 +54,6 @@
         native_alloc_gc_count: 0
         explicit_gc_count: 0
         alloc_gc_count: 0
-        mb_per_ms_of_gc: 0.8829305684617433
+        mb_per_ms_of_gc: 0.8829305684617432
     }
 }
\ No newline at end of file
diff --git a/test/trace_processor/diff_tests/metrics/camera/tests.py b/test/trace_processor/diff_tests/metrics/camera/tests.py
index fecb492..999c69a 100644
--- a/test/trace_processor/diff_tests/metrics/camera/tests.py
+++ b/test/trace_processor/diff_tests/metrics/camera/tests.py
@@ -30,7 +30,7 @@
           gc_rss_and_dma {
             min: 47779840.0
             max: 2536079360.0
-            avg: 1464706457.7348418
+            avg: 1464706457.734843
           }
         }
         """))
diff --git a/test/trace_processor/diff_tests/metrics/chrome/frame_times_metric.out b/test/trace_processor/diff_tests/metrics/chrome/frame_times_metric.out
index 3ae3370..12a0fc0 100644
--- a/test/trace_processor/diff_tests/metrics/chrome/frame_times_metric.out
+++ b/test/trace_processor/diff_tests/metrics/chrome/frame_times_metric.out
@@ -1205,6 +1205,6 @@
   exp_frame_time: 16.787
   exp_frame_time: 16.623
   exp_frame_time: 16.707
-  avg_surface_fps: 59.86008821173197
-  exp_avg_surface_fps: 59.861591661151287
+  avg_surface_fps: 59.860088211731984
+  exp_avg_surface_fps: 59.86159166115123
 }
diff --git a/test/trace_processor/diff_tests/parser/parsing/tests.py b/test/trace_processor/diff_tests/parser/parsing/tests.py
index 5df7a52..8619bc3 100644
--- a/test/trace_processor/diff_tests/parser/parsing/tests.py
+++ b/test/trace_processor/diff_tests/parser/parsing/tests.py
@@ -1318,3 +1318,39 @@
         "all_data_source_flushed_ns",12344
         "all_data_source_flushed_ns",12345
         """))
+
+  def test_ftrace_abi_errors_skipped_zero_data_length(self):
+    return DiffTestBlueprint(
+        trace=TextProto(r"""
+        packet {
+          ftrace_stats {
+            phase: END_OF_TRACE
+            cpu_stats {
+              cpu: 0
+              entries: 14
+              overrun: 0
+              commit_overrun: 0
+              bytes_read: 840
+              oldest_event_ts: 86557.552705
+              now_ts: 86557.574310
+              dropped_events: 0
+              read_events: 199966062
+            }
+            kernel_symbols_parsed: 128611
+            kernel_symbols_mem_kb: 1322
+            ftrace_parse_errors: FTRACE_STATUS_ABI_ZERO_DATA_LENGTH
+          }
+          trusted_uid: 9999
+          trusted_packet_sequence_id: 2
+          trusted_pid: 1069
+        }
+        """),
+        query="""
+        select name, severity, value
+        from stats
+        where name = "ftrace_abi_errors_skipped_zero_data_length"
+        """,
+        out=Csv("""
+        "name","severity","value"
+        "ftrace_abi_errors_skipped_zero_data_length","info",1
+        """))
diff --git a/tools/install-build-deps b/tools/install-build-deps
index 02149a1..e43f4f9 100755
--- a/tools/install-build-deps
+++ b/tools/install-build-deps
@@ -232,13 +232,13 @@
     # If updating the version, also update bazel/deps.bzl.
     Dependency(
         'buildtools/sqlite.zip',
-        'https://storage.googleapis.com/perfetto/sqlite-amalgamation-3390200.zip',
-        '87775784f8b22d0d0f1d7811870d39feaa7896319c7c20b849a4181c5a50609b',
+        'https://storage.googleapis.com/perfetto/sqlite-amalgamation-3440200.zip',
+        '833be89b53b3be8b40a2e3d5fedb635080e3edb204957244f3d6987c2bb2345f',
         'all', 'all'),
     Dependency(
         'buildtools/sqlite_src',
         'https://chromium.googlesource.com/external/github.com/sqlite/sqlite.git',
-        '202b2a7b54ea2dd13a8a5adfd75523abe4dcf17f',  # refs/tags/version-3.39.2.
+        'c8f9803dc32bfee78a9ca2b1abbe39499729219b',  # refs/tags/version-3.44.2.
         'all',
         'all'),