summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2020-08-05 19:51:36 +0000
committerYabin Cui <yabinc@google.com>2020-08-06 18:48:35 +0000
commit075dd1876248e2746542f644e59e331900586cfc (patch)
treed0771a16a55c1fc32422333bf4a312d1bb0c4473
parent3c69332324978a62891160ed298bedacb18c4c0a (diff)
downloadextras-075dd1876248e2746542f644e59e331900586cfc.tar.gz
simpleperf: fix jit cache path in report cmd.
1. Separate app cache and zygote cache in ElfDso::GetReportPath(). 2. Use GetReportPath() in --dsos option in report cmd. So "[JIT app cache]" can be used to filter binaries. Bug: 159155297 Test: run simpleperf_unit_test Change-Id: Idc52bd1b2496aae30721a224d93621f776f2ae03
-rw-r--r--simpleperf/JITDebugReader.cpp4
-rw-r--r--simpleperf/JITDebugReader.h3
-rw-r--r--simpleperf/cmd_report.cpp2
-rw-r--r--simpleperf/cmd_report_test.cpp11
-rw-r--r--simpleperf/dso.cpp12
-rw-r--r--simpleperf/testdata/perf_with_jit_symbol.databin0 -> 280739 bytes
6 files changed, 27 insertions, 5 deletions
diff --git a/simpleperf/JITDebugReader.cpp b/simpleperf/JITDebugReader.cpp
index efc4fae3..622c073b 100644
--- a/simpleperf/JITDebugReader.cpp
+++ b/simpleperf/JITDebugReader.cpp
@@ -732,14 +732,14 @@ TempSymFile* JITDebugReader::GetTempSymFile(Process& process, const CodeEntry& j
}
if (is_zygote) {
if (!zygote_symfile_) {
- std::string path = symfile_prefix_ + "_jit_zygote_cache";
+ std::string path = symfile_prefix_ + "_" + kJITZygoteCacheFile;
zygote_symfile_ =
TempSymFile::Create(std::move(path), symfile_option_ == SymFileOption::kDropSymFiles);
}
return zygote_symfile_.get();
}
if (!app_symfile_) {
- std::string path = symfile_prefix_ + "_jit_app_cache";
+ std::string path = symfile_prefix_ + "_" + kJITAppCacheFile;
app_symfile_ =
TempSymFile::Create(std::move(path), symfile_option_ == SymFileOption::kDropSymFiles);
}
diff --git a/simpleperf/JITDebugReader.h b/simpleperf/JITDebugReader.h
index 167b0e9f..a6c9c030 100644
--- a/simpleperf/JITDebugReader.h
+++ b/simpleperf/JITDebugReader.h
@@ -36,6 +36,9 @@
namespace simpleperf {
+inline constexpr const char* kJITAppCacheFile = "jit_app_cache";
+inline constexpr const char* kJITZygoteCacheFile = "jit_zygote_cache";
+
// JITDebugInfo represents the debug info of a JITed Java method or a dex file.
struct JITDebugInfo {
enum {
diff --git a/simpleperf/cmd_report.cpp b/simpleperf/cmd_report.cpp
index 873819a3..40b6b735 100644
--- a/simpleperf/cmd_report.cpp
+++ b/simpleperf/cmd_report.cpp
@@ -235,7 +235,7 @@ class ReportCmdSampleTreeBuilder : public SampleTreeBuilder<SampleEntry, uint64_
return false;
}
if (!dso_filter_.empty() &&
- dso_filter_.find(sample->map->dso->Path()) == dso_filter_.end()) {
+ dso_filter_.find(sample->map->dso->GetReportPath().data()) == dso_filter_.end()) {
return false;
}
if (!symbol_filter_.empty() &&
diff --git a/simpleperf/cmd_report_test.cpp b/simpleperf/cmd_report_test.cpp
index ae081148..25b88b77 100644
--- a/simpleperf/cmd_report_test.cpp
+++ b/simpleperf/cmd_report_test.cpp
@@ -507,6 +507,17 @@ TEST_F(ReportCommandTest, csv_option) {
ASSERT_NE(content.find("AccEventCount,SelfEventCount,EventName"), std::string::npos);
}
+TEST_F(ReportCommandTest, dso_path_for_jit_cache) {
+ Report("perf_with_jit_symbol.data", {"--sort", "dso"});
+ ASSERT_TRUE(success);
+ ASSERT_NE(content.find("[JIT app cache]"), std::string::npos);
+
+ // Check if we can filter dso by "[JIT app cache]".
+ Report("perf_with_jit_symbol.data", {"--dsos", "[JIT app cache]"});
+ ASSERT_TRUE(success);
+ ASSERT_NE(content.find("[JIT app cache]"), std::string::npos);
+}
+
#if defined(__linux__)
#include "event_selection_set.h"
diff --git a/simpleperf/dso.cpp b/simpleperf/dso.cpp
index c1a474ca..f4239a60 100644
--- a/simpleperf/dso.cpp
+++ b/simpleperf/dso.cpp
@@ -29,18 +29,20 @@
#include <android-base/strings.h>
#include "environment.h"
+#include "JITDebugReader.h"
#include "read_apk.h"
#include "read_dex_file.h"
#include "read_elf.h"
#include "utils.h"
+using android::base::EndsWith;
using namespace simpleperf;
namespace simpleperf_dso_impl {
std::string RemovePathSeparatorSuffix(const std::string& path) {
// Don't remove path separator suffix for '/'.
- if (android::base::EndsWith(path, OS_PATH_SEPARATOR) && path.size() > 1u) {
+ if (EndsWith(path, OS_PATH_SEPARATOR) && path.size() > 1u) {
return path.substr(0, path.size() - 1);
}
return path;
@@ -486,7 +488,13 @@ class ElfDso : public Dso {
std::string_view GetReportPath() const override {
if (size_t colon_pos = path_.find(':'); colon_pos != std::string::npos) {
- return "[JIT app cache]";
+ std::string file_path = path_.substr(0, colon_pos);
+ if (EndsWith(file_path, kJITAppCacheFile)) {
+ return "[JIT app cache]";
+ }
+ if (EndsWith(file_path, kJITZygoteCacheFile)) {
+ return "[JIT zygote cache]";
+ }
}
return path_;
}
diff --git a/simpleperf/testdata/perf_with_jit_symbol.data b/simpleperf/testdata/perf_with_jit_symbol.data
new file mode 100644
index 00000000..5f139204
--- /dev/null
+++ b/simpleperf/testdata/perf_with_jit_symbol.data
Binary files differ