summaryrefslogtreecommitdiff
path: root/libunwindstack/Memory.h
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2017-03-17 17:01:45 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-03-17 17:01:46 +0000
commitcc404b51fc424cbb786abce8b8f36b1dce1c0ab9 (patch)
tree62ebb9ce531a818efa51e551179dccad32ea949e /libunwindstack/Memory.h
parent0add3ca7c47b287bc01b5e738cb9b682d43f6f97 (diff)
parent3958f8060ac0adccd977c0fab7a53d45f3fce58d (diff)
Merge "Elf interface for new unwinder."
Diffstat (limited to 'libunwindstack/Memory.h')
-rw-r--r--libunwindstack/Memory.h26
1 files changed, 21 insertions, 5 deletions
diff --git a/libunwindstack/Memory.h b/libunwindstack/Memory.h
index 5ab031dd0..c5316a1d0 100644
--- a/libunwindstack/Memory.h
+++ b/libunwindstack/Memory.h
@@ -22,10 +22,7 @@
#include <unistd.h>
#include <string>
-
-#include <android-base/unique_fd.h>
-
-constexpr bool kMemoryStatsEnabled = true;
+#include <vector>
class Memory {
public:
@@ -50,15 +47,34 @@ class Memory {
}
};
+class MemoryBuffer : public Memory {
+ public:
+ MemoryBuffer() = default;
+ virtual ~MemoryBuffer() = default;
+
+ bool Read(uint64_t addr, void* dst, size_t size) override;
+
+ uint8_t* GetPtr(size_t offset);
+
+ void Resize(size_t size) { raw_.resize(size); }
+
+ uint64_t Size() { return raw_.size(); }
+
+ private:
+ std::vector<uint8_t> raw_;
+};
+
class MemoryFileAtOffset : public Memory {
public:
MemoryFileAtOffset() = default;
virtual ~MemoryFileAtOffset();
- bool Init(const std::string& file, uint64_t offset);
+ bool Init(const std::string& file, uint64_t offset, uint64_t size = UINT64_MAX);
bool Read(uint64_t addr, void* dst, size_t size) override;
+ void Clear();
+
protected:
size_t size_ = 0;
size_t offset_ = 0;