diff options
| author | Christopher Ferris <cferris@google.com> | 2018-02-21 15:39:07 -0800 |
|---|---|---|
| committer | Christopher Ferris <cferris@google.com> | 2018-02-21 20:16:39 -0800 |
| commit | a2ec50bf57c9dba78459ef011cd13f8525ea57b4 (patch) | |
| tree | ace0f0bd418003176089db54641bd11f00c08244 /libunwindstack | |
| parent | 2733708cfb2ed041e0a82593eeaae5b48ca44a66 (diff) | |
| download | system_core-a2ec50bf57c9dba78459ef011cd13f8525ea57b4.tar.gz system_core-a2ec50bf57c9dba78459ef011cd13f8525ea57b4.tar.bz2 system_core-a2ec50bf57c9dba78459ef011cd13f8525ea57b4.zip | |
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
Diffstat (limited to 'libunwindstack')
| -rw-r--r-- | libunwindstack/RegsArm.cpp | 13 | ||||
| -rw-r--r-- | libunwindstack/RegsArm64.cpp | 12 | ||||
| -rw-r--r-- | libunwindstack/RegsMips.cpp | 14 | ||||
| -rw-r--r-- | libunwindstack/RegsMips64.cpp | 14 | ||||
| -rw-r--r-- | libunwindstack/RegsX86.cpp | 10 | ||||
| -rw-r--r-- | libunwindstack/RegsX86_64.cpp | 11 | ||||
| -rw-r--r-- | libunwindstack/Unwinder.cpp | 32 | ||||
| -rw-r--r-- | libunwindstack/include/unwindstack/Regs.h | 2 | ||||
| -rw-r--r-- | libunwindstack/include/unwindstack/RegsArm.h | 2 | ||||
| -rw-r--r-- | libunwindstack/include/unwindstack/RegsArm64.h | 2 | ||||
| -rw-r--r-- | libunwindstack/include/unwindstack/RegsMips.h | 2 | ||||
| -rw-r--r-- | libunwindstack/include/unwindstack/RegsMips64.h | 2 | ||||
| -rw-r--r-- | libunwindstack/include/unwindstack/RegsX86.h | 2 | ||||
| -rw-r--r-- | libunwindstack/include/unwindstack/RegsX86_64.h | 2 | ||||
| -rw-r--r-- | libunwindstack/include/unwindstack/Unwinder.h | 3 | ||||
| -rw-r--r-- | libunwindstack/tests/RegsFake.h | 4 | ||||
| -rw-r--r-- | libunwindstack/tests/RegsTest.cpp | 114 | ||||
| -rw-r--r-- | libunwindstack/tests/UnwindOfflineTest.cpp | 344 |
18 files changed, 453 insertions, 132 deletions
diff --git a/libunwindstack/RegsArm.cpp b/libunwindstack/RegsArm.cpp index 7f1614690..5502ce1fe 100644 --- a/libunwindstack/RegsArm.cpp +++ b/libunwindstack/RegsArm.cpp @@ -35,26 +35,25 @@ ArchEnum RegsArm::Arch() { 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() { diff --git a/libunwindstack/RegsArm64.cpp b/libunwindstack/RegsArm64.cpp index d6b467ade..cc6f5ce87 100644 --- a/libunwindstack/RegsArm64.cpp +++ b/libunwindstack/RegsArm64.cpp @@ -35,15 +35,11 @@ ArchEnum RegsArm64::Arch() { return ARCH_ARM64; } -uint64_t RegsArm64::GetAdjustedPc(uint64_t rel_pc, Elf* elf) { - if (!elf->valid()) { - return rel_pc; +uint64_t RegsArm64::GetPcAdjustment(uint64_t rel_pc, Elf* elf) { + if (!elf->valid() || rel_pc < 4) { + return 0; } - - if (rel_pc < 4) { - return rel_pc; - } - return rel_pc - 4; + return 4; } void RegsArm64::SetFromRaw() { diff --git a/libunwindstack/RegsMips.cpp b/libunwindstack/RegsMips.cpp index 6751f52dd..5d20bef4a 100644 --- a/libunwindstack/RegsMips.cpp +++ b/libunwindstack/RegsMips.cpp @@ -35,16 +35,12 @@ ArchEnum RegsMips::Arch() { return ARCH_MIPS; } -uint64_t RegsMips::GetAdjustedPc(uint64_t rel_pc, Elf* elf) { - if (!elf->valid()) { - return rel_pc; +uint64_t RegsMips::GetPcAdjustment(uint64_t rel_pc, Elf* elf) { + if (!elf->valid() || rel_pc < 8) { + return 0; } - - // For now, just assuming no compact branches - if (rel_pc < 8) { - return rel_pc; - } - return rel_pc - 8; + // For now, just assume no compact branches + return 8; } void RegsMips::SetFromRaw() { diff --git a/libunwindstack/RegsMips64.cpp b/libunwindstack/RegsMips64.cpp index 97082bd9d..4a03538e2 100644 --- a/libunwindstack/RegsMips64.cpp +++ b/libunwindstack/RegsMips64.cpp @@ -36,16 +36,12 @@ ArchEnum RegsMips64::Arch() { return ARCH_MIPS64; } -uint64_t RegsMips64::GetAdjustedPc(uint64_t rel_pc, Elf* elf) { - if (!elf->valid()) { - return rel_pc; +uint64_t RegsMips64::GetPcAdjustment(uint64_t rel_pc, Elf* elf) { + if (!elf->valid() || rel_pc < 8) { + return 0; } - - // For now, just assuming no compact branches - if (rel_pc < 8) { - return rel_pc; - } - return rel_pc - 8; + // For now, just assume no compact branches + return 8; } void RegsMips64::SetFromRaw() { diff --git a/libunwindstack/RegsX86.cpp b/libunwindstack/RegsX86.cpp index 27476b7cb..573cb2382 100644 --- a/libunwindstack/RegsX86.cpp +++ b/libunwindstack/RegsX86.cpp @@ -35,15 +35,11 @@ ArchEnum RegsX86::Arch() { return ARCH_X86; } -uint64_t RegsX86::GetAdjustedPc(uint64_t rel_pc, Elf* elf) { - if (!elf->valid()) { - return rel_pc; - } - - if (rel_pc == 0) { +uint64_t RegsX86::GetPcAdjustment(uint64_t rel_pc, Elf* elf) { + if (!elf->valid() || rel_pc == 0) { return 0; } - return rel_pc - 1; + return 1; } void RegsX86::SetFromRaw() { diff --git a/libunwindstack/RegsX86_64.cpp b/libunwindstack/RegsX86_64.cpp index 0f66943aa..3175a90c2 100644 --- a/libunwindstack/RegsX86_64.cpp +++ b/libunwindstack/RegsX86_64.cpp @@ -35,16 +35,11 @@ ArchEnum RegsX86_64::Arch() { return ARCH_X86_64; } -uint64_t RegsX86_64::GetAdjustedPc(uint64_t rel_pc, Elf* elf) { - if (!elf->valid()) { - return rel_pc; - } - - if (rel_pc == 0) { +uint64_t RegsX86_64::GetPcAdjustment(uint64_t rel_pc, Elf* elf) { + if (!elf->valid() || rel_pc == 0) { return 0; } - - return rel_pc - 1; + return 1; } void RegsX86_64::SetFromRaw() { diff --git a/libunwindstack/Unwinder.cpp b/libunwindstack/Unwinder.cpp index 5a4f5e04c..7da699441 100644 --- a/libunwindstack/Unwinder.cpp +++ b/libunwindstack/Unwinder.cpp @@ -83,20 +83,20 @@ void Unwinder::FillInDexFrame() { #endif } -void Unwinder::FillInFrame(MapInfo* map_info, Elf* elf, uint64_t adjusted_rel_pc, uint64_t func_pc) { +void Unwinder::FillInFrame(MapInfo* map_info, Elf* elf, uint64_t rel_pc, uint64_t func_pc, + uint64_t pc_adjustment) { size_t frame_num = frames_.size(); frames_.resize(frame_num + 1); FrameData* frame = &frames_.at(frame_num); frame->num = frame_num; frame->sp = regs_->sp(); - frame->rel_pc = adjusted_rel_pc; + frame->rel_pc = rel_pc - pc_adjustment; + frame->pc = regs_->pc() - pc_adjustment; if (map_info == nullptr) { - frame->pc = regs_->pc(); return; } - frame->pc = map_info->start + adjusted_rel_pc - elf->GetLoadBias() - map_info->elf_offset; frame->map_name = map_info->name; frame->map_offset = map_info->offset; frame->map_start = map_info->start; @@ -140,13 +140,12 @@ void Unwinder::Unwind(const std::vector<std::string>* initial_map_names_to_skip, MapInfo* map_info = maps_->Find(regs_->pc()); uint64_t rel_pc; - uint64_t adjusted_pc; - uint64_t adjusted_rel_pc; + uint64_t pc_adjustment = 0; + uint64_t step_pc; Elf* elf; if (map_info == nullptr) { rel_pc = regs_->pc(); - adjusted_rel_pc = rel_pc; - adjusted_pc = rel_pc; + step_pc = rel_pc; last_error_.code = ERROR_INVALID_MAP; } else { if (ShouldStop(map_suffixes_to_ignore, map_info->name)) { @@ -155,21 +154,20 @@ void Unwinder::Unwind(const std::vector<std::string>* initial_map_names_to_skip, elf = map_info->GetElf(process_memory_, true); rel_pc = elf->GetRelPc(regs_->pc(), map_info); if (adjust_pc) { - adjusted_pc = regs_->GetAdjustedPc(rel_pc, elf); + pc_adjustment = regs_->GetPcAdjustment(rel_pc, elf); } else { - adjusted_pc = rel_pc; + pc_adjustment = 0; } - adjusted_rel_pc = adjusted_pc; + step_pc = rel_pc - pc_adjustment; // If the pc is in an invalid elf file, try and get an Elf object // using the jit debug information. if (!elf->valid() && jit_debug_ != nullptr) { - uint64_t adjusted_jit_pc = regs_->pc() - (rel_pc - adjusted_pc); + uint64_t adjusted_jit_pc = regs_->pc() - pc_adjustment; Elf* jit_elf = jit_debug_->GetElf(maps_, adjusted_jit_pc); if (jit_elf != nullptr) { // The jit debug information requires a non relative adjusted pc. - adjusted_pc = adjusted_jit_pc; - adjusted_rel_pc = adjusted_pc - map_info->start; + step_pc = adjusted_jit_pc; elf = jit_elf; } } @@ -185,7 +183,7 @@ void Unwinder::Unwind(const std::vector<std::string>* initial_map_names_to_skip, regs_->set_dex_pc(0); } - FillInFrame(map_info, elf, adjusted_rel_pc, adjusted_pc); + FillInFrame(map_info, elf, rel_pc, step_pc, pc_adjustment); // Once a frame is added, stop skipping frames. initial_map_names_to_skip = nullptr; @@ -213,8 +211,8 @@ void Unwinder::Unwind(const std::vector<std::string>* initial_map_names_to_skip, in_device_map = true; } else { bool finished; - stepped = elf->Step(rel_pc, adjusted_pc, map_info->elf_offset, regs_, - process_memory_.get(), &finished); + stepped = elf->Step(rel_pc, step_pc, map_info->elf_offset, regs_, process_memory_.get(), + &finished); elf->GetLastError(&last_error_); if (stepped && finished) { break; diff --git a/libunwindstack/include/unwindstack/Regs.h b/libunwindstack/include/unwindstack/Regs.h index a5ba7a078..b0e7ea152 100644 --- a/libunwindstack/include/unwindstack/Regs.h +++ b/libunwindstack/include/unwindstack/Regs.h @@ -60,7 +60,7 @@ class Regs { uint64_t dex_pc() { return dex_pc_; } void set_dex_pc(uint64_t dex_pc) { dex_pc_ = dex_pc; } - virtual uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) = 0; + virtual uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) = 0; virtual bool StepIfSignalHandler(uint64_t rel_pc, Elf* elf, Memory* process_memory) = 0; diff --git a/libunwindstack/include/unwindstack/RegsArm.h b/libunwindstack/include/unwindstack/RegsArm.h index b5d344be6..5af90d3f5 100644 --- a/libunwindstack/include/unwindstack/RegsArm.h +++ b/libunwindstack/include/unwindstack/RegsArm.h @@ -36,7 +36,7 @@ class RegsArm : public RegsImpl<uint32_t> { virtual ArchEnum Arch() override final; - uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override; + uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override; void SetFromRaw() override; diff --git a/libunwindstack/include/unwindstack/RegsArm64.h b/libunwindstack/include/unwindstack/RegsArm64.h index 30e626ccf..cb05732ee 100644 --- a/libunwindstack/include/unwindstack/RegsArm64.h +++ b/libunwindstack/include/unwindstack/RegsArm64.h @@ -36,7 +36,7 @@ class RegsArm64 : public RegsImpl<uint64_t> { virtual ArchEnum Arch() override final; - uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override; + uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override; void SetFromRaw() override; diff --git a/libunwindstack/include/unwindstack/RegsMips.h b/libunwindstack/include/unwindstack/RegsMips.h index 3fe6a9f7f..8e3c01f20 100644 --- a/libunwindstack/include/unwindstack/RegsMips.h +++ b/libunwindstack/include/unwindstack/RegsMips.h @@ -36,7 +36,7 @@ class RegsMips : public RegsImpl<uint32_t> { virtual ArchEnum Arch() override final; - uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override; + uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override; void SetFromRaw() override; diff --git a/libunwindstack/include/unwindstack/RegsMips64.h b/libunwindstack/include/unwindstack/RegsMips64.h index 6b4bcdf92..8c2d4437f 100644 --- a/libunwindstack/include/unwindstack/RegsMips64.h +++ b/libunwindstack/include/unwindstack/RegsMips64.h @@ -36,7 +36,7 @@ class RegsMips64 : public RegsImpl<uint64_t> { virtual ArchEnum Arch() override final; - uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override; + uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override; void SetFromRaw() override; diff --git a/libunwindstack/include/unwindstack/RegsX86.h b/libunwindstack/include/unwindstack/RegsX86.h index a695bbfbb..1bc145d97 100644 --- a/libunwindstack/include/unwindstack/RegsX86.h +++ b/libunwindstack/include/unwindstack/RegsX86.h @@ -37,7 +37,7 @@ class RegsX86 : public RegsImpl<uint32_t> { virtual ArchEnum Arch() override final; - uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override; + uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override; void SetFromRaw() override; diff --git a/libunwindstack/include/unwindstack/RegsX86_64.h b/libunwindstack/include/unwindstack/RegsX86_64.h index 23a3f2077..4cd45d4b9 100644 --- a/libunwindstack/include/unwindstack/RegsX86_64.h +++ b/libunwindstack/include/unwindstack/RegsX86_64.h @@ -37,7 +37,7 @@ class RegsX86_64 : public RegsImpl<uint64_t> { virtual ArchEnum Arch() override final; - uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override; + uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override; void SetFromRaw() override; diff --git a/libunwindstack/include/unwindstack/Unwinder.h b/libunwindstack/include/unwindstack/Unwinder.h index 5770c1a97..56b058156 100644 --- a/libunwindstack/include/unwindstack/Unwinder.h +++ b/libunwindstack/include/unwindstack/Unwinder.h @@ -88,7 +88,8 @@ class Unwinder { private: void FillInDexFrame(); - void FillInFrame(MapInfo* map_info, Elf* elf, uint64_t adjusted_rel_pc, uint64_t adjusted_pc); + void FillInFrame(MapInfo* map_info, Elf* elf, uint64_t rel_pc, uint64_t func_pc, + uint64_t pc_adjustment); size_t max_frames_; Maps* maps_; diff --git a/libunwindstack/tests/RegsFake.h b/libunwindstack/tests/RegsFake.h index cd7f2ff2b..ab23194e5 100644 --- a/libunwindstack/tests/RegsFake.h +++ b/libunwindstack/tests/RegsFake.h @@ -47,7 +47,7 @@ class RegsFake : public Regs { bool Is32Bit() { return false; } - uint64_t GetAdjustedPc(uint64_t rel_pc, Elf*) override { return rel_pc - 2; } + uint64_t GetPcAdjustment(uint64_t, Elf*) override { return 2; } bool StepIfSignalHandler(uint64_t, Elf*, Memory*) override { return false; } @@ -77,7 +77,7 @@ class RegsImplFake : public RegsImpl<TypeParam> { ArchEnum Arch() override { return ARCH_UNKNOWN; } - uint64_t GetAdjustedPc(uint64_t, Elf*) override { return 0; } + uint64_t GetPcAdjustment(uint64_t, Elf*) override { return 0; } void SetFromRaw() override {} bool SetPcFromReturnAddress(Memory*) override { return false; } bool StepIfSignalHandler(uint64_t, Elf*, Memory*) override { return false; } diff --git a/libunwindstack/tests/RegsTest.cpp b/libunwindstack/tests/RegsTest.cpp index 7c063739d..8b2f6c83f 100644 --- a/libunwindstack/tests/RegsTest.cpp +++ b/libunwindstack/tests/RegsTest.cpp @@ -96,48 +96,48 @@ TEST_F(RegsTest, regs64) { TEST_F(RegsTest, rel_pc) { RegsArm64 arm64; - ASSERT_EQ(0xcU, arm64.GetAdjustedPc(0x10, elf_.get())); - ASSERT_EQ(0x0U, arm64.GetAdjustedPc(0x4, elf_.get())); - ASSERT_EQ(0x3U, arm64.GetAdjustedPc(0x3, elf_.get())); - ASSERT_EQ(0x2U, arm64.GetAdjustedPc(0x2, elf_.get())); - ASSERT_EQ(0x1U, arm64.GetAdjustedPc(0x1, elf_.get())); - ASSERT_EQ(0x0U, arm64.GetAdjustedPc(0x0, elf_.get())); + ASSERT_EQ(4U, arm64.GetPcAdjustment(0x10, elf_.get())); + ASSERT_EQ(4U, arm64.GetPcAdjustment(0x4, elf_.get())); + ASSERT_EQ(0U, arm64.GetPcAdjustment(0x3, elf_.get())); + ASSERT_EQ(0U, arm64.GetPcAdjustment(0x2, elf_.get())); + ASSERT_EQ(0U, arm64.GetPcAdjustment(0x1, elf_.get())); + ASSERT_EQ(0U, arm64.GetPcAdjustment(0x0, elf_.get())); RegsX86 x86; - ASSERT_EQ(0xffU, x86.GetAdjustedPc(0x100, elf_.get())); - ASSERT_EQ(0x1U, x86.GetAdjustedPc(0x2, elf_.get())); - ASSERT_EQ(0x0U, x86.GetAdjustedPc(0x1, elf_.get())); - ASSERT_EQ(0x0U, x86.GetAdjustedPc(0x0, elf_.get())); + ASSERT_EQ(1U, x86.GetPcAdjustment(0x100, elf_.get())); + ASSERT_EQ(1U, x86.GetPcAdjustment(0x2, elf_.get())); + ASSERT_EQ(1U, x86.GetPcAdjustment(0x1, elf_.get())); + ASSERT_EQ(0U, x86.GetPcAdjustment(0x0, elf_.get())); RegsX86_64 x86_64; - ASSERT_EQ(0xffU, x86_64.GetAdjustedPc(0x100, elf_.get())); - ASSERT_EQ(0x1U, x86_64.GetAdjustedPc(0x2, elf_.get())); - ASSERT_EQ(0x0U, x86_64.GetAdjustedPc(0x1, elf_.get())); - ASSERT_EQ(0x0U, x86_64.GetAdjustedPc(0x0, elf_.get())); + ASSERT_EQ(1U, x86_64.GetPcAdjustment(0x100, elf_.get())); + ASSERT_EQ(1U, x86_64.GetPcAdjustment(0x2, elf_.get())); + ASSERT_EQ(1U, x86_64.GetPcAdjustment(0x1, elf_.get())); + ASSERT_EQ(0U, x86_64.GetPcAdjustment(0x0, elf_.get())); RegsMips mips; - ASSERT_EQ(0x8U, mips.GetAdjustedPc(0x10, elf_.get())); - ASSERT_EQ(0x0U, mips.GetAdjustedPc(0x8, elf_.get())); - ASSERT_EQ(0x7U, mips.GetAdjustedPc(0x7, elf_.get())); - ASSERT_EQ(0x6U, mips.GetAdjustedPc(0x6, elf_.get())); - ASSERT_EQ(0x5U, mips.GetAdjustedPc(0x5, elf_.get())); - ASSERT_EQ(0x4U, mips.GetAdjustedPc(0x4, elf_.get())); - ASSERT_EQ(0x3U, mips.GetAdjustedPc(0x3, elf_.get())); - ASSERT_EQ(0x2U, mips.GetAdjustedPc(0x2, elf_.get())); - ASSERT_EQ(0x1U, mips.GetAdjustedPc(0x1, elf_.get())); - ASSERT_EQ(0x0U, mips.GetAdjustedPc(0x0, elf_.get())); + ASSERT_EQ(8U, mips.GetPcAdjustment(0x10, elf_.get())); + ASSERT_EQ(8U, mips.GetPcAdjustment(0x8, elf_.get())); + ASSERT_EQ(0U, mips.GetPcAdjustment(0x7, elf_.get())); + ASSERT_EQ(0U, mips.GetPcAdjustment(0x6, elf_.get())); + ASSERT_EQ(0U, mips.GetPcAdjustment(0x5, elf_.get())); + ASSERT_EQ(0U, mips.GetPcAdjustment(0x4, elf_.get())); + ASSERT_EQ(0U, mips.GetPcAdjustment(0x3, elf_.get())); + ASSERT_EQ(0U, mips.GetPcAdjustment(0x2, elf_.get())); + ASSERT_EQ(0U, mips.GetPcAdjustment(0x1, elf_.get())); + ASSERT_EQ(0U, mips.GetPcAdjustment(0x0, elf_.get())); RegsMips64 mips64; - ASSERT_EQ(0x8U, mips64.GetAdjustedPc(0x10, elf_.get())); - ASSERT_EQ(0x0U, mips64.GetAdjustedPc(0x8, elf_.get())); - ASSERT_EQ(0x7U, mips64.GetAdjustedPc(0x7, elf_.get())); - ASSERT_EQ(0x6U, mips64.GetAdjustedPc(0x6, elf_.get())); - ASSERT_EQ(0x5U, mips64.GetAdjustedPc(0x5, elf_.get())); - ASSERT_EQ(0x4U, mips64.GetAdjustedPc(0x4, elf_.get())); - ASSERT_EQ(0x3U, mips64.GetAdjustedPc(0x3, elf_.get())); - ASSERT_EQ(0x2U, mips64.GetAdjustedPc(0x2, elf_.get())); - ASSERT_EQ(0x1U, mips64.GetAdjustedPc(0x1, elf_.get())); - ASSERT_EQ(0x0U, mips64.GetAdjustedPc(0x0, elf_.get())); + ASSERT_EQ(8U, mips64.GetPcAdjustment(0x10, elf_.get())); + ASSERT_EQ(8U, mips64.GetPcAdjustment(0x8, elf_.get())); + ASSERT_EQ(0U, mips64.GetPcAdjustment(0x7, elf_.get())); + ASSERT_EQ(0U, mips64.GetPcAdjustment(0x6, elf_.get())); + ASSERT_EQ(0U, mips64.GetPcAdjustment(0x5, elf_.get())); + ASSERT_EQ(0U, mips64.GetPcAdjustment(0x4, elf_.get())); + ASSERT_EQ(0U, mips64.GetPcAdjustment(0x3, elf_.get())); + ASSERT_EQ(0U, mips64.GetPcAdjustment(0x2, elf_.get())); + ASSERT_EQ(0U, mips64.GetPcAdjustment(0x1, elf_.get())); + ASSERT_EQ(0U, mips64.GetPcAdjustment(0x0, elf_.get())); } TEST_F(RegsTest, rel_pc_arm) { @@ -145,34 +145,34 @@ TEST_F(RegsTest, rel_pc_arm) { // Check fence posts. elf_->FakeSetLoadBias(0); - ASSERT_EQ(3U, arm.GetAdjustedPc(0x5, elf_.get())); - ASSERT_EQ(4U, arm.GetAdjustedPc(0x4, elf_.get())); - ASSERT_EQ(3U, arm.GetAdjustedPc(0x3, elf_.get())); - ASSERT_EQ(2U, arm.GetAdjustedPc(0x2, elf_.get())); - ASSERT_EQ(1U, arm.GetAdjustedPc(0x1, elf_.get())); - ASSERT_EQ(0U, arm.GetAdjustedPc(0x0, elf_.get())); + ASSERT_EQ(2U, arm.GetPcAdjustment(0x5, elf_.get())); + ASSERT_EQ(0U, arm.GetPcAdjustment(0x4, elf_.get())); + ASSERT_EQ(0U, arm.GetPcAdjustment(0x3, elf_.get())); + ASSERT_EQ(0U, arm.GetPcAdjustment(0x2, elf_.get())); + ASSERT_EQ(0U, arm.GetPcAdjustment(0x1, elf_.get())); + ASSERT_EQ(0U, arm.GetPcAdjustment(0x0, elf_.get())); elf_->FakeSetLoadBias(0x100); - ASSERT_EQ(0xffU, arm.GetAdjustedPc(0xff, elf_.get())); - ASSERT_EQ(0x103U, arm.GetAdjustedPc(0x105, elf_.get())); - ASSERT_EQ(0x104U, arm.GetAdjustedPc(0x104, elf_.get())); - ASSERT_EQ(0x103U, arm.GetAdjustedPc(0x103, elf_.get())); - ASSERT_EQ(0x102U, arm.GetAdjustedPc(0x102, elf_.get())); - ASSERT_EQ(0x101U, arm.GetAdjustedPc(0x101, elf_.get())); - ASSERT_EQ(0x100U, arm.GetAdjustedPc(0x100, elf_.get())); + ASSERT_EQ(0U, arm.GetPcAdjustment(0xff, elf_.get())); + ASSERT_EQ(2U, arm.GetPcAdjustment(0x105, elf_.get())); + ASSERT_EQ(0U, arm.GetPcAdjustment(0x104, elf_.get())); + ASSERT_EQ(0U, arm.GetPcAdjustment(0x103, elf_.get())); + ASSERT_EQ(0U, arm.GetPcAdjustment(0x102, elf_.get())); + ASSERT_EQ(0U, arm.GetPcAdjustment(0x101, elf_.get())); + ASSERT_EQ(0U, arm.GetPcAdjustment(0x100, elf_.get())); // Check thumb instructions handling. elf_->FakeSetLoadBias(0); memory_->SetData32(0x2000, 0); - ASSERT_EQ(0x2003U, arm.GetAdjustedPc(0x2005, elf_.get())); + ASSERT_EQ(2U, arm.GetPcAdjustment(0x2005, elf_.get())); memory_->SetData32(0x2000, 0xe000f000); - ASSERT_EQ(0x2001U, arm.GetAdjustedPc(0x2005, elf_.get())); + ASSERT_EQ(4U, arm.GetPcAdjustment(0x2005, elf_.get())); elf_->FakeSetLoadBias(0x400); memory_->SetData32(0x2100, 0); - ASSERT_EQ(0x2503U, arm.GetAdjustedPc(0x2505, elf_.get())); + ASSERT_EQ(2U, arm.GetPcAdjustment(0x2505, elf_.get())); memory_->SetData32(0x2100, 0xf111f111); - ASSERT_EQ(0x2501U, arm.GetAdjustedPc(0x2505, elf_.get())); + ASSERT_EQ(4U, arm.GetPcAdjustment(0x2505, elf_.get())); } TEST_F(RegsTest, elf_invalid) { @@ -188,27 +188,27 @@ TEST_F(RegsTest, elf_invalid) { regs_arm.set_pc(0x1500); EXPECT_EQ(0x500U, invalid_elf->GetRelPc(regs_arm.pc(), &map_info)); - EXPECT_EQ(0x4fcU, regs_arm.GetAdjustedPc(0x500U, invalid_elf)); + EXPECT_EQ(4U, regs_arm.GetPcAdjustment(0x500U, invalid_elf)); regs_arm64.set_pc(0x1600); EXPECT_EQ(0x600U, invalid_elf->GetRelPc(regs_arm64.pc(), &map_info)); - EXPECT_EQ(0x600U, regs_arm64.GetAdjustedPc(0x600U, invalid_elf)); + EXPECT_EQ(0U, regs_arm64.GetPcAdjustment(0x600U, invalid_elf)); regs_x86.set_pc(0x1700); EXPECT_EQ(0x700U, invalid_elf->GetRelPc(regs_x86.pc(), &map_info)); - EXPECT_EQ(0x700U, regs_x86.GetAdjustedPc(0x700U, invalid_elf)); + EXPECT_EQ(0U, regs_x86.GetPcAdjustment(0x700U, invalid_elf)); regs_x86_64.set_pc(0x1800); EXPECT_EQ(0x800U, invalid_elf->GetRelPc(regs_x86_64.pc(), &map_info)); - EXPECT_EQ(0x800U, regs_x86_64.GetAdjustedPc(0x800U, invalid_elf)); + EXPECT_EQ(0U, regs_x86_64.GetPcAdjustment(0x800U, invalid_elf)); regs_mips.set_pc(0x1900); EXPECT_EQ(0x900U, invalid_elf->GetRelPc(regs_mips.pc(), &map_info)); - EXPECT_EQ(0x900U, regs_mips.GetAdjustedPc(0x900U, invalid_elf)); + EXPECT_EQ(0U, regs_mips.GetPcAdjustment(0x900U, invalid_elf)); regs_mips64.set_pc(0x1a00); EXPECT_EQ(0xa00U, invalid_elf->GetRelPc(regs_mips64.pc(), &map_info)); - EXPECT_EQ(0xa00U, regs_mips64.GetAdjustedPc(0xa00U, invalid_elf)); + EXPECT_EQ(0U, regs_mips64.GetPcAdjustment(0xa00U, invalid_elf)); } TEST_F(RegsTest, arm_set_from_raw) { diff --git a/libunwindstack/tests/UnwindOfflineTest.cpp b/libunwindstack/tests/UnwindOfflineTest.cpp index df262f525..af4a5b59e 100644 --- a/libunwindstack/tests/UnwindOfflineTest.cpp +++ b/libunwindstack/tests/UnwindOfflineTest.cpp @@ -193,6 +193,14 @@ TEST_F(UnwindOfflineTest, pc_straddle_arm) { " #02 pc 00007441 libbase.so (_ZN7android4base10LogMessageD2Ev+748)\n" " #03 pc 00015147 /does/not/exist/libhidlbase.so\n", frame_info); + EXPECT_EQ(0xf31ea9f8U, unwinder.frames()[0].pc); + EXPECT_EQ(0xe9c866f8U, unwinder.frames()[0].sp); + EXPECT_EQ(0xf2da0a1bU, unwinder.frames()[1].pc); + EXPECT_EQ(0xe9c86728U, unwinder.frames()[1].sp); + EXPECT_EQ(0xf2da1441U, unwinder.frames()[2].pc); + EXPECT_EQ(0xe9c86730U, unwinder.frames()[2].sp); + EXPECT_EQ(0xf3367147U, unwinder.frames()[3].pc); + EXPECT_EQ(0xe9c86778U, unwinder.frames()[3].sp); } TEST_F(UnwindOfflineTest, pc_in_gnu_debugdata_arm) { @@ -209,6 +217,10 @@ TEST_F(UnwindOfflineTest, pc_in_gnu_debugdata_arm) { " #01 pc 0006dce5 libandroid_runtime.so " "(_ZN7android14AndroidRuntime19javaCreateThreadEtcEPFiPvES1_PKcijPS1_)\n", frame_info); + EXPECT_EQ(0xf1f6dc49U, unwinder.frames()[0].pc); + EXPECT_EQ(0xd8fe6930U, unwinder.frames()[0].sp); + EXPECT_EQ(0xf1f6dce5U, unwinder.frames()[1].pc); + EXPECT_EQ(0xd8fe6958U, unwinder.frames()[1].sp); } TEST_F(UnwindOfflineTest, pc_straddle_arm64) { @@ -229,6 +241,18 @@ TEST_F(UnwindOfflineTest, pc_straddle_arm64) { "(_ZN11unwindstack37UnwindTest_remote_through_signal_Test8TestBodyEv+32)\n" " #05 pc 0000000000455d70 libunwindstack_test (_ZN7testing4Test3RunEv+392)\n", frame_info); + EXPECT_EQ(0x64d09d4fd8U, unwinder.frames()[0].pc); + EXPECT_EQ(0x7fe0d84040U, unwinder.frames()[0].sp); + EXPECT_EQ(0x64d09d5078U, unwinder.frames()[1].pc); + EXPECT_EQ(0x7fe0d84070U, unwinder.frames()[1].sp); + EXPECT_EQ(0x64d09d508cU, unwinder.frames()[2].pc); + EXPECT_EQ(0x7fe0d84080U, unwinder.frames()[2].sp); + EXPECT_EQ(0x64d09d88fcU, unwinder.frames()[3].pc); + EXPECT_EQ(0x7fe0d84090U, unwinder.frames()[3].sp); + EXPECT_EQ(0x64d09d88d8U, unwinder.frames()[4].pc); + EXPECT_EQ(0x7fe0d840f0U, unwinder.frames()[4].sp); + EXPECT_EQ(0x64d0a00d70U, unwinder.frames()[5].pc); + EXPECT_EQ(0x7fe0d84110U, unwinder.frames()[5].sp); } static void AddMemory(std::string file_name, MemoryOfflineParts* parts) { @@ -390,6 +414,144 @@ TEST_F(UnwindOfflineTest, jit_debug_x86) { " #67 pc 00001a80 dalvikvm32 (main+1312)\n" " #68 pc 00018275 libc.so\n", frame_info); + EXPECT_EQ(0xeb89bfb8U, unwinder.frames()[0].pc); + EXPECT_EQ(0xffeb5280U, unwinder.frames()[0].sp); + EXPECT_EQ(0xeb89af00U, unwinder.frames()[1].pc); + EXPECT_EQ(0xffeb52a0U, unwinder.frames()[1].sp); + EXPECT_EQ(0xec6061a8U, unwinder.frames()[2].pc); + EXPECT_EQ(0xffeb5ce0U, unwinder.frames()[2].sp); + EXPECT_EQ(0xee75be81U, unwinder.frames()[3].pc); + EXPECT_EQ(0xffeb5d30U, unwinder.frames()[3].sp); + EXPECT_EQ(0xf728e4d2U, unwinder.frames()[4].pc); + EXPECT_EQ(0xffeb5d60U, unwinder.frames()[4].sp); + EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[5].pc); + EXPECT_EQ(0xffeb5d80U, unwinder.frames()[5].sp); + EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[6].pc); + EXPECT_EQ(0xffeb5e20U, unwinder.frames()[6].sp); + EXPECT_EQ(0xf6f73552U, unwinder.frames()[7].pc); + EXPECT_EQ(0xffeb5ec0U, unwinder.frames()[7].sp); + EXPECT_EQ(0xf6f7499aU, unwinder.frames()[8].pc); + EXPECT_EQ(0xffeb5f40U, unwinder.frames()[8].sp); + EXPECT_EQ(0xf7265362U, unwinder.frames()[9].pc); + EXPECT_EQ(0xffeb5fb0U, unwinder.frames()[9].sp); + EXPECT_EQ(0xf72945bdU, unwinder.frames()[10].pc); + EXPECT_EQ(0xffeb6110U, unwinder.frames()[10].sp); + EXPECT_EQ(0xee75be04U, unwinder.frames()[11].pc); + EXPECT_EQ(0xffeb6160U, unwinder.frames()[11].sp); + EXPECT_EQ(0xf728e4d2U, unwinder.frames()[12].pc); + EXPECT_EQ(0xffeb6180U, unwinder.frames()[12].sp); + EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[13].pc); + EXPECT_EQ(0xffeb61b0U, unwinder.frames()[13].sp); + EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[14].pc); + EXPECT_EQ(0xffeb6250U, unwinder.frames()[14].sp); + EXPECT_EQ(0xf6f73552U, unwinder.frames()[15].pc); + EXPECT_EQ(0xffeb62f0U, unwinder.frames()[15].sp); + EXPECT_EQ(0xf6f7499aU, unwinder.frames()[16].pc); + EXPECT_EQ(0xffeb6370U, unwinder.frames()[16].sp); + EXPECT_EQ(0xf7265362U, unwinder.frames()[17].pc); + EXPECT_EQ(0xffeb63e0U, unwinder.frames()[17].sp); + EXPECT_EQ(0xf72945bdU, unwinder.frames()[18].pc); + EXPECT_EQ(0xffeb6530U, unwinder.frames()[18].sp); + EXPECT_EQ(0xee75bd3cU, unwinder.frames()[19].pc); + EXPECT_EQ(0xffeb6580U, unwinder.frames()[19].sp); + EXPECT_EQ(0xf728e4d2U, unwinder.frames()[20].pc); + EXPECT_EQ(0xffeb65b0U, unwinder.frames()[20].sp); + EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[21].pc); + EXPECT_EQ(0xffeb65e0U, unwinder.frames()[21].sp); + EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[22].pc); + EXPECT_EQ(0xffeb6680U, unwinder.frames()[22].sp); + EXPECT_EQ(0xf6f73552U, unwinder.frames()[23].pc); + EXPECT_EQ(0xffeb6720U, unwinder.frames()[23].sp); + EXPECT_EQ(0xf6f7499aU, unwinder.frames()[24].pc); + EXPECT_EQ(0xffeb67a0U, unwinder.frames()[24].sp); + EXPECT_EQ(0xf7265362U, unwinder.frames()[25].pc); + EXPECT_EQ(0xffeb6810U, unwinder.frames()[25].sp); + EXPECT_EQ(0xf72945bdU, unwinder.frames()[26].pc); + EXPECT_EQ(0xffeb6960U, unwinder.frames()[26].sp); + EXPECT_EQ(0xee75bbdcU, unwinder.frames()[27].pc); + EXPECT_EQ(0xffeb69b0U, unwinder.frames()[27].sp); + EXPECT_EQ(0xf728e6a2U, unwinder.frames()[28].pc); + EXPECT_EQ(0xffeb69f0U, unwinder.frames()[28].sp); + EXPECT_EQ(0xf6d27acbU, unwinder.frames()[29].pc); + EXPECT_EQ(0xffeb6a20U, unwinder.frames()[29].sp); + EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[30].pc); + EXPECT_EQ(0xffeb6ac0U, unwinder.frames()[30].sp); + EXPECT_EQ(0xf6f73552U, unwinder.frames()[31].pc); + EXPECT_EQ(0xffeb6b60U, unwinder.frames()[31].sp); + EXPECT_EQ(0xf6f7499aU, unwinder.frames()[32].pc); + EXPECT_EQ(0xffeb6be0U, unwinder.frames()[32].sp); + EXPECT_EQ(0xf7265362U, unwinder.frames()[33].pc); + EXPECT_EQ(0xffeb6c50U, unwinder.frames()[33].sp); + EXPECT_EQ(0xf72945bdU, unwinder.frames()[34].pc); + EXPECT_EQ(0xffeb6dd0U, unwinder.frames()[34].sp); + EXPECT_EQ(0xee75b625U, unwinder.frames()[35].pc); + EXPECT_EQ(0xffeb6e20U, unwinder.frames()[35].sp); + EXPECT_EQ(0xf728e4d2U, unwinder.frames()[36].pc); + EXPECT_EQ(0xffeb6e50U, unwinder.frames()[36].sp); + EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[37].pc); + EXPECT_EQ(0xffeb6e70U, unwinder.frames()[37].sp); + EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[38].pc); + EXPECT_EQ(0xffeb6f10U, unwinder.frames()[38].sp); + EXPECT_EQ(0xf6f73552U, unwinder.frames()[39].pc); + EXPECT_EQ(0xffeb6fb0U, unwinder.frames()[39].sp); + EXPECT_EQ(0xf6f7499aU, unwinder.frames()[40].pc); + EXPECT_EQ(0xffeb7030U, unwinder.frames()[40].sp); + EXPECT_EQ(0xf7265362U, unwinder.frames()[41].pc); + EXPECT_EQ(0xffeb70a0U, unwinder.frames()[41].sp); + EXPECT_EQ(0xf72945bdU, unwinder.frames()[42].pc); + EXPECT_EQ(0xffeb71f0U, unwinder.frames()[42].sp); + EXPECT_EQ(0xee75aedcU, unwinder.frames()[43].pc); + EXPECT_EQ(0xffeb7240U, unwinder.frames()[43].sp); + EXPECT_EQ(0xf728e4d2U, unwinder.frames()[44].pc); + EXPECT_EQ(0xffeb72a0U, unwinder.frames()[44].sp); + EXPECT_EQ(0xf6d27ab5U, unwinder.frames()[45].pc); + EXPECT_EQ(0xffeb72c0U, unwinder.frames()[45].sp); + EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[46].pc); + EXPECT_EQ(0xffeb7360U, unwinder.frames()[46].sp); + EXPECT_EQ(0xf6f73552U, unwinder.frames()[47].pc); + EXPECT_EQ(0xffeb7400U, unwinder.frames()[47].sp); + EXPECT_EQ(0xf6f7499aU, unwinder.frames()[48].pc); + EXPECT_EQ(0xffeb7480U, unwinder.frames()[48].sp); + EXPECT_EQ(0xf7265362U, unwinder.frames()[49].pc); + EXPECT_EQ(0xffeb74f0U, unwinder.frames()[49].sp); + EXPECT_EQ(0xf72945bdU, unwinder.frames()[50].pc); + EXPECT_EQ(0xffeb7680U, unwinder.frames()[50].sp); + EXPECT_EQ(0xee756c22U, unwinder.frames()[51].pc); + EXPECT_EQ(0xffeb76d0U, unwinder.frames()[51].sp); + EXPECT_EQ(0xf728e6a2U, unwinder.frames()[52].pc); + EXPECT_EQ(0xffeb76f0U, unwinder.frames()[52].sp); + EXPECT_EQ(0xf6d27acbU, unwinder.frames()[53].pc); + EXPECT_EQ(0xffeb7710U, unwinder.frames()[53].sp); + EXPECT_EQ(0xf6f7df0dU, unwinder.frames()[54].pc); + EXPECT_EQ(0xffeb77b0U, unwinder.frames()[54].sp); + EXPECT_EQ(0xf6f73552U, unwinder.frames()[55].pc); + EXPECT_EQ(0xffeb7850U, unwinder.frames()[55].sp); + EXPECT_EQ(0xf6f7499aU, unwinder.frames()[56].pc); + EXPECT_EQ(0xffeb78d0U, unwinder.frames()[56].sp); + EXPECT_EQ(0xf7265362U, unwinder.frames()[57].pc); + EXPECT_EQ(0xffeb7940U, unwinder.frames()[57].sp); + EXPECT_EQ(0xf72945bdU, unwinder.frames()[58].pc); + EXPECT_EQ(0xffeb7a80U, unwinder.frames()[58].sp); + EXPECT_EQ(0xf728e6a2U, unwinder.frames()[59].pc); + EXPECT_EQ(0xffeb7ad0U, unwinder.frames()[59].sp); + EXPECT_EQ(0xf6d27acbU, unwinder.frames()[60].pc); + EXPECT_EQ(0xffeb7af0U, unwinder.frames()[60].sp); + EXPECT_EQ(0xf718bc95U, unwinder.frames()[61].pc); + EXPECT_EQ(0xffeb7b90U, unwinder.frames()[61].sp); + EXPECT_EQ(0xf718bb5aU, unwinder.frames()[62].pc); + EXPECT_EQ(0xffeb7c50U, unwinder.frames()[62].sp); + EXPECT_EQ(0xf706b3ddU, unwinder.frames()[63].pc); + EXPECT_EQ(0xffeb7d10U, unwinder.frames()[63].sp); + EXPECT_EQ(0xf6d6548cU, unwinder.frames()[64].pc); + EXPECT_EQ(0xffeb7d70U, unwinder.frames()[64].sp); + EXPECT_EQ(0xf6d5df06U, unwinder.frames()[65].pc); + EXPECT_EQ(0xffeb7df0U, unwinder.frames()[65].sp); + EXPECT_EQ(0x56574d8cU, unwinder.frames()[66].pc); + EXPECT_EQ(0xffeb7e40U, unwinder.frames()[66].sp); + EXPECT_EQ(0x56574a80U, unwinder.frames()[67].pc); + EXPECT_EQ(0xffeb7e70U, unwinder.frames()[67].sp); + EXPECT_EQ(0xf7363275U, unwinder.frames()[68].pc); + EXPECT_EQ(0xffeb7ef0U, unwinder.frames()[68].sp); } TEST_F(UnwindOfflineTest, jit_debug_arm) { @@ -553,6 +715,158 @@ TEST_F(UnwindOfflineTest, jit_debug_arm) { " #74 pc 00001349 dalvikvm32 (main+896)\n" " #75 pc 000850c9 libc.so\n", frame_info); + EXPECT_EQ(0xdfe66a5eU, unwinder.frames()[0].pc); + EXPECT_EQ(0xff85d180U, unwinder.frames()[0].sp); + EXPECT_EQ(0xe044712dU, unwinder.frames()[1].pc); + EXPECT_EQ(0xff85d200U, unwinder.frames()[1].sp); + EXPECT_EQ(0xe27a7cb1U, unwinder.frames()[2].pc); + EXPECT_EQ(0xff85d290U, unwinder.frames()[2].sp); + EXPECT_EQ(0xed75c175U, unwinder.frames()[3].pc); + EXPECT_EQ(0xff85d2b0U, unwinder.frames()[3].sp); + EXPECT_EQ(0xed761129U, unwinder.frames()[4].pc); + EXPECT_EQ(0xff85d2e8U, unwinder.frames()[4].sp); + EXPECT_EQ(0xed3b97a9U, unwinder.frames()[5].pc); + EXPECT_EQ(0xff85d370U, unwinder.frames()[5].sp); + EXPECT_EQ(0xed541833U, unwinder.frames()[6].pc); + EXPECT_EQ(0xff85d3d8U, unwinder.frames()[6].sp); + EXPECT_EQ(0xed528935U, unwinder.frames()[7].pc); + EXPECT_EQ(0xff85d428U, unwinder.frames()[7].sp); + EXPECT_EQ(0xed52971dU, unwinder.frames()[8].pc); + EXPECT_EQ(0xff85d470U, unwinder.frames()[8].sp); + EXPECT_EQ(0xed73c865U, unwinder.frames()[9].pc); + EXPECT_EQ(0xff85d4b0U, unwinder.frames()[9].sp); + EXPECT_EQ(0xed7606ffU, unwinder.frames()[10].pc); + EXPECT_EQ(0xff85d5d0U, unwinder.frames()[10].sp); + EXPECT_EQ(0xe27a7c31U, unwinder.frames()[11].pc); + EXPECT_EQ(0xff85d640U, unwinder.frames()[11].sp); + EXPECT_EQ(0xed75c175U, unwinder.frames()[12].pc); + EXPECT_EQ(0xff85d660U, unwinder.frames()[12].sp); + EXPECT_EQ(0xed761129U, unwinder.frames()[13].pc); + EXPECT_EQ(0xff85d698U, unwinder.frames()[13].sp); + EXPECT_EQ(0xed3b97a9U, unwinder.frames()[14].pc); + EXPECT_EQ(0xff85d720U, unwinder.frames()[14].sp); + EXPECT_EQ(0xed541833U, unwinder.frames()[15].pc); + EXPECT_EQ(0xff85d788U, unwinder.frames()[15].sp); + EXPECT_EQ(0xed528935U, unwinder.frames()[16].pc); + EXPECT_EQ(0xff85d7d8U, unwinder.frames()[16].sp); + EXPECT_EQ(0xed52971dU, unwinder.frames()[17].pc); + EXPECT_EQ(0xff85d820U, unwinder.frames()[17].sp); + EXPECT_EQ(0xed73c865U, unwinder.frames()[18].pc); + EXPECT_EQ(0xff85d860U, unwinder.frames()[18].sp); + EXPECT_EQ(0xed7606ffU, unwinder.frames()[19].pc); + EXPECT_EQ(0xff85d970U, unwinder.frames()[19].sp); + EXPECT_EQ(0xe27a7b77U, unwinder.frames()[20].pc); + EXPECT_EQ(0xff85d9e0U, unwinder.frames()[20].sp); + EXPECT_EQ(0xed75c175U, unwinder.frames()[21].pc); + EXPECT_EQ(0xff85da10U, unwinder.frames()[21].sp); + EXPECT_EQ(0xed761129U, unwinder.frames()[22].pc); + EXPECT_EQ(0xff85da48U, unwinder.frames()[22].sp); + EXPECT_EQ(0xed3b97a9U, unwinder.frames()[23].pc); + EXPECT_EQ(0xff85dad0U, unwinder.frames()[23].sp); + EXPECT_EQ(0xed541833U, unwinder.frames()[24].pc); + EXPECT_EQ(0xff85db38U, unwinder.frames()[24].sp); + EXPECT_EQ(0xed528935U, unwinder.frames()[25].pc); + EXPECT_EQ(0xff85db88U, unwinder.frames()[25].sp); + EXPECT_EQ(0xed52971dU, unwinder.frames()[26].pc); + EXPECT_EQ(0xff85dbd0U, unwinder.frames()[26].sp); + EXPECT_EQ(0xed73c865U, unwinder.frames()[27].pc); + EXPECT_EQ(0xff85dc10U, unwinder.frames()[27].sp); + EXPECT_EQ(0xed7606ffU, unwinder.frames()[28].pc); + EXPECT_EQ(0xff85dd20U, unwinder.frames()[28].sp); + EXPECT_EQ(0xe27a7a29U, unwinder.frames()[29].pc); + EXPECT_EQ(0xff85dd90U, unwinder.frames()[29].sp); + EXPECT_EQ(0xed75c175U, unwinder.frames()[30].pc); + EXPECT_EQ(0xff85ddc0U, unwinder.frames()[30].sp); + EXPECT_EQ(0xed76122fU, unwinder.frames()[31].pc); + EXPECT_EQ(0xff85de08U, unwinder.frames()[31].sp); + EXPECT_EQ(0xed3b97bbU, unwinder.frames()[32].pc); + EXPECT_EQ(0xff85de90U, unwinder.frames()[32].sp); + EXPECT_EQ(0xed541833U, unwinder.frames()[33].pc); + EXPECT_EQ(0xff85def8U, unwinder.frames()[33].sp); + EXPECT_EQ(0xed528935U, unwinder.frames()[34].pc); + EXPECT_EQ(0xff85df48U, unwinder.frames()[34].sp); + EXPECT_EQ(0xed52971dU, unwinder.frames()[35].pc); + EXPECT_EQ(0xff85df90U, unwinder.frames()[35].sp); + EXPECT_EQ(0xed73c865U, unwinder.frames()[36].pc); + EXPECT_EQ(0xff85dfd0U, unwinder.frames()[36].sp); + EXPECT_EQ(0xed7606ffU, unwinder.frames()[37].pc); + EXPECT_EQ(0xff85e110U, unwinder.frames()[37].sp); + EXPECT_EQ(0xe27a739bU, unwinder.frames()[38].pc); + EXPECT_EQ(0xff85e180U, unwinder.frames()[38].sp); + EXPECT_EQ(0xed75c175U, unwinder.frames()[39].pc); + EXPECT_EQ(0xff85e1b0U, unwinder.frames()[39].sp); + EXPECT_EQ(0xed761129U, unwinder.frames()[40].pc); + EXPECT_EQ(0xff85e1e0U, unwinder.frames()[40].sp); + EXPECT_EQ(0xed3b97a9U, unwinder.frames()[41].pc); + EXPECT_EQ(0xff85e268U, unwinder.frames()[41].sp); + EXPECT_EQ(0xed541833U, unwinder.frames()[42].pc); + EXPECT_EQ(0xff85e2d0U, unwinder.frames()[42].sp); + EXPECT_EQ(0xed528935U, unwinder.frames()[43].pc); + EXPECT_EQ(0xff85e320U, unwinder.frames()[43].sp); + EXPECT_EQ(0xed52971dU, unwinder.frames()[44].pc); + EXPECT_EQ(0xff85e368U, unwinder.frames()[44].sp); + EXPECT_EQ(0xed73c865U, unwinder.frames()[45].pc); + EXPECT_EQ(0xff85e3a8U, unwinder.frames()[45].sp); + EXPECT_EQ(0xed7606ffU, unwinder.frames()[46].pc); + EXPECT_EQ(0xff85e4c0U, unwinder.frames()[46].sp); + EXPECT_EQ(0xe27a6aa7U, unwinder.frames()[47].pc); + EXPECT_EQ(0xff85e530U, unwinder.frames()[47].sp); + EXPECT_EQ(0xed75c175U, unwinder.frames()[48].pc); + EXPECT_EQ(0xff85e5a0U, unwinder.frames()[48].sp); + EXPECT_EQ(0xed761129U, unwinder.frames()[49].pc); + EXPECT_EQ(0xff85e5d8U, unwinder.frames()[49].sp); + EXPECT_EQ(0xed3b97a9U, unwinder.frames()[50].pc); + EXPECT_EQ(0xff85e660U, unwinder.frames()[50].sp); + EXPECT_EQ(0xed541833U, unwinder.frames()[51].pc); + EXPECT_EQ(0xff85e6c8U, unwinder.frames()[51].sp); + EXPECT_EQ(0xed528935U, unwinder.frames()[52].pc); + EXPECT_EQ(0xff85e718U, unwinder.frames()[52].sp); + EXPECT_EQ(0xed52971dU, unwinder.frames()[53].pc); + EXPECT_EQ(0xff85e760U, unwinder.frames()[53].sp); + EXPECT_EQ(0xed73c865U, unwinder.frames()[54].pc); + EXPECT_EQ(0xff85e7a0U, unwinder.frames()[54].sp); + EXPECT_EQ(0xed7606ffU, unwinder.frames()[55].pc); + EXPECT_EQ(0xff85e8f0U, unwinder.frames()[55].sp); + EXPECT_EQ(0xe27a1a99U, unwinder.frames()[56].pc); + EXPECT_EQ(0xff85e960U, unwinder.frames()[56].sp); + EXPECT_EQ(0xed75c175U, unwinder.frames()[57].pc); + EXPECT_EQ(0xff85e990U, unwinder.frames()[57].sp); + EXPECT_EQ(0xed76122fU, unwinder.frames()[58].pc); + EXPECT_EQ(0xff85e9c8U, unwinder.frames()[58].sp); + EXPECT_EQ(0xed3b97bbU, unwinder.frames()[59].pc); + EXPECT_EQ(0xff85ea50U, unwinder.frames()[59].sp); + EXPECT_EQ(0xed541833U, unwinder.frames()[60].pc); + EXPECT_EQ(0xff85eab8U, unwinder.frames()[60].sp); + EXPECT_EQ(0xed528935U, unwinder.frames()[61].pc); + EXPECT_EQ(0xff85eb08U, unwinder.frames()[61].sp); + EXPECT_EQ(0xed52971dU, unwinder.frames()[62].pc); + EXPECT_EQ(0xff85eb50U, unwinder.frames()[62].sp); + EXPECT_EQ(0xed73c865U, unwinder.frames()[63].pc); + EXPECT_EQ(0xff85eb90U, unwinder.frames()[63].sp); + EXPECT_EQ(0xed7606ffU, unwinder.frames()[64].pc); + EXPECT_EQ(0xff85ec90U, unwinder.frames()[64].sp); + EXPECT_EQ(0xed75c175U, unwinder.frames()[65].pc); + EXPECT_EQ(0xff85ed00U, unwinder.frames()[65].sp); + EXPECT_EQ(0xed76122fU, unwinder.frames()[66].pc); + EXPECT_EQ(0xff85ed38U, unwinder.frames()[66].sp); + EXPECT_EQ(0xed3b97bbU, unwinder.frames()[67].pc); + EXPECT_EQ(0xff85edc0U, unwinder.frames()[67].sp); + EXPECT_EQ(0xed6ac92dU, unwinder.frames()[68].pc); + EXPECT_EQ(0xff85ee28U, unwinder.frames()[68].sp); + EXPECT_EQ(0xed6ac6c3U, unwinder.frames()[69].pc); + EXPECT_EQ(0xff85eeb8U, unwinder.frames()[69].sp); + EXPECT_EQ(0xed602411U, unwinder.frames()[70].pc); + EXPECT_EQ(0xff85ef48U, unwinder.frames()[70].sp); + EXPECT_EQ(0xed3e0a9fU, unwinder.frames()[71].pc); + EXPECT_EQ(0xff85ef90U, unwinder.frames()[71].sp); + EXPECT_EQ(0xed3db9b9U, unwinder.frames()[72].pc); + EXPECT_EQ(0xff85f008U, unwinder.frames()[72].sp); + EXPECT_EQ(0xab0d459fU, unwinder.frames()[73].pc); + EXPECT_EQ(0xff85f038U, unwinder.frames()[73].sp); + EXPECT_EQ(0xab0d4349U, unwinder.frames()[74].pc); + EXPECT_EQ(0xff85f050U, unwinder.frames()[74].sp); + EXPECT_EQ(0xedb0d0c9U, unwinder.frames()[75].pc); + EXPECT_EQ(0xff85f0c0U, unwinder.frames()[75].sp); } // The eh_frame_hdr data is present but set to zero fdes. This should @@ -573,6 +887,16 @@ TEST_F(UnwindOfflineTest, bad_eh_frame_hdr_arm64) { " #03 pc 0000000000000590 waiter64\n" " #04 pc 00000000000a8e98 libc.so (__libc_init+88)\n", frame_info); + EXPECT_EQ(0x60a9fdf550U, unwinder.frames()[0].pc); + EXPECT_EQ(0x7fdd141990U, unwinder.frames()[0].sp); + EXPECT_EQ(0x60a9fdf568U, unwinder.frames()[1].pc); + EXPECT_EQ(0x7fdd1419a0U, unwinder.frames()[1].sp); + EXPECT_EQ(0x60a9fdf57cU, unwinder.frames()[2].pc); + EXPECT_EQ(0x7fdd1419b0U, unwinder.frames()[2].sp); + EXPECT_EQ(0x60a9fdf590U, unwinder.frames()[3].pc); + EXPECT_EQ(0x7fdd1419c0U, unwinder.frames()[3].sp); + EXPECT_EQ(0x7542d68e98U, unwinder.frames()[4].pc); + EXPECT_EQ(0x7fdd1419d0U, unwinder.frames()[4].sp); } // The elf has bad eh_frame unwind information for the pcs. If eh_frame @@ -592,6 +916,16 @@ TEST_F(UnwindOfflineTest, debug_frame_first_x86) { " #03 pc 000006f7 waiter (main+23)\n" " #04 pc 00018275 libc.so\n", frame_info); + EXPECT_EQ(0x56598685U, unwinder.frames()[0].pc); + EXPECT_EQ(0xffcf9e38U, unwinder.frames()[0].sp); + EXPECT_EQ(0x565986b7U, unwinder.frames()[1].pc); + EXPECT_EQ(0xffcf9e50U, unwinder.frames()[1].sp); + EXPECT_EQ(0x565986d7U, unwinder.frames()[2].pc); + EXPECT_EQ(0xffcf9e60U, unwinder.frames()[2].sp); + EXPECT_EQ(0x565986f7U, unwinder.frames()[3].pc); + EXPECT_EQ(0xffcf9e70U, unwinder.frames()[3].sp); + EXPECT_EQ(0xf744a275U, unwinder.frames()[4].pc); + EXPECT_EQ(0xffcf9e80U, unwinder.frames()[4].sp); } // Make sure that a pc that is at the beginning of an fde unwinds correctly. @@ -610,6 +944,16 @@ TEST_F(UnwindOfflineTest, eh_frame_hdr_begin_x86_64) { " #03 pc 00000000000013ed unwind_test64 (main+13)\n" " #04 pc 00000000000202b0 libc.so\n", frame_info); + EXPECT_EQ(0x561550b17a80U, unwinder.frames()[0].pc); + EXPECT_EQ(0x7ffcc8596ce8U, unwinder.frames()[0].sp); + EXPECT_EQ(0x561550b17dd9U, unwinder.frames()[1].pc); + EXPECT_EQ(0x7ffcc8596cf0U, unwinder.frames()[1].sp); + EXPECT_EQ(0x561550b1821eU, unwinder.frames()[2].pc); + EXPECT_EQ(0x7ffcc8596f40U, unwinder.frames()[2].sp); + EXPECT_EQ(0x561550b183edU, unwinder.frames()[3].pc); + EXPECT_EQ(0x7ffcc8597190U, unwinder.frames()[3].sp); + EXPECT_EQ(0x7f4de62162b0U, unwinder.frames()[4].pc); + EXPECT_EQ(0x7ffcc85971a0U, unwinder.frames()[4].sp); } } // namespace unwindstack |
