summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fernandes <joelaf@google.com>2018-08-24 12:20:28 -0700
committerYabin Cui <yabinc@google.com>2018-08-27 10:38:46 -0700
commit7e8b2b9a20952d8c91044763ebf5cbca486c3989 (patch)
treed87a12c74d53639ea6f110924058c3eaff5285f4
parentc239784153d6b28f381061225e4c4997323118b3 (diff)
downloadextras-7e8b2b9a20952d8c91044763ebf5cbca486c3989.tar.gz
Remove ashmem from system/extras
This topic removes ashmem from ART. Changes the names in system/extras too. It only affects "dalvik-" ashmem regions which are the majority. Test: run simpleperf_unit_test. Test: run perfprofd_test. Change-Id: I3ee65c8d401427613b4b17a66af807ab81ff8a80 Signed-off-by: Joel Fernandes <joelaf@google.com>
-rw-r--r--perfprofd/tests/perfprofd_test.cc2
-rw-r--r--simpleperf/cmd_record.cpp2
-rw-r--r--simpleperf/read_apk.cpp33
-rw-r--r--simpleperf/read_apk.h3
-rw-r--r--simpleperf/read_apk_test.cpp8
-rwxr-xr-xsimpleperf/scripts/debug_unwind_reporter.py4
6 files changed, 33 insertions, 19 deletions
diff --git a/perfprofd/tests/perfprofd_test.cc b/perfprofd/tests/perfprofd_test.cc
index a26694c7..67564da1 100644
--- a/perfprofd/tests/perfprofd_test.cc
+++ b/perfprofd/tests/perfprofd_test.cc
@@ -209,7 +209,7 @@ class PerfProfdTest : public testing::Test {
std::string sqexp = squeezeWhite(expected, "expected");
// Strip out JIT errors.
- std::regex jit_regex("E: Failed to open ELF file: [^ ]*ashmem/dalvik-jit-code-cache.*");
+ std::regex jit_regex("E: Failed to open ELF file: [^ ]*dalvik-jit-code-cache.*");
auto strip_jit = [&](const std::string& str) {
std::smatch jit_match;
return !std::regex_match(str, jit_match, jit_regex);
diff --git a/simpleperf/cmd_record.cpp b/simpleperf/cmd_record.cpp
index 60307b83..b42927b0 100644
--- a/simpleperf/cmd_record.cpp
+++ b/simpleperf/cmd_record.cpp
@@ -1138,7 +1138,7 @@ bool MapOnlyExistInMemory(MmapRecordType* record) {
bool RecordCommand::ShouldOmitRecord(Record* record) {
if (jit_debug_reader_) {
// To profile jitted Java code, we need PROT_JIT_SYMFILE_MAP maps not overlapped by maps for
- // /dev/ashmem/dalvik-jit-code-cache. To profile interpreted Java code, we record maps that
+ // [anon:dalvik-jit-code-cache]. To profile interpreted Java code, we record maps that
// are not executable. Some non-exec maps (like those for stack, heap) provide misleading map
// entries for unwinding, as in http://b/77236599. So it is better to remove
// dalvik-jit-code-cache and other maps that only exist in memory.
diff --git a/simpleperf/read_apk.cpp b/simpleperf/read_apk.cpp
index fd0e0f70..8c85073b 100644
--- a/simpleperf/read_apk.cpp
+++ b/simpleperf/read_apk.cpp
@@ -139,24 +139,29 @@ std::tuple<bool, std::string, std::string> SplitUrlInApk(const std::string& path
return std::make_tuple(true, path.substr(0, pos), path.substr(pos + 2));
}
-// Parse path like "/dev/ashmem/dalvik-classes.dex extracted in memory from /..base.apk (deleted)".
+// Parse path like "[anon:dalvik-classes.dex extracted in memory from /..base.apk] (deleted)",
+// or "/dev/ashmem/dalvik-classes.dex extracted in memory from /..base.apk (deleted)" on Android P.
bool ParseExtractedInMemoryPath(const std::string& path, std::string* zip_path,
std::string* entry_name) {
- const char* prefix = "/dev/ashmem/dalvik-";
+ const char* prefixes[2] = {"[anon:dalvik-", "/dev/ashmem/dalvik-"};
const char* key = " extracted in memory from ";
size_t pos = path.find(key);
- if (pos != std::string::npos && android::base::StartsWith(path, prefix)) {
- size_t entry_name_start = strlen(prefix);
- size_t entry_name_end = pos;
- size_t zip_path_start = pos + strlen(key);
- size_t zip_path_end = path.find(' ', zip_path_start);
- if (zip_path_end == std::string::npos) {
- zip_path_end = path.size();
- }
- if (entry_name_start < entry_name_end && zip_path_start < zip_path_end) {
- *entry_name = path.substr(entry_name_start, entry_name_end - entry_name_start);
- *zip_path = path.substr(zip_path_start, zip_path_end - zip_path_start);
- return true;
+ if (pos != std::string::npos) {
+ for (const char* prefix : prefixes) {
+ if (android::base::StartsWith(path, prefix)) {
+ size_t entry_name_start = strlen(prefix);
+ size_t entry_name_end = pos;
+ size_t zip_path_start = pos + strlen(key);
+ size_t zip_path_end = path.find_first_of(" ]", zip_path_start);
+ if (zip_path_end == std::string::npos) {
+ zip_path_end = path.size();
+ }
+ if (entry_name_start < entry_name_end && zip_path_start < zip_path_end) {
+ *entry_name = path.substr(entry_name_start, entry_name_end - entry_name_start);
+ *zip_path = path.substr(zip_path_start, zip_path_end - zip_path_start);
+ return true;
+ }
+ }
}
}
return false;
diff --git a/simpleperf/read_apk.h b/simpleperf/read_apk.h
index 329b05ea..c37366b9 100644
--- a/simpleperf/read_apk.h
+++ b/simpleperf/read_apk.h
@@ -90,7 +90,8 @@ class ApkInspector {
std::string GetUrlInApk(const std::string& apk_path, const std::string& elf_filename);
std::tuple<bool, std::string, std::string> SplitUrlInApk(const std::string& path);
-// Parse path like "/dev/ashmem/dalvik-classes.dex extracted in memory from /..base.apk (deleted)".
+// Parse path like "[anon:dalvik-classes.dex extracted in memory from /..base.apk] (deleted)",
+// or "/dev/ashmem/dalvik-classes.dex extracted in memory from /..base.apk (deleted)" on Android P.
bool ParseExtractedInMemoryPath(const std::string& path, std::string* zip_path,
std::string* entry_name);
diff --git a/simpleperf/read_apk_test.cpp b/simpleperf/read_apk_test.cpp
index d5e44e1b..6d8bf2d1 100644
--- a/simpleperf/read_apk_test.cpp
+++ b/simpleperf/read_apk_test.cpp
@@ -46,6 +46,14 @@ TEST(read_apk, FindElfInApkByName) {
TEST(read_apk, ParseExtractedInMemoryPath) {
std::string zip_path;
std::string entry_name;
+ ASSERT_TRUE(ParseExtractedInMemoryPath("[anon:dalvik-classes.dex extracted in memory from "
+ "/data/app/com.example.simpleperf.simpleperfexamplepurejava-HZK6bPs3Z9SDT3a-tqmasA==/"
+ "base.apk]", &zip_path, &entry_name));
+ ASSERT_EQ(zip_path, "/data/app/com.example.simpleperf.simpleperfexamplepurejava"
+ "-HZK6bPs3Z9SDT3a-tqmasA==/base.apk");
+ ASSERT_EQ(entry_name, "classes.dex");
+ ASSERT_FALSE(ParseExtractedInMemoryPath("[anon:dalvik-thread local mark stack]",
+ &zip_path, &entry_name));
ASSERT_TRUE(ParseExtractedInMemoryPath("/dev/ashmem/dalvik-classes.dex extracted in memory from "
"/data/app/com.example.simpleperf.simpleperfexamplepurejava-HZK6bPs3Z9SDT3a-tqmasA==/base.apk"
" (deleted)", &zip_path, &entry_name));
diff --git a/simpleperf/scripts/debug_unwind_reporter.py b/simpleperf/scripts/debug_unwind_reporter.py
index b60dea60..864003a9 100755
--- a/simpleperf/scripts/debug_unwind_reporter.py
+++ b/simpleperf/scripts/debug_unwind_reporter.py
@@ -251,7 +251,7 @@ class UnwindingResultErrorReport(object):
def should_omit(self, sample_result, joined_record):
# 1. Can't unwind code generated in memory.
- for name in ['/dev/ashmem/dalvik-jit-code-cache', '//anon']:
+ for name in ['/dev/ashmem/dalvik-jit-code-cache', '[anon:dalvik-jit-code-cache]', '//anon']:
if name in sample_result.callchain[-1].filename:
return True
# 2. Don't report complete callchains, which can reach __libc_init or __start_thread in
@@ -341,7 +341,7 @@ def parse_callchain_record(lines, i, chain_type, process_maps):
elif items[0] == 'callchain:':
in_callchain = True
elif in_callchain:
- # "dalvik-jit-code-cache (deleted)[+346c] (/dev/ashmem/dalvik-jit-code-cache
+ # "dalvik-jit-code-cache (deleted)[+346c] ([anon:dalvik-jit-code-cache]
# (deleted)[+346c])"
if re.search(r'\)\[\+\w+\]\)$', line):
break_pos = line.rfind('(', 0, line.rfind('('))