summaryrefslogtreecommitdiff
path: root/libunwindstack/tests/DexFilesTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libunwindstack/tests/DexFilesTest.cpp')
-rw-r--r--libunwindstack/tests/DexFilesTest.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/libunwindstack/tests/DexFilesTest.cpp b/libunwindstack/tests/DexFilesTest.cpp
index ce3def6..8da32a1 100644
--- a/libunwindstack/tests/DexFilesTest.cpp
+++ b/libunwindstack/tests/DexFilesTest.cpp
@@ -101,8 +101,10 @@ class DexFilesTest : public ::testing::Test {
void WriteDescriptor32(uint64_t addr, uint32_t head);
void WriteDescriptor64(uint64_t addr, uint64_t head);
- void WriteEntry32(uint64_t entry_addr, uint32_t next, uint32_t prev, uint32_t dex_file);
- void WriteEntry64(uint64_t entry_addr, uint64_t next, uint64_t prev, uint64_t dex_file);
+ void WriteEntry32(uint64_t entry_addr, uint32_t next, uint32_t prev, uint32_t dex_file,
+ uint64_t dex_size);
+ void WriteEntry64(uint64_t entry_addr, uint64_t next, uint64_t prev, uint64_t dex_file,
+ uint64_t dex_size);
void WriteDex(uint64_t dex_file);
static constexpr size_t kMapGlobalNonReadable = 2;
@@ -143,7 +145,7 @@ void DexFilesTest::WriteDescriptor64(uint64_t addr, uint64_t entry) {
}
void DexFilesTest::WriteEntry32(uint64_t entry_addr, uint32_t next, uint32_t prev,
- uint32_t dex_file) {
+ uint32_t dex_file, uint64_t dex_size) {
// Format of the 32 bit DEXFileEntry structure:
// uint32_t next
memory_->SetData32(entry_addr, next);
@@ -153,11 +155,11 @@ void DexFilesTest::WriteEntry32(uint64_t entry_addr, uint32_t next, uint32_t pre
memory_->SetData32(entry_addr + 8, dex_file);
// uint32_t dex_size (present in the struct, but we ignore it)
memory_->SetData32(entry_addr + 12, 0); // Align.
- memory_->SetData64(entry_addr + 16, 0);
+ memory_->SetData64(entry_addr + 16, dex_size);
}
void DexFilesTest::WriteEntry64(uint64_t entry_addr, uint64_t next, uint64_t prev,
- uint64_t dex_file) {
+ uint64_t dex_file, uint64_t dex_size) {
// Format of the 64 bit DEXFileEntry structure:
// uint64_t next
memory_->SetData64(entry_addr, next);
@@ -166,7 +168,7 @@ void DexFilesTest::WriteEntry64(uint64_t entry_addr, uint64_t next, uint64_t pre
// uint64_t dex_file
memory_->SetData64(entry_addr + 16, dex_file);
// uint32_t dex_size (present in the struct, but we ignore it)
- memory_->SetData64(entry_addr + 24, 0);
+ memory_->SetData64(entry_addr + 24, dex_size);
}
void DexFilesTest::WriteDex(uint64_t dex_file) {
@@ -187,7 +189,7 @@ TEST_F(DexFilesTest, get_method_information_32) {
uint64_t method_offset = 0x124;
WriteDescriptor32(0x100800, 0x200000);
- WriteEntry32(0x200000, 0, 0, 0x300000);
+ WriteEntry32(0x200000, 0, 0, 0x300000, sizeof(kDexData));
WriteDex(0x300000);
dex_files_->GetFunctionName(maps_.get(), 0x300100, &method_name, &method_offset);
@@ -202,7 +204,7 @@ TEST_F(DexFilesTest, get_method_information_64) {
uint64_t method_offset = 0x124;
WriteDescriptor64(0x100800, 0x200000);
- WriteEntry64(0x200000, 0, 0, 0x301000);
+ WriteEntry64(0x200000, 0, 0, 0x301000, sizeof(kDexData));
WriteDex(0x301000);
dex_files_->GetFunctionName(maps_.get(), 0x301102, &method_name, &method_offset);
@@ -215,8 +217,8 @@ TEST_F(DexFilesTest, get_method_information_not_first_entry_32) {
uint64_t method_offset = 0x124;
WriteDescriptor32(0x100800, 0x200000);
- WriteEntry32(0x200000, 0x200100, 0, 0x100000);
- WriteEntry32(0x200100, 0, 0x200000, 0x300000);
+ WriteEntry32(0x200000, 0x200100, 0, 0x100000, sizeof(kDexData));
+ WriteEntry32(0x200100, 0, 0x200000, 0x300000, sizeof(kDexData));
WriteDex(0x300000);
dex_files_->GetFunctionName(maps_.get(), 0x300104, &method_name, &method_offset);
@@ -231,8 +233,8 @@ TEST_F(DexFilesTest, get_method_information_not_first_entry_64) {
uint64_t method_offset = 0x124;
WriteDescriptor64(0x100800, 0x200000);
- WriteEntry64(0x200000, 0x200100, 0, 0x100000);
- WriteEntry64(0x200100, 0, 0x200000, 0x300000);
+ WriteEntry64(0x200000, 0x200100, 0, 0x100000, sizeof(kDexData));
+ WriteEntry64(0x200100, 0, 0x200000, 0x300000, sizeof(kDexData));
WriteDex(0x300000);
dex_files_->GetFunctionName(maps_.get(), 0x300106, &method_name, &method_offset);
@@ -245,7 +247,7 @@ TEST_F(DexFilesTest, get_method_information_cached) {
uint64_t method_offset = 0x124;
WriteDescriptor32(0x100800, 0x200000);
- WriteEntry32(0x200000, 0, 0, 0x300000);
+ WriteEntry32(0x200000, 0, 0, 0x300000, sizeof(kDexData));
WriteDex(0x300000);
dex_files_->GetFunctionName(maps_.get(), 0x300100, &method_name, &method_offset);
@@ -264,8 +266,8 @@ TEST_F(DexFilesTest, get_method_information_search_libs) {
uint64_t method_offset = 0x124;
WriteDescriptor32(0x100800, 0x200000);
- WriteEntry32(0x200000, 0x200100, 0, 0x100000);
- WriteEntry32(0x200100, 0, 0x200000, 0x300000);
+ WriteEntry32(0x200000, 0x200100, 0, 0x100000, sizeof(kDexData));
+ WriteEntry32(0x200100, 0, 0x200000, 0x300000, sizeof(kDexData));
WriteDex(0x300000);
// Only search a given named list of libs.
@@ -299,7 +301,7 @@ TEST_F(DexFilesTest, get_method_information_global_skip_zero_32) {
WriteDescriptor32(0xc800, 0);
WriteDescriptor32(0x100800, 0x200000);
- WriteEntry32(0x200000, 0, 0, 0x300000);
+ WriteEntry32(0x200000, 0, 0, 0x300000, sizeof(kDexData));
WriteDex(0x300000);
dex_files_->GetFunctionName(maps_.get(), 0x300100, &method_name, &method_offset);
@@ -326,7 +328,7 @@ TEST_F(DexFilesTest, get_method_information_global_skip_zero_64) {
WriteDescriptor64(0xc800, 0);
WriteDescriptor64(0x100800, 0x200000);
- WriteEntry64(0x200000, 0, 0, 0x300000);
+ WriteEntry64(0x200000, 0, 0, 0x300000, sizeof(kDexData));
WriteDex(0x300000);
dex_files_->GetFunctionName(maps_.get(), 0x300100, &method_name, &method_offset);
@@ -348,7 +350,7 @@ TEST_F(DexFilesTest, get_method_information_with_empty_map) {
uint64_t method_offset = 0x124;
WriteDescriptor32(0x503800, 0x506000);
- WriteEntry32(0x506000, 0, 0, 0x510000);
+ WriteEntry32(0x506000, 0, 0, 0x510000, sizeof(kDexData));
WriteDex(0x510000);
dex_files_->GetFunctionName(maps_.get(), 0x510100, &method_name, &method_offset);