summaryrefslogtreecommitdiff
path: root/simpleperf/dso_test.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2018-05-09 17:27:27 -0700
committerYabin Cui <yabinc@google.com>2018-05-09 17:47:08 -0700
commit8422f3437188ae3e4d4b8ee5f65804cc23d9fda4 (patch)
treef987549465c839100723ffab08ac9a30a19f28a6 /simpleperf/dso_test.cpp
parentdc0191161cb4557535e89d45c8cfdd2305dcef4e (diff)
downloadextras-8422f3437188ae3e4d4b8ee5f65804cc23d9fda4.tar.gz
simpleperf: change interface of read_apk.h.
1. Remove GetBuildIdFromApkFile and ParseSymbolsFromApkFile, because their function can be supported using ApkInspector::FindElfInApkByName and read_elf.h. 2. Remove ApkInspector::FindOffsetInApkByName, instead the caller can use ApkInspector::FindElfInApkByName directly. 3. In ApkInspector::embedded_elf_cache_, add map for entry_name. So the EmbeddedElfs added by cmd_record.cpp can be used by OfflineUnwinder. Also support reading min executable virtual address from embedded elfs in ElfDso. Also avoid segfault reading build id of elf files with broken section table, and add test. Bug: none. Test: run simpleperf_unit_test. Change-Id: I2e4f51a5e348138cbf7445ec6dd42dbd6ae1b03d
Diffstat (limited to 'simpleperf/dso_test.cpp')
-rw-r--r--simpleperf/dso_test.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/simpleperf/dso_test.cpp b/simpleperf/dso_test.cpp
index cc441939..175ce1d5 100644
--- a/simpleperf/dso_test.cpp
+++ b/simpleperf/dso_test.cpp
@@ -23,6 +23,7 @@
#include <android-base/test_utils.h>
#include "get_test_data.h"
+#include "read_apk.h"
using namespace simpleperf_dso_impl;
@@ -85,3 +86,18 @@ TEST(dso, dex_file_dso) {
GTEST_LOG_(INFO) << "This test only runs on linux because of libdexfile";
#endif // defined(__linux__)
}
+
+TEST(dso, embedded_elf) {
+ const std::string file_path = GetUrlInApk(GetTestData(APK_FILE), NATIVELIB_IN_APK);
+ std::unique_ptr<Dso> dso = Dso::CreateDso(DSO_ELF_FILE, file_path);
+ ASSERT_TRUE(dso);
+ ASSERT_EQ(dso->Path(), file_path);
+ ASSERT_EQ(dso->GetDebugFilePath(), file_path);
+ ASSERT_EQ(dso->MinVirtualAddress(), 0u);
+ const Symbol* symbol = dso->FindSymbol(0x9a4);
+ ASSERT_TRUE(symbol != nullptr);
+ ASSERT_STREQ(symbol->Name(), "Java_com_example_hellojni_HelloJni_callFunc1");
+ BuildId build_id;
+ ASSERT_TRUE(GetBuildIdFromDsoPath(file_path, &build_id));
+ ASSERT_EQ(build_id, native_lib_build_id);
+}