diff --git a/libunwindstack/DwarfOp.h b/libunwindstack/DwarfOp.h index ed6537aeb..0f4b36d7c 100644 --- a/libunwindstack/DwarfOp.h +++ b/libunwindstack/DwarfOp.h @@ -37,7 +37,7 @@ enum DwarfVersion : uint8_t { class DwarfMemory; class Memory; template -class RegsTmpl; +class RegsImpl; template class DwarfOp { @@ -67,7 +67,7 @@ class DwarfOp { AddressType StackAt(size_t index) { return stack_[index]; } size_t StackSize() { return stack_.size(); } - void set_regs(RegsTmpl* regs) { regs_ = regs; } + void set_regs(RegsImpl* regs) { regs_ = regs; } DwarfError last_error() { return last_error_; } @@ -91,7 +91,7 @@ class DwarfOp { DwarfMemory* memory_; Memory* regular_memory_; - RegsTmpl* regs_; + RegsImpl* regs_; bool is_register_ = false; DwarfError last_error_ = DWARF_ERROR_NONE; uint8_t cur_op_; diff --git a/libunwindstack/DwarfSection.cpp b/libunwindstack/DwarfSection.cpp index 0148ffb1d..4c98aa343 100644 --- a/libunwindstack/DwarfSection.cpp +++ b/libunwindstack/DwarfSection.cpp @@ -86,7 +86,7 @@ bool DwarfSectionImpl::EvalExpression(const DwarfLocation& loc, uin template bool DwarfSectionImpl::Eval(const DwarfCie* cie, Memory* regular_memory, const dwarf_loc_regs_t& loc_regs, Regs* regs) { - RegsTmpl* cur_regs = reinterpret_cast*>(regs); + RegsImpl* cur_regs = reinterpret_cast*>(regs); if (cie->return_address_register >= cur_regs->total_regs()) { last_error_ = DWARF_ERROR_ILLEGAL_VALUE; return false; diff --git a/libunwindstack/Regs.cpp b/libunwindstack/Regs.cpp index adb652224..e7d10b203 100644 --- a/libunwindstack/Regs.cpp +++ b/libunwindstack/Regs.cpp @@ -30,7 +30,7 @@ #include "User.h" template -uint64_t RegsTmpl::GetRelPc(Elf* elf, const MapInfo* map_info) { +uint64_t RegsImpl::GetRelPc(Elf* elf, const MapInfo* map_info) { uint64_t load_bias = 0; if (elf->valid()) { load_bias = elf->interface()->load_bias(); @@ -40,7 +40,7 @@ uint64_t RegsTmpl::GetRelPc(Elf* elf, const MapInfo* map_info) { } template -bool RegsTmpl::GetReturnAddressFromDefault(Memory* memory, uint64_t* value) { +bool RegsImpl::GetReturnAddressFromDefault(Memory* memory, uint64_t* value) { switch (return_loc_.type) { case LOCATION_REGISTER: assert(return_loc_.value < total_regs_); @@ -59,9 +59,8 @@ bool RegsTmpl::GetReturnAddressFromDefault(Memory* memory, uint64_t } } -RegsArm::RegsArm() : RegsTmpl(ARM_REG_LAST, ARM_REG_SP, - Location(LOCATION_REGISTER, ARM_REG_LR)) { -} +RegsArm::RegsArm() + : RegsImpl(ARM_REG_LAST, ARM_REG_SP, Location(LOCATION_REGISTER, ARM_REG_LR)) {} uint64_t RegsArm::GetAdjustedPc(uint64_t rel_pc, Elf* elf) { if (!elf->valid()) { @@ -89,9 +88,8 @@ uint64_t RegsArm::GetAdjustedPc(uint64_t rel_pc, Elf* elf) { return rel_pc - 4; } -RegsArm64::RegsArm64() : RegsTmpl(ARM64_REG_LAST, ARM64_REG_SP, - Location(LOCATION_REGISTER, ARM64_REG_LR)) { -} +RegsArm64::RegsArm64() + : RegsImpl(ARM64_REG_LAST, ARM64_REG_SP, Location(LOCATION_REGISTER, ARM64_REG_LR)) {} uint64_t RegsArm64::GetAdjustedPc(uint64_t rel_pc, Elf* elf) { if (!elf->valid()) { @@ -104,9 +102,8 @@ uint64_t RegsArm64::GetAdjustedPc(uint64_t rel_pc, Elf* elf) { return rel_pc - 4; } -RegsX86::RegsX86() : RegsTmpl(X86_REG_LAST, X86_REG_SP, - Location(LOCATION_SP_OFFSET, -4)) { -} +RegsX86::RegsX86() + : RegsImpl(X86_REG_LAST, X86_REG_SP, Location(LOCATION_SP_OFFSET, -4)) {} uint64_t RegsX86::GetAdjustedPc(uint64_t rel_pc, Elf* elf) { if (!elf->valid()) { @@ -119,9 +116,8 @@ uint64_t RegsX86::GetAdjustedPc(uint64_t rel_pc, Elf* elf) { return rel_pc - 1; } -RegsX86_64::RegsX86_64() : RegsTmpl(X86_64_REG_LAST, X86_64_REG_SP, - Location(LOCATION_SP_OFFSET, -8)) { -} +RegsX86_64::RegsX86_64() + : RegsImpl(X86_64_REG_LAST, X86_64_REG_SP, Location(LOCATION_SP_OFFSET, -8)) {} uint64_t RegsX86_64::GetAdjustedPc(uint64_t rel_pc, Elf* elf) { if (!elf->valid()) { diff --git a/libunwindstack/Regs.h b/libunwindstack/Regs.h index 718fc8581..8f5a72158 100644 --- a/libunwindstack/Regs.h +++ b/libunwindstack/Regs.h @@ -66,11 +66,11 @@ class Regs { }; template -class RegsTmpl : public Regs { +class RegsImpl : public Regs { public: - RegsTmpl(uint16_t total_regs, uint16_t sp_reg, Location return_loc) + RegsImpl(uint16_t total_regs, uint16_t sp_reg, Location return_loc) : Regs(total_regs, sp_reg, return_loc), regs_(total_regs) {} - virtual ~RegsTmpl() = default; + virtual ~RegsImpl() = default; uint64_t GetRelPc(Elf* elf, const MapInfo* map_info) override; @@ -92,7 +92,7 @@ class RegsTmpl : public Regs { std::vector regs_; }; -class RegsArm : public RegsTmpl { +class RegsArm : public RegsImpl { public: RegsArm(); virtual ~RegsArm() = default; @@ -100,7 +100,7 @@ class RegsArm : public RegsTmpl { uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override; }; -class RegsArm64 : public RegsTmpl { +class RegsArm64 : public RegsImpl { public: RegsArm64(); virtual ~RegsArm64() = default; @@ -108,7 +108,7 @@ class RegsArm64 : public RegsTmpl { uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override; }; -class RegsX86 : public RegsTmpl { +class RegsX86 : public RegsImpl { public: RegsX86(); virtual ~RegsX86() = default; @@ -116,7 +116,7 @@ class RegsX86 : public RegsTmpl { uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override; }; -class RegsX86_64 : public RegsTmpl { +class RegsX86_64 : public RegsImpl { public: RegsX86_64(); virtual ~RegsX86_64() = default; diff --git a/libunwindstack/tests/RegsFake.h b/libunwindstack/tests/RegsFake.h index dbc06a495..ff030c81d 100644 --- a/libunwindstack/tests/RegsFake.h +++ b/libunwindstack/tests/RegsFake.h @@ -22,10 +22,10 @@ #include "Regs.h" template -class RegsFake : public RegsTmpl { +class RegsFake : public RegsImpl { public: RegsFake(uint16_t total_regs, uint16_t sp_reg) - : RegsTmpl(total_regs, sp_reg, Regs::Location(Regs::LOCATION_UNKNOWN, 0)) {} + : RegsImpl(total_regs, sp_reg, Regs::Location(Regs::LOCATION_UNKNOWN, 0)) {} virtual ~RegsFake() = default; uint64_t GetRelPc(Elf*, const MapInfo*) override { return 0; } diff --git a/libunwindstack/tests/RegsTest.cpp b/libunwindstack/tests/RegsTest.cpp index 0dac2788c..305637371 100644 --- a/libunwindstack/tests/RegsTest.cpp +++ b/libunwindstack/tests/RegsTest.cpp @@ -48,13 +48,13 @@ class ElfInterfaceFake : public ElfInterface { }; template -class RegsTestTmpl : public RegsTmpl { +class RegsTestImpl : public RegsImpl { public: - RegsTestTmpl(uint16_t total_regs, uint16_t regs_sp) - : RegsTmpl(total_regs, regs_sp, Regs::Location(Regs::LOCATION_UNKNOWN, 0)) {} - RegsTestTmpl(uint16_t total_regs, uint16_t regs_sp, Regs::Location return_loc) - : RegsTmpl(total_regs, regs_sp, return_loc) {} - virtual ~RegsTestTmpl() = default; + RegsTestImpl(uint16_t total_regs, uint16_t regs_sp) + : RegsImpl(total_regs, regs_sp, Regs::Location(Regs::LOCATION_UNKNOWN, 0)) {} + RegsTestImpl(uint16_t total_regs, uint16_t regs_sp, Regs::Location return_loc) + : RegsImpl(total_regs, regs_sp, return_loc) {} + virtual ~RegsTestImpl() = default; uint64_t GetAdjustedPc(uint64_t, Elf*) { return 0; } }; @@ -80,7 +80,7 @@ class RegsTest : public ::testing::Test { }; TEST_F(RegsTest, regs32) { - RegsTestTmpl regs32(50, 10); + RegsTestImpl regs32(50, 10); ASSERT_EQ(50U, regs32.total_regs()); ASSERT_EQ(10U, regs32.sp_reg()); @@ -103,7 +103,7 @@ TEST_F(RegsTest, regs32) { } TEST_F(RegsTest, regs64) { - RegsTestTmpl regs64(30, 12); + RegsTestImpl regs64(30, 12); ASSERT_EQ(30U, regs64.total_regs()); ASSERT_EQ(12U, regs64.sp_reg()); @@ -127,7 +127,7 @@ TEST_F(RegsTest, regs64) { template void RegsTest::regs_rel_pc() { - RegsTestTmpl regs(30, 12); + RegsTestImpl regs(30, 12); elf_interface_->set_load_bias(0); MapInfo map_info{.start = 0x1000, .end = 0x2000}; @@ -147,7 +147,7 @@ TEST_F(RegsTest, regs64_rel_pc) { template void RegsTest::regs_return_address_register() { - RegsTestTmpl regs(20, 10, Regs::Location(Regs::LOCATION_REGISTER, 5)); + RegsTestImpl regs(20, 10, Regs::Location(Regs::LOCATION_REGISTER, 5)); regs[5] = 0x12345; uint64_t value; @@ -164,7 +164,7 @@ TEST_F(RegsTest, regs64_return_address_register) { } TEST_F(RegsTest, regs32_return_address_sp_offset) { - RegsTestTmpl regs(20, 10, Regs::Location(Regs::LOCATION_SP_OFFSET, -2)); + RegsTestImpl regs(20, 10, Regs::Location(Regs::LOCATION_SP_OFFSET, -2)); regs.set_sp(0x2002); memory_->SetData32(0x2000, 0x12345678); @@ -174,7 +174,7 @@ TEST_F(RegsTest, regs32_return_address_sp_offset) { } TEST_F(RegsTest, regs64_return_address_sp_offset) { - RegsTestTmpl regs(20, 10, Regs::Location(Regs::LOCATION_SP_OFFSET, -8)); + RegsTestImpl regs(20, 10, Regs::Location(Regs::LOCATION_SP_OFFSET, -8)); regs.set_sp(0x2008); memory_->SetData64(0x2000, 0x12345678aabbccddULL);