summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'libunwindstack/Memory.cpp')
-rw-r--r--libunwindstack/Memory.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/libunwindstack/Memory.cpp b/libunwindstack/Memory.cpp
index 9e4650998..8c36055c4 100644
--- a/libunwindstack/Memory.cpp
+++ b/libunwindstack/Memory.cpp
@@ -28,7 +28,11 @@
28 28
29#include <android-base/unique_fd.h> 29#include <android-base/unique_fd.h>
30 30
31#include "Memory.h" 31#include <unwindstack/Memory.h>
32
33#include "Check.h"
34
35namespace unwindstack {
32 36
33bool Memory::ReadString(uint64_t addr, std::string* string, uint64_t max_read) { 37bool Memory::ReadString(uint64_t addr, std::string* string, uint64_t max_read) {
34 string->clear(); 38 string->clear();
@@ -245,6 +249,11 @@ bool MemoryOffline::Read(uint64_t addr, void* dst, size_t size) {
245 return true; 249 return true;
246} 250}
247 251
252MemoryRange::MemoryRange(Memory* memory, uint64_t begin, uint64_t end)
253 : memory_(memory), begin_(begin), length_(end - begin) {
254 CHECK(end > begin);
255}
256
248bool MemoryRange::Read(uint64_t addr, void* dst, size_t size) { 257bool MemoryRange::Read(uint64_t addr, void* dst, size_t size) {
249 uint64_t max_read; 258 uint64_t max_read;
250 if (__builtin_add_overflow(addr, size, &max_read) || max_read > length_) { 259 if (__builtin_add_overflow(addr, size, &max_read) || max_read > length_) {
@@ -253,3 +262,5 @@ bool MemoryRange::Read(uint64_t addr, void* dst, size_t size) {
253 // The check above guarantees that addr + begin_ will not overflow. 262 // The check above guarantees that addr + begin_ will not overflow.
254 return memory_->Read(addr + begin_, dst, size); 263 return memory_->Read(addr + begin_, dst, size);
255} 264}
265
266} // namespace unwindstack