aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrimiano Tucci <primiano@google.com>2022-02-09 10:45:37 +0000
committerPrimiano Tucci <primiano@google.com>2022-02-09 10:45:37 +0000
commitee002581ad43cda9bc2ccca6f6ba43de19b5819e (patch)
tree4e5144f5f76d0ac7ce70aee72c5815a850fa8f33
parent268533951336a467736c95356a8cc06f328592ac (diff)
parentd59e9de3211ff20ac512c44a1d12d2f6c81a44f6 (diff)
downloadperfetto-ee002581ad43cda9bc2ccca6f6ba43de19b5819e.tar.gz
Merge 'origin/master' for v24.1 into releases/v24.x
Picks up Windows build fixes Change-Id: I904bb49a11b9de0deacece7828a16831091a7d3a
-rw-r--r--CHANGELOG11
-rw-r--r--src/profiling/symbolizer/local_symbolizer.cc6
-rw-r--r--src/profiling/symbolizer/local_symbolizer_unittest.cc73
-rw-r--r--src/traced/service/builtin_producer.cc10
-rw-r--r--test/test_helper.h5
5 files changed, 101 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index d6eec943c..76b42be0e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,17 @@ Unreleased:
*
+v24.1 - 2022-02-09:
+ Tracing service and probes:
+ * Fixed build failures on Windows.
+ Trace Processor:
+ * Fixed build failures on Windows.
+ UI:
+ *
+ SDK:
+ *
+
+
v24.0 - 2022-02-08:
Tracing service and probes:
* Added "cpufreq_period_ms" in data source "linux.sys_stats" to poll
diff --git a/src/profiling/symbolizer/local_symbolizer.cc b/src/profiling/symbolizer/local_symbolizer.cc
index bcacb37e4..1fe4dbdeb 100644
--- a/src/profiling/symbolizer/local_symbolizer.cc
+++ b/src/profiling/symbolizer/local_symbolizer.cc
@@ -423,8 +423,8 @@ base::Optional<FoundBinary> LocalBinaryFinder::FindBinaryInRoot(
}
if (base::StartsWith(filename, kApkPrefix)) {
- symbol_file =
- root_str + "/" + dirname + "/" + filename.substr(sizeof(kApkPrefix));
+ symbol_file = root_str + "/" + dirname + "/" +
+ filename.substr(sizeof(kApkPrefix) - 1);
result = IsCorrectFile(symbol_file, build_id);
if (result) {
return result;
@@ -438,7 +438,7 @@ base::Optional<FoundBinary> LocalBinaryFinder::FindBinaryInRoot(
}
if (base::StartsWith(filename, kApkPrefix)) {
- symbol_file = root_str + "/" + filename.substr(sizeof(kApkPrefix));
+ symbol_file = root_str + "/" + filename.substr(sizeof(kApkPrefix) - 1);
result = IsCorrectFile(symbol_file, build_id);
if (result) {
return result;
diff --git a/src/profiling/symbolizer/local_symbolizer_unittest.cc b/src/profiling/symbolizer/local_symbolizer_unittest.cc
index 921c878a6..cb0c11d72 100644
--- a/src/profiling/symbolizer/local_symbolizer_unittest.cc
+++ b/src/profiling/symbolizer/local_symbolizer_unittest.cc
@@ -162,6 +162,79 @@ TEST(LocalBinaryIndexerTest, SimpleTree) {
EXPECT_EQ(bin2.value().file_name, tmp.path() + "/dir2/elf1");
}
+TEST(LocalBinaryFinderTest, AbsolutePath) {
+ base::TmpDirTree tmp;
+ tmp.AddDir("root");
+ tmp.AddDir("root/dir");
+ tmp.AddFile("root/dir/elf1.so", CreateElfWithBuildId("AAAAAAAAAAAAAAAAAAAA"));
+
+ LocalBinaryFinder finder({tmp.path() + "/root"});
+
+ base::Optional<FoundBinary> bin1 =
+ finder.FindBinary("/dir/elf1.so", "AAAAAAAAAAAAAAAAAAAA");
+ ASSERT_TRUE(bin1.has_value());
+ EXPECT_EQ(bin1.value().file_name, tmp.path() + "/root/dir/elf1.so");
+}
+
+TEST(LocalBinaryFinderTest, AbsolutePathWithoutBaseApk) {
+ base::TmpDirTree tmp;
+ tmp.AddDir("root");
+ tmp.AddDir("root/dir");
+ tmp.AddFile("root/dir/elf1.so", CreateElfWithBuildId("AAAAAAAAAAAAAAAAAAAA"));
+
+ LocalBinaryFinder finder({tmp.path() + "/root"});
+
+ base::Optional<FoundBinary> bin1 =
+ finder.FindBinary("/dir/base.apk!elf1.so", "AAAAAAAAAAAAAAAAAAAA");
+ ASSERT_TRUE(bin1.has_value());
+ EXPECT_EQ(bin1.value().file_name, tmp.path() + "/root/dir/elf1.so");
+}
+
+TEST(LocalBinaryFinderTest, OnlyFilename) {
+ base::TmpDirTree tmp;
+ tmp.AddDir("root");
+ tmp.AddFile("root/elf1.so", CreateElfWithBuildId("AAAAAAAAAAAAAAAAAAAA"));
+
+ LocalBinaryFinder finder({tmp.path() + "/root"});
+
+ base::Optional<FoundBinary> bin1 =
+ finder.FindBinary("/ignored_dir/elf1.so", "AAAAAAAAAAAAAAAAAAAA");
+ ASSERT_TRUE(bin1.has_value());
+ EXPECT_EQ(bin1.value().file_name, tmp.path() + "/root/elf1.so");
+}
+
+TEST(LocalBinaryFinderTest, OnlyFilenameWithoutBaseApk) {
+ base::TmpDirTree tmp;
+ tmp.AddDir("root");
+ tmp.AddFile("root/elf1.so", CreateElfWithBuildId("AAAAAAAAAAAAAAAAAAAA"));
+
+ LocalBinaryFinder finder({tmp.path() + "/root"});
+
+ base::Optional<FoundBinary> bin1 = finder.FindBinary(
+ "/ignored_dir/base.apk!elf1.so", "AAAAAAAAAAAAAAAAAAAA");
+ ASSERT_TRUE(bin1.has_value());
+ EXPECT_EQ(bin1.value().file_name, tmp.path() + "/root/elf1.so");
+}
+
+TEST(LocalBinaryFinderTest, BuildIdSubdir) {
+ base::TmpDirTree tmp;
+ tmp.AddDir("root");
+ tmp.AddDir("root/.build-id");
+ tmp.AddDir("root/.build-id/41");
+ tmp.AddFile("root/.build-id/41/41414141414141414141414141414141414141.debug",
+ CreateElfWithBuildId("AAAAAAAAAAAAAAAAAAAA"));
+
+ LocalBinaryFinder finder({tmp.path() + "/root"});
+
+ base::Optional<FoundBinary> bin1 =
+ finder.FindBinary("/ignored_dir/ignored_name.so", "AAAAAAAAAAAAAAAAAAAA");
+ ASSERT_TRUE(bin1.has_value());
+ EXPECT_EQ(
+ bin1.value().file_name,
+ tmp.path() +
+ "/root/.build-id/41/41414141414141414141414141414141414141.debug");
+}
+
} // namespace
} // namespace profiling
} // namespace perfetto
diff --git a/src/traced/service/builtin_producer.cc b/src/traced/service/builtin_producer.cc
index 20d98497a..a2007beb5 100644
--- a/src/traced/service/builtin_producer.cc
+++ b/src/traced/service/builtin_producer.cc
@@ -67,8 +67,16 @@ BuiltinProducer::~BuiltinProducer() {
}
void BuiltinProducer::ConnectInProcess(TracingService* svc) {
+#if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
+ // TODO(primiano): ConnectProducer should take a base::PlatformProcessId not
+ // pid_t, as they are different on Windows. But that is a larger refactoring
+ // and not worth given this is the only use case where it clashes.
+ const pid_t cur_proc_id = 0;
+#else
+ const pid_t cur_proc_id = base::GetProcessId();
+#endif
endpoint_ = svc->ConnectProducer(
- this, base::GetCurrentUserId(), base::GetProcessId(), "traced",
+ this, base::GetCurrentUserId(), cur_proc_id, "traced",
/*shared_memory_size_hint_bytes=*/16 * 1024, /*in_process=*/true,
TracingService::ProducerSMBScrapingMode::kDisabled,
/*shared_memory_page_size_hint_bytes=*/4096);
diff --git a/test/test_helper.h b/test/test_helper.h
index 8407f2042..778f88a71 100644
--- a/test/test_helper.h
+++ b/test/test_helper.h
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "perfetto/base/build_config.h"
#include "perfetto/ext/base/file_utils.h"
#include "perfetto/ext/base/optional.h"
#include "perfetto/ext/base/scoped_file.h"
@@ -317,6 +318,8 @@ class TestHelper : public Consumer {
std::unique_ptr<TracingService::ConsumerEndpoint> endpoint_; // Keep last.
};
+#if !PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
+
// This class is a reference to a child process that has in essence been execv
// to the requested binary. The process will start and then wait for Run()
// before proceeding. We use this to fork new processes before starting any
@@ -414,6 +417,8 @@ class Exec {
base::Pipe sync_pipe_;
};
+#endif // !PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
+
} // namespace perfetto
#endif // TEST_TEST_HELPER_H_