summaryrefslogtreecommitdiff
path: root/libunwindstack/DexFile.h
diff options
context:
space:
mode:
Diffstat (limited to 'libunwindstack/DexFile.h')
-rw-r--r--libunwindstack/DexFile.h58
1 files changed, 20 insertions, 38 deletions
diff --git a/libunwindstack/DexFile.h b/libunwindstack/DexFile.h
index 59ad2f6..a80ea94 100644
--- a/libunwindstack/DexFile.h
+++ b/libunwindstack/DexFile.h
@@ -31,57 +31,39 @@
namespace unwindstack {
-class DexFile : protected art_api::dex::DexFile {
+struct MapInfo;
+class Memory;
+
+class DexFile {
struct Info {
uint32_t offset; // Symbol start offset (relative to start of dex file).
SharedString name;
};
public:
- virtual ~DexFile() = default;
-
- bool IsValidPc(uint64_t dex_pc);
+ bool IsValidPc(uint64_t dex_pc) {
+ return base_addr_ <= dex_pc && (dex_pc - base_addr_) < file_size_;
+ }
bool GetFunctionName(uint64_t dex_pc, SharedString* method_name, uint64_t* method_offset);
- static std::unique_ptr<DexFile> Create(uint64_t dex_file_offset_in_memory, Memory* memory,
+ static std::unique_ptr<DexFile> Create(uint64_t base_addr, uint64_t file_size, Memory* memory,
MapInfo* info);
- protected:
- DexFile(uint64_t base_addr, uint64_t size, std::unique_ptr<art_api::dex::DexFile>& art_dex_file)
- : art_api::dex::DexFile(art_dex_file), base_addr_(base_addr), size_(size) {}
-
- uint64_t base_addr_ = 0; // Absolute address where this DEX file is in memory.
- uint64_t size_ = 0; // Size of the dex file.
-
- std::map<uint32_t, Info> symbols_; // Cache of read symbols (keyed by *end* offset).
-};
-
-class DexFileFromFile : public DexFile {
- public:
- static std::unique_ptr<DexFileFromFile> Create(uint64_t base_addr,
- uint64_t dex_file_offset_in_file,
- const std::string& file);
-
private:
- DexFileFromFile(uint64_t base_addr, uint64_t size,
- std::unique_ptr<art_api::dex::DexFile>& art_dex_file)
- : DexFile(base_addr, size, art_dex_file) {}
-};
-
-class DexFileFromMemory : public DexFile {
- public:
- static std::unique_ptr<DexFileFromMemory> Create(uint64_t dex_file_offset_in_memory,
- Memory* memory, const std::string& name,
- size_t max_size);
+ DexFile(std::unique_ptr<Memory>&& memory, uint64_t base_addr, uint64_t file_size,
+ std::unique_ptr<art_api::dex::DexFile>&& dex)
+ : memory_(std::move(memory)),
+ base_addr_(base_addr),
+ file_size_(file_size),
+ dex_(std::move(dex)) {}
+
+ std::unique_ptr<Memory> memory_; // Memory range containing the dex file.
+ uint64_t base_addr_ = 0; // Absolute address where this DEX file is in memory.
+ uint64_t file_size_ = 0; // Total number of bytes in the dex file.
+ std::unique_ptr<art_api::dex::DexFile> dex_; // Loaded underling dex object.
- private:
- DexFileFromMemory(uint64_t base_addr, uint64_t size,
- std::unique_ptr<art_api::dex::DexFile>& art_dex_file,
- std::vector<uint8_t>&& memory)
- : DexFile(base_addr, size, art_dex_file), memory_(std::move(memory)) {}
-
- std::vector<uint8_t> memory_;
+ std::map<uint32_t, Info> symbols_; // Cache of read symbols (keyed by *end* offset).
};
} // namespace unwindstack