diff options
author | Yabin Cui <yabinc@google.com> | 2016-03-02 13:56:28 -0800 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2016-03-02 18:21:14 -0800 |
commit | be7ec66eaa4f995bd9068637f7c7d5718173922c (patch) | |
tree | 3340b9e58baa518f75b60bfabac56532f25a1a26 /simpleperf/read_apk.cpp | |
parent | 5cfed7b49b1ae706265d4181b1d4f0dbb79491f5 (diff) | |
download | extras-be7ec66eaa4f995bd9068637f7c7d5718173922c.tar.gz |
simpleperf: support building cts test.
1. build cts test libraries.
2. change tests to use tmpfile instead of perf.data.
3. support extracting testdata from cts test file.
Bug: 27387280
Change-Id: I7c5db77f3157d586d0c9beb446b247626e7cce36
Diffstat (limited to 'simpleperf/read_apk.cpp')
-rw-r--r-- | simpleperf/read_apk.cpp | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/simpleperf/read_apk.cpp b/simpleperf/read_apk.cpp index 8029dc53..18c76c23 100644 --- a/simpleperf/read_apk.cpp +++ b/simpleperf/read_apk.cpp @@ -31,29 +31,6 @@ #include "read_elf.h" #include "utils.h" -class ArchiveHelper { - public: - explicit ArchiveHelper(int fd, const std::string& debug_filename) : valid_(false) { - int rc = OpenArchiveFd(fd, "", &handle_, false); - if (rc == 0) { - valid_ = true; - } else { - LOG(ERROR) << "Failed to open archive " << debug_filename << ": " << ErrorCodeString(rc); - } - } - ~ArchiveHelper() { - if (valid_) { - CloseArchive(handle_); - } - } - bool valid() const { return valid_; } - ZipArchiveHandle &archive_handle() { return handle_; } - - private: - ZipArchiveHandle handle_; - bool valid_; -}; - std::map<ApkInspector::ApkOffset, std::unique_ptr<EmbeddedElf>> ApkInspector::embedded_elf_cache_; EmbeddedElf* ApkInspector::FindElfInApkByOffset(const std::string& apk_path, uint64_t file_offset) { @@ -75,13 +52,13 @@ std::unique_ptr<EmbeddedElf> ApkInspector::FindElfInApkByOffsetWithoutCache(cons if (!IsValidApkPath(apk_path)) { return nullptr; } - FileHelper fhelper(apk_path.c_str()); + FileHelper fhelper = FileHelper::OpenReadOnly(apk_path); if (!fhelper) { return nullptr; } ArchiveHelper ahelper(fhelper.fd(), apk_path); - if (!ahelper.valid()) { + if (!ahelper) { return nullptr; } ZipArchiveHandle &handle = ahelper.archive_handle(); @@ -135,12 +112,12 @@ std::unique_ptr<EmbeddedElf> ApkInspector::FindElfInApkByName(const std::string& if (!IsValidApkPath(apk_path)) { return nullptr; } - FileHelper fhelper(apk_path.c_str()); + FileHelper fhelper = FileHelper::OpenReadOnly(apk_path); if (!fhelper) { return nullptr; } ArchiveHelper ahelper(fhelper.fd(), apk_path); - if (!ahelper.valid()) { + if (!ahelper) { return nullptr; } ZipArchiveHandle& handle = ahelper.archive_handle(); |