summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp')
-rw-r--r--libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp b/libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp
index ef2fb32ab..a2ae5ebf7 100644
--- a/libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp
+++ b/libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp
@@ -19,9 +19,10 @@
19#include <gmock/gmock.h> 19#include <gmock/gmock.h>
20#include <gtest/gtest.h> 20#include <gtest/gtest.h>
21 21
22#include <unwindstack/DwarfError.h>
23
22#include "DwarfEhFrameWithHdr.h" 24#include "DwarfEhFrameWithHdr.h"
23#include "DwarfEncoding.h" 25#include "DwarfEncoding.h"
24#include "DwarfError.h"
25 26
26#include "LogFake.h" 27#include "LogFake.h"
27#include "MemoryFake.h" 28#include "MemoryFake.h"
@@ -97,25 +98,29 @@ TYPED_TEST_P(DwarfEhFrameWithHdrTest, Init) {
97 // Verify a zero fde count fails to init. 98 // Verify a zero fde count fails to init.
98 this->memory_.SetData32(0x1006, 0); 99 this->memory_.SetData32(0x1006, 0);
99 ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100)); 100 ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100));
100 ASSERT_EQ(DWARF_ERROR_NO_FDES, this->eh_frame_->last_error()); 101 ASSERT_EQ(DWARF_ERROR_NO_FDES, this->eh_frame_->LastErrorCode());
101 102
102 // Verify an unexpected version will cause a fail. 103 // Verify an unexpected version will cause a fail.
103 this->memory_.SetData32(0x1006, 126); 104 this->memory_.SetData32(0x1006, 126);
104 this->memory_.SetData8(0x1000, 0); 105 this->memory_.SetData8(0x1000, 0);
105 ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100)); 106 ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100));
106 ASSERT_EQ(DWARF_ERROR_UNSUPPORTED_VERSION, this->eh_frame_->last_error()); 107 ASSERT_EQ(DWARF_ERROR_UNSUPPORTED_VERSION, this->eh_frame_->LastErrorCode());
107 this->memory_.SetData8(0x1000, 2); 108 this->memory_.SetData8(0x1000, 2);
108 ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100)); 109 ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100));
109 ASSERT_EQ(DWARF_ERROR_UNSUPPORTED_VERSION, this->eh_frame_->last_error()); 110 ASSERT_EQ(DWARF_ERROR_UNSUPPORTED_VERSION, this->eh_frame_->LastErrorCode());
110} 111}
111 112
112TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeInfoFromIndex_expect_cache_fail) { 113TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeInfoFromIndex_expect_cache_fail) {
113 this->eh_frame_->TestSetTableEntrySize(0x10); 114 this->eh_frame_->TestSetTableEntrySize(0x10);
114 this->eh_frame_->TestSetTableEncoding(DW_EH_PE_udata4); 115 this->eh_frame_->TestSetTableEncoding(DW_EH_PE_udata4);
116 this->eh_frame_->TestSetEntriesOffset(0x1000);
117
115 ASSERT_TRUE(this->eh_frame_->GetFdeInfoFromIndex(0) == nullptr); 118 ASSERT_TRUE(this->eh_frame_->GetFdeInfoFromIndex(0) == nullptr);
116 ASSERT_EQ(DWARF_ERROR_MEMORY_INVALID, this->eh_frame_->last_error()); 119 ASSERT_EQ(DWARF_ERROR_MEMORY_INVALID, this->eh_frame_->LastErrorCode());
120 EXPECT_EQ(0x1000U, this->eh_frame_->LastErrorAddress());
117 ASSERT_TRUE(this->eh_frame_->GetFdeInfoFromIndex(0) == nullptr); 121 ASSERT_TRUE(this->eh_frame_->GetFdeInfoFromIndex(0) == nullptr);
118 ASSERT_EQ(DWARF_ERROR_MEMORY_INVALID, this->eh_frame_->last_error()); 122 ASSERT_EQ(DWARF_ERROR_MEMORY_INVALID, this->eh_frame_->LastErrorCode());
123 EXPECT_EQ(0x1000U, this->eh_frame_->LastErrorAddress());
119} 124}
120 125
121TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeInfoFromIndex_read_pcrel) { 126TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeInfoFromIndex_read_pcrel) {
@@ -184,7 +189,7 @@ TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeOffsetBinary_verify) {
184 uint64_t fde_offset; 189 uint64_t fde_offset;
185 EXPECT_FALSE(this->eh_frame_->GetFdeOffsetBinary(0x100, &fde_offset, 10)); 190 EXPECT_FALSE(this->eh_frame_->GetFdeOffsetBinary(0x100, &fde_offset, 10));
186 // Not an error, just not found. 191 // Not an error, just not found.
187 ASSERT_EQ(DWARF_ERROR_NONE, this->eh_frame_->last_error()); 192 ASSERT_EQ(DWARF_ERROR_NONE, this->eh_frame_->LastErrorCode());
188 // Even number of elements. 193 // Even number of elements.
189 for (size_t i = 0; i < 10; i++) { 194 for (size_t i = 0; i < 10; i++) {
190 TypeParam pc = 0x1000 * (i + 1); 195 TypeParam pc = 0x1000 * (i + 1);
@@ -280,7 +285,7 @@ TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeOffsetSequential_end_check) {
280 285
281 uint64_t fde_offset; 286 uint64_t fde_offset;
282 ASSERT_FALSE(this->eh_frame_->GetFdeOffsetSequential(0x540, &fde_offset)); 287 ASSERT_FALSE(this->eh_frame_->GetFdeOffsetSequential(0x540, &fde_offset));
283 ASSERT_EQ(DWARF_ERROR_NONE, this->eh_frame_->last_error()); 288 ASSERT_EQ(DWARF_ERROR_NONE, this->eh_frame_->LastErrorCode());
284} 289}
285 290
286TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeOffsetFromPc_fail_fde_count) { 291TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeOffsetFromPc_fail_fde_count) {
@@ -288,7 +293,7 @@ TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeOffsetFromPc_fail_fde_count) {
288 293
289 uint64_t fde_offset; 294 uint64_t fde_offset;
290 ASSERT_FALSE(this->eh_frame_->GetFdeOffsetFromPc(0x100, &fde_offset)); 295 ASSERT_FALSE(this->eh_frame_->GetFdeOffsetFromPc(0x100, &fde_offset));
291 ASSERT_EQ(DWARF_ERROR_NONE, this->eh_frame_->last_error()); 296 ASSERT_EQ(DWARF_ERROR_NONE, this->eh_frame_->LastErrorCode());
292} 297}
293 298
294TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeOffsetFromPc_binary_search) { 299TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeOffsetFromPc_binary_search) {