diff options
author | Joel Fernandes <joelaf@google.com> | 2018-08-30 19:30:58 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-08-30 19:30:58 +0000 |
commit | 887e7e9641360d77a0bd591b61e6c17267859402 (patch) | |
tree | f15544f6989d111a589e2002547c915288fb7102 | |
parent | 92f265a84ab69f632f183660d880ff5667027294 (diff) | |
parent | 7e8b2b9a20952d8c91044763ebf5cbca486c3989 (diff) | |
download | extras-887e7e9641360d77a0bd591b61e6c17267859402.tar.gz |
Merge "Remove ashmem from system/extras"
-rw-r--r-- | perfprofd/tests/perfprofd_test.cc | 2 | ||||
-rw-r--r-- | simpleperf/cmd_record.cpp | 2 | ||||
-rw-r--r-- | simpleperf/read_apk.cpp | 33 | ||||
-rw-r--r-- | simpleperf/read_apk.h | 3 | ||||
-rw-r--r-- | simpleperf/read_apk_test.cpp | 8 | ||||
-rwxr-xr-x | simpleperf/scripts/debug_unwind_reporter.py | 4 |
6 files changed, 33 insertions, 19 deletions
diff --git a/perfprofd/tests/perfprofd_test.cc b/perfprofd/tests/perfprofd_test.cc index 3748f3af..530d5f49 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 ff1977ee..db21d4cb 100644 --- a/simpleperf/cmd_record.cpp +++ b/simpleperf/cmd_record.cpp @@ -1140,7 +1140,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('(')) |