trace_processor: Remove two more build flags
This CL removes PERFETTO_TP_SYSCALLS and PERFETTO_TP_SYSTEM_PROBES build
flags. The system probes module is moved to storage_full. Also syscall
tracker is now created on demand, when modules actually need it.
Bug: 141459049
Change-Id: I099351edb33748cb68ef18ba6ea18d564d811f10
diff --git a/Android.bp b/Android.bp
index 7a622db..88157c8 100644
--- a/Android.bp
+++ b/Android.bp
@@ -5742,8 +5742,11 @@
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",
],
}
@@ -5754,6 +5757,7 @@
"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",
@@ -5778,8 +5782,6 @@
"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",
@@ -5788,7 +5790,6 @@
"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 1dde88e..1a75ab3 100644
--- a/BUILD
+++ b/BUILD
@@ -779,10 +779,19 @@
"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",
],
)
@@ -797,6 +806,8 @@
"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",
@@ -853,10 +864,6 @@
"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",
@@ -875,12 +882,7 @@
"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 bed38a3..3d38f11 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -83,13 +83,11 @@
"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 97563dc..4f6291a 100644
--- a/gn/perfetto.gni
+++ b/gn/perfetto.gni
@@ -215,10 +215,6 @@
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)
@@ -249,13 +245,6 @@
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
@@ -311,9 +300,3 @@
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 004dfe0..190733d 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,13 +37,11 @@
#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 a760898..7cc1a68 100644
--- a/include/perfetto/base/build_configs/bazel/perfetto_build_flags.h
+++ b/include/perfetto/base/build_configs/bazel/perfetto_build_flags.h
@@ -37,13 +37,11 @@
#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 df2329f..8e17fc3 100644
--- a/src/trace_processor/BUILD.gn
+++ b/src/trace_processor/BUILD.gn
@@ -83,6 +83,8 @@
"chunked_trace_reader.h",
"clock_tracker.cc",
"clock_tracker.h",
+ "destructible.cc",
+ "destructible.h",
"event_tracker.cc",
"event_tracker.h",
"forwarding_trace_parser.cc",
@@ -115,8 +117,6 @@
"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,18 +203,12 @@
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 += [
@@ -234,15 +228,6 @@
"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") {
@@ -251,20 +236,32 @@
"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) {
@@ -428,6 +425,7 @@
"protozero_to_text_unittests.cc",
"slice_tracker_unittest.cc",
"string_pool_unittest.cc",
+ "syscall_tracker_unittest.cc",
"trace_sorter_unittest.cc",
]
deps = [
@@ -502,9 +500,6 @@
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
new file mode 100644
index 0000000..22bcf6a
--- /dev/null
+++ b/src/trace_processor/destructible.cc
@@ -0,0 +1,24 @@
+/*
+ * 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
new file mode 100644
index 0000000..9b9c20f
--- /dev/null
+++ b/src/trace_processor/destructible.h
@@ -0,0 +1,36 @@
+/*
+ * 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 c07fd8d..d5e68ef 100644
--- a/src/trace_processor/importers/ftrace/ftrace_parser.cc
+++ b/src/trace_processor/importers/ftrace/ftrace_parser.cc
@@ -707,10 +707,11 @@
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) {
- context_->syscall_tracker->Enter(ts, utid, syscall_num);
+ syscall_tracker->Enter(ts, utid, syscall_num);
} else {
- context_->syscall_tracker->Exit(ts, utid, syscall_num);
+ 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 4d9150d..aab449a 100644
--- a/src/trace_processor/importers/proto/proto_trace_parser_unittest.cc
+++ b/src/trace_processor/importers/proto/proto_trace_parser_unittest.cc
@@ -84,8 +84,6 @@
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
@@ -97,8 +95,6 @@
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 {
@@ -265,9 +261,6 @@
#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_);
@@ -611,8 +604,6 @@
#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;
@@ -687,8 +678,6 @@
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 8fb1281..5beed38 100644
--- a/src/trace_processor/importers/proto/system_probes_parser.cc
+++ b/src/trace_processor/importers/proto/system_probes_parser.cc
@@ -290,10 +290,11 @@
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") {
- context_->syscall_tracker->SetArchitecture(kAarch64);
+ syscall_tracker->SetArchitecture(kAarch64);
} else if (machine == "x86_64") {
- context_->syscall_tracker->SetArchitecture(kX86_64);
+ 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 cb2b68b..3eeb1b7 100644
--- a/src/trace_processor/register_additional_modules.cc
+++ b/src/trace_processor/register_additional_modules.cc
@@ -16,12 +16,15 @@
#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 09cf772..31e39e1 100644
--- a/src/trace_processor/syscall_tracker.h
+++ b/src/trace_processor/syscall_tracker.h
@@ -21,6 +21,7 @@
#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"
@@ -39,12 +40,18 @@
kX86_64,
};
-class SyscallTracker {
+class SyscallTracker : public Destructible {
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 a659a64..1d9f513 100644
--- a/src/trace_processor/syscall_tracker_unittest.cc
+++ b/src/trace_processor/syscall_tracker_unittest.cc
@@ -54,7 +54,6 @@
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:
@@ -72,19 +71,21 @@
EXPECT_CALL(*slice_tracker, End(110, track, kNullStringId, _, _))
.WillOnce(DoAll(SaveArg<3>(&end_name), Return(base::nullopt)));
- context.syscall_tracker->Enter(100 /*ts*/, 42 /*utid*/, 57 /*sys_read*/);
- context.syscall_tracker->Exit(110 /*ts*/, 42 /*utid*/, 57 /*sys_read*/);
+ 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*/);
EXPECT_EQ(context.storage->GetString(begin_name), "sys_57");
EXPECT_EQ(context.storage->GetString(end_name), "sys_57");
}
TEST_F(SyscallTrackerTest, IgnoreWriteSyscalls) {
- context.syscall_tracker->SetArchitecture(kAarch64);
+ SyscallTracker* syscall_tracker = SyscallTracker::GetOrCreate(&context);
+ syscall_tracker->SetArchitecture(kAarch64);
EXPECT_CALL(*slice_tracker, Begin(_, _, _, _, _)).Times(0);
EXPECT_CALL(*slice_tracker, End(_, _, _, _, _)).Times(0);
- context.syscall_tracker->Enter(100 /*ts*/, 42 /*utid*/, 64 /*sys_write*/);
- context.syscall_tracker->Exit(110 /*ts*/, 42 /*utid*/, 64 /*sys_write*/);
+ syscall_tracker->Enter(100 /*ts*/, 42 /*utid*/, 64 /*sys_write*/);
+ syscall_tracker->Exit(110 /*ts*/, 42 /*utid*/, 64 /*sys_write*/);
}
TEST_F(SyscallTrackerTest, Aarch64) {
@@ -96,9 +97,10 @@
EXPECT_CALL(*slice_tracker, End(110, track, kNullStringId, _, _))
.WillOnce(DoAll(SaveArg<3>(&end_name), Return(base::nullopt)));
- 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*/);
+ 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*/);
EXPECT_EQ(context.storage->GetString(begin_name), "sys_read");
EXPECT_EQ(context.storage->GetString(end_name), "sys_read");
}
@@ -112,9 +114,10 @@
EXPECT_CALL(*slice_tracker, End(110, track, kNullStringId, _, _))
.WillOnce(DoAll(SaveArg<3>(&end_name), Return(base::nullopt)));
- 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*/);
+ 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*/);
EXPECT_EQ(context.storage->GetString(begin_name), "sys_read");
EXPECT_EQ(context.storage->GetString(end_name), "sys_read");
}
@@ -122,9 +125,11 @@
TEST_F(SyscallTrackerTest, SyscallNumberTooLarge) {
EXPECT_CALL(*slice_tracker, Begin(_, _, _, _, _)).Times(0);
EXPECT_CALL(*slice_tracker, End(_, _, _, _, _)).Times(0);
- context.syscall_tracker->SetArchitecture(kAarch64);
- context.syscall_tracker->Enter(100 /*ts*/, 42 /*utid*/, 9999);
- context.syscall_tracker->Exit(110 /*ts*/, 42 /*utid*/, 9999);
+
+ 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);
}
} // namespace
diff --git a/src/trace_processor/trace_processor_context.cc b/src/trace_processor/trace_processor_context.cc
index a6b1c03..b5667f4 100644
--- a/src/trace_processor/trace_processor_context.cc
+++ b/src/trace_processor/trace_processor_context.cc
@@ -29,13 +29,11 @@
#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 3eab980..9fb7a6a 100644
--- a/src/trace_processor/trace_processor_context.h
+++ b/src/trace_processor/trace_processor_context.h
@@ -21,6 +21,7 @@
#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 {
@@ -37,7 +38,6 @@
class ProcessTracker;
class SchedEventTracker;
class SliceTracker;
-class SyscallTracker;
class SystraceParser;
class TraceParser;
class TraceSorter;
@@ -56,7 +56,6 @@
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;
@@ -68,6 +67,13 @@
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 e47806d..02a1ff7 100644
--- a/src/trace_processor/trace_processor_impl.cc
+++ b/src/trace_processor/trace_processor_impl.cc
@@ -41,6 +41,7 @@
#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 2ceb370..c7e3ad2 100644
--- a/src/trace_processor/trace_processor_storage_impl.cc
+++ b/src/trace_processor/trace_processor_storage_impl.cc
@@ -30,14 +30,12 @@
#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"
@@ -53,9 +51,6 @@
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)
@@ -80,9 +75,6 @@
#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_));
}