summaryrefslogtreecommitdiff
path: root/simpleperf/read_apk_test.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2018-05-21 17:37:00 -0700
committerYabin Cui <yabinc@google.com>2018-05-22 11:28:47 -0700
commit2a53ff331b4ca0bb55f20115e95454c9afcc97c4 (patch)
tree904e80ffc98ab18011cbf0d7bf450916491fa76b /simpleperf/read_apk_test.cpp
parent9f3f98476cbfb1f35238689a57800be47b5be138 (diff)
downloadextras-2a53ff331b4ca0bb55f20115e95454c9afcc97c4.tar.gz
simpleperf: get symbols from dex files extracted from zip files.
ART may extract dex files into memory from zip files. This CL supports getting symbols from extracted dex files in below steps: 1. Change map names in "/dev/ashmem/dalvik-xxx extracted in memory from yyy.apk" format into yyy.apk!/xxx format. 2. Support dumping dex files in yyy.apk!/xxx format in JITDebugReader. 3. Support reading symbols from dex files in yyy.apk!/xxx format in DexFileDso. Also refactor FileHelper to return android::base::unique_fd, refactor ArchiveHelper to wrap all operations to zip files. Bug: 79118393 Test: run simpleperf_unit_test. Test: run simpleperf on an app containing extracted dex files. Change-Id: I65dbd98843f2d47272ea72935fd3d2b6d6e8ae40
Diffstat (limited to 'simpleperf/read_apk_test.cpp')
-rw-r--r--simpleperf/read_apk_test.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/simpleperf/read_apk_test.cpp b/simpleperf/read_apk_test.cpp
index 4d9e2e1a..d5e44e1b 100644
--- a/simpleperf/read_apk_test.cpp
+++ b/simpleperf/read_apk_test.cpp
@@ -20,13 +20,6 @@
#include "get_test_data.h"
#include "test_util.h"
-
-TEST(read_apk, IsValidApkPath) {
- ASSERT_FALSE(IsValidApkPath("/dev/zero"));
- ASSERT_FALSE(IsValidApkPath(GetTestData(ELF_FILE)));
- ASSERT_TRUE(IsValidApkPath(GetTestData(APK_FILE)));
-}
-
TEST(read_apk, FindElfInApkByOffset) {
ApkInspector inspector;
ASSERT_TRUE(inspector.FindElfInApkByOffset("/dev/null", 0) == nullptr);
@@ -49,3 +42,16 @@ TEST(read_apk, FindElfInApkByName) {
ASSERT_EQ(NATIVELIB_OFFSET_IN_APK, ee->entry_offset());
ASSERT_EQ(NATIVELIB_SIZE_IN_APK, ee->entry_size());
}
+
+TEST(read_apk, ParseExtractedInMemoryPath) {
+ std::string zip_path;
+ std::string 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));
+ ASSERT_EQ(zip_path, "/data/app/com.example.simpleperf.simpleperfexamplepurejava"
+ "-HZK6bPs3Z9SDT3a-tqmasA==/base.apk");
+ ASSERT_EQ(entry_name, "classes.dex");
+ ASSERT_FALSE(ParseExtractedInMemoryPath("/dev/ashmem/dalvik-thread local mark stack (deleted)",
+ &zip_path, &entry_name));
+}