Revert "trace_processor: Remove two more build flags"

This reverts commit 8368ee96a3d0ebd2b407e97c9adc150f220f6517.

Reason for revert: Breaks the chromium roll:
https://chromium-review.googlesource.com/c/chromium/src/+/1968891

Change-Id: Ib28617dcb9e9cc6622229b4b3630d49ca8667a0e
diff --git a/Android.bp b/Android.bp
index 88157c8..7a622db 100644
--- a/Android.bp
+++ b/Android.bp
@@ -5742,11 +5742,8 @@
   srcs: [
     "src/trace_processor/importers/proto/graphics_event_module.cc",
     "src/trace_processor/importers/proto/graphics_event_parser.cc",
-    "src/trace_processor/importers/proto/system_probes_module.cc",
-    "src/trace_processor/importers/proto/system_probes_parser.cc",
     "src/trace_processor/importers/proto/vulkan_memory_tracker.cc",
     "src/trace_processor/register_additional_modules.cc",
-    "src/trace_processor/syscall_tracker.cc",
   ],
 }
 
@@ -5757,7 +5754,6 @@
     "src/trace_processor/args_tracker.cc",
     "src/trace_processor/binder_tracker.cc",
     "src/trace_processor/clock_tracker.cc",
-    "src/trace_processor/destructible.cc",
     "src/trace_processor/event_tracker.cc",
     "src/trace_processor/forwarding_trace_parser.cc",
     "src/trace_processor/ftrace_utils.cc",
@@ -5782,6 +5778,8 @@
     "src/trace_processor/importers/proto/proto_importer_module.cc",
     "src/trace_processor/importers/proto/proto_trace_parser.cc",
     "src/trace_processor/importers/proto/proto_trace_tokenizer.cc",
+    "src/trace_processor/importers/proto/system_probes_module.cc",
+    "src/trace_processor/importers/proto/system_probes_parser.cc",
     "src/trace_processor/importers/proto/track_event_module.cc",
     "src/trace_processor/importers/proto/track_event_parser.cc",
     "src/trace_processor/importers/proto/track_event_tokenizer.cc",
@@ -5790,6 +5788,7 @@
     "src/trace_processor/process_tracker.cc",
     "src/trace_processor/slice_tracker.cc",
     "src/trace_processor/stack_profile_tracker.cc",
+    "src/trace_processor/syscall_tracker.cc",
     "src/trace_processor/trace_processor_context.cc",
     "src/trace_processor/trace_processor_storage.cc",
     "src/trace_processor/trace_processor_storage_impl.cc",
diff --git a/BUILD b/BUILD
index 1a75ab3..1dde88e 100644
--- a/BUILD
+++ b/BUILD
@@ -779,19 +779,10 @@
         "src/trace_processor/importers/proto/graphics_event_module.h",
         "src/trace_processor/importers/proto/graphics_event_parser.cc",
         "src/trace_processor/importers/proto/graphics_event_parser.h",
-        "src/trace_processor/importers/proto/system_probes_module.cc",
-        "src/trace_processor/importers/proto/system_probes_module.h",
-        "src/trace_processor/importers/proto/system_probes_parser.cc",
-        "src/trace_processor/importers/proto/system_probes_parser.h",
         "src/trace_processor/importers/proto/vulkan_memory_tracker.cc",
         "src/trace_processor/importers/proto/vulkan_memory_tracker.h",
         "src/trace_processor/register_additional_modules.cc",
         "src/trace_processor/register_additional_modules.h",
-        "src/trace_processor/syscall_tracker.cc",
-        "src/trace_processor/syscalls_aarch32.h",
-        "src/trace_processor/syscalls_aarch64.h",
-        "src/trace_processor/syscalls_armeabi.h",
-        "src/trace_processor/syscalls_x86_64.h",
     ],
 )
 
@@ -806,8 +797,6 @@
         "src/trace_processor/chunked_trace_reader.h",
         "src/trace_processor/clock_tracker.cc",
         "src/trace_processor/clock_tracker.h",
-        "src/trace_processor/destructible.cc",
-        "src/trace_processor/destructible.h",
         "src/trace_processor/event_tracker.cc",
         "src/trace_processor/event_tracker.h",
         "src/trace_processor/forwarding_trace_parser.cc",
@@ -864,6 +853,10 @@
         "src/trace_processor/importers/proto/proto_trace_parser.h",
         "src/trace_processor/importers/proto/proto_trace_tokenizer.cc",
         "src/trace_processor/importers/proto/proto_trace_tokenizer.h",
+        "src/trace_processor/importers/proto/system_probes_module.cc",
+        "src/trace_processor/importers/proto/system_probes_module.h",
+        "src/trace_processor/importers/proto/system_probes_parser.cc",
+        "src/trace_processor/importers/proto/system_probes_parser.h",
         "src/trace_processor/importers/proto/track_event_module.cc",
         "src/trace_processor/importers/proto/track_event_module.h",
         "src/trace_processor/importers/proto/track_event_parser.cc",
@@ -882,7 +875,12 @@
         "src/trace_processor/stack_profile_tracker.cc",
         "src/trace_processor/stack_profile_tracker.h",
         "src/trace_processor/stats.h",
+        "src/trace_processor/syscall_tracker.cc",
         "src/trace_processor/syscall_tracker.h",
+        "src/trace_processor/syscalls_aarch32.h",
+        "src/trace_processor/syscalls_aarch64.h",
+        "src/trace_processor/syscalls_armeabi.h",
+        "src/trace_processor/syscalls_x86_64.h",
         "src/trace_processor/timestamped_trace_piece.h",
         "src/trace_processor/trace_blob_view.h",
         "src/trace_processor/trace_parser.h",
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
index 3d38f11..bed38a3 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -83,11 +83,13 @@
     "PERFETTO_TP_METRICS=$enable_perfetto_trace_processor_metrics",
     "PERFETTO_TP_FTRACE=$enable_perfetto_trace_processor_ftrace",
     "PERFETTO_TP_HTTPD=$perfetto_tp_httpd",
+    "PERFETTO_TP_SYSTEM_PROBES=$enable_perfetto_trace_processor_system_probes",
     "PERFETTO_TP_ANDROID_PROBES=$enable_perfetto_trace_processor_android_probes",
     "PERFETTO_TP_HEAP_GRAPHS=$enable_perfetto_trace_processor_heap_graphs",
     "PERFETTO_TP_JSON=$enable_perfetto_trace_processor_json",
     "PERFETTO_TP_JSON_IMPORT=$enable_perfetto_trace_processor_json_import",
     "PERFETTO_TP_FUCHSIA=$enable_perfetto_trace_processor_fuchsia",
+    "PERFETTO_TP_SYSCALLS=$enable_perfetto_trace_processor_syscalls",
     "PERFETTO_LOCAL_SYMBOLIZER=$perfetto_local_symbolizer",
   ]
 
diff --git a/gn/perfetto.gni b/gn/perfetto.gni
index 4f6291a..97563dc 100644
--- a/gn/perfetto.gni
+++ b/gn/perfetto.gni
@@ -215,6 +215,10 @@
   enable_perfetto_trace_processor_ftrace =
       enable_perfetto_trace_processor && !(build_with_chromium && is_android)
 
+  # Enables parsing support for system probes in trace processor.
+  enable_perfetto_trace_processor_system_probes =
+      enable_perfetto_trace_processor && !(build_with_chromium && is_android)
+
   # Enables parsing support for android system probes in trace processor.
   enable_perfetto_trace_processor_android_probes =
       enable_perfetto_trace_processor && !(build_with_chromium && is_android)
@@ -245,6 +249,13 @@
       enable_perfetto_trace_processor_json &&
       !(build_with_chromium && is_android)
 
+  # Enables syscall support in trace processor. Required for ftrace, system
+  # probes, and android probes support.
+  enable_perfetto_trace_processor_syscalls =
+      enable_perfetto_trace_processor_ftrace ||
+      enable_perfetto_trace_processor_system_probes ||
+      enable_perfetto_trace_processor_android_probes
+
   # Enables metrics support in the trace processor, which require SQL support.
   enable_perfetto_trace_processor_metrics =
       enable_perfetto_trace_processor_sqlite
@@ -300,3 +311,9 @@
 assert(!enable_perfetto_tools_trace_to_text ||
        enable_perfetto_trace_processor_sqlite)
 assert(!enable_perfetto_ui || enable_perfetto_trace_processor_sqlite)
+
+# Syscall support is required for ftrace, system probes, and android probes.
+assert(enable_perfetto_trace_processor_syscalls ||
+       (!enable_perfetto_trace_processor_ftrace &&
+        !enable_perfetto_trace_processor_system_probes &&
+        !enable_perfetto_trace_processor_android_probes))
diff --git a/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h b/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h
index 190733d..004dfe0 100644
--- a/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h
+++ b/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h
@@ -37,11 +37,13 @@
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_METRICS() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_FTRACE() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_HTTPD() (0)
+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_SYSTEM_PROBES() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_ANDROID_PROBES() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_HEAP_GRAPHS() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_JSON() (0)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_JSON_IMPORT() (0)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_FUCHSIA() (1)
+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_SYSCALLS() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_LOCAL_SYMBOLIZER() (PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX())
 
 // clang-format on
diff --git a/include/perfetto/base/build_configs/bazel/perfetto_build_flags.h b/include/perfetto/base/build_configs/bazel/perfetto_build_flags.h
index 7cc1a68..a760898 100644
--- a/include/perfetto/base/build_configs/bazel/perfetto_build_flags.h
+++ b/include/perfetto/base/build_configs/bazel/perfetto_build_flags.h
@@ -37,11 +37,13 @@
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_METRICS() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_FTRACE() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_HTTPD() (PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() || PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() || PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MACOSX())
+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_SYSTEM_PROBES() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_ANDROID_PROBES() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_HEAP_GRAPHS() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_JSON() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_JSON_IMPORT() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_FUCHSIA() (1)
+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_SYSCALLS() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_LOCAL_SYMBOLIZER() (PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX())
 
 // clang-format on
diff --git a/src/trace_processor/BUILD.gn b/src/trace_processor/BUILD.gn
index 8e17fc3..df2329f 100644
--- a/src/trace_processor/BUILD.gn
+++ b/src/trace_processor/BUILD.gn
@@ -83,8 +83,6 @@
     "chunked_trace_reader.h",
     "clock_tracker.cc",
     "clock_tracker.h",
-    "destructible.cc",
-    "destructible.h",
     "event_tracker.cc",
     "event_tracker.h",
     "forwarding_trace_parser.cc",
@@ -117,6 +115,8 @@
     "importers/proto/proto_trace_parser.h",
     "importers/proto/proto_trace_tokenizer.cc",
     "importers/proto/proto_trace_tokenizer.h",
+    "importers/proto/system_probes_module.h",
+    "importers/proto/system_probes_parser.h",
     "importers/proto/track_event_module.cc",
     "importers/proto/track_event_module.h",
     "importers/proto/track_event_parser.cc",
@@ -203,12 +203,18 @@
       enable_perfetto_trace_processor_fuchsia) {
     sources += [ "ftrace_utils.cc" ]
   }
+  if (enable_perfetto_trace_processor_system_probes) {
+    sources += [
+      "importers/proto/system_probes_module.cc",
+      "importers/proto/system_probes_parser.cc",
+    ]
+    deps += [ "../../include/perfetto/ext/traced:sys_stats_counters" ]
+  }
   if (enable_perfetto_trace_processor_android_probes) {
     sources += [
       "importers/proto/android_probes_module.cc",
       "importers/proto/android_probes_parser.cc",
     ]
-    deps += [ "../../include/perfetto/ext/traced:sys_stats_counters" ]
   }
   if (enable_perfetto_trace_processor_heap_graphs) {
     sources += [
@@ -228,6 +234,15 @@
       "importers/fuchsia/fuchsia_trace_utils.h",
     ]
   }
+  if (enable_perfetto_trace_processor_syscalls) {
+    sources += [
+      "syscall_tracker.cc",
+      "syscalls_aarch32.h",
+      "syscalls_aarch64.h",
+      "syscalls_armeabi.h",
+      "syscalls_x86_64.h",
+    ]
+  }
 }
 
 source_set("storage_full") {
@@ -236,32 +251,20 @@
     "importers/proto/graphics_event_module.h",
     "importers/proto/graphics_event_parser.cc",
     "importers/proto/graphics_event_parser.h",
-    "importers/proto/system_probes_module.cc",
-    "importers/proto/system_probes_module.h",
-    "importers/proto/system_probes_parser.cc",
-    "importers/proto/system_probes_parser.h",
     "importers/proto/vulkan_memory_tracker.cc",
     "importers/proto/vulkan_memory_tracker.h",
     "register_additional_modules.cc",
     "register_additional_modules.h",
-    "syscall_tracker.cc",
-    "syscalls_aarch32.h",
-    "syscalls_aarch64.h",
-    "syscalls_armeabi.h",
-    "syscalls_x86_64.h",
   ]
   public_deps = [
     ":storage_minimal",
   ]
   deps = [
-    "../../include/perfetto/ext/traced:sys_stats_counters",
     "../../protos/perfetto/common:zero",
     "../../protos/perfetto/trace:zero",
     "../../protos/perfetto/trace/android:zero",
     "../../protos/perfetto/trace/gpu:zero",
     "../../protos/perfetto/trace/interned_data:zero",
-    "../../protos/perfetto/trace/ps:zero",
-    "../../protos/perfetto/trace/sys_stats:zero",
     "../protozero",
   ]
   if (enable_perfetto_trace_processor_json) {
@@ -425,7 +428,6 @@
     "protozero_to_text_unittests.cc",
     "slice_tracker_unittest.cc",
     "string_pool_unittest.cc",
-    "syscall_tracker_unittest.cc",
     "trace_sorter_unittest.cc",
   ]
   deps = [
@@ -500,6 +502,9 @@
   if (enable_perfetto_trace_processor_fuchsia) {
     sources += [ "importers/fuchsia/fuchsia_trace_utils_unittest.cc" ]
   }
+  if (enable_perfetto_trace_processor_syscalls) {
+    sources += [ "syscall_tracker_unittest.cc" ]
+  }
 }
 
 source_set("integrationtests") {
diff --git a/src/trace_processor/destructible.cc b/src/trace_processor/destructible.cc
deleted file mode 100644
index 22bcf6a..0000000
--- a/src/trace_processor/destructible.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "src/trace_processor/destructible.h"
-
-namespace perfetto {
-namespace trace_processor {
-
-Destructible::~Destructible() = default;
-
-}  // namespace trace_processor
-}  // namespace perfetto
diff --git a/src/trace_processor/destructible.h b/src/trace_processor/destructible.h
deleted file mode 100644
index 9b9c20f..0000000
--- a/src/trace_processor/destructible.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SRC_TRACE_PROCESSOR_DESTRUCTIBLE_H_
-#define SRC_TRACE_PROCESSOR_DESTRUCTIBLE_H_
-
-namespace perfetto {
-namespace trace_processor {
-
-// To reduce Chrome binary size, we exclude the source code of several
-// trackers from the storage_minimal build target. So the trace processor
-// context can't always know the exact types of the tracker classes, but
-// it still needs to destruct them. To solve this, we subclass all trackers
-// from this Desctructible class.
-class Destructible {
- public:
-  virtual ~Destructible();
-};
-
-}  // namespace trace_processor
-}  // namespace perfetto
-
-#endif  // SRC_TRACE_PROCESSOR_DESTRUCTIBLE_H_
diff --git a/src/trace_processor/importers/ftrace/ftrace_parser.cc b/src/trace_processor/importers/ftrace/ftrace_parser.cc
index d5e68ef..c07fd8d 100644
--- a/src/trace_processor/importers/ftrace/ftrace_parser.cc
+++ b/src/trace_processor/importers/ftrace/ftrace_parser.cc
@@ -707,11 +707,10 @@
   uint32_t syscall_num = static_cast<uint32_t>(evt.id());
   UniqueTid utid = context_->process_tracker->GetOrCreateThread(pid);
 
-  SyscallTracker* syscall_tracker = SyscallTracker::GetOrCreate(context_);
   if (is_enter) {
-    syscall_tracker->Enter(ts, utid, syscall_num);
+    context_->syscall_tracker->Enter(ts, utid, syscall_num);
   } else {
-    syscall_tracker->Exit(ts, utid, syscall_num);
+    context_->syscall_tracker->Exit(ts, utid, syscall_num);
   }
 
   // We are reusing the same function for sys_enter and sys_exit.
diff --git a/src/trace_processor/importers/proto/proto_trace_parser_unittest.cc b/src/trace_processor/importers/proto/proto_trace_parser_unittest.cc
index aab449a..4d9150d 100644
--- a/src/trace_processor/importers/proto/proto_trace_parser_unittest.cc
+++ b/src/trace_processor/importers/proto/proto_trace_parser_unittest.cc
@@ -84,6 +84,8 @@
 using ::testing::Return;
 using ::testing::UnorderedElementsAreArray;
 
+#if PERFETTO_BUILDFLAG(PERFETTO_TP_FTRACE) || \
+    PERFETTO_BUILDFLAG(PERFETTO_TP_SYSTEM_PROBES)
 namespace {
 MATCHER_P(DoubleEq, exp, "Double matcher that satisfies -Wfloat-equal") {
   // The IEEE standard says that any comparison operation involving
@@ -95,6 +97,8 @@
   return fabs(d_arg - d_exp) < 1e-128;
 }
 }  // namespace
+#endif  // PERFETTO_BUILDFLAG(PERFETTO_TP_FTRACE) ||
+        // PERFETTO_BUILDFLAG(PERFETTO_TP_SYSTEM_PROBES)
 
 #if PERFETTO_BUILDFLAG(PERFETTO_TP_FTRACE)
 class MockSchedEventTracker : public SchedEventTracker {
@@ -261,6 +265,9 @@
 #if PERFETTO_BUILDFLAG(PERFETTO_TP_ANDROID_PROBES)
     context_.modules.emplace_back(new AndroidProbesModule(&context_));
 #endif  // PERFETTO_BUILDFLAG(PERFETTO_TP_ANDROID_PROBES)
+#if PERFETTO_BUILDFLAG(PERFETTO_TP_SYSTEM_PROBES)
+    context_.modules.emplace_back(new SystemProbesModule(&context_));
+#endif  // PERFETTO_BUILDFLAG(PERFETTO_TP_SYSTEM_PROBES)
     context_.modules.emplace_back(new TrackEventModule(&context_));
 
     RegisterAdditionalModules(&context_);
@@ -604,6 +611,8 @@
 
 #endif  // PERFETTO_BUILDFLAG(PERFETTO_TP_FTRACE)
 
+#if PERFETTO_BUILDFLAG(PERFETTO_TP_SYSTEM_PROBES)
+
 TEST_F(ProtoTraceParserTest, LoadMemInfo) {
   auto* packet = trace_.add_packet();
   uint64_t ts = 1000;
@@ -678,6 +687,8 @@
   Tokenize();
 }
 
+#endif  // PERFETTO_BUILDFLAG(PERFETTO_TP_SYSTEM_PROBES)
+
 TEST_F(ProtoTraceParserTest, ThreadNameFromThreadDescriptor) {
   context_.sorter.reset(new TraceSorter(
       &context_, std::numeric_limits<int64_t>::max() /*window size*/));
diff --git a/src/trace_processor/importers/proto/system_probes_parser.cc b/src/trace_processor/importers/proto/system_probes_parser.cc
index 5beed38..8fb1281 100644
--- a/src/trace_processor/importers/proto/system_probes_parser.cc
+++ b/src/trace_processor/importers/proto/system_probes_parser.cc
@@ -290,11 +290,10 @@
     protos::pbzero::Utsname::Decoder utsname(utsname_blob.data,
                                              utsname_blob.size);
     base::StringView machine = utsname.machine();
-    SyscallTracker* syscall_tracker = SyscallTracker::GetOrCreate(context_);
     if (machine == "aarch64" || machine == "armv8l") {
-      syscall_tracker->SetArchitecture(kAarch64);
+      context_->syscall_tracker->SetArchitecture(kAarch64);
     } else if (machine == "x86_64") {
-      syscall_tracker->SetArchitecture(kX86_64);
+      context_->syscall_tracker->SetArchitecture(kX86_64);
     } else {
       PERFETTO_ELOG("Unknown architecture %s", machine.ToStdString().c_str());
     }
diff --git a/src/trace_processor/register_additional_modules.cc b/src/trace_processor/register_additional_modules.cc
index 3eeb1b7..cb2b68b 100644
--- a/src/trace_processor/register_additional_modules.cc
+++ b/src/trace_processor/register_additional_modules.cc
@@ -16,15 +16,12 @@
 
 #include "src/trace_processor/register_additional_modules.h"
 #include "src/trace_processor/importers/proto/graphics_event_module.h"
-#include "src/trace_processor/importers/proto/system_probes_module.h"
-#include "src/trace_processor/syscall_tracker.h"
 
 namespace perfetto {
 namespace trace_processor {
 
 void RegisterAdditionalModules(TraceProcessorContext* context) {
   context->modules.emplace_back(new GraphicsEventModule(context));
-  context->modules.emplace_back(new SystemProbesModule(context));
 }
 
 }  // namespace trace_processor
diff --git a/src/trace_processor/syscall_tracker.h b/src/trace_processor/syscall_tracker.h
index 31e39e1..09cf772 100644
--- a/src/trace_processor/syscall_tracker.h
+++ b/src/trace_processor/syscall_tracker.h
@@ -21,7 +21,6 @@
 #include <tuple>
 
 #include "perfetto/ext/base/string_view.h"
-#include "src/trace_processor/destructible.h"
 #include "src/trace_processor/slice_tracker.h"
 #include "src/trace_processor/trace_processor_context.h"
 #include "src/trace_processor/trace_storage.h"
@@ -40,18 +39,12 @@
   kX86_64,
 };
 
-class SyscallTracker : public Destructible {
+class SyscallTracker {
  public:
   explicit SyscallTracker(TraceProcessorContext*);
   SyscallTracker(const SyscallTracker&) = delete;
   SyscallTracker& operator=(const SyscallTracker&) = delete;
   virtual ~SyscallTracker();
-  static SyscallTracker* GetOrCreate(TraceProcessorContext* context) {
-    if (!context->syscall_tracker) {
-      context->syscall_tracker.reset(new SyscallTracker(context));
-    }
-    return static_cast<SyscallTracker*>(context->syscall_tracker.get());
-  }
 
   void SetArchitecture(Architecture architecture);
 
diff --git a/src/trace_processor/syscall_tracker_unittest.cc b/src/trace_processor/syscall_tracker_unittest.cc
index 1d9f513..a659a64 100644
--- a/src/trace_processor/syscall_tracker_unittest.cc
+++ b/src/trace_processor/syscall_tracker_unittest.cc
@@ -54,6 +54,7 @@
     context.track_tracker.reset(track_tracker);
     slice_tracker = new MockSliceTracker(&context);
     context.slice_tracker.reset(slice_tracker);
+    context.syscall_tracker.reset(new SyscallTracker(&context));
   }
 
  protected:
@@ -71,21 +72,19 @@
   EXPECT_CALL(*slice_tracker, End(110, track, kNullStringId, _, _))
       .WillOnce(DoAll(SaveArg<3>(&end_name), Return(base::nullopt)));
 
-  SyscallTracker* syscall_tracker = SyscallTracker::GetOrCreate(&context);
-  syscall_tracker->Enter(100 /*ts*/, 42 /*utid*/, 57 /*sys_read*/);
-  syscall_tracker->Exit(110 /*ts*/, 42 /*utid*/, 57 /*sys_read*/);
+  context.syscall_tracker->Enter(100 /*ts*/, 42 /*utid*/, 57 /*sys_read*/);
+  context.syscall_tracker->Exit(110 /*ts*/, 42 /*utid*/, 57 /*sys_read*/);
   EXPECT_EQ(context.storage->GetString(begin_name), "sys_57");
   EXPECT_EQ(context.storage->GetString(end_name), "sys_57");
 }
 
 TEST_F(SyscallTrackerTest, IgnoreWriteSyscalls) {
-  SyscallTracker* syscall_tracker = SyscallTracker::GetOrCreate(&context);
-  syscall_tracker->SetArchitecture(kAarch64);
+  context.syscall_tracker->SetArchitecture(kAarch64);
   EXPECT_CALL(*slice_tracker, Begin(_, _, _, _, _)).Times(0);
   EXPECT_CALL(*slice_tracker, End(_, _, _, _, _)).Times(0);
 
-  syscall_tracker->Enter(100 /*ts*/, 42 /*utid*/, 64 /*sys_write*/);
-  syscall_tracker->Exit(110 /*ts*/, 42 /*utid*/, 64 /*sys_write*/);
+  context.syscall_tracker->Enter(100 /*ts*/, 42 /*utid*/, 64 /*sys_write*/);
+  context.syscall_tracker->Exit(110 /*ts*/, 42 /*utid*/, 64 /*sys_write*/);
 }
 
 TEST_F(SyscallTrackerTest, Aarch64) {
@@ -97,10 +96,9 @@
   EXPECT_CALL(*slice_tracker, End(110, track, kNullStringId, _, _))
       .WillOnce(DoAll(SaveArg<3>(&end_name), Return(base::nullopt)));
 
-  SyscallTracker* syscall_tracker = SyscallTracker::GetOrCreate(&context);
-  syscall_tracker->SetArchitecture(kAarch64);
-  syscall_tracker->Enter(100 /*ts*/, 42 /*utid*/, 63 /*sys_read*/);
-  syscall_tracker->Exit(110 /*ts*/, 42 /*utid*/, 63 /*sys_read*/);
+  context.syscall_tracker->SetArchitecture(kAarch64);
+  context.syscall_tracker->Enter(100 /*ts*/, 42 /*utid*/, 63 /*sys_read*/);
+  context.syscall_tracker->Exit(110 /*ts*/, 42 /*utid*/, 63 /*sys_read*/);
   EXPECT_EQ(context.storage->GetString(begin_name), "sys_read");
   EXPECT_EQ(context.storage->GetString(end_name), "sys_read");
 }
@@ -114,10 +112,9 @@
   EXPECT_CALL(*slice_tracker, End(110, track, kNullStringId, _, _))
       .WillOnce(DoAll(SaveArg<3>(&end_name), Return(base::nullopt)));
 
-  SyscallTracker* syscall_tracker = SyscallTracker::GetOrCreate(&context);
-  syscall_tracker->SetArchitecture(kX86_64);
-  syscall_tracker->Enter(100 /*ts*/, 42 /*utid*/, 0 /*sys_read*/);
-  syscall_tracker->Exit(110 /*ts*/, 42 /*utid*/, 0 /*sys_read*/);
+  context.syscall_tracker->SetArchitecture(kX86_64);
+  context.syscall_tracker->Enter(100 /*ts*/, 42 /*utid*/, 0 /*sys_read*/);
+  context.syscall_tracker->Exit(110 /*ts*/, 42 /*utid*/, 0 /*sys_read*/);
   EXPECT_EQ(context.storage->GetString(begin_name), "sys_read");
   EXPECT_EQ(context.storage->GetString(end_name), "sys_read");
 }
@@ -125,11 +122,9 @@
 TEST_F(SyscallTrackerTest, SyscallNumberTooLarge) {
   EXPECT_CALL(*slice_tracker, Begin(_, _, _, _, _)).Times(0);
   EXPECT_CALL(*slice_tracker, End(_, _, _, _, _)).Times(0);
-
-  SyscallTracker* syscall_tracker = SyscallTracker::GetOrCreate(&context);
-  syscall_tracker->SetArchitecture(kAarch64);
-  syscall_tracker->Enter(100 /*ts*/, 42 /*utid*/, 9999);
-  syscall_tracker->Exit(110 /*ts*/, 42 /*utid*/, 9999);
+  context.syscall_tracker->SetArchitecture(kAarch64);
+  context.syscall_tracker->Enter(100 /*ts*/, 42 /*utid*/, 9999);
+  context.syscall_tracker->Exit(110 /*ts*/, 42 /*utid*/, 9999);
 }
 
 }  // namespace
diff --git a/src/trace_processor/trace_processor_context.cc b/src/trace_processor/trace_processor_context.cc
index b5667f4..a6b1c03 100644
--- a/src/trace_processor/trace_processor_context.cc
+++ b/src/trace_processor/trace_processor_context.cc
@@ -29,11 +29,13 @@
 #include "src/trace_processor/importers/proto/heap_graph_module.h"
 #include "src/trace_processor/importers/proto/heap_graph_tracker.h"
 #include "src/trace_processor/importers/proto/proto_trace_parser.h"
+#include "src/trace_processor/importers/proto/system_probes_module.h"
 #include "src/trace_processor/importers/proto/track_event_module.h"
 #include "src/trace_processor/importers/systrace/systrace_parser.h"
 #include "src/trace_processor/process_tracker.h"
 #include "src/trace_processor/slice_tracker.h"
 #include "src/trace_processor/stack_profile_tracker.h"
+#include "src/trace_processor/syscall_tracker.h"
 #include "src/trace_processor/trace_sorter.h"
 #include "src/trace_processor/track_tracker.h"
 
diff --git a/src/trace_processor/trace_processor_context.h b/src/trace_processor/trace_processor_context.h
index 9fb7a6a..3eab980 100644
--- a/src/trace_processor/trace_processor_context.h
+++ b/src/trace_processor/trace_processor_context.h
@@ -21,7 +21,6 @@
 #include <vector>
 
 #include "perfetto/trace_processor/basic_types.h"
-#include "src/trace_processor/destructible.h"
 #include "src/trace_processor/importers/proto/proto_importer_module.h"
 
 namespace perfetto {
@@ -38,6 +37,7 @@
 class ProcessTracker;
 class SchedEventTracker;
 class SliceTracker;
+class SyscallTracker;
 class SystraceParser;
 class TraceParser;
 class TraceSorter;
@@ -56,6 +56,7 @@
   std::unique_ptr<ArgsTracker> args_tracker;
   std::unique_ptr<SliceTracker> slice_tracker;
   std::unique_ptr<ProcessTracker> process_tracker;
+  std::unique_ptr<SyscallTracker> syscall_tracker;
   std::unique_ptr<EventTracker> event_tracker;
   std::unique_ptr<SchedEventTracker> sched_tracker;
   std::unique_ptr<ClockTracker> clock_tracker;
@@ -67,13 +68,6 @@
   std::unique_ptr<HeapGraphTracker> heap_graph_tracker;
   std::unique_ptr<BinderTracker> binder_tracker;
 
-  // These fields are stored as pointers to Destructible objects rather than
-  // their actual type (a subclass of Destructible), as the concrete subclass
-  // type is only available in the storage_full target. To access these fields,
-  // use the GetOrCreate() method on their subclass type,
-  // e.g. SyscallTracker::GetOrCreate(context).
-  std::unique_ptr<Destructible> syscall_tracker;  // SyscallTracker.
-
   // The module at the index N is registered to handle field id N in
   // TracePacket.
   std::vector<ProtoImporterModule*> modules_by_field;
diff --git a/src/trace_processor/trace_processor_impl.cc b/src/trace_processor/trace_processor_impl.cc
index 02a1ff7..e47806d 100644
--- a/src/trace_processor/trace_processor_impl.cc
+++ b/src/trace_processor/trace_processor_impl.cc
@@ -41,7 +41,6 @@
 #include "src/trace_processor/stack_profile_frame_table.h"
 #include "src/trace_processor/stack_profile_mapping_table.h"
 #include "src/trace_processor/stats_table.h"
-#include "src/trace_processor/syscall_tracker.h"
 #include "src/trace_processor/thread_table.h"
 #include "src/trace_processor/window_operator_table.h"
 
diff --git a/src/trace_processor/trace_processor_storage_impl.cc b/src/trace_processor/trace_processor_storage_impl.cc
index c7e3ad2..2ceb370 100644
--- a/src/trace_processor/trace_processor_storage_impl.cc
+++ b/src/trace_processor/trace_processor_storage_impl.cc
@@ -30,12 +30,14 @@
 #include "src/trace_processor/importers/proto/heap_graph_tracker.h"
 #include "src/trace_processor/importers/proto/proto_importer_module.h"
 #include "src/trace_processor/importers/proto/proto_trace_tokenizer.h"
+#include "src/trace_processor/importers/proto/system_probes_module.h"
 #include "src/trace_processor/importers/proto/track_event_module.h"
 #include "src/trace_processor/importers/systrace/systrace_parser.h"
 #include "src/trace_processor/importers/systrace/systrace_trace_parser.h"
 #include "src/trace_processor/process_tracker.h"
 #include "src/trace_processor/slice_tracker.h"
 #include "src/trace_processor/stack_profile_tracker.h"
+#include "src/trace_processor/syscall_tracker.h"
 #include "src/trace_processor/trace_blob_view.h"
 #include "src/trace_processor/trace_sorter.h"
 #include "src/trace_processor/track_tracker.h"
@@ -51,6 +53,9 @@
   context_.slice_tracker.reset(new SliceTracker(&context_));
   context_.event_tracker.reset(new EventTracker(&context_));
   context_.process_tracker.reset(new ProcessTracker(&context_));
+#if PERFETTO_BUILDFLAG(PERFETTO_TP_SYSCALLS)
+  context_.syscall_tracker.reset(new SyscallTracker(&context_));
+#endif  // PERFETTO_BUILDFLAG(PERFETTO_TP_SYSCALLS)
   context_.clock_tracker.reset(new ClockTracker(&context_));
   context_.heap_profile_tracker.reset(new HeapProfileTracker(&context_));
 #if PERFETTO_BUILDFLAG(PERFETTO_TP_FTRACE)
@@ -75,6 +80,9 @@
 #if PERFETTO_BUILDFLAG(PERFETTO_TP_ANDROID_PROBES)
   context_.modules.emplace_back(new AndroidProbesModule(&context_));
 #endif  // PERFETTO_BUILDFLAG(PERFETTO_TP_ANDROID_PROBES)
+#if PERFETTO_BUILDFLAG(PERFETTO_TP_SYSTEM_PROBES)
+  context_.modules.emplace_back(new SystemProbesModule(&context_));
+#endif  // PERFETTO_BUILDFLAG(PERFETTO_TP_SYSTEM_PROBES)
   context_.modules.emplace_back(new TrackEventModule(&context_));
 }