Fix handling of load bias values.
It turns out that for the dwarf information, if a FDE indicates it's pc
relative, then pc has to be incremented by the load bias. If not, then
it should not be incremented.
Previously, the code always subtracted load bias values from pcs, and assumed
that all fdes were incremented by load bias values. The new code actually
reads the fdes and adjusted the pcs in the fde and in the eh frame hdr so
that load bias values are already handled properly.
In addition, add dumping of arm exidx values in unwind_reg_info. This allowed
verifying that the debug frame in those elf files was being handled properly.
Added a new unit test that only has a debug frame that has a non-zero load
bias and has fde entries that do not have pc relative encoding.
Fix a couple of other small bugs.
Bug: 109824792
Test: All libbacktrace/libunwindstack unit tests pass.
Test: Ran ART 137-cfi test and 004-ThreadStress.
Test: Verify that displaying the fde start and end pc actually match the
Test: real data for fde that have pc relative set, and that don't.
Test: Verified that the unwind information for arm exidx matches the
Test: debug frame data.
Change-Id: I707555286b5cb05df9f25489e8c5ede753cfe0fb
diff --git a/libunwindstack/tests/ArmExidxDecodeTest.cpp b/libunwindstack/tests/ArmExidxDecodeTest.cpp
index 8d6d00d..5f3d1ea 100644
--- a/libunwindstack/tests/ArmExidxDecodeTest.cpp
+++ b/libunwindstack/tests/ArmExidxDecodeTest.cpp
@@ -36,8 +36,6 @@
class ArmExidxDecodeTest : public ::testing::TestWithParam<std::string> {
protected:
void Init(Memory* process_memory = nullptr) {
- TearDown();
-
if (process_memory == nullptr) {
process_memory = &process_memory_;
}
@@ -50,8 +48,8 @@
regs_arm_->set_sp(0);
exidx_.reset(new ArmExidx(regs_arm_.get(), &elf_memory_, process_memory));
- if (log_) {
- exidx_->set_log(true);
+ if (log_ != ARM_LOG_NONE) {
+ exidx_->set_log(log_);
exidx_->set_log_indent(0);
exidx_->set_log_skip_execution(false);
}
@@ -60,14 +58,20 @@
}
void SetUp() override {
- if (GetParam() != "no_logging") {
- log_ = false;
+ if (GetParam() == "no_logging") {
+ log_ = ARM_LOG_NONE;
+ } else if (GetParam() == "register_logging") {
+ log_ = ARM_LOG_BY_REG;
} else {
- log_ = true;
+ log_ = ARM_LOG_FULL;
}
- ResetLogs();
elf_memory_.Clear();
process_memory_.Clear();
+ ResetExidx();
+ }
+
+ void ResetExidx() {
+ ResetLogs();
Init();
}
@@ -77,7 +81,7 @@
MemoryFake elf_memory_;
MemoryFake process_memory_;
- bool log_;
+ ArmLogType log_;
};
TEST_P(ArmExidxDecodeTest, vsp_incr) {
@@ -86,38 +90,59 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind vsp = vsp + 4\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind vsp = vsp + 4\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ("4 unwind cfa = r13 + 4\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10004U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->clear();
data_->push_back(0x01);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind vsp = vsp + 8\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind vsp = vsp + 8\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ("4 unwind cfa = r13 + 8\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x1000cU, exidx_->cfa());
+ ASSERT_EQ(0x10008U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->clear();
data_->push_back(0x3f);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind vsp = vsp + 256\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind vsp = vsp + 256\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ("4 unwind cfa = r13 + 256\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x1010cU, exidx_->cfa());
+ ASSERT_EQ(0x10100U, exidx_->cfa());
}
TEST_P(ArmExidxDecodeTest, vsp_decr) {
@@ -126,38 +151,59 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind vsp = vsp - 4\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind vsp = vsp - 4\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ("4 unwind cfa = r13 - 4\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0xfffcU, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->clear();
data_->push_back(0x41);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind vsp = vsp - 8\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind vsp = vsp - 8\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ("4 unwind cfa = r13 - 8\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0xfff4U, exidx_->cfa());
+ ASSERT_EQ(0xfff8U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->clear();
data_->push_back(0x7f);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind vsp = vsp - 256\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind vsp = vsp - 256\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ("4 unwind cfa = r13 - 256\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0xfef4U, exidx_->cfa());
+ ASSERT_EQ(0xff00U, exidx_->cfa());
}
TEST_P(ArmExidxDecodeTest, refuse_unwind) {
@@ -166,10 +212,14 @@
data_->push_back(0x00);
ASSERT_FALSE(exidx_->Decode());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind Refuse to unwind\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Refuse to unwind\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(ARM_STATUS_NO_UNWIND, exidx_->status());
}
@@ -182,29 +232,60 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_TRUE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {r15}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {r15}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 4\n"
+ "4 unwind r15 = [cfa - 4]\n",
+ GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10004U, exidx_->cfa());
ASSERT_EQ(0x10U, (*exidx_->regs())[15]);
- ResetLogs();
+ ResetExidx();
data_->push_back(0x8f);
data_->push_back(0xff);
for (size_t i = 0; i < 12; i++) {
- process_memory_.SetData32(0x10004 + i * 4, i + 0x20);
+ process_memory_.SetData32(0x10000 + i * 4, i + 0x20);
}
exidx_->set_pc_set(false);
ASSERT_TRUE(exidx_->Decode());
ASSERT_TRUE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15}\n",
- GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15}\n",
+ GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 48\n"
+ "4 unwind r4 = [cfa - 48]\n"
+ "4 unwind r5 = [cfa - 44]\n"
+ "4 unwind r6 = [cfa - 40]\n"
+ "4 unwind r7 = [cfa - 36]\n"
+ "4 unwind r8 = [cfa - 32]\n"
+ "4 unwind r9 = [cfa - 28]\n"
+ "4 unwind r10 = [cfa - 24]\n"
+ "4 unwind r11 = [cfa - 20]\n"
+ "4 unwind r12 = [cfa - 16]\n"
+ "4 unwind r13 = [cfa - 12]\n"
+ "4 unwind r14 = [cfa - 8]\n"
+ "4 unwind r15 = [cfa - 4]\n",
+ GetFakeLogPrint());
+ break;
}
// Popping r13 results in a modified cfa.
ASSERT_EQ(0x29U, exidx_->cfa());
@@ -222,7 +303,7 @@
ASSERT_EQ(0x2aU, (*exidx_->regs())[14]);
ASSERT_EQ(0x2bU, (*exidx_->regs())[15]);
- ResetLogs();
+ ResetExidx();
exidx_->set_cfa(0x10034);
data_->push_back(0x81);
data_->push_back(0x28);
@@ -233,10 +314,22 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {r7, r9, r12}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {r7, r9, r12}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 12\n"
+ "4 unwind r7 = [cfa - 12]\n"
+ "4 unwind r9 = [cfa - 8]\n"
+ "4 unwind r12 = [cfa - 4]\n",
+ GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10040U, exidx_->cfa());
ASSERT_EQ(0x11U, (*exidx_->regs())[7]);
@@ -255,34 +348,63 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind vsp = r0\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind vsp = r0\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ("4 unwind cfa = r0\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(1U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
+ exidx_->set_cfa(0x100);
+ for (size_t i = 0; i < 15; i++) {
+ (*regs_arm_)[i] = i + 1;
+ }
data_->push_back(0x93);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind vsp = r3\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind vsp = r3\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ("4 unwind cfa = r3\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(4U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
+ exidx_->set_cfa(0x100);
+ for (size_t i = 0; i < 15; i++) {
+ (*regs_arm_)[i] = i + 1;
+ }
data_->push_back(0x9e);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind vsp = r14\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind vsp = r14\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ("4 unwind cfa = r14\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(15U, exidx_->cfa());
}
@@ -292,22 +414,30 @@
data_->push_back(0x9d);
ASSERT_FALSE(exidx_->Decode());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind [Reserved]\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind [Reserved]\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(ARM_STATUS_RESERVED, exidx_->status());
// 10011111: Reserved as prefix for Intel Wireless MMX register to register moves
- ResetLogs();
+ ResetExidx();
data_->push_back(0x9f);
ASSERT_FALSE(exidx_->Decode());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind [Reserved]\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind [Reserved]\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(ARM_STATUS_RESERVED, exidx_->status());
}
@@ -319,53 +449,93 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {r4}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {r4}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 4\n"
+ "4 unwind r4 = [cfa - 4]\n",
+ GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10004U, exidx_->cfa());
ASSERT_EQ(0x14U, (*exidx_->regs())[4]);
- ResetLogs();
+ ResetExidx();
data_->push_back(0xa3);
- process_memory_.SetData32(0x10004, 0x20);
- process_memory_.SetData32(0x10008, 0x30);
- process_memory_.SetData32(0x1000c, 0x40);
- process_memory_.SetData32(0x10010, 0x50);
+ process_memory_.SetData32(0x10000, 0x20);
+ process_memory_.SetData32(0x10004, 0x30);
+ process_memory_.SetData32(0x10008, 0x40);
+ process_memory_.SetData32(0x1000c, 0x50);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {r4-r7}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {r4-r7}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 16\n"
+ "4 unwind r4 = [cfa - 16]\n"
+ "4 unwind r5 = [cfa - 12]\n"
+ "4 unwind r6 = [cfa - 8]\n"
+ "4 unwind r7 = [cfa - 4]\n",
+ GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x10014U, exidx_->cfa());
+ ASSERT_EQ(0x10010U, exidx_->cfa());
ASSERT_EQ(0x20U, (*exidx_->regs())[4]);
ASSERT_EQ(0x30U, (*exidx_->regs())[5]);
ASSERT_EQ(0x40U, (*exidx_->regs())[6]);
ASSERT_EQ(0x50U, (*exidx_->regs())[7]);
- ResetLogs();
+ ResetExidx();
data_->push_back(0xa7);
- process_memory_.SetData32(0x10014, 0x41);
- process_memory_.SetData32(0x10018, 0x51);
- process_memory_.SetData32(0x1001c, 0x61);
- process_memory_.SetData32(0x10020, 0x71);
- process_memory_.SetData32(0x10024, 0x81);
- process_memory_.SetData32(0x10028, 0x91);
- process_memory_.SetData32(0x1002c, 0xa1);
- process_memory_.SetData32(0x10030, 0xb1);
+ process_memory_.SetData32(0x10000, 0x41);
+ process_memory_.SetData32(0x10004, 0x51);
+ process_memory_.SetData32(0x10008, 0x61);
+ process_memory_.SetData32(0x1000c, 0x71);
+ process_memory_.SetData32(0x10010, 0x81);
+ process_memory_.SetData32(0x10014, 0x91);
+ process_memory_.SetData32(0x10018, 0xa1);
+ process_memory_.SetData32(0x1001c, 0xb1);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {r4-r11}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {r4-r11}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 32\n"
+ "4 unwind r4 = [cfa - 32]\n"
+ "4 unwind r5 = [cfa - 28]\n"
+ "4 unwind r6 = [cfa - 24]\n"
+ "4 unwind r7 = [cfa - 20]\n"
+ "4 unwind r8 = [cfa - 16]\n"
+ "4 unwind r9 = [cfa - 12]\n"
+ "4 unwind r10 = [cfa - 8]\n"
+ "4 unwind r11 = [cfa - 4]\n",
+ GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x10034U, exidx_->cfa());
+ ASSERT_EQ(0x10020U, exidx_->cfa());
ASSERT_EQ(0x41U, (*exidx_->regs())[4]);
ASSERT_EQ(0x51U, (*exidx_->regs())[5]);
ASSERT_EQ(0x61U, (*exidx_->regs())[6]);
@@ -384,57 +554,100 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {r4, r14}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {r4, r14}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 8\n"
+ "4 unwind r4 = [cfa - 8]\n"
+ "4 unwind r14 = [cfa - 4]\n",
+ GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10008U, exidx_->cfa());
ASSERT_EQ(0x12U, (*exidx_->regs())[4]);
ASSERT_EQ(0x22U, (*exidx_->regs())[14]);
- ResetLogs();
+ ResetExidx();
data_->push_back(0xab);
- process_memory_.SetData32(0x10008, 0x1);
- process_memory_.SetData32(0x1000c, 0x2);
- process_memory_.SetData32(0x10010, 0x3);
- process_memory_.SetData32(0x10014, 0x4);
- process_memory_.SetData32(0x10018, 0x5);
+ process_memory_.SetData32(0x10000, 0x1);
+ process_memory_.SetData32(0x10004, 0x2);
+ process_memory_.SetData32(0x10008, 0x3);
+ process_memory_.SetData32(0x1000c, 0x4);
+ process_memory_.SetData32(0x10010, 0x5);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {r4-r7, r14}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {r4-r7, r14}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 20\n"
+ "4 unwind r4 = [cfa - 20]\n"
+ "4 unwind r5 = [cfa - 16]\n"
+ "4 unwind r6 = [cfa - 12]\n"
+ "4 unwind r7 = [cfa - 8]\n"
+ "4 unwind r14 = [cfa - 4]\n",
+ GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x1001cU, exidx_->cfa());
+ ASSERT_EQ(0x10014U, exidx_->cfa());
ASSERT_EQ(0x1U, (*exidx_->regs())[4]);
ASSERT_EQ(0x2U, (*exidx_->regs())[5]);
ASSERT_EQ(0x3U, (*exidx_->regs())[6]);
ASSERT_EQ(0x4U, (*exidx_->regs())[7]);
ASSERT_EQ(0x5U, (*exidx_->regs())[14]);
- ResetLogs();
+ ResetExidx();
data_->push_back(0xaf);
- process_memory_.SetData32(0x1001c, 0x1a);
- process_memory_.SetData32(0x10020, 0x2a);
- process_memory_.SetData32(0x10024, 0x3a);
- process_memory_.SetData32(0x10028, 0x4a);
- process_memory_.SetData32(0x1002c, 0x5a);
- process_memory_.SetData32(0x10030, 0x6a);
- process_memory_.SetData32(0x10034, 0x7a);
- process_memory_.SetData32(0x10038, 0x8a);
- process_memory_.SetData32(0x1003c, 0x9a);
+ process_memory_.SetData32(0x10000, 0x1a);
+ process_memory_.SetData32(0x10004, 0x2a);
+ process_memory_.SetData32(0x10008, 0x3a);
+ process_memory_.SetData32(0x1000c, 0x4a);
+ process_memory_.SetData32(0x10010, 0x5a);
+ process_memory_.SetData32(0x10014, 0x6a);
+ process_memory_.SetData32(0x10018, 0x7a);
+ process_memory_.SetData32(0x1001c, 0x8a);
+ process_memory_.SetData32(0x10020, 0x9a);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {r4-r11, r14}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {r4-r11, r14}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 36\n"
+ "4 unwind r4 = [cfa - 36]\n"
+ "4 unwind r5 = [cfa - 32]\n"
+ "4 unwind r6 = [cfa - 28]\n"
+ "4 unwind r7 = [cfa - 24]\n"
+ "4 unwind r8 = [cfa - 20]\n"
+ "4 unwind r9 = [cfa - 16]\n"
+ "4 unwind r10 = [cfa - 12]\n"
+ "4 unwind r11 = [cfa - 8]\n"
+ "4 unwind r14 = [cfa - 4]\n",
+ GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x10040U, exidx_->cfa());
+ ASSERT_EQ(0x10024U, exidx_->cfa());
ASSERT_EQ(0x1aU, (*exidx_->regs())[4]);
ASSERT_EQ(0x2aU, (*exidx_->regs())[5]);
ASSERT_EQ(0x3aU, (*exidx_->regs())[6]);
@@ -451,10 +664,17 @@
data_->push_back(0xb0);
ASSERT_FALSE(exidx_->Decode());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind finish\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind finish\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ("4 unwind cfa = r13\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10000U, exidx_->cfa());
ASSERT_EQ(ARM_STATUS_FINISH, exidx_->status());
@@ -466,10 +686,14 @@
data_->push_back(0x00);
ASSERT_FALSE(exidx_->Decode());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind Spare\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Spare\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10000U, exidx_->cfa());
ASSERT_EQ(ARM_STATUS_SPARE, exidx_->status());
@@ -477,15 +701,19 @@
// 10110001 xxxxyyyy: Spare (xxxx != 0000)
for (size_t x = 1; x < 16; x++) {
for (size_t y = 0; y < 16; y++) {
- ResetLogs();
+ ResetExidx();
data_->push_back(0xb1);
data_->push_back((x << 4) | y);
ASSERT_FALSE(exidx_->Decode()) << "x, y = " << x << ", " << y;
ASSERT_EQ("", GetFakeLogBuf()) << "x, y = " << x << ", " << y;
- if (log_) {
- ASSERT_EQ("4 unwind Spare\n", GetFakeLogPrint()) << "x, y = " << x << ", " << y;
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Spare\n", GetFakeLogPrint()) << "x, y = " << x << ", " << y;
+ break;
}
ASSERT_EQ(0x10000U, exidx_->cfa()) << "x, y = " << x << ", " << y;
ASSERT_EQ(ARM_STATUS_SPARE, exidx_->status());
@@ -494,29 +722,37 @@
// 101101nn: Spare
for (size_t n = 0; n < 4; n++) {
- ResetLogs();
+ ResetExidx();
data_->push_back(0xb4 | n);
ASSERT_FALSE(exidx_->Decode()) << "n = " << n;
ASSERT_EQ("", GetFakeLogBuf()) << "n = " << n;
- if (log_) {
- ASSERT_EQ("4 unwind Spare\n", GetFakeLogPrint()) << "n = " << n;
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Spare\n", GetFakeLogPrint()) << "n = " << n;
+ break;
}
ASSERT_EQ(0x10000U, exidx_->cfa()) << "n = " << n;
ASSERT_EQ(ARM_STATUS_SPARE, exidx_->status());
}
// 11000111 00000000: Spare
- ResetLogs();
+ ResetExidx();
data_->push_back(0xc7);
data_->push_back(0x00);
ASSERT_FALSE(exidx_->Decode());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind Spare\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Spare\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10000U, exidx_->cfa());
ASSERT_EQ(ARM_STATUS_SPARE, exidx_->status());
@@ -524,15 +760,19 @@
// 11000111 xxxxyyyy: Spare (xxxx != 0000)
for (size_t x = 1; x < 16; x++) {
for (size_t y = 0; y < 16; y++) {
- ResetLogs();
+ ResetExidx();
data_->push_back(0xc7);
data_->push_back(0x10);
ASSERT_FALSE(exidx_->Decode()) << "x, y = " << x << ", " << y;
ASSERT_EQ("", GetFakeLogBuf()) << "x, y = " << x << ", " << y;
- if (log_) {
- ASSERT_EQ("4 unwind Spare\n", GetFakeLogPrint()) << "x, y = " << x << ", " << y;
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Spare\n", GetFakeLogPrint()) << "x, y = " << x << ", " << y;
+ break;
}
ASSERT_EQ(0x10000U, exidx_->cfa()) << "x, y = " << x << ", " << y;
ASSERT_EQ(ARM_STATUS_SPARE, exidx_->status());
@@ -541,14 +781,18 @@
// 11001yyy: Spare (yyy != 000, 001)
for (size_t y = 2; y < 8; y++) {
- ResetLogs();
+ ResetExidx();
data_->push_back(0xc8 | y);
ASSERT_FALSE(exidx_->Decode()) << "y = " << y;
ASSERT_EQ("", GetFakeLogBuf()) << "y = " << y;
- if (log_) {
- ASSERT_EQ("4 unwind Spare\n", GetFakeLogPrint()) << "y = " << y;
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Spare\n", GetFakeLogPrint()) << "y = " << y;
+ break;
}
ASSERT_EQ(0x10000U, exidx_->cfa()) << "y = " << y;
ASSERT_EQ(ARM_STATUS_SPARE, exidx_->status());
@@ -557,14 +801,18 @@
// 11xxxyyy: Spare (xxx != 000, 001, 010)
for (size_t x = 3; x < 8; x++) {
for (size_t y = 0; y < 8; y++) {
- ResetLogs();
+ ResetExidx();
data_->push_back(0xc0 | (x << 3) | y);
ASSERT_FALSE(exidx_->Decode()) << "x, y = " << x << ", " << y;
ASSERT_EQ("", GetFakeLogBuf()) << "x, y = " << x << ", " << y;
- if (log_) {
- ASSERT_EQ("4 unwind Spare\n", GetFakeLogPrint()) << "x, y = " << x << ", " << y;
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Spare\n", GetFakeLogPrint()) << "x, y = " << x << ", " << y;
+ break;
}
ASSERT_EQ(0x10000U, exidx_->cfa()) << "x, y = " << x << ", " << y;
ASSERT_EQ(ARM_STATUS_SPARE, exidx_->status());
@@ -580,47 +828,81 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {r0}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {r0}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 4\n"
+ "4 unwind r0 = [cfa - 4]\n",
+ GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10004U, exidx_->cfa());
ASSERT_EQ(0x45U, (*exidx_->regs())[0]);
- ResetLogs();
+ ResetExidx();
data_->push_back(0xb1);
data_->push_back(0x0a);
- process_memory_.SetData32(0x10004, 0x23);
- process_memory_.SetData32(0x10008, 0x24);
+ process_memory_.SetData32(0x10000, 0x23);
+ process_memory_.SetData32(0x10004, 0x24);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {r1, r3}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {r1, r3}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 8\n"
+ "4 unwind r1 = [cfa - 8]\n"
+ "4 unwind r3 = [cfa - 4]\n",
+ GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x1000cU, exidx_->cfa());
+ ASSERT_EQ(0x10008U, exidx_->cfa());
ASSERT_EQ(0x23U, (*exidx_->regs())[1]);
ASSERT_EQ(0x24U, (*exidx_->regs())[3]);
- ResetLogs();
+ ResetExidx();
data_->push_back(0xb1);
data_->push_back(0x0f);
- process_memory_.SetData32(0x1000c, 0x65);
- process_memory_.SetData32(0x10010, 0x54);
- process_memory_.SetData32(0x10014, 0x43);
- process_memory_.SetData32(0x10018, 0x32);
+ process_memory_.SetData32(0x10000, 0x65);
+ process_memory_.SetData32(0x10004, 0x54);
+ process_memory_.SetData32(0x10008, 0x43);
+ process_memory_.SetData32(0x1000c, 0x32);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {r0, r1, r2, r3}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {r0, r1, r2, r3}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 16\n"
+ "4 unwind r0 = [cfa - 16]\n"
+ "4 unwind r1 = [cfa - 12]\n"
+ "4 unwind r2 = [cfa - 8]\n"
+ "4 unwind r3 = [cfa - 4]\n",
+ GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x1001cU, exidx_->cfa());
+ ASSERT_EQ(0x10010U, exidx_->cfa());
ASSERT_EQ(0x65U, (*exidx_->regs())[0]);
ASSERT_EQ(0x54U, (*exidx_->regs())[1]);
ASSERT_EQ(0x43U, (*exidx_->regs())[2]);
@@ -634,28 +916,42 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind vsp = vsp + 1024\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind vsp = vsp + 1024\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ("4 unwind cfa = r13 + 1024\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10400U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xb2);
data_->push_back(0xff);
data_->push_back(0x02);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind vsp = vsp + 2048\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind vsp = vsp + 2048\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ("4 unwind cfa = r13 + 2048\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x10c00U, exidx_->cfa());
+ ASSERT_EQ(0x10800U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xb2);
data_->push_back(0xff);
data_->push_back(0x82);
@@ -663,12 +959,19 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind vsp = vsp + 3147776\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind vsp = vsp + 3147776\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ("4 unwind cfa = r13 + 3147776\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x311400U, exidx_->cfa());
+ ASSERT_EQ(0x310800U, exidx_->cfa());
}
TEST_P(ArmExidxDecodeTest, pop_vfp_fstmfdx) {
@@ -678,25 +981,37 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {d0}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {d0}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported DX register display\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x1000cU, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xb3);
data_->push_back(0x48);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {d4-d12}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {d4-d12}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported DX register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x10058U, exidx_->cfa());
+ ASSERT_EQ(0x1004cU, exidx_->cfa());
}
TEST_P(ArmExidxDecodeTest, pop_vfp8_fstmfdx) {
@@ -705,36 +1020,54 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {d8}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {d8}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported DX register display\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x1000cU, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xbb);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {d8-d11}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {d8-d11}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported DX register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x10030U, exidx_->cfa());
+ ASSERT_EQ(0x10024U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xbf);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {d8-d15}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {d8-d15}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported DX register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x10074U, exidx_->cfa());
+ ASSERT_EQ(0x10044U, exidx_->cfa());
}
TEST_P(ArmExidxDecodeTest, pop_mmx_wr10) {
@@ -743,36 +1076,54 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {wR10}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {wR10}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported wRX register display\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10008U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xc2);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {wR10-wR12}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {wR10-wR12}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported wRX register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x10020U, exidx_->cfa());
+ ASSERT_EQ(0x10018U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xc5);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {wR10-wR15}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {wR10-wR15}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported wRX register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x10050U, exidx_->cfa());
+ ASSERT_EQ(0x10030U, exidx_->cfa());
}
TEST_P(ArmExidxDecodeTest, pop_mmx_wr) {
@@ -782,38 +1133,56 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {wR0}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {wR0}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported wRX register display\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10008U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xc6);
data_->push_back(0x25);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {wR2-wR7}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {wR2-wR7}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported wRX register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x10038U, exidx_->cfa());
+ ASSERT_EQ(0x10030U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xc6);
data_->push_back(0xff);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {wR15-wR30}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {wR15-wR30}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported wRX register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x100b8U, exidx_->cfa());
+ ASSERT_EQ(0x10080U, exidx_->cfa());
}
TEST_P(ArmExidxDecodeTest, pop_mmx_wcgr) {
@@ -823,38 +1192,56 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {wCGR0}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {wCGR0}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported wCGR register display\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10004U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xc7);
data_->push_back(0x0a);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {wCGR1, wCGR3}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {wCGR1, wCGR3}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported wCGR register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x1000cU, exidx_->cfa());
+ ASSERT_EQ(0x10008U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xc7);
data_->push_back(0x0f);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {wCGR0, wCGR1, wCGR2, wCGR3}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {wCGR0, wCGR1, wCGR2, wCGR3}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported wCGR register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x1001cU, exidx_->cfa());
+ ASSERT_EQ(0x10010U, exidx_->cfa());
}
TEST_P(ArmExidxDecodeTest, pop_vfp16_vpush) {
@@ -864,38 +1251,56 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {d16}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {d16}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported DX register display\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10008U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xc8);
data_->push_back(0x14);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {d17-d21}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {d17-d21}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported DX register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x10030U, exidx_->cfa());
+ ASSERT_EQ(0x10028U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xc8);
data_->push_back(0xff);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {d31-d46}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {d31-d46}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported DX register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x100b0U, exidx_->cfa());
+ ASSERT_EQ(0x10080U, exidx_->cfa());
}
TEST_P(ArmExidxDecodeTest, pop_vfp_vpush) {
@@ -905,38 +1310,56 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {d0}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {d0}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported DX register display\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10008U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xc9);
data_->push_back(0x23);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {d2-d5}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {d2-d5}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported DX register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x10028U, exidx_->cfa());
+ ASSERT_EQ(0x10020U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xc9);
data_->push_back(0xff);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {d15-d30}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {d15-d30}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported DX register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x100a8U, exidx_->cfa());
+ ASSERT_EQ(0x10080U, exidx_->cfa());
}
TEST_P(ArmExidxDecodeTest, pop_vfp8_vpush) {
@@ -945,36 +1368,54 @@
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {d8}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {d8}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported DX register display\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10008U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xd2);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {d8-d10}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {d8-d10}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported DX register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x10020U, exidx_->cfa());
+ ASSERT_EQ(0x10018U, exidx_->cfa());
- ResetLogs();
+ ResetExidx();
data_->push_back(0xd7);
ASSERT_TRUE(exidx_->Decode());
ASSERT_FALSE(exidx_->pc_set());
ASSERT_EQ("", GetFakeLogBuf());
- if (log_) {
- ASSERT_EQ("4 unwind pop {d8-d15}\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ("4 unwind pop {d8-d15}\n", GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ ASSERT_EQ("4 unwind Unsupported DX register display\n", GetFakeLogPrint());
+ break;
}
- ASSERT_EQ(0x10060U, exidx_->cfa());
+ ASSERT_EQ(0x10040U, exidx_->cfa());
}
TEST_P(ArmExidxDecodeTest, expect_truncated) {
@@ -1047,32 +1488,147 @@
TEST_P(ArmExidxDecodeTest, eval_multiple_decodes) {
// vsp = vsp + 4
data_->push_back(0x00);
- // vsp = vsp + 8
+ // vsp = vsp + 12
data_->push_back(0x02);
// Finish
data_->push_back(0xb0);
ASSERT_TRUE(exidx_->Eval());
- if (log_) {
- ASSERT_EQ("4 unwind vsp = vsp + 4\n"
- "4 unwind vsp = vsp + 12\n"
- "4 unwind finish\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ(
+ "4 unwind vsp = vsp + 4\n"
+ "4 unwind vsp = vsp + 12\n"
+ "4 unwind finish\n",
+ GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ("4 unwind cfa = r13 + 16\n", GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10010U, exidx_->cfa());
ASSERT_FALSE(exidx_->pc_set());
}
+TEST_P(ArmExidxDecodeTest, eval_vsp_add_after_pop) {
+ // Pop {r15}
+ data_->push_back(0x88);
+ data_->push_back(0x00);
+ // vsp = vsp + 12
+ data_->push_back(0x02);
+ // Finish
+ data_->push_back(0xb0);
+ process_memory_.SetData32(0x10000, 0x10);
+
+ ASSERT_TRUE(exidx_->Eval());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ(
+ "4 unwind pop {r15}\n"
+ "4 unwind vsp = vsp + 12\n"
+ "4 unwind finish\n",
+ GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 16\n"
+ "4 unwind r15 = [cfa - 16]\n",
+ GetFakeLogPrint());
+ break;
+ }
+ ASSERT_EQ(0x10010U, exidx_->cfa());
+ ASSERT_TRUE(exidx_->pc_set());
+ ASSERT_EQ(0x10U, (*exidx_->regs())[15]);
+}
+
+TEST_P(ArmExidxDecodeTest, eval_vsp_add_large_after_pop) {
+ // Pop {r15}
+ data_->push_back(0x88);
+ data_->push_back(0x00);
+ // vsp = vsp + 1024
+ data_->push_back(0xb2);
+ data_->push_back(0x7f);
+ // Finish
+ data_->push_back(0xb0);
+ process_memory_.SetData32(0x10000, 0x10);
+
+ ASSERT_TRUE(exidx_->Eval());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ(
+ "4 unwind pop {r15}\n"
+ "4 unwind vsp = vsp + 1024\n"
+ "4 unwind finish\n",
+ GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 1028\n"
+ "4 unwind r15 = [cfa - 1028]\n",
+ GetFakeLogPrint());
+ break;
+ }
+ ASSERT_EQ(0x10404U, exidx_->cfa());
+ ASSERT_TRUE(exidx_->pc_set());
+ ASSERT_EQ(0x10U, (*exidx_->regs())[15]);
+}
+
+TEST_P(ArmExidxDecodeTest, eval_vsp_sub_after_pop) {
+ // Pop {r15}
+ data_->push_back(0x88);
+ data_->push_back(0x00);
+ // vsp = vsp - 4
+ data_->push_back(0x41);
+ // Finish
+ data_->push_back(0xb0);
+ process_memory_.SetData32(0x10000, 0x10);
+
+ ASSERT_TRUE(exidx_->Eval());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ(
+ "4 unwind pop {r15}\n"
+ "4 unwind vsp = vsp - 8\n"
+ "4 unwind finish\n",
+ GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 - 4\n"
+ "4 unwind r15 = [cfa + 4]\n",
+ GetFakeLogPrint());
+ break;
+ }
+ ASSERT_EQ(0xfffcU, exidx_->cfa());
+ ASSERT_TRUE(exidx_->pc_set());
+ ASSERT_EQ(0x10U, (*exidx_->regs())[15]);
+}
+
TEST_P(ArmExidxDecodeTest, eval_pc_set) {
// vsp = vsp + 4
data_->push_back(0x00);
- // vsp = vsp + 8
+ // vsp = vsp + 12
data_->push_back(0x02);
// Pop {r15}
data_->push_back(0x88);
data_->push_back(0x00);
- // vsp = vsp + 8
+ // vsp = vsp + 12
data_->push_back(0x02);
// Finish
data_->push_back(0xb0);
@@ -1080,20 +1636,33 @@
process_memory_.SetData32(0x10010, 0x10);
ASSERT_TRUE(exidx_->Eval());
- if (log_) {
- ASSERT_EQ("4 unwind vsp = vsp + 4\n"
- "4 unwind vsp = vsp + 12\n"
- "4 unwind pop {r15}\n"
- "4 unwind vsp = vsp + 12\n"
- "4 unwind finish\n", GetFakeLogPrint());
- } else {
- ASSERT_EQ("", GetFakeLogPrint());
+ switch (log_) {
+ case ARM_LOG_NONE:
+ ASSERT_EQ("", GetFakeLogPrint());
+ break;
+ case ARM_LOG_FULL:
+ ASSERT_EQ(
+ "4 unwind vsp = vsp + 4\n"
+ "4 unwind vsp = vsp + 12\n"
+ "4 unwind pop {r15}\n"
+ "4 unwind vsp = vsp + 12\n"
+ "4 unwind finish\n",
+ GetFakeLogPrint());
+ break;
+ case ARM_LOG_BY_REG:
+ exidx_->LogByReg();
+ ASSERT_EQ(
+ "4 unwind cfa = r13 + 32\n"
+ "4 unwind r15 = [cfa - 16]\n",
+ GetFakeLogPrint());
+ break;
}
ASSERT_EQ(0x10020U, exidx_->cfa());
ASSERT_TRUE(exidx_->pc_set());
ASSERT_EQ(0x10U, (*exidx_->regs())[15]);
}
-INSTANTIATE_TEST_CASE_P(, ArmExidxDecodeTest, ::testing::Values("logging", "no_logging"));
+INSTANTIATE_TEST_CASE_P(, ArmExidxDecodeTest,
+ ::testing::Values("logging", "register_logging", "no_logging"));
} // namespace unwindstack
diff --git a/libunwindstack/tests/ArmExidxExtractTest.cpp b/libunwindstack/tests/ArmExidxExtractTest.cpp
index 8d0f0e5..79c799c 100644
--- a/libunwindstack/tests/ArmExidxExtractTest.cpp
+++ b/libunwindstack/tests/ArmExidxExtractTest.cpp
@@ -301,7 +301,7 @@
elf_memory_.SetData32(0x1000, 0x7fff2340);
elf_memory_.SetData32(0x1004, 1);
- exidx_->set_log(true);
+ exidx_->set_log(ARM_LOG_FULL);
exidx_->set_log_indent(0);
exidx_->set_log_skip_execution(false);
@@ -316,7 +316,7 @@
elf_memory_.SetData32(0x4000, 0x7ffa3000);
elf_memory_.SetData32(0x4004, 0x80a8b0b0);
- exidx_->set_log(true);
+ exidx_->set_log(ARM_LOG_FULL);
exidx_->set_log_indent(0);
exidx_->set_log_skip_execution(false);
@@ -330,7 +330,7 @@
elf_memory_.SetData32(0x6234, 0x2);
elf_memory_.SetData32(0x6238, 0x00112233);
- exidx_->set_log(true);
+ exidx_->set_log(ARM_LOG_FULL);
exidx_->set_log_indent(0);
exidx_->set_log_skip_execution(false);
diff --git a/libunwindstack/tests/DwarfCfaLogTest.cpp b/libunwindstack/tests/DwarfCfaLogTest.cpp
index b17ca33..bb2e8f0 100644
--- a/libunwindstack/tests/DwarfCfaLogTest.cpp
+++ b/libunwindstack/tests/DwarfCfaLogTest.cpp
@@ -79,7 +79,7 @@
this->memory_.SetMemory(0x2000, std::vector<uint8_t>{i});
ResetLogs();
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x2000, 0x2001));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x2000, 0x2001));
std::string expected = "4 unwind Illegal\n";
expected += android::base::StringPrintf("4 unwind Raw Data: 0x%02x\n", i);
ASSERT_EQ(expected, GetFakeLogPrint());
@@ -90,7 +90,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_nop) {
this->memory_.SetMemory(0x2000, std::vector<uint8_t>{0x00});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x2000, 0x2001));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x2000, 0x2001));
std::string expected =
"4 unwind DW_CFA_nop\n"
"4 unwind Raw Data: 0x00\n";
@@ -101,7 +101,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_offset) {
this->memory_.SetMemory(0x2000, std::vector<uint8_t>{0x83, 0x04});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x2000, 0x2002));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x2000, 0x2002));
std::string expected =
"4 unwind DW_CFA_offset register(3) 4\n"
"4 unwind Raw Data: 0x83 0x04\n";
@@ -111,7 +111,7 @@
ResetLogs();
this->memory_.SetMemory(0x2100, std::vector<uint8_t>{0x83, 0x84, 0x01});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x2100, 0x2103));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x2100, 0x2103));
expected =
"4 unwind DW_CFA_offset register(3) 132\n"
"4 unwind Raw Data: 0x83 0x84 0x01\n";
@@ -122,7 +122,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_offset_extended) {
this->memory_.SetMemory(0x500, std::vector<uint8_t>{0x05, 0x03, 0x02});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x500, 0x503));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x500, 0x503));
std::string expected =
"4 unwind DW_CFA_offset_extended register(3) 2\n"
"4 unwind Raw Data: 0x05 0x03 0x02\n";
@@ -132,7 +132,7 @@
ResetLogs();
this->memory_.SetMemory(0x1500, std::vector<uint8_t>{0x05, 0x81, 0x01, 0x82, 0x12});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x1500, 0x1505));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x1500, 0x1505));
expected =
"4 unwind DW_CFA_offset_extended register(129) 2306\n"
"4 unwind Raw Data: 0x05 0x81 0x01 0x82 0x12\n";
@@ -143,7 +143,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_offset_extended_sf) {
this->memory_.SetMemory(0x500, std::vector<uint8_t>{0x11, 0x05, 0x10});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x500, 0x503));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x500, 0x503));
std::string expected =
"4 unwind DW_CFA_offset_extended_sf register(5) 16\n"
"4 unwind Raw Data: 0x11 0x05 0x10\n";
@@ -154,7 +154,7 @@
ResetLogs();
this->memory_.SetMemory(0x1500, std::vector<uint8_t>{0x11, 0x86, 0x01, 0xff, 0x7f});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x1500, 0x1505));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x1500, 0x1505));
expected =
"4 unwind DW_CFA_offset_extended_sf register(134) -1\n"
"4 unwind Raw Data: 0x11 0x86 0x01 0xff 0x7f\n";
@@ -165,7 +165,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_restore) {
this->memory_.SetMemory(0x2000, std::vector<uint8_t>{0xc2});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x2000, 0x2001));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x2000, 0x2001));
std::string expected =
"4 unwind DW_CFA_restore register(2)\n"
"4 unwind Raw Data: 0xc2\n";
@@ -175,7 +175,7 @@
ResetLogs();
this->memory_.SetMemory(0x3000, std::vector<uint8_t>{0x82, 0x04, 0xc2});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x3000, 0x3003));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x3000, 0x3003));
expected =
"4 unwind DW_CFA_offset register(2) 4\n"
"4 unwind Raw Data: 0x82 0x04\n"
@@ -188,7 +188,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_restore_extended) {
this->memory_.SetMemory(0x4000, std::vector<uint8_t>{0x06, 0x08});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x4000, 0x4002));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x4000, 0x4002));
std::string expected =
"4 unwind DW_CFA_restore_extended register(8)\n"
"4 unwind Raw Data: 0x06 0x08\n";
@@ -198,7 +198,7 @@
ResetLogs();
this->memory_.SetMemory(0x5000, std::vector<uint8_t>{0x05, 0x82, 0x02, 0x04, 0x06, 0x82, 0x02});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x5000, 0x5007));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x5000, 0x5007));
expected =
"4 unwind DW_CFA_offset_extended register(258) 4\n"
"4 unwind Raw Data: 0x05 0x82 0x02 0x04\n"
@@ -228,7 +228,7 @@
this->memory_.SetMemory(0x50, buffer, sizeof(buffer));
ResetLogs();
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x50, 0x51 + sizeof(TypeParam)));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x50, 0x51 + sizeof(TypeParam)));
std::string expected = "4 unwind DW_CFA_set_loc " + address_str + "\n";
expected += "4 unwind " + raw_data + "\n";
expected += "4 unwind \n";
@@ -240,7 +240,7 @@
ResetLogs();
this->fde_.pc_start = address + 0x10;
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x50, 0x51 + sizeof(TypeParam)));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x50, 0x51 + sizeof(TypeParam)));
expected = "4 unwind DW_CFA_set_loc " + address_str + "\n";
expected += "4 unwind " + raw_data + "\n";
expected += "4 unwind \n";
@@ -252,7 +252,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_advance_loc) {
this->memory_.SetMemory(0x200, std::vector<uint8_t>{0x44});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x200, 0x201));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x200, 0x201));
std::string expected =
"4 unwind DW_CFA_advance_loc 4\n"
"4 unwind Raw Data: 0x44\n"
@@ -260,22 +260,12 @@
"4 unwind PC 0x2010\n";
ASSERT_EQ(expected, GetFakeLogPrint());
ASSERT_EQ("", GetFakeLogBuf());
-
- ResetLogs();
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x100, 0x200, 0x201));
- expected =
- "4 unwind DW_CFA_advance_loc 4\n"
- "4 unwind Raw Data: 0x44\n"
- "4 unwind \n"
- "4 unwind PC 0x2110\n";
- ASSERT_EQ(expected, GetFakeLogPrint());
- ASSERT_EQ("", GetFakeLogBuf());
}
TYPED_TEST_P(DwarfCfaLogTest, cfa_advance_loc1) {
this->memory_.SetMemory(0x200, std::vector<uint8_t>{0x02, 0x04});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x200, 0x202));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x200, 0x202));
std::string expected =
"4 unwind DW_CFA_advance_loc1 4\n"
"4 unwind Raw Data: 0x02 0x04\n"
@@ -283,22 +273,12 @@
"4 unwind PC 0x2004\n";
ASSERT_EQ(expected, GetFakeLogPrint());
ASSERT_EQ("", GetFakeLogBuf());
-
- ResetLogs();
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x10, 0x200, 0x202));
- expected =
- "4 unwind DW_CFA_advance_loc1 4\n"
- "4 unwind Raw Data: 0x02 0x04\n"
- "4 unwind \n"
- "4 unwind PC 0x2014\n";
- ASSERT_EQ(expected, GetFakeLogPrint());
- ASSERT_EQ("", GetFakeLogBuf());
}
TYPED_TEST_P(DwarfCfaLogTest, cfa_advance_loc2) {
this->memory_.SetMemory(0x600, std::vector<uint8_t>{0x03, 0x04, 0x03});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x600, 0x603));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x600, 0x603));
std::string expected =
"4 unwind DW_CFA_advance_loc2 772\n"
"4 unwind Raw Data: 0x03 0x04 0x03\n"
@@ -306,22 +286,12 @@
"4 unwind PC 0x2304\n";
ASSERT_EQ(expected, GetFakeLogPrint());
ASSERT_EQ("", GetFakeLogBuf());
-
- ResetLogs();
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x1000, 0x600, 0x603));
- expected =
- "4 unwind DW_CFA_advance_loc2 772\n"
- "4 unwind Raw Data: 0x03 0x04 0x03\n"
- "4 unwind \n"
- "4 unwind PC 0x3304\n";
- ASSERT_EQ(expected, GetFakeLogPrint());
- ASSERT_EQ("", GetFakeLogBuf());
}
TYPED_TEST_P(DwarfCfaLogTest, cfa_advance_loc4) {
this->memory_.SetMemory(0x500, std::vector<uint8_t>{0x04, 0x04, 0x03, 0x02, 0x01});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x500, 0x505));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x500, 0x505));
std::string expected =
"4 unwind DW_CFA_advance_loc4 16909060\n"
"4 unwind Raw Data: 0x04 0x04 0x03 0x02 0x01\n"
@@ -329,22 +299,12 @@
"4 unwind PC 0x1022304\n";
ASSERT_EQ(expected, GetFakeLogPrint());
ASSERT_EQ("", GetFakeLogBuf());
-
- ResetLogs();
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x2000, 0x500, 0x505));
- expected =
- "4 unwind DW_CFA_advance_loc4 16909060\n"
- "4 unwind Raw Data: 0x04 0x04 0x03 0x02 0x01\n"
- "4 unwind \n"
- "4 unwind PC 0x1024304\n";
- ASSERT_EQ(expected, GetFakeLogPrint());
- ASSERT_EQ("", GetFakeLogBuf());
}
TYPED_TEST_P(DwarfCfaLogTest, cfa_undefined) {
this->memory_.SetMemory(0xa00, std::vector<uint8_t>{0x07, 0x09});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0xa00, 0xa02));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0xa00, 0xa02));
std::string expected =
"4 unwind DW_CFA_undefined register(9)\n"
"4 unwind Raw Data: 0x07 0x09\n";
@@ -355,7 +315,7 @@
dwarf_loc_regs_t cie_loc_regs;
this->memory_.SetMemory(0x1a00, std::vector<uint8_t>{0x07, 0x81, 0x01});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x1a00, 0x1a03));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x1a00, 0x1a03));
expected =
"4 unwind DW_CFA_undefined register(129)\n"
"4 unwind Raw Data: 0x07 0x81 0x01\n";
@@ -366,7 +326,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_same) {
this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x08, 0x7f});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x100, 0x102));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x100, 0x102));
std::string expected =
"4 unwind DW_CFA_same_value register(127)\n"
"4 unwind Raw Data: 0x08 0x7f\n";
@@ -376,7 +336,7 @@
ResetLogs();
this->memory_.SetMemory(0x2100, std::vector<uint8_t>{0x08, 0xff, 0x01});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x2100, 0x2103));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x2100, 0x2103));
expected =
"4 unwind DW_CFA_same_value register(255)\n"
"4 unwind Raw Data: 0x08 0xff 0x01\n";
@@ -387,7 +347,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_register) {
this->memory_.SetMemory(0x300, std::vector<uint8_t>{0x09, 0x02, 0x01});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x300, 0x303));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x300, 0x303));
std::string expected =
"4 unwind DW_CFA_register register(2) register(1)\n"
"4 unwind Raw Data: 0x09 0x02 0x01\n";
@@ -397,7 +357,7 @@
ResetLogs();
this->memory_.SetMemory(0x4300, std::vector<uint8_t>{0x09, 0xff, 0x01, 0xff, 0x03});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x4300, 0x4305));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x4300, 0x4305));
expected =
"4 unwind DW_CFA_register register(255) register(511)\n"
"4 unwind Raw Data: 0x09 0xff 0x01 0xff 0x03\n";
@@ -408,7 +368,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_state) {
this->memory_.SetMemory(0x300, std::vector<uint8_t>{0x0a});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x300, 0x301));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x300, 0x301));
std::string expected =
"4 unwind DW_CFA_remember_state\n"
@@ -419,7 +379,7 @@
ResetLogs();
this->memory_.SetMemory(0x4300, std::vector<uint8_t>{0x0b});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x4300, 0x4301));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x4300, 0x4301));
expected =
"4 unwind DW_CFA_restore_state\n"
@@ -431,7 +391,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_state_cfa_offset_restore) {
this->memory_.SetMemory(0x3000, std::vector<uint8_t>{0x0a, 0x0e, 0x40, 0x0b});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x3000, 0x3004));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x3000, 0x3004));
std::string expected =
"4 unwind DW_CFA_remember_state\n"
@@ -447,7 +407,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_def_cfa) {
this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x0c, 0x7f, 0x74});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x100, 0x103));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x100, 0x103));
std::string expected =
"4 unwind DW_CFA_def_cfa register(127) 116\n"
@@ -458,7 +418,7 @@
ResetLogs();
this->memory_.SetMemory(0x200, std::vector<uint8_t>{0x0c, 0xff, 0x02, 0xf4, 0x04});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x200, 0x205));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x200, 0x205));
expected =
"4 unwind DW_CFA_def_cfa register(383) 628\n"
@@ -470,7 +430,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_def_cfa_sf) {
this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x12, 0x30, 0x25});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x100, 0x103));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x100, 0x103));
std::string expected =
"4 unwind DW_CFA_def_cfa_sf register(48) 37\n"
@@ -482,7 +442,7 @@
ResetLogs();
this->memory_.SetMemory(0x200, std::vector<uint8_t>{0x12, 0xa3, 0x01, 0xfa, 0x7f});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x200, 0x205));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x200, 0x205));
expected =
"4 unwind DW_CFA_def_cfa_sf register(163) -6\n"
@@ -494,7 +454,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_def_cfa_register) {
this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x0d, 0x72});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x100, 0x102));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x100, 0x102));
std::string expected =
"4 unwind DW_CFA_def_cfa_register register(114)\n"
@@ -505,7 +465,7 @@
ResetLogs();
this->memory_.SetMemory(0x200, std::vector<uint8_t>{0x0d, 0xf9, 0x20});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x200, 0x203));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x200, 0x203));
expected =
"4 unwind DW_CFA_def_cfa_register register(4217)\n"
@@ -517,7 +477,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_def_cfa_offset) {
this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x0e, 0x59});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x100, 0x102));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x100, 0x102));
std::string expected =
"4 unwind DW_CFA_def_cfa_offset 89\n"
@@ -526,7 +486,7 @@
ASSERT_EQ("", GetFakeLogBuf());
ResetLogs();
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x100, 0x102));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x100, 0x102));
expected =
"4 unwind DW_CFA_def_cfa_offset 89\n"
@@ -537,7 +497,7 @@
ResetLogs();
this->memory_.SetMemory(0x200, std::vector<uint8_t>{0x0e, 0xd4, 0x0a});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x200, 0x203));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x200, 0x203));
expected =
"4 unwind DW_CFA_def_cfa_offset 1364\n"
@@ -549,7 +509,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_def_cfa_offset_sf) {
this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x13, 0x23});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x100, 0x102));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x100, 0x102));
std::string expected =
"4 unwind DW_CFA_def_cfa_offset_sf 35\n"
@@ -558,7 +518,7 @@
ASSERT_EQ("", GetFakeLogBuf());
ResetLogs();
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x100, 0x102));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x100, 0x102));
expected =
"4 unwind DW_CFA_def_cfa_offset_sf 35\n"
@@ -570,7 +530,7 @@
ResetLogs();
this->memory_.SetMemory(0x200, std::vector<uint8_t>{0x13, 0xf6, 0x7f});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x200, 0x203));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x200, 0x203));
expected =
"4 unwind DW_CFA_def_cfa_offset_sf -10\n"
@@ -582,7 +542,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_def_cfa_expression) {
this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x0f, 0x04, 0x01, 0x02, 0x04, 0x05});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x100, 0x106));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x100, 0x106));
std::string expected =
"4 unwind DW_CFA_def_cfa_expression 4\n"
@@ -614,7 +574,7 @@
}
expected += '\n';
this->memory_.SetMemory(0x200, ops);
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x200, 0x284));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x200, 0x284));
expected = "4 unwind DW_CFA_def_cfa_expression 129\n" + expected;
ASSERT_EQ(expected + op_string, GetFakeLogPrint());
@@ -624,7 +584,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_expression) {
this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x10, 0x04, 0x02, 0xc0, 0xc1});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x100, 0x105));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x100, 0x105));
std::string expected =
"4 unwind DW_CFA_expression register(4) 2\n"
@@ -652,7 +612,7 @@
expected = "4 unwind DW_CFA_expression register(255) 130\n" + expected + "\n";
this->memory_.SetMemory(0x200, ops);
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x200, 0x287));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x200, 0x287));
ASSERT_EQ(expected + op_string, GetFakeLogPrint());
ASSERT_EQ("", GetFakeLogBuf());
@@ -661,7 +621,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_val_offset) {
this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x14, 0x45, 0x54});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x100, 0x103));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x100, 0x103));
std::string expected =
"4 unwind DW_CFA_val_offset register(69) 84\n"
@@ -672,7 +632,7 @@
ResetLogs();
this->memory_.SetMemory(0x400, std::vector<uint8_t>{0x14, 0xa2, 0x02, 0xb4, 0x05});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x400, 0x405));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x400, 0x405));
expected =
"4 unwind DW_CFA_val_offset register(290) 692\n"
@@ -684,7 +644,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_val_offset_sf) {
this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x15, 0x56, 0x12});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x100, 0x103));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x100, 0x103));
std::string expected =
"4 unwind DW_CFA_val_offset_sf register(86) 18\n"
@@ -696,7 +656,7 @@
ResetLogs();
this->memory_.SetMemory(0xa00, std::vector<uint8_t>{0x15, 0xff, 0x01, 0xc0, 0x7f});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0xa00, 0xa05));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0xa00, 0xa05));
expected =
"4 unwind DW_CFA_val_offset_sf register(255) -64\n"
@@ -708,7 +668,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_val_expression) {
this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x16, 0x05, 0x02, 0xb0, 0xb1});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x100, 0x105));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x100, 0x105));
std::string expected =
"4 unwind DW_CFA_val_expression register(5) 2\n"
@@ -737,7 +697,7 @@
this->memory_.SetMemory(0xa00, ops);
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0xa00, 0xaad));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0xa00, 0xaad));
ASSERT_EQ(expected + op_string, GetFakeLogPrint());
ASSERT_EQ("", GetFakeLogBuf());
@@ -746,7 +706,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_gnu_args_size) {
this->memory_.SetMemory(0x2000, std::vector<uint8_t>{0x2e, 0x04});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x2000, 0x2002));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x2000, 0x2002));
std::string expected =
"4 unwind DW_CFA_GNU_args_size 4\n"
@@ -757,7 +717,7 @@
ResetLogs();
this->memory_.SetMemory(0x5000, std::vector<uint8_t>{0x2e, 0xa4, 0x80, 0x04});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x5000, 0x5004));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x5000, 0x5004));
expected =
"4 unwind DW_CFA_GNU_args_size 65572\n"
@@ -769,7 +729,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_gnu_negative_offset_extended) {
this->memory_.SetMemory(0x500, std::vector<uint8_t>{0x2f, 0x08, 0x10});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x500, 0x503));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x500, 0x503));
std::string expected =
"4 unwind DW_CFA_GNU_negative_offset_extended register(8) 16\n"
@@ -780,7 +740,7 @@
ResetLogs();
this->memory_.SetMemory(0x1500, std::vector<uint8_t>{0x2f, 0x81, 0x02, 0xff, 0x01});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x1500, 0x1505));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x1500, 0x1505));
expected =
"4 unwind DW_CFA_GNU_negative_offset_extended register(257) 255\n"
@@ -792,7 +752,7 @@
TYPED_TEST_P(DwarfCfaLogTest, cfa_register_override) {
this->memory_.SetMemory(0x300, std::vector<uint8_t>{0x09, 0x02, 0x01, 0x09, 0x02, 0x04});
- ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0, 0x300, 0x306));
+ ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x300, 0x306));
std::string expected =
"4 unwind DW_CFA_register register(2) register(1)\n"
diff --git a/libunwindstack/tests/DwarfDebugFrameTest.cpp b/libunwindstack/tests/DwarfDebugFrameTest.cpp
index c28a41e..3a52044 100644
--- a/libunwindstack/tests/DwarfDebugFrameTest.cpp
+++ b/libunwindstack/tests/DwarfDebugFrameTest.cpp
@@ -103,7 +103,7 @@
this->memory_.SetData32(0x5508, 0x4500);
this->memory_.SetData32(0x550c, 0x500);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600));
+ ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600, 0));
ASSERT_EQ(4U, this->debug_frame_->TestGetFdeCount());
typename DwarfDebugFrame<TypeParam>::FdeInfo info(0, 0, 0);
@@ -142,7 +142,7 @@
this->memory_.SetData32(0x5108, 0x1500);
this->memory_.SetData32(0x510c, 0x200);
- ASSERT_FALSE(this->debug_frame_->Init(0x5000, 0x600));
+ ASSERT_FALSE(this->debug_frame_->Init(0x5000, 0x600, 0));
ASSERT_EQ(DWARF_ERROR_ILLEGAL_VALUE, this->debug_frame_->LastErrorCode());
}
@@ -181,7 +181,7 @@
this->memory_.SetData32(0x5508, 0x4500);
this->memory_.SetData32(0x550c, 0x500);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600));
+ ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600, 0));
ASSERT_EQ(2U, this->debug_frame_->TestGetFdeCount());
}
@@ -226,7 +226,7 @@
this->memory_.SetData64(0x5514, 0x4500);
this->memory_.SetData64(0x551c, 0x500);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600));
+ ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600, 0));
ASSERT_EQ(4U, this->debug_frame_->TestGetFdeCount());
typename DwarfDebugFrame<TypeParam>::FdeInfo info(0, 0, 0);
@@ -267,7 +267,7 @@
this->memory_.SetData64(0x5114, 0x1500);
this->memory_.SetData64(0x511c, 0x200);
- ASSERT_FALSE(this->debug_frame_->Init(0x5000, 0x600));
+ ASSERT_FALSE(this->debug_frame_->Init(0x5000, 0x600, 0));
ASSERT_EQ(DWARF_ERROR_ILLEGAL_VALUE, this->debug_frame_->LastErrorCode());
}
@@ -312,10 +312,48 @@
this->memory_.SetData64(0x5514, 0x4500);
this->memory_.SetData64(0x551c, 0x500);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600));
+ ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x600, 0));
ASSERT_EQ(2U, this->debug_frame_->TestGetFdeCount());
}
+TYPED_TEST_P(DwarfDebugFrameTest, Init_non_zero_load_bias) {
+ // CIE 32 information.
+ this->memory_.SetData32(0x5000, 0xfc);
+ this->memory_.SetData32(0x5004, 0xffffffff);
+ this->memory_.SetData8(0x5008, 1);
+ this->memory_.SetData8(0x5009, 'z');
+ this->memory_.SetData8(0x500a, 'R');
+ this->memory_.SetData8(0x500b, '\0');
+ this->memory_.SetData8(0x500c, 0);
+ this->memory_.SetData8(0x500d, 0);
+ this->memory_.SetData8(0x500e, 0);
+ this->memory_.SetData8(0x500f, 0);
+ this->memory_.SetData8(0x5010, 0x1b);
+
+ // FDE 32 information.
+ this->memory_.SetData32(0x5100, 0xfc);
+ this->memory_.SetData32(0x5104, 0);
+ this->memory_.SetData32(0x5108, 0x1500);
+ this->memory_.SetData32(0x510c, 0x200);
+ this->memory_.SetData8(0x5110, 0);
+ this->memory_.SetData8(0x5111, 0);
+
+ ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x200, 0x1000));
+ ASSERT_EQ(1U, this->debug_frame_->TestGetFdeCount());
+
+ typename DwarfDebugFrame<TypeParam>::FdeInfo info(0, 0, 0);
+
+ this->debug_frame_->TestGetFdeInfo(0, &info);
+ EXPECT_EQ(0x5100U, info.offset);
+ EXPECT_EQ(0x2500U, info.start);
+ EXPECT_EQ(0x2700U, info.end);
+
+ const DwarfFde* fde = this->debug_frame_->GetFdeFromPc(0x2504);
+ ASSERT_TRUE(fde != nullptr);
+ EXPECT_EQ(0x2500U, fde->pc_start);
+ EXPECT_EQ(0x2700U, fde->pc_end);
+}
+
TYPED_TEST_P(DwarfDebugFrameTest, Init_version1) {
// CIE 32 information.
this->memory_.SetData32(0x5000, 0xfc);
@@ -340,7 +378,7 @@
this->memory_.SetData16(0x5108, 0x1500);
this->memory_.SetData16(0x510a, 0x200);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x200));
+ ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x200, 0));
ASSERT_EQ(1U, this->debug_frame_->TestGetFdeCount());
typename DwarfDebugFrame<TypeParam>::FdeInfo info(0, 0, 0);
@@ -383,7 +421,7 @@
this->memory_.SetData16(0x5108, 0x1500);
this->memory_.SetData16(0x510a, 0x200);
- ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x200));
+ ASSERT_TRUE(this->debug_frame_->Init(0x5000, 0x200, 0));
ASSERT_EQ(1U, this->debug_frame_->TestGetFdeCount());
typename DwarfDebugFrame<TypeParam>::FdeInfo info(0, 0, 0);
@@ -538,8 +576,8 @@
REGISTER_TYPED_TEST_CASE_P(DwarfDebugFrameTest, Init32, Init32_fde_not_following_cie,
Init32_do_not_fail_on_bad_next_entry, Init64,
Init64_do_not_fail_on_bad_next_entry, Init64_fde_not_following_cie,
- Init_version1, Init_version4, GetFdeOffsetFromPc, GetCieFde32,
- GetCieFde64);
+ Init_non_zero_load_bias, Init_version1, Init_version4,
+ GetFdeOffsetFromPc, GetCieFde32, GetCieFde64);
typedef ::testing::Types<uint32_t, uint64_t> DwarfDebugFrameTestTypes;
INSTANTIATE_TYPED_TEST_CASE_P(, DwarfDebugFrameTest, DwarfDebugFrameTestTypes);
diff --git a/libunwindstack/tests/DwarfEhFrameTest.cpp b/libunwindstack/tests/DwarfEhFrameTest.cpp
index a73db65..e8d53e6 100644
--- a/libunwindstack/tests/DwarfEhFrameTest.cpp
+++ b/libunwindstack/tests/DwarfEhFrameTest.cpp
@@ -103,7 +103,7 @@
this->memory_.SetData32(0x5508, 0x4500);
this->memory_.SetData32(0x550c, 0x500);
- ASSERT_TRUE(this->eh_frame_->Init(0x5000, 0x600));
+ ASSERT_TRUE(this->eh_frame_->Init(0x5000, 0x600, 0));
ASSERT_EQ(4U, this->eh_frame_->TestGetFdeCount());
typename DwarfEhFrame<TypeParam>::FdeInfo info(0, 0, 0);
@@ -142,7 +142,7 @@
this->memory_.SetData32(0x5108, 0x1500);
this->memory_.SetData32(0x510c, 0x200);
- ASSERT_FALSE(this->eh_frame_->Init(0x5000, 0x600));
+ ASSERT_FALSE(this->eh_frame_->Init(0x5000, 0x600, 0));
ASSERT_EQ(DWARF_ERROR_ILLEGAL_VALUE, this->eh_frame_->LastErrorCode());
}
@@ -187,7 +187,7 @@
this->memory_.SetData64(0x5514, 0x4500);
this->memory_.SetData64(0x551c, 0x500);
- ASSERT_TRUE(this->eh_frame_->Init(0x5000, 0x600));
+ ASSERT_TRUE(this->eh_frame_->Init(0x5000, 0x600, 0));
ASSERT_EQ(4U, this->eh_frame_->TestGetFdeCount());
typename DwarfEhFrame<TypeParam>::FdeInfo info(0, 0, 0);
@@ -228,10 +228,48 @@
this->memory_.SetData64(0x5114, 0x1500);
this->memory_.SetData64(0x511c, 0x200);
- ASSERT_FALSE(this->eh_frame_->Init(0x5000, 0x600));
+ ASSERT_FALSE(this->eh_frame_->Init(0x5000, 0x600, 0));
ASSERT_EQ(DWARF_ERROR_ILLEGAL_VALUE, this->eh_frame_->LastErrorCode());
}
+TYPED_TEST_P(DwarfEhFrameTest, Init_non_zero_load_bias) {
+ // CIE 32 information.
+ this->memory_.SetData32(0x5000, 0xfc);
+ this->memory_.SetData32(0x5004, 0);
+ this->memory_.SetData8(0x5008, 1);
+ this->memory_.SetData8(0x5009, 'z');
+ this->memory_.SetData8(0x500a, 'R');
+ this->memory_.SetData8(0x500b, '\0');
+ this->memory_.SetData8(0x500c, 0);
+ this->memory_.SetData8(0x500d, 0);
+ this->memory_.SetData8(0x500e, 0);
+ this->memory_.SetData8(0x500f, 0);
+ this->memory_.SetData8(0x5010, 0x1b);
+
+ // FDE 32 information.
+ this->memory_.SetData32(0x5100, 0xfc);
+ this->memory_.SetData32(0x5104, 0x104);
+ this->memory_.SetData32(0x5108, 0x1500);
+ this->memory_.SetData32(0x510c, 0x200);
+ this->memory_.SetData8(0x5110, 0);
+ this->memory_.SetData8(0x5111, 0);
+
+ ASSERT_TRUE(this->eh_frame_->Init(0x5000, 0x200, 0x2000));
+ ASSERT_EQ(1U, this->eh_frame_->TestGetFdeCount());
+
+ typename DwarfEhFrame<TypeParam>::FdeInfo info(0, 0, 0);
+
+ this->eh_frame_->TestGetFdeInfo(0, &info);
+ EXPECT_EQ(0x5100U, info.offset);
+ EXPECT_EQ(0x8608U, info.start);
+ EXPECT_EQ(0x8808U, info.end);
+
+ const DwarfFde* fde = this->eh_frame_->GetFdeFromPc(0x8700);
+ ASSERT_TRUE(fde != nullptr);
+ EXPECT_EQ(0x8608U, fde->pc_start);
+ EXPECT_EQ(0x8808U, fde->pc_end);
+}
+
TYPED_TEST_P(DwarfEhFrameTest, Init_version1) {
// CIE 32 information.
this->memory_.SetData32(0x5000, 0xfc);
@@ -256,7 +294,7 @@
this->memory_.SetData16(0x5108, 0x1500);
this->memory_.SetData16(0x510a, 0x200);
- ASSERT_TRUE(this->eh_frame_->Init(0x5000, 0x200));
+ ASSERT_TRUE(this->eh_frame_->Init(0x5000, 0x200, 0));
ASSERT_EQ(1U, this->eh_frame_->TestGetFdeCount());
typename DwarfEhFrame<TypeParam>::FdeInfo info(0, 0, 0);
@@ -299,7 +337,7 @@
this->memory_.SetData16(0x5108, 0x1500);
this->memory_.SetData16(0x510a, 0x200);
- ASSERT_TRUE(this->eh_frame_->Init(0x5000, 0x200));
+ ASSERT_TRUE(this->eh_frame_->Init(0x5000, 0x200, 0));
ASSERT_EQ(1U, this->eh_frame_->TestGetFdeCount());
typename DwarfEhFrame<TypeParam>::FdeInfo info(0, 0, 0);
@@ -450,8 +488,8 @@
}
REGISTER_TYPED_TEST_CASE_P(DwarfEhFrameTest, Init32, Init32_fde_not_following_cie, Init64,
- Init64_fde_not_following_cie, Init_version1, Init_version4,
- GetFdeOffsetFromPc, GetCieFde32, GetCieFde64);
+ Init64_fde_not_following_cie, Init_non_zero_load_bias, Init_version1,
+ Init_version4, GetFdeOffsetFromPc, GetCieFde32, GetCieFde64);
typedef ::testing::Types<uint32_t, uint64_t> DwarfEhFrameTestTypes;
INSTANTIATE_TYPED_TEST_CASE_P(, DwarfEhFrameTest, DwarfEhFrameTestTypes);
diff --git a/libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp b/libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp
index 4240419..19c7b98 100644
--- a/libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp
+++ b/libunwindstack/tests/DwarfEhFrameWithHdrTest.cpp
@@ -83,7 +83,7 @@
this->memory_.SetData16(0x1004, 0x500);
this->memory_.SetData32(0x1006, 126);
- ASSERT_TRUE(this->eh_frame_->Init(0x1000, 0x100));
+ ASSERT_TRUE(this->eh_frame_->Init(0x1000, 0x100, 0));
EXPECT_EQ(1U, this->eh_frame_->TestGetVersion());
EXPECT_EQ(DW_EH_PE_udata2, this->eh_frame_->TestGetPtrEncoding());
EXPECT_EQ(DW_EH_PE_sdata4, this->eh_frame_->TestGetTableEncoding());
@@ -97,19 +97,66 @@
// Verify a zero fde count fails to init.
this->memory_.SetData32(0x1006, 0);
- ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100));
+ ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100, 0));
ASSERT_EQ(DWARF_ERROR_NO_FDES, this->eh_frame_->LastErrorCode());
// Verify an unexpected version will cause a fail.
this->memory_.SetData32(0x1006, 126);
this->memory_.SetData8(0x1000, 0);
- ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100));
+ ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100, 0));
ASSERT_EQ(DWARF_ERROR_UNSUPPORTED_VERSION, this->eh_frame_->LastErrorCode());
this->memory_.SetData8(0x1000, 2);
- ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100));
+ ASSERT_FALSE(this->eh_frame_->Init(0x1000, 0x100, 0));
ASSERT_EQ(DWARF_ERROR_UNSUPPORTED_VERSION, this->eh_frame_->LastErrorCode());
}
+TYPED_TEST_P(DwarfEhFrameWithHdrTest, Init_non_zero_load_bias) {
+ this->memory_.SetMemory(0x1000, std::vector<uint8_t>{0x1, DW_EH_PE_udata2, DW_EH_PE_udata4,
+ DW_EH_PE_pcrel | DW_EH_PE_sdata4});
+ this->memory_.SetData16(0x1004, 0x500);
+ this->memory_.SetData32(0x1006, 1);
+ this->memory_.SetData32(0x100a, 0x2500);
+ this->memory_.SetData32(0x100e, 0x1400);
+
+ // CIE 32 information.
+ this->memory_.SetData32(0x1300, 0xfc);
+ this->memory_.SetData32(0x1304, 0);
+ this->memory_.SetData8(0x1308, 1);
+ this->memory_.SetData8(0x1309, 'z');
+ this->memory_.SetData8(0x130a, 'R');
+ this->memory_.SetData8(0x130b, '\0');
+ this->memory_.SetData8(0x130c, 0);
+ this->memory_.SetData8(0x130d, 0);
+ this->memory_.SetData8(0x130e, 0);
+ this->memory_.SetData8(0x130f, 0);
+ this->memory_.SetData8(0x1310, 0x1b);
+
+ // FDE 32 information.
+ this->memory_.SetData32(0x1400, 0xfc);
+ this->memory_.SetData32(0x1404, 0x104);
+ this->memory_.SetData32(0x1408, 0x10f8);
+ this->memory_.SetData32(0x140c, 0x200);
+ this->memory_.SetData8(0x1410, 0);
+ this->memory_.SetData8(0x1411, 0);
+
+ ASSERT_TRUE(this->eh_frame_->Init(0x1000, 0x100, 0x2000));
+ EXPECT_EQ(1U, this->eh_frame_->TestGetVersion());
+ EXPECT_EQ(DW_EH_PE_udata2, this->eh_frame_->TestGetPtrEncoding());
+ EXPECT_EQ(0x1b, this->eh_frame_->TestGetTableEncoding());
+ EXPECT_EQ(4U, this->eh_frame_->TestGetTableEntrySize());
+ EXPECT_EQ(1U, this->eh_frame_->TestGetFdeCount());
+ EXPECT_EQ(0x500U, this->eh_frame_->TestGetPtrOffset());
+ EXPECT_EQ(0x100aU, this->eh_frame_->TestGetEntriesOffset());
+ EXPECT_EQ(0x1100U, this->eh_frame_->TestGetEntriesEnd());
+ EXPECT_EQ(0x1000U, this->eh_frame_->TestGetEntriesDataOffset());
+ EXPECT_EQ(0x100aU, this->eh_frame_->TestGetCurEntriesOffset());
+
+ const DwarfFde* fde = this->eh_frame_->GetFdeFromPc(0x4600);
+ ASSERT_TRUE(fde != nullptr);
+ EXPECT_EQ(0x4500U, fde->pc_start);
+ EXPECT_EQ(0x4700U, fde->pc_end);
+}
+
TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeInfoFromIndex_expect_cache_fail) {
this->eh_frame_->TestSetTableEntrySize(0x10);
this->eh_frame_->TestSetTableEncoding(DW_EH_PE_udata4);
@@ -123,6 +170,7 @@
EXPECT_EQ(0x1000U, this->eh_frame_->LastErrorAddress());
}
+// We are assuming that pc rel, is really relative to the load_bias.
TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeInfoFromIndex_read_pcrel) {
this->eh_frame_->TestSetTableEncoding(DW_EH_PE_pcrel | DW_EH_PE_udata4);
this->eh_frame_->TestSetEntriesOffset(0x1000);
@@ -134,8 +182,8 @@
auto info = this->eh_frame_->GetFdeInfoFromIndex(2);
ASSERT_TRUE(info != nullptr);
- EXPECT_EQ(0x1380U, info->pc);
- EXPECT_EQ(0x1540U, info->offset);
+ EXPECT_EQ(0x340U, info->pc);
+ EXPECT_EQ(0x500U, info->offset);
}
TYPED_TEST_P(DwarfEhFrameWithHdrTest, GetFdeInfoFromIndex_read_datarel) {
@@ -430,14 +478,14 @@
ASSERT_EQ(nullptr, this->eh_frame_->GetFdeFromPc(0x800));
}
-REGISTER_TYPED_TEST_CASE_P(DwarfEhFrameWithHdrTest, Init, GetFdeInfoFromIndex_expect_cache_fail,
- GetFdeInfoFromIndex_read_pcrel, GetFdeInfoFromIndex_read_datarel,
- GetFdeInfoFromIndex_cached, GetFdeOffsetBinary_verify,
- GetFdeOffsetBinary_index_fail, GetFdeOffsetSequential,
- GetFdeOffsetSequential_last_element, GetFdeOffsetSequential_end_check,
- GetFdeOffsetFromPc_fail_fde_count, GetFdeOffsetFromPc_binary_search,
- GetFdeOffsetFromPc_sequential_search, GetCieFde32, GetCieFde64,
- GetFdeFromPc_fde_not_found);
+REGISTER_TYPED_TEST_CASE_P(DwarfEhFrameWithHdrTest, Init, Init_non_zero_load_bias,
+ GetFdeInfoFromIndex_expect_cache_fail, GetFdeInfoFromIndex_read_pcrel,
+ GetFdeInfoFromIndex_read_datarel, GetFdeInfoFromIndex_cached,
+ GetFdeOffsetBinary_verify, GetFdeOffsetBinary_index_fail,
+ GetFdeOffsetSequential, GetFdeOffsetSequential_last_element,
+ GetFdeOffsetSequential_end_check, GetFdeOffsetFromPc_fail_fde_count,
+ GetFdeOffsetFromPc_binary_search, GetFdeOffsetFromPc_sequential_search,
+ GetCieFde32, GetCieFde64, GetFdeFromPc_fde_not_found);
typedef ::testing::Types<uint32_t, uint64_t> DwarfEhFrameWithHdrTestTypes;
INSTANTIATE_TYPED_TEST_CASE_P(, DwarfEhFrameWithHdrTest, DwarfEhFrameWithHdrTestTypes);
diff --git a/libunwindstack/tests/DwarfSectionImplTest.cpp b/libunwindstack/tests/DwarfSectionImplTest.cpp
index c340291..414f2f2 100644
--- a/libunwindstack/tests/DwarfSectionImplTest.cpp
+++ b/libunwindstack/tests/DwarfSectionImplTest.cpp
@@ -36,7 +36,7 @@
MockDwarfSectionImpl(Memory* memory) : DwarfSectionImpl<TypeParam>(memory) {}
virtual ~MockDwarfSectionImpl() = default;
- MOCK_METHOD2(Init, bool(uint64_t, uint64_t));
+ MOCK_METHOD3(Init, bool(uint64_t, uint64_t, uint64_t));
MOCK_METHOD2(GetFdeOffsetFromPc, bool(uint64_t, uint64_t*));
@@ -884,7 +884,7 @@
this->memory_.SetMemory(0x5000, std::vector<uint8_t>{0x00});
this->memory_.SetMemory(0x6000, std::vector<uint8_t>{0xc2});
- ASSERT_TRUE(this->section_->Log(2, 0x1000, 0x1000, &fde));
+ ASSERT_TRUE(this->section_->Log(2, 0x1000, &fde));
ASSERT_EQ(
"4 unwind DW_CFA_nop\n"
diff --git a/libunwindstack/tests/DwarfSectionTest.cpp b/libunwindstack/tests/DwarfSectionTest.cpp
index 071d2df..2c6c879 100644
--- a/libunwindstack/tests/DwarfSectionTest.cpp
+++ b/libunwindstack/tests/DwarfSectionTest.cpp
@@ -30,13 +30,13 @@
MockDwarfSection(Memory* memory) : DwarfSection(memory) {}
virtual ~MockDwarfSection() = default;
- MOCK_METHOD4(Log, bool(uint8_t, uint64_t, uint64_t, const DwarfFde*));
+ MOCK_METHOD3(Log, bool(uint8_t, uint64_t, const DwarfFde*));
MOCK_METHOD5(Eval, bool(const DwarfCie*, Memory*, const dwarf_loc_regs_t&, Regs*, bool*));
MOCK_METHOD3(GetCfaLocationInfo, bool(uint64_t, const DwarfFde*, dwarf_loc_regs_t*));
- MOCK_METHOD2(Init, bool(uint64_t, uint64_t));
+ MOCK_METHOD3(Init, bool(uint64_t, uint64_t, uint64_t));
MOCK_METHOD2(GetFdeOffsetFromPc, bool(uint64_t, uint64_t*));
diff --git a/libunwindstack/tests/ElfFake.cpp b/libunwindstack/tests/ElfFake.cpp
index 66207db..3d5ddd6 100644
--- a/libunwindstack/tests/ElfFake.cpp
+++ b/libunwindstack/tests/ElfFake.cpp
@@ -32,7 +32,7 @@
std::deque<FunctionData> ElfInterfaceFake::functions_;
std::deque<StepData> ElfInterfaceFake::steps_;
-bool ElfInterfaceFake::GetFunctionName(uint64_t, uint64_t, std::string* name, uint64_t* offset) {
+bool ElfInterfaceFake::GetFunctionName(uint64_t, std::string* name, uint64_t* offset) {
if (functions_.empty()) {
return false;
}
@@ -52,7 +52,7 @@
return true;
}
-bool ElfInterfaceFake::Step(uint64_t, uint64_t, Regs* regs, Memory*, bool* finished) {
+bool ElfInterfaceFake::Step(uint64_t, Regs* regs, Memory*, bool* finished) {
if (steps_.empty()) {
return false;
}
diff --git a/libunwindstack/tests/ElfFake.h b/libunwindstack/tests/ElfFake.h
index e232986..a3bf5ce 100644
--- a/libunwindstack/tests/ElfFake.h
+++ b/libunwindstack/tests/ElfFake.h
@@ -67,13 +67,13 @@
virtual ~ElfInterfaceFake() = default;
bool Init(uint64_t*) override { return false; }
- void InitHeaders() override {}
+ void InitHeaders(uint64_t) override {}
bool GetSoname(std::string*) override { return false; }
- bool GetFunctionName(uint64_t, uint64_t, std::string*, uint64_t*) override;
+ bool GetFunctionName(uint64_t, std::string*, uint64_t*) override;
bool GetGlobalVariable(const std::string&, uint64_t*) override;
- bool Step(uint64_t, uint64_t, Regs*, Memory*, bool*) override;
+ bool Step(uint64_t, Regs*, Memory*, bool*) override;
void FakeSetGlobalVariable(const std::string& global, uint64_t offset) {
globals_[global] = offset;
diff --git a/libunwindstack/tests/ElfInterfaceArmTest.cpp b/libunwindstack/tests/ElfInterfaceArmTest.cpp
index 70a52ad..5f1c2ac 100644
--- a/libunwindstack/tests/ElfInterfaceArmTest.cpp
+++ b/libunwindstack/tests/ElfInterfaceArmTest.cpp
@@ -302,7 +302,7 @@
// FindEntry fails.
bool finished;
- ASSERT_FALSE(interface.StepExidx(0x7000, 0, nullptr, nullptr, &finished));
+ ASSERT_FALSE(interface.StepExidx(0x7000, nullptr, nullptr, &finished));
EXPECT_EQ(ERROR_UNWIND_INFO, interface.LastErrorCode());
// ExtractEntry should fail.
@@ -316,18 +316,18 @@
regs[ARM_REG_LR] = 0x20000;
regs.set_sp(regs[ARM_REG_SP]);
regs.set_pc(0x1234);
- ASSERT_FALSE(interface.StepExidx(0x7000, 0, ®s, &process_memory_, &finished));
+ ASSERT_FALSE(interface.StepExidx(0x7000, ®s, &process_memory_, &finished));
EXPECT_EQ(ERROR_MEMORY_INVALID, interface.LastErrorCode());
EXPECT_EQ(0x1004U, interface.LastErrorAddress());
// Eval should fail.
memory_.SetData32(0x1004, 0x81000000);
- ASSERT_FALSE(interface.StepExidx(0x7000, 0, ®s, &process_memory_, &finished));
+ ASSERT_FALSE(interface.StepExidx(0x7000, ®s, &process_memory_, &finished));
EXPECT_EQ(ERROR_UNWIND_INFO, interface.LastErrorCode());
// Everything should pass.
memory_.SetData32(0x1004, 0x80b0b0b0);
- ASSERT_TRUE(interface.StepExidx(0x7000, 0, ®s, &process_memory_, &finished));
+ ASSERT_TRUE(interface.StepExidx(0x7000, ®s, &process_memory_, &finished));
EXPECT_EQ(ERROR_UNWIND_INFO, interface.LastErrorCode());
ASSERT_FALSE(finished);
ASSERT_EQ(0x1000U, regs.sp());
@@ -336,11 +336,13 @@
ASSERT_EQ(0x20000U, regs[ARM_REG_PC]);
// Load bias is non-zero.
- ASSERT_TRUE(interface.StepExidx(0x8000, 0x1000, ®s, &process_memory_, &finished));
+ interface.set_load_bias(0x1000);
+ ASSERT_TRUE(interface.StepExidx(0x8000, ®s, &process_memory_, &finished));
EXPECT_EQ(ERROR_UNWIND_INFO, interface.LastErrorCode());
// Pc too small.
- ASSERT_FALSE(interface.StepExidx(0x8000, 0x9000, ®s, &process_memory_, &finished));
+ interface.set_load_bias(0x9000);
+ ASSERT_FALSE(interface.StepExidx(0x8000, ®s, &process_memory_, &finished));
EXPECT_EQ(ERROR_UNWIND_INFO, interface.LastErrorCode());
}
@@ -362,7 +364,7 @@
// Everything should pass.
bool finished;
- ASSERT_TRUE(interface.StepExidx(0x7000, 0, ®s, &process_memory_, &finished));
+ ASSERT_TRUE(interface.StepExidx(0x7000, ®s, &process_memory_, &finished));
EXPECT_EQ(ERROR_NONE, interface.LastErrorCode());
ASSERT_FALSE(finished);
ASSERT_EQ(0x10004U, regs.sp());
@@ -386,7 +388,7 @@
regs.set_pc(0x1234);
bool finished;
- ASSERT_TRUE(interface.StepExidx(0x7000, 0, ®s, &process_memory_, &finished));
+ ASSERT_TRUE(interface.StepExidx(0x7000, ®s, &process_memory_, &finished));
EXPECT_EQ(ERROR_NONE, interface.LastErrorCode());
ASSERT_TRUE(finished);
ASSERT_EQ(0x10000U, regs.sp());
@@ -409,7 +411,7 @@
regs.set_pc(0x1234);
bool finished;
- ASSERT_TRUE(interface.StepExidx(0x7000, 0, ®s, &process_memory_, &finished));
+ ASSERT_TRUE(interface.StepExidx(0x7000, ®s, &process_memory_, &finished));
EXPECT_EQ(ERROR_NONE, interface.LastErrorCode());
ASSERT_TRUE(finished);
ASSERT_EQ(0x10000U, regs.sp());
@@ -436,7 +438,7 @@
regs.set_pc(0x1234);
bool finished;
- ASSERT_TRUE(interface.StepExidx(0x7000, 0, ®s, &process_memory_, &finished));
+ ASSERT_TRUE(interface.StepExidx(0x7000, ®s, &process_memory_, &finished));
EXPECT_EQ(ERROR_NONE, interface.LastErrorCode());
ASSERT_TRUE(finished);
ASSERT_EQ(0U, regs.pc());
@@ -449,7 +451,7 @@
regs.set_sp(regs[ARM_REG_SP]);
regs.set_pc(0x1234);
- ASSERT_TRUE(interface.StepExidx(0x7000, 0, ®s, &process_memory_, &finished));
+ ASSERT_TRUE(interface.StepExidx(0x7000, ®s, &process_memory_, &finished));
EXPECT_EQ(ERROR_NONE, interface.LastErrorCode());
ASSERT_TRUE(finished);
ASSERT_EQ(0U, regs.pc());
diff --git a/libunwindstack/tests/ElfInterfaceTest.cpp b/libunwindstack/tests/ElfInterfaceTest.cpp
index bf97e30..4008e9b 100644
--- a/libunwindstack/tests/ElfInterfaceTest.cpp
+++ b/libunwindstack/tests/ElfInterfaceTest.cpp
@@ -647,7 +647,7 @@
memory_.SetData32(0x10004, 0x500);
memory_.SetData32(0x10008, 250);
- elf.InitHeaders();
+ elf.InitHeaders(0);
EXPECT_FALSE(elf.eh_frame() == nullptr);
EXPECT_TRUE(elf.debug_frame() == nullptr);
@@ -680,7 +680,7 @@
memory_.SetData32(0x5108, 0x1500);
memory_.SetData32(0x510c, 0x200);
- elf.InitHeaders();
+ elf.InitHeaders(0);
EXPECT_TRUE(elf.eh_frame() == nullptr);
EXPECT_FALSE(elf.debug_frame() == nullptr);
@@ -703,7 +703,7 @@
elf.FakeSetDebugFrameOffset(0);
elf.FakeSetDebugFrameSize(0);
- elf.InitHeaders();
+ elf.InitHeaders(0);
EXPECT_TRUE(elf.eh_frame() == nullptr);
EXPECT_EQ(0U, elf.eh_frame_offset());
@@ -728,7 +728,7 @@
elf.FakeSetDebugFrameOffset(0x1000);
elf.FakeSetDebugFrameSize(0x100);
- elf.InitHeaders();
+ elf.InitHeaders(0);
EXPECT_TRUE(elf.eh_frame() == nullptr);
EXPECT_TRUE(elf.debug_frame() == nullptr);
@@ -833,10 +833,10 @@
// Look in the first symbol table.
std::string name;
uint64_t name_offset;
- ASSERT_TRUE(elf->GetFunctionName(0x90010, 0, &name, &name_offset));
+ ASSERT_TRUE(elf->GetFunctionName(0x90010, &name, &name_offset));
EXPECT_EQ("function_one", name);
EXPECT_EQ(16U, name_offset);
- ASSERT_TRUE(elf->GetFunctionName(0xd0020, 0, &name, &name_offset));
+ ASSERT_TRUE(elf->GetFunctionName(0xd0020, &name, &name_offset));
EXPECT_EQ("function_two", name);
EXPECT_EQ(32U, name_offset);
}
@@ -1065,7 +1065,7 @@
uint64_t load_bias = 0;
ASSERT_TRUE(elf->Init(&load_bias));
- elf->InitHeaders();
+ elf->InitHeaders(0);
EXPECT_EQ(0U, load_bias);
EXPECT_FALSE(elf->IsValidPc(0));
EXPECT_FALSE(elf->IsValidPc(0x20ff));
@@ -1128,7 +1128,7 @@
uint64_t load_bias = 0;
ASSERT_TRUE(elf->Init(&load_bias));
- elf->InitHeaders();
+ elf->InitHeaders(0);
EXPECT_EQ(0U, load_bias);
EXPECT_FALSE(elf->IsValidPc(0));
EXPECT_FALSE(elf->IsValidPc(0x27ff));
diff --git a/libunwindstack/tests/ElfTest.cpp b/libunwindstack/tests/ElfTest.cpp
index aecbf6d..55fe16f 100644
--- a/libunwindstack/tests/ElfTest.cpp
+++ b/libunwindstack/tests/ElfTest.cpp
@@ -297,16 +297,11 @@
elf.FakeSetInterface(interface);
elf.FakeSetValid(true);
- elf.FakeSetLoadBias(0);
MapInfo map_info(0x1000, 0x2000);
ASSERT_EQ(0x101U, elf.GetRelPc(0x1101, &map_info));
- elf.FakeSetLoadBias(0x3000);
- ASSERT_EQ(0x3101U, elf.GetRelPc(0x1101, &map_info));
-
elf.FakeSetValid(false);
- elf.FakeSetLoadBias(0);
ASSERT_EQ(0x101U, elf.GetRelPc(0x1101, &map_info));
}
@@ -328,7 +323,6 @@
}
elf.FakeSetValid(true);
- elf.FakeSetLoadBias(0);
bool finished;
ASSERT_TRUE(elf.Step(0x3000, 0x1000, ®s, &process_memory, &finished));
EXPECT_FALSE(finished);
@@ -342,11 +336,11 @@
virtual ~ElfInterfaceMock() = default;
bool Init(uint64_t*) override { return false; }
- void InitHeaders() override {}
+ void InitHeaders(uint64_t) override {}
bool GetSoname(std::string*) override { return false; }
- bool GetFunctionName(uint64_t, uint64_t, std::string*, uint64_t*) override { return false; }
+ bool GetFunctionName(uint64_t, std::string*, uint64_t*) override { return false; }
- MOCK_METHOD5(Step, bool(uint64_t, uint64_t, Regs*, Memory*, bool*));
+ MOCK_METHOD4(Step, bool(uint64_t, Regs*, Memory*, bool*));
MOCK_METHOD2(GetGlobalVariable, bool(const std::string&, uint64_t*));
MOCK_METHOD1(IsValidPc, bool(uint64_t));
@@ -358,7 +352,6 @@
TEST_F(ElfTest, step_in_interface) {
ElfFake elf(memory_);
elf.FakeSetValid(true);
- elf.FakeSetLoadBias(0);
RegsArm regs;
@@ -367,30 +360,12 @@
MemoryFake process_memory;
bool finished;
- EXPECT_CALL(*interface, Step(0x1000, 0, ®s, &process_memory, &finished))
+ EXPECT_CALL(*interface, Step(0x1000, ®s, &process_memory, &finished))
.WillOnce(::testing::Return(true));
ASSERT_TRUE(elf.Step(0x1004, 0x1000, ®s, &process_memory, &finished));
}
-TEST_F(ElfTest, step_in_interface_non_zero_load_bias) {
- ElfFake elf(memory_);
- elf.FakeSetValid(true);
- elf.FakeSetLoadBias(0x4000);
-
- RegsArm regs;
-
- ElfInterfaceMock* interface = new ElfInterfaceMock(memory_);
- elf.FakeSetInterface(interface);
- MemoryFake process_memory;
-
- bool finished;
- EXPECT_CALL(*interface, Step(0x7300, 0x4000, ®s, &process_memory, &finished))
- .WillOnce(::testing::Return(true));
-
- ASSERT_TRUE(elf.Step(0x7304, 0x7300, ®s, &process_memory, &finished));
-}
-
TEST_F(ElfTest, get_global_invalid_elf) {
ElfFake elf(memory_);
elf.FakeSetValid(false);
@@ -403,7 +378,6 @@
TEST_F(ElfTest, get_global_valid_not_in_interface) {
ElfFake elf(memory_);
elf.FakeSetValid(true);
- elf.FakeSetLoadBias(0);
ElfInterfaceMock* interface = new ElfInterfaceMock(memory_);
elf.FakeSetInterface(interface);
@@ -431,10 +405,26 @@
ASSERT_FALSE(elf.GetGlobalVariable(global, &offset));
}
+TEST_F(ElfTest, get_global_valid_dynamic_zero_non_zero_load_bias) {
+ ElfFake elf(memory_);
+ elf.FakeSetValid(true);
+ elf.FakeSetLoadBias(0x100);
+
+ ElfInterfaceMock* interface = new ElfInterfaceMock(memory_);
+ elf.FakeSetInterface(interface);
+
+ uint64_t offset;
+ std::string global("something");
+ EXPECT_CALL(*interface, GetGlobalVariable(global, &offset))
+ .WillOnce(::testing::DoAll(::testing::SetArgPointee<1>(0x300), ::testing::Return(true)));
+
+ ASSERT_TRUE(elf.GetGlobalVariable(global, &offset));
+ EXPECT_EQ(0x200U, offset);
+}
+
TEST_F(ElfTest, get_global_valid_dynamic_zero) {
ElfFake elf(memory_);
elf.FakeSetValid(true);
- elf.FakeSetLoadBias(0);
ElfInterfaceMock* interface = new ElfInterfaceMock(memory_);
elf.FakeSetInterface(interface);
@@ -456,7 +446,6 @@
TEST_F(ElfTest, get_global_valid_in_gnu_debugdata_dynamic_zero) {
ElfFake elf(memory_);
elf.FakeSetValid(true);
- elf.FakeSetLoadBias(0);
ElfInterfaceMock* interface = new ElfInterfaceMock(memory_);
elf.FakeSetInterface(interface);
@@ -470,27 +459,9 @@
EXPECT_EQ(0x300U, offset);
}
-TEST_F(ElfTest, get_global_valid_dynamic_zero_non_zero_load_bias) {
- ElfFake elf(memory_);
- elf.FakeSetValid(true);
- elf.FakeSetLoadBias(0x100);
-
- ElfInterfaceMock* interface = new ElfInterfaceMock(memory_);
- elf.FakeSetInterface(interface);
-
- uint64_t offset;
- std::string global("something");
- EXPECT_CALL(*interface, GetGlobalVariable(global, &offset))
- .WillOnce(::testing::DoAll(::testing::SetArgPointee<1>(0x300), ::testing::Return(true)));
-
- ASSERT_TRUE(elf.GetGlobalVariable(global, &offset));
- EXPECT_EQ(0x200U, offset);
-}
-
TEST_F(ElfTest, get_global_valid_dynamic_adjust_negative) {
ElfFake elf(memory_);
elf.FakeSetValid(true);
- elf.FakeSetLoadBias(0);
ElfInterfaceMock* interface = new ElfInterfaceMock(memory_);
interface->MockSetDynamicOffset(0x400);
@@ -510,7 +481,6 @@
TEST_F(ElfTest, get_global_valid_dynamic_adjust_positive) {
ElfFake elf(memory_);
elf.FakeSetValid(true);
- elf.FakeSetLoadBias(0);
ElfInterfaceMock* interface = new ElfInterfaceMock(memory_);
interface->MockSetDynamicOffset(0x1000);
@@ -530,7 +500,6 @@
TEST_F(ElfTest, is_valid_pc_elf_invalid) {
ElfFake elf(memory_);
elf.FakeSetValid(false);
- elf.FakeSetLoadBias(0);
EXPECT_FALSE(elf.IsValidPc(0x100));
EXPECT_FALSE(elf.IsValidPc(0x200));
@@ -539,7 +508,6 @@
TEST_F(ElfTest, is_valid_pc_interface) {
ElfFake elf(memory_);
elf.FakeSetValid(true);
- elf.FakeSetLoadBias(0);
ElfInterfaceMock* interface = new ElfInterfaceMock(memory_);
elf.FakeSetInterface(interface);
@@ -549,25 +517,9 @@
EXPECT_TRUE(elf.IsValidPc(0x1500));
}
-TEST_F(ElfTest, is_valid_pc_non_zero_load_bias) {
- ElfFake elf(memory_);
- elf.FakeSetValid(true);
- elf.FakeSetLoadBias(0x1000);
-
- ElfInterfaceMock* interface = new ElfInterfaceMock(memory_);
- elf.FakeSetInterface(interface);
-
- EXPECT_CALL(*interface, IsValidPc(0x500)).WillOnce(::testing::Return(true));
-
- EXPECT_FALSE(elf.IsValidPc(0x100));
- EXPECT_FALSE(elf.IsValidPc(0x200));
- EXPECT_TRUE(elf.IsValidPc(0x1500));
-}
-
TEST_F(ElfTest, is_valid_pc_from_gnu_debugdata) {
ElfFake elf(memory_);
elf.FakeSetValid(true);
- elf.FakeSetLoadBias(0);
ElfInterfaceMock* interface = new ElfInterfaceMock(memory_);
elf.FakeSetInterface(interface);
diff --git a/libunwindstack/tests/SymbolsTest.cpp b/libunwindstack/tests/SymbolsTest.cpp
index 45a7b58..b40a253 100644
--- a/libunwindstack/tests/SymbolsTest.cpp
+++ b/libunwindstack/tests/SymbolsTest.cpp
@@ -70,18 +70,18 @@
std::string name;
uint64_t func_offset;
- ASSERT_TRUE(symbols.GetName<TypeParam>(0x5000, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0x5000, &this->memory_, &name, &func_offset));
ASSERT_EQ("fake_function", name);
ASSERT_EQ(0U, func_offset);
name.clear();
- ASSERT_TRUE(symbols.GetName<TypeParam>(0x500f, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0x500f, &this->memory_, &name, &func_offset));
ASSERT_EQ("fake_function", name);
ASSERT_EQ(0xfU, func_offset);
// Check one before and one after the function.
- ASSERT_FALSE(symbols.GetName<TypeParam>(0x4fff, 0, &this->memory_, &name, &func_offset));
- ASSERT_FALSE(symbols.GetName<TypeParam>(0x5010, 0, &this->memory_, &name, &func_offset));
+ ASSERT_FALSE(symbols.GetName<TypeParam>(0x4fff, &this->memory_, &name, &func_offset));
+ ASSERT_FALSE(symbols.GetName<TypeParam>(0x5010, &this->memory_, &name, &func_offset));
}
TYPED_TEST_P(SymbolsTest, no_symbol) {
@@ -98,7 +98,7 @@
// First verify that we can get the name.
std::string name;
uint64_t func_offset;
- ASSERT_TRUE(symbols.GetName<TypeParam>(0x5000, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0x5000, &this->memory_, &name, &func_offset));
ASSERT_EQ("fake_function", name);
ASSERT_EQ(0U, func_offset);
@@ -107,7 +107,7 @@
this->memory_.SetMemory(offset, &sym, sizeof(sym));
// Clear the cache to force the symbol data to be re-read.
symbols.ClearCache();
- ASSERT_FALSE(symbols.GetName<TypeParam>(0x5000, 0, &this->memory_, &name, &func_offset));
+ ASSERT_FALSE(symbols.GetName<TypeParam>(0x5000, &this->memory_, &name, &func_offset));
// Set the function back, and set the shndx to UNDEF.
sym.st_info = STT_FUNC;
@@ -115,7 +115,7 @@
this->memory_.SetMemory(offset, &sym, sizeof(sym));
// Clear the cache to force the symbol data to be re-read.
symbols.ClearCache();
- ASSERT_FALSE(symbols.GetName<TypeParam>(0x5000, 0, &this->memory_, &name, &func_offset));
+ ASSERT_FALSE(symbols.GetName<TypeParam>(0x5000, &this->memory_, &name, &func_offset));
}
TYPED_TEST_P(SymbolsTest, multiple_entries) {
@@ -144,34 +144,34 @@
std::string name;
uint64_t func_offset;
- ASSERT_TRUE(symbols.GetName<TypeParam>(0x3005, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0x3005, &this->memory_, &name, &func_offset));
ASSERT_EQ("function_two", name);
ASSERT_EQ(1U, func_offset);
name.clear();
- ASSERT_TRUE(symbols.GetName<TypeParam>(0x5004, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0x5004, &this->memory_, &name, &func_offset));
ASSERT_EQ("function_one", name);
ASSERT_EQ(4U, func_offset);
name.clear();
- ASSERT_TRUE(symbols.GetName<TypeParam>(0xa011, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0xa011, &this->memory_, &name, &func_offset));
ASSERT_EQ("function_three", name);
ASSERT_EQ(1U, func_offset);
// Reget some of the others to verify getting one function name doesn't
// affect any of the next calls.
name.clear();
- ASSERT_TRUE(symbols.GetName<TypeParam>(0x5008, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0x5008, &this->memory_, &name, &func_offset));
ASSERT_EQ("function_one", name);
ASSERT_EQ(8U, func_offset);
name.clear();
- ASSERT_TRUE(symbols.GetName<TypeParam>(0x3008, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0x3008, &this->memory_, &name, &func_offset));
ASSERT_EQ("function_two", name);
ASSERT_EQ(4U, func_offset);
name.clear();
- ASSERT_TRUE(symbols.GetName<TypeParam>(0xa01a, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0xa01a, &this->memory_, &name, &func_offset));
ASSERT_EQ("function_three", name);
ASSERT_EQ(0xaU, func_offset);
}
@@ -203,47 +203,21 @@
std::string name;
uint64_t func_offset;
- ASSERT_TRUE(symbols.GetName<TypeParam>(0x3005, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0x3005, &this->memory_, &name, &func_offset));
ASSERT_EQ("function_two", name);
ASSERT_EQ(1U, func_offset);
name.clear();
- ASSERT_TRUE(symbols.GetName<TypeParam>(0x5004, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0x5004, &this->memory_, &name, &func_offset));
ASSERT_EQ("function_one", name);
ASSERT_EQ(4U, func_offset);
name.clear();
- ASSERT_TRUE(symbols.GetName<TypeParam>(0xa011, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0xa011, &this->memory_, &name, &func_offset));
ASSERT_EQ("function_three", name);
ASSERT_EQ(1U, func_offset);
}
-TYPED_TEST_P(SymbolsTest, load_bias) {
- Symbols symbols(0x1000, sizeof(TypeParam), sizeof(TypeParam), 0x2000, 0x100);
-
- TypeParam sym;
- this->InitSym(&sym, 0x5000, 0x10, 0x40);
- uint64_t offset = 0x1000;
- this->memory_.SetMemory(offset, &sym, sizeof(sym));
-
- std::string fake_name("fake_function");
- this->memory_.SetMemory(0x2040, fake_name.c_str(), fake_name.size() + 1);
-
- // Set a non-zero load_bias that should be a valid function offset.
- std::string name;
- uint64_t func_offset;
- ASSERT_TRUE(symbols.GetName<TypeParam>(0x5004, 0x1000, &this->memory_, &name, &func_offset));
- ASSERT_EQ("fake_function", name);
- ASSERT_EQ(4U, func_offset);
-
- // Set a flag that should cause the load_bias to be ignored.
- sym.st_shndx = SHN_ABS;
- this->memory_.SetMemory(offset, &sym, sizeof(sym));
- // Clear the cache to force the symbol data to be re-read.
- symbols.ClearCache();
- ASSERT_FALSE(symbols.GetName<TypeParam>(0x5004, 0x1000, &this->memory_, &name, &func_offset));
-}
-
TYPED_TEST_P(SymbolsTest, symtab_value_out_of_bounds) {
Symbols symbols_end_at_100(0x1000, sizeof(TypeParam) * 2, sizeof(TypeParam), 0x2000, 0x100);
Symbols symbols_end_at_200(0x1000, sizeof(TypeParam) * 2, sizeof(TypeParam), 0x2000, 0x200);
@@ -265,18 +239,16 @@
std::string name;
uint64_t func_offset;
// Verify that we can get the function name properly for both entries.
- ASSERT_TRUE(symbols_end_at_200.GetName<TypeParam>(0x5000, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols_end_at_200.GetName<TypeParam>(0x5000, &this->memory_, &name, &func_offset));
ASSERT_EQ("fake_function", name);
ASSERT_EQ(0U, func_offset);
- ASSERT_TRUE(symbols_end_at_200.GetName<TypeParam>(0x3000, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols_end_at_200.GetName<TypeParam>(0x3000, &this->memory_, &name, &func_offset));
ASSERT_EQ("function", name);
ASSERT_EQ(0U, func_offset);
// Now use the symbol table that ends at 0x100.
- ASSERT_FALSE(
- symbols_end_at_100.GetName<TypeParam>(0x5000, 0, &this->memory_, &name, &func_offset));
- ASSERT_FALSE(
- symbols_end_at_100.GetName<TypeParam>(0x3000, 0, &this->memory_, &name, &func_offset));
+ ASSERT_FALSE(symbols_end_at_100.GetName<TypeParam>(0x5000, &this->memory_, &name, &func_offset));
+ ASSERT_FALSE(symbols_end_at_100.GetName<TypeParam>(0x3000, &this->memory_, &name, &func_offset));
}
// Verify the entire func table is cached.
@@ -302,9 +274,9 @@
// Do call that should cache all of the entries (except the string data).
std::string name;
uint64_t func_offset;
- ASSERT_FALSE(symbols.GetName<TypeParam>(0x6000, 0, &this->memory_, &name, &func_offset));
+ ASSERT_FALSE(symbols.GetName<TypeParam>(0x6000, &this->memory_, &name, &func_offset));
this->memory_.Clear();
- ASSERT_FALSE(symbols.GetName<TypeParam>(0x6000, 0, &this->memory_, &name, &func_offset));
+ ASSERT_FALSE(symbols.GetName<TypeParam>(0x6000, &this->memory_, &name, &func_offset));
// Clear the memory and only put the symbol data string data in memory.
this->memory_.Clear();
@@ -317,15 +289,15 @@
fake_name = "third_entry";
this->memory_.SetMemory(0xa300, fake_name.c_str(), fake_name.size() + 1);
- ASSERT_TRUE(symbols.GetName<TypeParam>(0x5001, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0x5001, &this->memory_, &name, &func_offset));
ASSERT_EQ("first_entry", name);
ASSERT_EQ(1U, func_offset);
- ASSERT_TRUE(symbols.GetName<TypeParam>(0x2002, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0x2002, &this->memory_, &name, &func_offset));
ASSERT_EQ("second_entry", name);
ASSERT_EQ(2U, func_offset);
- ASSERT_TRUE(symbols.GetName<TypeParam>(0x1003, 0, &this->memory_, &name, &func_offset));
+ ASSERT_TRUE(symbols.GetName<TypeParam>(0x1003, &this->memory_, &name, &func_offset));
ASSERT_EQ("third_entry", name);
ASSERT_EQ(3U, func_offset);
}
@@ -381,17 +353,17 @@
EXPECT_FALSE(symbols.GetGlobal<TypeParam>(&this->memory_, "function_1", &offset));
std::string name;
- EXPECT_TRUE(symbols.GetName<TypeParam>(0x10002, 0, &this->memory_, &name, &offset));
+ EXPECT_TRUE(symbols.GetName<TypeParam>(0x10002, &this->memory_, &name, &offset));
EXPECT_EQ("function_0", name);
EXPECT_EQ(2U, offset);
- EXPECT_TRUE(symbols.GetName<TypeParam>(0x12004, 0, &this->memory_, &name, &offset));
+ EXPECT_TRUE(symbols.GetName<TypeParam>(0x12004, &this->memory_, &name, &offset));
EXPECT_EQ("function_1", name);
EXPECT_EQ(4U, offset);
}
REGISTER_TYPED_TEST_CASE_P(SymbolsTest, function_bounds_check, no_symbol, multiple_entries,
- multiple_entries_nonstandard_size, load_bias, symtab_value_out_of_bounds,
+ multiple_entries_nonstandard_size, symtab_value_out_of_bounds,
symtab_read_cached, get_global);
typedef ::testing::Types<Elf32_Sym, Elf64_Sym> SymbolsTestTypes;
diff --git a/libunwindstack/tests/UnwindOfflineTest.cpp b/libunwindstack/tests/UnwindOfflineTest.cpp
index 285fc9e..a65c077 100644
--- a/libunwindstack/tests/UnwindOfflineTest.cpp
+++ b/libunwindstack/tests/UnwindOfflineTest.cpp
@@ -1200,4 +1200,43 @@
EXPECT_EQ(0xffcc1558U, unwinder.frames()[18].sp);
}
+// Test using a non-zero load bias library that has the fde entries
+// encoded as 0xb, which is not set as pc relative.
+TEST_F(UnwindOfflineTest, debug_frame_load_bias_arm) {
+ ASSERT_NO_FATAL_FAILURE(Init("debug_frame_load_bias_arm/", ARCH_ARM));
+
+ Unwinder unwinder(128, maps_.get(), regs_.get(), process_memory_);
+ unwinder.Unwind();
+
+ std::string frame_info(DumpFrames(unwinder));
+ ASSERT_EQ(8U, unwinder.NumFrames()) << "Unwind:\n" << frame_info;
+ EXPECT_EQ(
+ " #00 pc 0005138c libc.so (__ioctl+8)\n"
+ " #01 pc 0002140f libc.so (ioctl+30)\n"
+ " #02 pc 00039535 libbinder.so (_ZN7android14IPCThreadState14talkWithDriverEb+204)\n"
+ " #03 pc 00039633 libbinder.so (_ZN7android14IPCThreadState20getAndExecuteCommandEv+10)\n"
+ " #04 pc 00039b57 libbinder.so (_ZN7android14IPCThreadState14joinThreadPoolEb+38)\n"
+ " #05 pc 00000c21 mediaserver (main+104)\n"
+ " #06 pc 00084b89 libc.so (__libc_init+48)\n"
+ " #07 pc 00000b77 mediaserver (_start_main+38)\n",
+ frame_info);
+
+ EXPECT_EQ(0xf0be238cU, unwinder.frames()[0].pc);
+ EXPECT_EQ(0xffd4a638U, unwinder.frames()[0].sp);
+ EXPECT_EQ(0xf0bb240fU, unwinder.frames()[1].pc);
+ EXPECT_EQ(0xffd4a638U, unwinder.frames()[1].sp);
+ EXPECT_EQ(0xf1a75535U, unwinder.frames()[2].pc);
+ EXPECT_EQ(0xffd4a650U, unwinder.frames()[2].sp);
+ EXPECT_EQ(0xf1a75633U, unwinder.frames()[3].pc);
+ EXPECT_EQ(0xffd4a6b0U, unwinder.frames()[3].sp);
+ EXPECT_EQ(0xf1a75b57U, unwinder.frames()[4].pc);
+ EXPECT_EQ(0xffd4a6d0U, unwinder.frames()[4].sp);
+ EXPECT_EQ(0x8d1cc21U, unwinder.frames()[5].pc);
+ EXPECT_EQ(0xffd4a6e8U, unwinder.frames()[5].sp);
+ EXPECT_EQ(0xf0c15b89U, unwinder.frames()[6].pc);
+ EXPECT_EQ(0xffd4a700U, unwinder.frames()[6].sp);
+ EXPECT_EQ(0x8d1cb77U, unwinder.frames()[7].pc);
+ EXPECT_EQ(0xffd4a718U, unwinder.frames()[7].sp);
+}
+
} // namespace unwindstack
diff --git a/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/libbinder.so b/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/libbinder.so
new file mode 100644
index 0000000..4b7bf44
--- /dev/null
+++ b/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/libbinder.so
Binary files differ
diff --git a/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/libc.so b/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/libc.so
new file mode 100644
index 0000000..013858e
--- /dev/null
+++ b/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/libc.so
Binary files differ
diff --git a/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/maps.txt b/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/maps.txt
new file mode 100644
index 0000000..10f1325
--- /dev/null
+++ b/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/maps.txt
@@ -0,0 +1,3 @@
+8d1c000-8d1f000 r-xp 0 00:00 0 mediaserver
+f0b91000-f0c2c000 r-xp 0 00:00 0 libc.so
+f1a41000-f1a97000 r-xp 0 00:00 0 libbinder.so
diff --git a/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/mediaserver b/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/mediaserver
new file mode 100644
index 0000000..9e4a83f
--- /dev/null
+++ b/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/mediaserver
Binary files differ
diff --git a/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/regs.txt b/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/regs.txt
new file mode 100644
index 0000000..f147247
--- /dev/null
+++ b/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/regs.txt
@@ -0,0 +1,16 @@
+r0: 3
+r1: c0306201
+r2: ffd4a658
+r3: 0
+r4: f0c36d8c
+r5: ffd4a658
+r6: f0168000
+r7: 36
+r8: ffd4a678
+r9: f016802c
+r10: ffd4a660
+r11: 0
+ip: 0
+sp: ffd4a638
+lr: f0bb2413
+pc: f0be238c
diff --git a/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/stack.data b/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/stack.data
new file mode 100644
index 0000000..847c819
--- /dev/null
+++ b/libunwindstack/tests/files/offline/debug_frame_load_bias_arm/stack.data
Binary files differ