Change the GetAdjustedRelPc to GetPcAdjustment.
This cleans up a bit of the Unwinder code to make it clear what's
going on.
Modify the offline unit tests to verify the pc and sp to make sure
that those values get computed correctly.
Test: Passes unit tests.
Test: Passes 137-cfi art tests.
Change-Id: I0787a1d77b8726d3defd08f31c7476f6798f8d0d
diff --git a/libunwindstack/RegsArm.cpp b/libunwindstack/RegsArm.cpp
index 7f16146..5502ce1 100644
--- a/libunwindstack/RegsArm.cpp
+++ b/libunwindstack/RegsArm.cpp
@@ -35,26 +35,25 @@
return ARCH_ARM;
}
-uint64_t RegsArm::GetAdjustedPc(uint64_t rel_pc, Elf* elf) {
+uint64_t RegsArm::GetPcAdjustment(uint64_t rel_pc, Elf* elf) {
uint64_t load_bias = elf->GetLoadBias();
if (rel_pc < load_bias) {
- return rel_pc;
+ return 0;
}
uint64_t adjusted_rel_pc = rel_pc - load_bias;
-
if (adjusted_rel_pc < 5) {
- return rel_pc;
+ return 0;
}
if (adjusted_rel_pc & 1) {
// This is a thumb instruction, it could be 2 or 4 bytes.
uint32_t value;
- if (rel_pc < 5 || !elf->memory()->ReadFully(adjusted_rel_pc - 5, &value, sizeof(value)) ||
+ if (!elf->memory()->ReadFully(adjusted_rel_pc - 5, &value, sizeof(value)) ||
(value & 0xe000f000) != 0xe000f000) {
- return rel_pc - 2;
+ return 2;
}
}
- return rel_pc - 4;
+ return 4;
}
void RegsArm::SetFromRaw() {