Merge "Change RegsTmpl to RegsImpl." am: 2065a741cd am: d34b599ec8

am: a32945f71a

Change-Id: If5f8b33dbeff59115888b0964c22e21a65ad7d06
This commit is contained in:
Christopher Ferris 2017-06-02 15:15:15 +00:00 committed by android-build-merger
commit d1019c33d7
6 changed files with 35 additions and 39 deletions

View file

@ -37,7 +37,7 @@ enum DwarfVersion : uint8_t {
class DwarfMemory;
class Memory;
template <typename AddressType>
class RegsTmpl;
class RegsImpl;
template <typename AddressType>
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<AddressType>* regs) { regs_ = regs; }
void set_regs(RegsImpl<AddressType>* regs) { regs_ = regs; }
DwarfError last_error() { return last_error_; }
@ -91,7 +91,7 @@ class DwarfOp {
DwarfMemory* memory_;
Memory* regular_memory_;
RegsTmpl<AddressType>* regs_;
RegsImpl<AddressType>* regs_;
bool is_register_ = false;
DwarfError last_error_ = DWARF_ERROR_NONE;
uint8_t cur_op_;

View file

@ -86,7 +86,7 @@ bool DwarfSectionImpl<AddressType>::EvalExpression(const DwarfLocation& loc, uin
template <typename AddressType>
bool DwarfSectionImpl<AddressType>::Eval(const DwarfCie* cie, Memory* regular_memory,
const dwarf_loc_regs_t& loc_regs, Regs* regs) {
RegsTmpl<AddressType>* cur_regs = reinterpret_cast<RegsTmpl<AddressType>*>(regs);
RegsImpl<AddressType>* cur_regs = reinterpret_cast<RegsImpl<AddressType>*>(regs);
if (cie->return_address_register >= cur_regs->total_regs()) {
last_error_ = DWARF_ERROR_ILLEGAL_VALUE;
return false;

View file

@ -30,7 +30,7 @@
#include "User.h"
template <typename AddressType>
uint64_t RegsTmpl<AddressType>::GetRelPc(Elf* elf, const MapInfo* map_info) {
uint64_t RegsImpl<AddressType>::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<AddressType>::GetRelPc(Elf* elf, const MapInfo* map_info) {
}
template <typename AddressType>
bool RegsTmpl<AddressType>::GetReturnAddressFromDefault(Memory* memory, uint64_t* value) {
bool RegsImpl<AddressType>::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<AddressType>::GetReturnAddressFromDefault(Memory* memory, uint64_t
}
}
RegsArm::RegsArm() : RegsTmpl<uint32_t>(ARM_REG_LAST, ARM_REG_SP,
Location(LOCATION_REGISTER, ARM_REG_LR)) {
}
RegsArm::RegsArm()
: RegsImpl<uint32_t>(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<uint64_t>(ARM64_REG_LAST, ARM64_REG_SP,
Location(LOCATION_REGISTER, ARM64_REG_LR)) {
}
RegsArm64::RegsArm64()
: RegsImpl<uint64_t>(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<uint32_t>(X86_REG_LAST, X86_REG_SP,
Location(LOCATION_SP_OFFSET, -4)) {
}
RegsX86::RegsX86()
: RegsImpl<uint32_t>(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<uint64_t>(X86_64_REG_LAST, X86_64_REG_SP,
Location(LOCATION_SP_OFFSET, -8)) {
}
RegsX86_64::RegsX86_64()
: RegsImpl<uint64_t>(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()) {

View file

@ -66,11 +66,11 @@ class Regs {
};
template <typename AddressType>
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<AddressType> regs_;
};
class RegsArm : public RegsTmpl<uint32_t> {
class RegsArm : public RegsImpl<uint32_t> {
public:
RegsArm();
virtual ~RegsArm() = default;
@ -100,7 +100,7 @@ class RegsArm : public RegsTmpl<uint32_t> {
uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override;
};
class RegsArm64 : public RegsTmpl<uint64_t> {
class RegsArm64 : public RegsImpl<uint64_t> {
public:
RegsArm64();
virtual ~RegsArm64() = default;
@ -108,7 +108,7 @@ class RegsArm64 : public RegsTmpl<uint64_t> {
uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override;
};
class RegsX86 : public RegsTmpl<uint32_t> {
class RegsX86 : public RegsImpl<uint32_t> {
public:
RegsX86();
virtual ~RegsX86() = default;
@ -116,7 +116,7 @@ class RegsX86 : public RegsTmpl<uint32_t> {
uint64_t GetAdjustedPc(uint64_t rel_pc, Elf* elf) override;
};
class RegsX86_64 : public RegsTmpl<uint64_t> {
class RegsX86_64 : public RegsImpl<uint64_t> {
public:
RegsX86_64();
virtual ~RegsX86_64() = default;

View file

@ -22,10 +22,10 @@
#include "Regs.h"
template <typename TypeParam>
class RegsFake : public RegsTmpl<TypeParam> {
class RegsFake : public RegsImpl<TypeParam> {
public:
RegsFake(uint16_t total_regs, uint16_t sp_reg)
: RegsTmpl<TypeParam>(total_regs, sp_reg, Regs::Location(Regs::LOCATION_UNKNOWN, 0)) {}
: RegsImpl<TypeParam>(total_regs, sp_reg, Regs::Location(Regs::LOCATION_UNKNOWN, 0)) {}
virtual ~RegsFake() = default;
uint64_t GetRelPc(Elf*, const MapInfo*) override { return 0; }

View file

@ -48,13 +48,13 @@ class ElfInterfaceFake : public ElfInterface {
};
template <typename TypeParam>
class RegsTestTmpl : public RegsTmpl<TypeParam> {
class RegsTestImpl : public RegsImpl<TypeParam> {
public:
RegsTestTmpl(uint16_t total_regs, uint16_t regs_sp)
: RegsTmpl<TypeParam>(total_regs, regs_sp, Regs::Location(Regs::LOCATION_UNKNOWN, 0)) {}
RegsTestTmpl(uint16_t total_regs, uint16_t regs_sp, Regs::Location return_loc)
: RegsTmpl<TypeParam>(total_regs, regs_sp, return_loc) {}
virtual ~RegsTestTmpl() = default;
RegsTestImpl(uint16_t total_regs, uint16_t regs_sp)
: RegsImpl<TypeParam>(total_regs, regs_sp, Regs::Location(Regs::LOCATION_UNKNOWN, 0)) {}
RegsTestImpl(uint16_t total_regs, uint16_t regs_sp, Regs::Location return_loc)
: RegsImpl<TypeParam>(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<uint32_t> regs32(50, 10);
RegsTestImpl<uint32_t> 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<uint64_t> regs64(30, 12);
RegsTestImpl<uint64_t> regs64(30, 12);
ASSERT_EQ(30U, regs64.total_regs());
ASSERT_EQ(12U, regs64.sp_reg());
@ -127,7 +127,7 @@ TEST_F(RegsTest, regs64) {
template <typename AddressType>
void RegsTest::regs_rel_pc() {
RegsTestTmpl<AddressType> regs(30, 12);
RegsTestImpl<AddressType> 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 <typename AddressType>
void RegsTest::regs_return_address_register() {
RegsTestTmpl<AddressType> regs(20, 10, Regs::Location(Regs::LOCATION_REGISTER, 5));
RegsTestImpl<AddressType> 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<uint32_t> regs(20, 10, Regs::Location(Regs::LOCATION_SP_OFFSET, -2));
RegsTestImpl<uint32_t> 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<uint64_t> regs(20, 10, Regs::Location(Regs::LOCATION_SP_OFFSET, -8));
RegsTestImpl<uint64_t> regs(20, 10, Regs::Location(Regs::LOCATION_SP_OFFSET, -8));
regs.set_sp(0x2008);
memory_->SetData64(0x2000, 0x12345678aabbccddULL);