diff options
author | Christopher Ferris <cferris@google.com> | 2018-06-29 16:30:55 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2018-07-12 12:45:31 -0700 |
commit | 5afddb06370dc8b3d04a31f6f3ae04a5fa379cde (patch) | |
tree | 274864d812331b87c63c44c344db70967d9b4033 /libunwindstack/tests/MemoryTest.cpp | |
parent | 32960e54b44042eb74c845fc9ae50aeb8b74841c (diff) |
Remove Memory::ReadField.
In almost all cases, it is faster to read the entire structure rather
than do multiple reads using ReadField. The only case where it would be
slower is if doing a remote unwind and ptrace is the only way to read. In
all other cases, it's a single system call. In the ptrace call, it will be
multiple calls. Given that it is unusual to be forced to use ptrace,
it's better to avoid it.
It also reduces the code complexity to do a single read, and avoids
issues where the code forgets to read the field it needs.
Test: Unit tests pass on host and target.
Change-Id: I7b3875b2c85d0d88115b1776e1be28521dc0b932
Diffstat (limited to 'libunwindstack/tests/MemoryTest.cpp')
-rw-r--r-- | libunwindstack/tests/MemoryTest.cpp | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/libunwindstack/tests/MemoryTest.cpp b/libunwindstack/tests/MemoryTest.cpp index 4a9ed9f58..365598499 100644 --- a/libunwindstack/tests/MemoryTest.cpp +++ b/libunwindstack/tests/MemoryTest.cpp @@ -51,40 +51,6 @@ struct FakeStruct { uint64_t four; }; -TEST(MemoryTest, read_field) { - MemoryFakeAlwaysReadZero memory; - - FakeStruct data; - memset(&data, 0xff, sizeof(data)); - ASSERT_TRUE(memory.ReadField(0, &data, &data.one, sizeof(data.one))); - ASSERT_EQ(0, data.one); - - memset(&data, 0xff, sizeof(data)); - ASSERT_TRUE(memory.ReadField(0, &data, &data.two, sizeof(data.two))); - ASSERT_FALSE(data.two); - - memset(&data, 0xff, sizeof(data)); - ASSERT_TRUE(memory.ReadField(0, &data, &data.three, sizeof(data.three))); - ASSERT_EQ(0U, data.three); - - memset(&data, 0xff, sizeof(data)); - ASSERT_TRUE(memory.ReadField(0, &data, &data.four, sizeof(data.four))); - ASSERT_EQ(0U, data.four); -} - -TEST(MemoryTest, read_field_fails) { - MemoryFakeAlwaysReadZero memory; - - FakeStruct data; - memset(&data, 0xff, sizeof(data)); - - ASSERT_FALSE(memory.ReadField(UINT64_MAX, &data, &data.three, sizeof(data.three))); - - // Field and start reversed, should fail. - ASSERT_FALSE(memory.ReadField(100, &data.two, &data, sizeof(data.two))); - ASSERT_FALSE(memory.ReadField(0, &data.two, &data, sizeof(data.two))); -} - TEST(MemoryTest, read_string) { std::string name("string_in_memory"); |