summaryrefslogtreecommitdiff
path: root/libunwindstack/tests/MemoryRemoteTest.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2017-12-15 20:00:59 -0800
committerChristopher Ferris <cferris@google.com>2017-12-20 12:57:01 -0800
commit3dfd2aea7a28faa5240cb308b9cdcca8b4025f83 (patch)
tree17773c49864e9c06f0f57401f84e6e051d2e4bd5 /libunwindstack/tests/MemoryRemoteTest.cpp
parentd848876ff76af3588d8e60415b68da7adcf361f2 (diff)
Add tool to save information from a process.
Also, modify the ProcessVmRead function to allow arbitrarily large reads and add a test for it. Test: Run tool and verify the output can be used to do an offline Test: unwind. Test: Ran unit tests. Change-Id: I0974ddca4f5cf72b4c9fa29b597a0a669e223828
Diffstat (limited to 'libunwindstack/tests/MemoryRemoteTest.cpp')
-rw-r--r--libunwindstack/tests/MemoryRemoteTest.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/libunwindstack/tests/MemoryRemoteTest.cpp b/libunwindstack/tests/MemoryRemoteTest.cpp
index f5492a267..fb56e8afb 100644
--- a/libunwindstack/tests/MemoryRemoteTest.cpp
+++ b/libunwindstack/tests/MemoryRemoteTest.cpp
@@ -79,6 +79,35 @@ TEST_F(MemoryRemoteTest, read) {
ASSERT_TRUE(Detach(pid));
}
+TEST_F(MemoryRemoteTest, read_large) {
+ static constexpr size_t kTotalPages = 245;
+ std::vector<uint8_t> src(kTotalPages * getpagesize());
+ for (size_t i = 0; i < kTotalPages; i++) {
+ memset(&src[i * getpagesize()], i, getpagesize());
+ }
+
+ pid_t pid;
+ if ((pid = fork()) == 0) {
+ while (true)
+ ;
+ exit(1);
+ }
+ ASSERT_LT(0, pid);
+ TestScopedPidReaper reap(pid);
+
+ ASSERT_TRUE(Attach(pid));
+
+ MemoryRemote remote(pid);
+
+ std::vector<uint8_t> dst(kTotalPages * getpagesize());
+ ASSERT_TRUE(remote.ReadFully(reinterpret_cast<uint64_t>(src.data()), dst.data(), src.size()));
+ for (size_t i = 0; i < kTotalPages * getpagesize(); i++) {
+ ASSERT_EQ(i / getpagesize(), dst[i]) << "Failed at byte " << i;
+ }
+
+ ASSERT_TRUE(Detach(pid));
+}
+
TEST_F(MemoryRemoteTest, read_partial) {
char* mapping = static_cast<char*>(
mmap(nullptr, 4 * getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));