Skip to content

Commit ee00258

Browse files
committed
Merge 'origin/master' for v24.1 into releases/v24.x
Picks up Windows build fixes Change-Id: I904bb49a11b9de0deacece7828a16831091a7d3a
2 parents 2685339 + d59e9de commit ee00258

File tree

5 files changed

+101
-4
lines changed

5 files changed

+101
-4
lines changed

CHANGELOG

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ Unreleased:
99
*
1010

1111

12+
v24.1 - 2022-02-09:
13+
Tracing service and probes:
14+
* Fixed build failures on Windows.
15+
Trace Processor:
16+
* Fixed build failures on Windows.
17+
UI:
18+
*
19+
SDK:
20+
*
21+
22+
1223
v24.0 - 2022-02-08:
1324
Tracing service and probes:
1425
* Added "cpufreq_period_ms" in data source "linux.sys_stats" to poll

src/profiling/symbolizer/local_symbolizer.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,8 @@ base::Optional<FoundBinary> LocalBinaryFinder::FindBinaryInRoot(
423423
}
424424

425425
if (base::StartsWith(filename, kApkPrefix)) {
426-
symbol_file =
427-
root_str + "/" + dirname + "/" + filename.substr(sizeof(kApkPrefix));
426+
symbol_file = root_str + "/" + dirname + "/" +
427+
filename.substr(sizeof(kApkPrefix) - 1);
428428
result = IsCorrectFile(symbol_file, build_id);
429429
if (result) {
430430
return result;
@@ -438,7 +438,7 @@ base::Optional<FoundBinary> LocalBinaryFinder::FindBinaryInRoot(
438438
}
439439

440440
if (base::StartsWith(filename, kApkPrefix)) {
441-
symbol_file = root_str + "/" + filename.substr(sizeof(kApkPrefix));
441+
symbol_file = root_str + "/" + filename.substr(sizeof(kApkPrefix) - 1);
442442
result = IsCorrectFile(symbol_file, build_id);
443443
if (result) {
444444
return result;

src/profiling/symbolizer/local_symbolizer_unittest.cc

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,79 @@ TEST(LocalBinaryIndexerTest, SimpleTree) {
162162
EXPECT_EQ(bin2.value().file_name, tmp.path() + "/dir2/elf1");
163163
}
164164

165+
TEST(LocalBinaryFinderTest, AbsolutePath) {
166+
base::TmpDirTree tmp;
167+
tmp.AddDir("root");
168+
tmp.AddDir("root/dir");
169+
tmp.AddFile("root/dir/elf1.so", CreateElfWithBuildId("AAAAAAAAAAAAAAAAAAAA"));
170+
171+
LocalBinaryFinder finder({tmp.path() + "/root"});
172+
173+
base::Optional<FoundBinary> bin1 =
174+
finder.FindBinary("/dir/elf1.so", "AAAAAAAAAAAAAAAAAAAA");
175+
ASSERT_TRUE(bin1.has_value());
176+
EXPECT_EQ(bin1.value().file_name, tmp.path() + "/root/dir/elf1.so");
177+
}
178+
179+
TEST(LocalBinaryFinderTest, AbsolutePathWithoutBaseApk) {
180+
base::TmpDirTree tmp;
181+
tmp.AddDir("root");
182+
tmp.AddDir("root/dir");
183+
tmp.AddFile("root/dir/elf1.so", CreateElfWithBuildId("AAAAAAAAAAAAAAAAAAAA"));
184+
185+
LocalBinaryFinder finder({tmp.path() + "/root"});
186+
187+
base::Optional<FoundBinary> bin1 =
188+
finder.FindBinary("/dir/base.apk!elf1.so", "AAAAAAAAAAAAAAAAAAAA");
189+
ASSERT_TRUE(bin1.has_value());
190+
EXPECT_EQ(bin1.value().file_name, tmp.path() + "/root/dir/elf1.so");
191+
}
192+
193+
TEST(LocalBinaryFinderTest, OnlyFilename) {
194+
base::TmpDirTree tmp;
195+
tmp.AddDir("root");
196+
tmp.AddFile("root/elf1.so", CreateElfWithBuildId("AAAAAAAAAAAAAAAAAAAA"));
197+
198+
LocalBinaryFinder finder({tmp.path() + "/root"});
199+
200+
base::Optional<FoundBinary> bin1 =
201+
finder.FindBinary("/ignored_dir/elf1.so", "AAAAAAAAAAAAAAAAAAAA");
202+
ASSERT_TRUE(bin1.has_value());
203+
EXPECT_EQ(bin1.value().file_name, tmp.path() + "/root/elf1.so");
204+
}
205+
206+
TEST(LocalBinaryFinderTest, OnlyFilenameWithoutBaseApk) {
207+
base::TmpDirTree tmp;
208+
tmp.AddDir("root");
209+
tmp.AddFile("root/elf1.so", CreateElfWithBuildId("AAAAAAAAAAAAAAAAAAAA"));
210+
211+
LocalBinaryFinder finder({tmp.path() + "/root"});
212+
213+
base::Optional<FoundBinary> bin1 = finder.FindBinary(
214+
"/ignored_dir/base.apk!elf1.so", "AAAAAAAAAAAAAAAAAAAA");
215+
ASSERT_TRUE(bin1.has_value());
216+
EXPECT_EQ(bin1.value().file_name, tmp.path() + "/root/elf1.so");
217+
}
218+
219+
TEST(LocalBinaryFinderTest, BuildIdSubdir) {
220+
base::TmpDirTree tmp;
221+
tmp.AddDir("root");
222+
tmp.AddDir("root/.build-id");
223+
tmp.AddDir("root/.build-id/41");
224+
tmp.AddFile("root/.build-id/41/41414141414141414141414141414141414141.debug",
225+
CreateElfWithBuildId("AAAAAAAAAAAAAAAAAAAA"));
226+
227+
LocalBinaryFinder finder({tmp.path() + "/root"});
228+
229+
base::Optional<FoundBinary> bin1 =
230+
finder.FindBinary("/ignored_dir/ignored_name.so", "AAAAAAAAAAAAAAAAAAAA");
231+
ASSERT_TRUE(bin1.has_value());
232+
EXPECT_EQ(
233+
bin1.value().file_name,
234+
tmp.path() +
235+
"/root/.build-id/41/41414141414141414141414141414141414141.debug");
236+
}
237+
165238
} // namespace
166239
} // namespace profiling
167240
} // namespace perfetto

src/traced/service/builtin_producer.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,16 @@ BuiltinProducer::~BuiltinProducer() {
6767
}
6868

6969
void BuiltinProducer::ConnectInProcess(TracingService* svc) {
70+
#if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
71+
// TODO(primiano): ConnectProducer should take a base::PlatformProcessId not
72+
// pid_t, as they are different on Windows. But that is a larger refactoring
73+
// and not worth given this is the only use case where it clashes.
74+
const pid_t cur_proc_id = 0;
75+
#else
76+
const pid_t cur_proc_id = base::GetProcessId();
77+
#endif
7078
endpoint_ = svc->ConnectProducer(
71-
this, base::GetCurrentUserId(), base::GetProcessId(), "traced",
79+
this, base::GetCurrentUserId(), cur_proc_id, "traced",
7280
/*shared_memory_size_hint_bytes=*/16 * 1024, /*in_process=*/true,
7381
TracingService::ProducerSMBScrapingMode::kDisabled,
7482
/*shared_memory_page_size_hint_bytes=*/4096);

test/test_helper.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <stdio.h>
2121
#include <stdlib.h>
2222

23+
#include "perfetto/base/build_config.h"
2324
#include "perfetto/ext/base/file_utils.h"
2425
#include "perfetto/ext/base/optional.h"
2526
#include "perfetto/ext/base/scoped_file.h"
@@ -317,6 +318,8 @@ class TestHelper : public Consumer {
317318
std::unique_ptr<TracingService::ConsumerEndpoint> endpoint_; // Keep last.
318319
};
319320

321+
#if !PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
322+
320323
// This class is a reference to a child process that has in essence been execv
321324
// to the requested binary. The process will start and then wait for Run()
322325
// before proceeding. We use this to fork new processes before starting any
@@ -414,6 +417,8 @@ class Exec {
414417
base::Pipe sync_pipe_;
415418
};
416419

420+
#endif // !PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
421+
417422
} // namespace perfetto
418423

419424
#endif // TEST_TEST_HELPER_H_

0 commit comments

Comments
 (0)