unwindstack: rename Memory::ReadPartially to Read.
Test: mma
Test: treehugger
Change-Id: I53c2c5600fb44620b629c01db85a67789594595f
diff --git a/libunwindstack/Memory.cpp b/libunwindstack/Memory.cpp
index 1f4cd03..2479655 100644
--- a/libunwindstack/Memory.cpp
+++ b/libunwindstack/Memory.cpp
@@ -85,7 +85,7 @@
namespace unwindstack {
bool Memory::ReadFully(uint64_t addr, void* dst, size_t size) {
- size_t rc = ReadPartially(addr, dst, size);
+ size_t rc = Read(addr, dst, size);
return rc == size;
}
@@ -114,7 +114,7 @@
return std::shared_ptr<Memory>(new MemoryRemote(pid));
}
-size_t MemoryBuffer::ReadPartially(uint64_t addr, void* dst, size_t size) {
+size_t MemoryBuffer::Read(uint64_t addr, void* dst, size_t size) {
if (addr >= raw_.size()) {
return 0;
}
@@ -185,7 +185,7 @@
return true;
}
-size_t MemoryFileAtOffset::ReadPartially(uint64_t addr, void* dst, size_t size) {
+size_t MemoryFileAtOffset::Read(uint64_t addr, void* dst, size_t size) {
if (addr >= size_) {
return 0;
}
@@ -198,11 +198,11 @@
return actual_len;
}
-size_t MemoryRemote::ReadPartially(uint64_t addr, void* dst, size_t size) {
+size_t MemoryRemote::Read(uint64_t addr, void* dst, size_t size) {
return ProcessVmRead(pid_, dst, addr, size);
}
-size_t MemoryLocal::ReadPartially(uint64_t addr, void* dst, size_t size) {
+size_t MemoryLocal::Read(uint64_t addr, void* dst, size_t size) {
return ProcessVmRead(getpid(), dst, addr, size);
}
@@ -210,7 +210,7 @@
uint64_t offset)
: memory_(memory), begin_(begin), length_(length), offset_(offset) {}
-size_t MemoryRange::ReadPartially(uint64_t addr, void* dst, size_t size) {
+size_t MemoryRange::Read(uint64_t addr, void* dst, size_t size) {
if (addr < offset_) {
return 0;
}
@@ -226,7 +226,7 @@
return 0;
}
- return memory_->ReadPartially(read_addr, dst, read_length);
+ return memory_->Read(read_addr, dst, read_length);
}
bool MemoryOffline::Init(const std::string& file, uint64_t offset) {
@@ -250,12 +250,12 @@
return true;
}
-size_t MemoryOffline::ReadPartially(uint64_t addr, void* dst, size_t size) {
+size_t MemoryOffline::Read(uint64_t addr, void* dst, size_t size) {
if (!memory_) {
return 0;
}
- return memory_->ReadPartially(addr, dst, size);
+ return memory_->Read(addr, dst, size);
}
} // namespace unwindstack
diff --git a/libunwindstack/include/unwindstack/Memory.h b/libunwindstack/include/unwindstack/Memory.h
index cab37d3..8163152 100644
--- a/libunwindstack/include/unwindstack/Memory.h
+++ b/libunwindstack/include/unwindstack/Memory.h
@@ -36,7 +36,7 @@
virtual bool ReadString(uint64_t addr, std::string* string, uint64_t max_read = UINT64_MAX);
- virtual size_t ReadPartially(uint64_t addr, void* dst, size_t size) = 0;
+ virtual size_t Read(uint64_t addr, void* dst, size_t size) = 0;
bool ReadFully(uint64_t addr, void* dst, size_t size);
@@ -66,7 +66,7 @@
MemoryBuffer() = default;
virtual ~MemoryBuffer() = default;
- size_t ReadPartially(uint64_t addr, void* dst, size_t size) override;
+ size_t Read(uint64_t addr, void* dst, size_t size) override;
uint8_t* GetPtr(size_t offset);
@@ -85,7 +85,7 @@
bool Init(const std::string& file, uint64_t offset, uint64_t size = UINT64_MAX);
- size_t ReadPartially(uint64_t addr, void* dst, size_t size) override;
+ size_t Read(uint64_t addr, void* dst, size_t size) override;
size_t Size() { return size_; }
@@ -102,7 +102,7 @@
MemoryRemote(pid_t pid) : pid_(pid) {}
virtual ~MemoryRemote() = default;
- size_t ReadPartially(uint64_t addr, void* dst, size_t size) override;
+ size_t Read(uint64_t addr, void* dst, size_t size) override;
pid_t pid() { return pid_; }
@@ -115,7 +115,7 @@
MemoryLocal() = default;
virtual ~MemoryLocal() = default;
- size_t ReadPartially(uint64_t addr, void* dst, size_t size) override;
+ size_t Read(uint64_t addr, void* dst, size_t size) override;
};
// MemoryRange maps one address range onto another.
@@ -127,7 +127,7 @@
uint64_t offset);
virtual ~MemoryRange() = default;
- size_t ReadPartially(uint64_t addr, void* dst, size_t size) override;
+ size_t Read(uint64_t addr, void* dst, size_t size) override;
private:
std::shared_ptr<Memory> memory_;
@@ -143,7 +143,7 @@
bool Init(const std::string& file, uint64_t offset);
- size_t ReadPartially(uint64_t addr, void* dst, size_t size) override;
+ size_t Read(uint64_t addr, void* dst, size_t size) override;
private:
std::unique_ptr<MemoryRange> memory_;
diff --git a/libunwindstack/tests/MemoryBufferTest.cpp b/libunwindstack/tests/MemoryBufferTest.cpp
index 350ffae..28e0e76 100644
--- a/libunwindstack/tests/MemoryBufferTest.cpp
+++ b/libunwindstack/tests/MemoryBufferTest.cpp
@@ -78,7 +78,7 @@
ASSERT_FALSE(memory_->ReadFully(UINT64_MAX - 100, buffer.data(), 200));
}
-TEST_F(MemoryBufferTest, ReadPartially) {
+TEST_F(MemoryBufferTest, Read) {
memory_->Resize(256);
ASSERT_EQ(256U, memory_->Size());
ASSERT_TRUE(memory_->GetPtr(0) != nullptr);
@@ -92,7 +92,7 @@
}
std::vector<uint8_t> buffer(memory_->Size());
- ASSERT_EQ(128U, memory_->ReadPartially(128, buffer.data(), buffer.size()));
+ ASSERT_EQ(128U, memory_->Read(128, buffer.data(), buffer.size()));
for (size_t i = 0; i < 128; i++) {
ASSERT_EQ(128 + i, buffer[i]) << "Failed at byte " << i;
}
diff --git a/libunwindstack/tests/MemoryFake.cpp b/libunwindstack/tests/MemoryFake.cpp
index e340dba..60936cd 100644
--- a/libunwindstack/tests/MemoryFake.cpp
+++ b/libunwindstack/tests/MemoryFake.cpp
@@ -35,7 +35,7 @@
}
}
-size_t MemoryFake::ReadPartially(uint64_t addr, void* memory, size_t size) {
+size_t MemoryFake::Read(uint64_t addr, void* memory, size_t size) {
uint8_t* dst = reinterpret_cast<uint8_t*>(memory);
for (size_t i = 0; i < size; i++, addr++) {
auto value = data_.find(addr);
diff --git a/libunwindstack/tests/MemoryFake.h b/libunwindstack/tests/MemoryFake.h
index 2b0297c..764a6c3 100644
--- a/libunwindstack/tests/MemoryFake.h
+++ b/libunwindstack/tests/MemoryFake.h
@@ -32,7 +32,7 @@
MemoryFake() = default;
virtual ~MemoryFake() = default;
- size_t ReadPartially(uint64_t addr, void* buffer, size_t size) override;
+ size_t Read(uint64_t addr, void* buffer, size_t size) override;
void SetMemory(uint64_t addr, const void* memory, size_t length);
@@ -71,7 +71,7 @@
MemoryFakeAlwaysReadZero() = default;
virtual ~MemoryFakeAlwaysReadZero() = default;
- size_t ReadPartially(uint64_t, void* buffer, size_t size) override {
+ size_t Read(uint64_t, void* buffer, size_t size) override {
memset(buffer, 0, size);
return size;
}
diff --git a/libunwindstack/tests/MemoryLocalTest.cpp b/libunwindstack/tests/MemoryLocalTest.cpp
index c483b74..5a389d0 100644
--- a/libunwindstack/tests/MemoryLocalTest.cpp
+++ b/libunwindstack/tests/MemoryLocalTest.cpp
@@ -68,7 +68,7 @@
ASSERT_FALSE(local.ReadFully(reinterpret_cast<uint64_t>(&value), dst.data(), SIZE_MAX));
}
-TEST(MemoryLocalTest, ReadPartially) {
+TEST(MemoryLocalTest, Read) {
char* mapping = static_cast<char*>(
mmap(nullptr, 2 * getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
@@ -80,8 +80,8 @@
MemoryLocal local;
std::vector<uint8_t> dst(4096);
- ASSERT_EQ(1024U, local.ReadPartially(reinterpret_cast<uint64_t>(mapping + getpagesize() - 1024),
- dst.data(), 4096));
+ ASSERT_EQ(1024U, local.Read(reinterpret_cast<uint64_t>(mapping + getpagesize() - 1024),
+ dst.data(), 4096));
for (size_t i = 0; i < 1024; i++) {
ASSERT_EQ(0x4cU, dst[i]) << "Failed at byte " << i;
}
@@ -98,7 +98,7 @@
MemoryLocal local;
std::vector<uint8_t> dst(4096 * 3, 0xCC);
- ASSERT_EQ(4096U, local.ReadPartially(reinterpret_cast<uintptr_t>(mapping), dst.data(), 4096 * 3));
+ ASSERT_EQ(4096U, local.Read(reinterpret_cast<uintptr_t>(mapping), dst.data(), 4096 * 3));
for (size_t i = 0; i < 4096; ++i) {
ASSERT_EQ(0xFF, dst[i]);
}
diff --git a/libunwindstack/tests/MemoryRangeTest.cpp b/libunwindstack/tests/MemoryRangeTest.cpp
index 499536c..cb1a0c9 100644
--- a/libunwindstack/tests/MemoryRangeTest.cpp
+++ b/libunwindstack/tests/MemoryRangeTest.cpp
@@ -76,7 +76,7 @@
ASSERT_FALSE(overflow->ReadFully(UINT64_MAX - 10, buffer.data(), 100));
}
-TEST(MemoryRangeTest, ReadPartially) {
+TEST(MemoryRangeTest, Read) {
std::vector<uint8_t> src(4096);
memset(src.data(), 0x4c, 4096);
MemoryFake* memory_fake = new MemoryFake;
@@ -85,7 +85,7 @@
MemoryRange range(process_memory, 1000, 1024, 0);
std::vector<uint8_t> dst(1024);
- ASSERT_EQ(4U, range.ReadPartially(1020, dst.data(), 1024));
+ ASSERT_EQ(4U, range.Read(1020, dst.data(), 1024));
for (size_t i = 0; i < 4; i++) {
ASSERT_EQ(0x4cU, dst[i]) << "Failed at byte " << i;
}
diff --git a/libunwindstack/tests/MemoryRemoteTest.cpp b/libunwindstack/tests/MemoryRemoteTest.cpp
index 73cace3..8aa4c3f 100644
--- a/libunwindstack/tests/MemoryRemoteTest.cpp
+++ b/libunwindstack/tests/MemoryRemoteTest.cpp
@@ -79,7 +79,7 @@
ASSERT_TRUE(Detach(pid));
}
-TEST_F(MemoryRemoteTest, ReadPartially) {
+TEST_F(MemoryRemoteTest, Read) {
char* mapping = static_cast<char*>(
mmap(nullptr, 2 * getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
@@ -102,8 +102,8 @@
MemoryRemote remote(pid);
std::vector<uint8_t> dst(4096);
- ASSERT_EQ(1024U, remote.ReadPartially(reinterpret_cast<uint64_t>(mapping + getpagesize() - 1024),
- dst.data(), 4096));
+ ASSERT_EQ(1024U, remote.Read(reinterpret_cast<uint64_t>(mapping + getpagesize() - 1024),
+ dst.data(), 4096));
for (size_t i = 0; i < 1024; i++) {
ASSERT_EQ(0x4cU, dst[i]) << "Failed at byte " << i;
}
@@ -211,7 +211,7 @@
MemoryRemote remote(pid);
std::vector<uint8_t> dst(4096 * 3, 0xCC);
- ASSERT_EQ(4096U, remote.ReadPartially(reinterpret_cast<uintptr_t>(mapping), dst.data(), 4096 * 3));
+ ASSERT_EQ(4096U, remote.Read(reinterpret_cast<uintptr_t>(mapping), dst.data(), 4096 * 3));
for (size_t i = 0; i < 4096; ++i) {
ASSERT_EQ(0xFF, dst[i]);
}