From 4b22a9522d9384c09eefe1398350ba69c344c129 Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Wed, 27 Feb 2019 13:44:16 -0800 Subject: [PATCH] simpleperf: add test for a problem recording user stack. Also fix a line in another test. Bug: 113127950 Test: run simpleperf_unit_test. Change-Id: Id7fd20cdc441734a8d39255fecfbd8fe9021274e --- simpleperf/cmd_record_test.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp index 6b47c1c7..fdc26e60 100644 --- a/simpleperf/cmd_record_test.cpp +++ b/simpleperf/cmd_record_test.cpp @@ -706,6 +706,35 @@ TEST(record_cmd, kernel_bug_making_zero_dyn_size) { } return true; })); + ASSERT_TRUE(has_sample); +} + +TEST(record_cmd, kernel_bug_making_zero_dyn_size_for_kernel_samples) { + // Test a kernel bug that makes zero dyn_size for syscalls of 32-bit applications in 64-bit + // kernels. If it fails, please cherry pick below kernel patch: + // 02e184476eff8 perf/core: Force USER_DS when recording user stack data + TEST_REQUIRE_HW_COUNTER(); + TEST_REQUIRE_HOST_ROOT(); + std::vector> workloads; + CreateProcesses(1, &workloads); + std::string pid = std::to_string(workloads[0]->GetPid()); + TemporaryFile tmpfile; + ASSERT_TRUE(RecordCmd()->Run({"-e", "sched:sched_switch", "-o", tmpfile.path, "-p", pid, + "--call-graph", "dwarf,8", "--no-unwind", "--duration", "1"})); + std::unique_ptr reader = RecordFileReader::CreateInstance(tmpfile.path); + ASSERT_TRUE(reader); + bool has_sample = false; + ASSERT_TRUE(reader->ReadDataSection([&](std::unique_ptr r) { + if (r->type() == PERF_RECORD_SAMPLE && r->InKernel()) { + SampleRecord* sr = static_cast(r.get()); + if (sr->stack_user_data.dyn_size == 0) { + return false; + } + has_sample = true; + } + return true; + })); + ASSERT_TRUE(has_sample); } TEST(record_cmd, cpu_percent_option) { -- 2.11.0