diff options
-rw-r--r-- | libunwindstack/DwarfCfa.cpp | 48 | ||||
-rw-r--r-- | libunwindstack/DwarfCfa.h | 56 | ||||
-rw-r--r-- | libunwindstack/DwarfSection.cpp | 8 | ||||
-rw-r--r-- | libunwindstack/include/unwindstack/DwarfLocation.h | 1 | ||||
-rw-r--r-- | libunwindstack/include/unwindstack/DwarfSection.h | 14 | ||||
-rw-r--r-- | libunwindstack/tests/DwarfCfaLogTest.cpp | 2 | ||||
-rw-r--r-- | libunwindstack/tests/DwarfCfaTest.cpp | 64 | ||||
-rw-r--r-- | libunwindstack/tests/DwarfSectionImplTest.cpp | 54 | ||||
-rw-r--r-- | libunwindstack/tests/DwarfSectionTest.cpp | 10 | ||||
-rw-r--r-- | libunwindstack/tests/VerifyBionicTerminationTest.cpp | 2 | ||||
-rw-r--r-- | libunwindstack/tools/unwind_reg_info.cpp | 2 |
11 files changed, 130 insertions, 131 deletions
diff --git a/libunwindstack/DwarfCfa.cpp b/libunwindstack/DwarfCfa.cpp index c6db209..884acf5 100644 --- a/libunwindstack/DwarfCfa.cpp +++ b/libunwindstack/DwarfCfa.cpp @@ -41,7 +41,7 @@ constexpr typename DwarfCfa<AddressType>::process_func DwarfCfa<AddressType>::kC template <typename AddressType> bool DwarfCfa<AddressType>::GetLocationInfo(uint64_t pc, uint64_t start_offset, uint64_t end_offset, - dwarf_loc_regs_t* loc_regs) { + DwarfLocations* loc_regs) { if (cie_loc_regs_ != nullptr) { for (const auto& entry : *cie_loc_regs_) { (*loc_regs)[entry.first] = entry.second; @@ -320,12 +320,12 @@ bool DwarfCfa<AddressType>::Log(uint32_t indent, uint64_t pc, uint64_t start_off // Static data. template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_nop(dwarf_loc_regs_t*) { +bool DwarfCfa<AddressType>::cfa_nop(DwarfLocations*) { return true; } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_set_loc(dwarf_loc_regs_t*) { +bool DwarfCfa<AddressType>::cfa_set_loc(DwarfLocations*) { AddressType cur_pc = cur_pc_; AddressType new_pc = operands_[0]; if (new_pc < cur_pc) { @@ -340,20 +340,20 @@ bool DwarfCfa<AddressType>::cfa_set_loc(dwarf_loc_regs_t*) { } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_advance_loc(dwarf_loc_regs_t*) { +bool DwarfCfa<AddressType>::cfa_advance_loc(DwarfLocations*) { cur_pc_ += operands_[0] * fde_->cie->code_alignment_factor; return true; } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_offset(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_offset(DwarfLocations* loc_regs) { AddressType reg = operands_[0]; (*loc_regs)[reg] = {.type = DWARF_LOCATION_OFFSET, .values = {operands_[1]}}; return true; } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_restore(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_restore(DwarfLocations* loc_regs) { AddressType reg = operands_[0]; if (cie_loc_regs_ == nullptr) { log(0, "restore while processing cie"); @@ -370,21 +370,21 @@ bool DwarfCfa<AddressType>::cfa_restore(dwarf_loc_regs_t* loc_regs) { } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_undefined(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_undefined(DwarfLocations* loc_regs) { AddressType reg = operands_[0]; (*loc_regs)[reg] = {.type = DWARF_LOCATION_UNDEFINED}; return true; } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_same_value(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_same_value(DwarfLocations* loc_regs) { AddressType reg = operands_[0]; loc_regs->erase(reg); return true; } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_register(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_register(DwarfLocations* loc_regs) { AddressType reg = operands_[0]; AddressType reg_dst = operands_[1]; (*loc_regs)[reg] = {.type = DWARF_LOCATION_REGISTER, .values = {reg_dst}}; @@ -392,13 +392,13 @@ bool DwarfCfa<AddressType>::cfa_register(dwarf_loc_regs_t* loc_regs) { } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_remember_state(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_remember_state(DwarfLocations* loc_regs) { loc_reg_state_.push(*loc_regs); return true; } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_restore_state(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_restore_state(DwarfLocations* loc_regs) { if (loc_reg_state_.size() == 0) { log(0, "Warning: Attempt to restore without remember."); return true; @@ -409,13 +409,13 @@ bool DwarfCfa<AddressType>::cfa_restore_state(dwarf_loc_regs_t* loc_regs) { } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_def_cfa(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_def_cfa(DwarfLocations* loc_regs) { (*loc_regs)[CFA_REG] = {.type = DWARF_LOCATION_REGISTER, .values = {operands_[0], operands_[1]}}; return true; } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_def_cfa_register(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_def_cfa_register(DwarfLocations* loc_regs) { auto cfa_location = loc_regs->find(CFA_REG); if (cfa_location == loc_regs->end() || cfa_location->second.type != DWARF_LOCATION_REGISTER) { log(0, "Attempt to set new register, but cfa is not already set to a register."); @@ -428,7 +428,7 @@ bool DwarfCfa<AddressType>::cfa_def_cfa_register(dwarf_loc_regs_t* loc_regs) { } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_def_cfa_offset(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_def_cfa_offset(DwarfLocations* loc_regs) { // Changing the offset if this is not a register is illegal. auto cfa_location = loc_regs->find(CFA_REG); if (cfa_location == loc_regs->end() || cfa_location->second.type != DWARF_LOCATION_REGISTER) { @@ -441,7 +441,7 @@ bool DwarfCfa<AddressType>::cfa_def_cfa_offset(dwarf_loc_regs_t* loc_regs) { } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_def_cfa_expression(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_def_cfa_expression(DwarfLocations* loc_regs) { // There is only one type of expression for CFA evaluation and the DWARF // specification is unclear whether it returns the address or the // dereferenced value. GDB expects the value, so will we. @@ -451,7 +451,7 @@ bool DwarfCfa<AddressType>::cfa_def_cfa_expression(dwarf_loc_regs_t* loc_regs) { } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_expression(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_expression(DwarfLocations* loc_regs) { AddressType reg = operands_[0]; (*loc_regs)[reg] = {.type = DWARF_LOCATION_EXPRESSION, .values = {operands_[1], memory_->cur_offset()}}; @@ -459,7 +459,7 @@ bool DwarfCfa<AddressType>::cfa_expression(dwarf_loc_regs_t* loc_regs) { } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_offset_extended_sf(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_offset_extended_sf(DwarfLocations* loc_regs) { AddressType reg = operands_[0]; SignedType value = static_cast<SignedType>(operands_[1]) * fde_->cie->data_alignment_factor; (*loc_regs)[reg] = {.type = DWARF_LOCATION_OFFSET, .values = {static_cast<uint64_t>(value)}}; @@ -467,7 +467,7 @@ bool DwarfCfa<AddressType>::cfa_offset_extended_sf(dwarf_loc_regs_t* loc_regs) { } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_def_cfa_sf(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_def_cfa_sf(DwarfLocations* loc_regs) { SignedType offset = static_cast<SignedType>(operands_[1]) * fde_->cie->data_alignment_factor; (*loc_regs)[CFA_REG] = {.type = DWARF_LOCATION_REGISTER, .values = {operands_[0], static_cast<uint64_t>(offset)}}; @@ -475,7 +475,7 @@ bool DwarfCfa<AddressType>::cfa_def_cfa_sf(dwarf_loc_regs_t* loc_regs) { } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_def_cfa_offset_sf(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_def_cfa_offset_sf(DwarfLocations* loc_regs) { // Changing the offset if this is not a register is illegal. auto cfa_location = loc_regs->find(CFA_REG); if (cfa_location == loc_regs->end() || cfa_location->second.type != DWARF_LOCATION_REGISTER) { @@ -489,7 +489,7 @@ bool DwarfCfa<AddressType>::cfa_def_cfa_offset_sf(dwarf_loc_regs_t* loc_regs) { } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_val_offset(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_val_offset(DwarfLocations* loc_regs) { AddressType reg = operands_[0]; SignedType offset = static_cast<SignedType>(operands_[1]) * fde_->cie->data_alignment_factor; (*loc_regs)[reg] = {.type = DWARF_LOCATION_VAL_OFFSET, .values = {static_cast<uint64_t>(offset)}}; @@ -497,7 +497,7 @@ bool DwarfCfa<AddressType>::cfa_val_offset(dwarf_loc_regs_t* loc_regs) { } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_val_offset_sf(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_val_offset_sf(DwarfLocations* loc_regs) { AddressType reg = operands_[0]; SignedType offset = static_cast<SignedType>(operands_[1]) * fde_->cie->data_alignment_factor; (*loc_regs)[reg] = {.type = DWARF_LOCATION_VAL_OFFSET, .values = {static_cast<uint64_t>(offset)}}; @@ -505,7 +505,7 @@ bool DwarfCfa<AddressType>::cfa_val_offset_sf(dwarf_loc_regs_t* loc_regs) { } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_val_expression(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_val_expression(DwarfLocations* loc_regs) { AddressType reg = operands_[0]; (*loc_regs)[reg] = {.type = DWARF_LOCATION_VAL_EXPRESSION, .values = {operands_[1], memory_->cur_offset()}}; @@ -513,7 +513,7 @@ bool DwarfCfa<AddressType>::cfa_val_expression(dwarf_loc_regs_t* loc_regs) { } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_gnu_negative_offset_extended(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_gnu_negative_offset_extended(DwarfLocations* loc_regs) { AddressType reg = operands_[0]; SignedType offset = -static_cast<SignedType>(operands_[1]); (*loc_regs)[reg] = {.type = DWARF_LOCATION_OFFSET, .values = {static_cast<uint64_t>(offset)}}; @@ -521,7 +521,7 @@ bool DwarfCfa<AddressType>::cfa_gnu_negative_offset_extended(dwarf_loc_regs_t* l } template <typename AddressType> -bool DwarfCfa<AddressType>::cfa_aarch64_negate_ra_state(dwarf_loc_regs_t* loc_regs) { +bool DwarfCfa<AddressType>::cfa_aarch64_negate_ra_state(DwarfLocations* loc_regs) { // Only supported on aarch64. if (arch_ != ARCH_ARM64) { last_error_.code = DWARF_ERROR_ILLEGAL_VALUE; diff --git a/libunwindstack/DwarfCfa.h b/libunwindstack/DwarfCfa.h index d627e15..c4425bd 100644 --- a/libunwindstack/DwarfCfa.h +++ b/libunwindstack/DwarfCfa.h @@ -80,7 +80,7 @@ class DwarfCfa { virtual ~DwarfCfa() = default; bool GetLocationInfo(uint64_t pc, uint64_t start_offset, uint64_t end_offset, - dwarf_loc_regs_t* loc_regs); + DwarfLocations* loc_regs); bool Log(uint32_t indent, uint64_t pc, uint64_t start_offset, uint64_t end_offset); @@ -90,7 +90,7 @@ class DwarfCfa { AddressType cur_pc() { return cur_pc_; } - void set_cie_loc_regs(const dwarf_loc_regs_t* cie_loc_regs) { cie_loc_regs_ = cie_loc_regs; } + void set_cie_loc_regs(const DwarfLocations* cie_loc_regs) { cie_loc_regs_ = cie_loc_regs; } protected: std::string GetOperandString(uint8_t operand, uint64_t value, uint64_t* cur_pc); @@ -106,36 +106,36 @@ class DwarfCfa { ArchEnum arch_; AddressType cur_pc_; - const dwarf_loc_regs_t* cie_loc_regs_ = nullptr; + const DwarfLocations* cie_loc_regs_ = nullptr; std::vector<AddressType> operands_; - std::stack<dwarf_loc_regs_t> loc_reg_state_; + std::stack<DwarfLocations> loc_reg_state_; // CFA processing functions. - bool cfa_nop(dwarf_loc_regs_t*); - bool cfa_set_loc(dwarf_loc_regs_t*); - bool cfa_advance_loc(dwarf_loc_regs_t*); - bool cfa_offset(dwarf_loc_regs_t*); - bool cfa_restore(dwarf_loc_regs_t*); - bool cfa_undefined(dwarf_loc_regs_t*); - bool cfa_same_value(dwarf_loc_regs_t*); - bool cfa_register(dwarf_loc_regs_t*); - bool cfa_remember_state(dwarf_loc_regs_t*); - bool cfa_restore_state(dwarf_loc_regs_t*); - bool cfa_def_cfa(dwarf_loc_regs_t*); - bool cfa_def_cfa_register(dwarf_loc_regs_t*); - bool cfa_def_cfa_offset(dwarf_loc_regs_t*); - bool cfa_def_cfa_expression(dwarf_loc_regs_t*); - bool cfa_expression(dwarf_loc_regs_t*); - bool cfa_offset_extended_sf(dwarf_loc_regs_t*); - bool cfa_def_cfa_sf(dwarf_loc_regs_t*); - bool cfa_def_cfa_offset_sf(dwarf_loc_regs_t*); - bool cfa_val_offset(dwarf_loc_regs_t*); - bool cfa_val_offset_sf(dwarf_loc_regs_t*); - bool cfa_val_expression(dwarf_loc_regs_t*); - bool cfa_gnu_negative_offset_extended(dwarf_loc_regs_t*); - bool cfa_aarch64_negate_ra_state(dwarf_loc_regs_t*); + bool cfa_nop(DwarfLocations*); + bool cfa_set_loc(DwarfLocations*); + bool cfa_advance_loc(DwarfLocations*); + bool cfa_offset(DwarfLocations*); + bool cfa_restore(DwarfLocations*); + bool cfa_undefined(DwarfLocations*); + bool cfa_same_value(DwarfLocations*); + bool cfa_register(DwarfLocations*); + bool cfa_remember_state(DwarfLocations*); + bool cfa_restore_state(DwarfLocations*); + bool cfa_def_cfa(DwarfLocations*); + bool cfa_def_cfa_register(DwarfLocations*); + bool cfa_def_cfa_offset(DwarfLocations*); + bool cfa_def_cfa_expression(DwarfLocations*); + bool cfa_expression(DwarfLocations*); + bool cfa_offset_extended_sf(DwarfLocations*); + bool cfa_def_cfa_sf(DwarfLocations*); + bool cfa_def_cfa_offset_sf(DwarfLocations*); + bool cfa_val_offset(DwarfLocations*); + bool cfa_val_offset_sf(DwarfLocations*); + bool cfa_val_expression(DwarfLocations*); + bool cfa_gnu_negative_offset_extended(DwarfLocations*); + bool cfa_aarch64_negate_ra_state(DwarfLocations*); - using process_func = bool (DwarfCfa::*)(dwarf_loc_regs_t*); + using process_func = bool (DwarfCfa::*)(DwarfLocations*); constexpr static process_func kCallbackTable[64] = { // 0x00 DW_CFA_nop &DwarfCfa::cfa_nop, diff --git a/libunwindstack/DwarfSection.cpp b/libunwindstack/DwarfSection.cpp index ad25e80..adadeb8 100644 --- a/libunwindstack/DwarfSection.cpp +++ b/libunwindstack/DwarfSection.cpp @@ -50,7 +50,7 @@ bool DwarfSection::Step(uint64_t pc, Regs* regs, Memory* process_memory, bool* f } // Now get the location information for this pc. - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; if (!GetCfaLocationInfo(pc, fde, &loc_regs, regs->Arch())) { return false; } @@ -412,7 +412,7 @@ bool DwarfSectionImpl<AddressType>::EvalExpression(const DwarfLocation& loc, Mem template <typename AddressType> struct EvalInfo { - const dwarf_loc_regs_t* loc_regs; + const DwarfLocations* loc_regs; const DwarfCie* cie; Memory* regular_memory; AddressType cfa; @@ -483,7 +483,7 @@ bool DwarfSectionImpl<AddressType>::EvalRegister(const DwarfLocation* loc, uint3 template <typename AddressType> bool DwarfSectionImpl<AddressType>::Eval(const DwarfCie* cie, Memory* regular_memory, - const dwarf_loc_regs_t& loc_regs, Regs* regs, + const DwarfLocations& loc_regs, Regs* regs, bool* finished) { RegsImpl<AddressType>* cur_regs = reinterpret_cast<RegsImpl<AddressType>*>(regs); if (cie->return_address_register >= cur_regs->total_regs()) { @@ -576,7 +576,7 @@ bool DwarfSectionImpl<AddressType>::Eval(const DwarfCie* cie, Memory* regular_me template <typename AddressType> bool DwarfSectionImpl<AddressType>::GetCfaLocationInfo(uint64_t pc, const DwarfFde* fde, - dwarf_loc_regs_t* loc_regs, ArchEnum arch) { + DwarfLocations* loc_regs, ArchEnum arch) { DwarfCfa<AddressType> cfa(&memory_, fde, arch); // Look for the cached copy of the cie data. diff --git a/libunwindstack/include/unwindstack/DwarfLocation.h b/libunwindstack/include/unwindstack/DwarfLocation.h index bf45bc7..22ed47a 100644 --- a/libunwindstack/include/unwindstack/DwarfLocation.h +++ b/libunwindstack/include/unwindstack/DwarfLocation.h @@ -47,7 +47,6 @@ struct DwarfLocations : public std::unordered_map<uint32_t, DwarfLocation> { uint64_t pc_start = 0; uint64_t pc_end = 0; }; -typedef DwarfLocations dwarf_loc_regs_t; } // namespace unwindstack diff --git a/libunwindstack/include/unwindstack/DwarfSection.h b/libunwindstack/include/unwindstack/DwarfSection.h index f28cf25..acb6528 100644 --- a/libunwindstack/include/unwindstack/DwarfSection.h +++ b/libunwindstack/include/unwindstack/DwarfSection.h @@ -89,7 +89,7 @@ class DwarfSection { virtual bool Init(uint64_t offset, uint64_t size, int64_t section_bias) = 0; - virtual bool Eval(const DwarfCie*, Memory*, const dwarf_loc_regs_t&, Regs*, bool*) = 0; + virtual bool Eval(const DwarfCie*, Memory*, const DwarfLocations&, Regs*, bool*) = 0; virtual bool Log(uint8_t indent, uint64_t pc, const DwarfFde* fde, ArchEnum arch) = 0; @@ -97,7 +97,7 @@ class DwarfSection { virtual const DwarfFde* GetFdeFromPc(uint64_t pc) = 0; - virtual bool GetCfaLocationInfo(uint64_t pc, const DwarfFde* fde, dwarf_loc_regs_t* loc_regs, + virtual bool GetCfaLocationInfo(uint64_t pc, const DwarfFde* fde, DwarfLocations* loc_regs, ArchEnum arch) = 0; virtual uint64_t GetCieOffsetFromFde32(uint32_t pointer) = 0; @@ -117,8 +117,8 @@ class DwarfSection { std::unordered_map<uint64_t, DwarfFde> fde_entries_; std::unordered_map<uint64_t, DwarfCie> cie_entries_; - std::unordered_map<uint64_t, dwarf_loc_regs_t> cie_loc_regs_; - std::map<uint64_t, dwarf_loc_regs_t> loc_regs_; // Single row indexed by pc_end. + std::unordered_map<uint64_t, DwarfLocations> cie_loc_regs_; + std::map<uint64_t, DwarfLocations> loc_regs_; // Single row indexed by pc_end. }; template <typename AddressType> @@ -139,10 +139,10 @@ class DwarfSectionImpl : public DwarfSection { bool EvalRegister(const DwarfLocation* loc, uint32_t reg, AddressType* reg_ptr, void* info); - bool Eval(const DwarfCie* cie, Memory* regular_memory, const dwarf_loc_regs_t& loc_regs, - Regs* regs, bool* finished) override; + bool Eval(const DwarfCie* cie, Memory* regular_memory, const DwarfLocations& loc_regs, Regs* regs, + bool* finished) override; - bool GetCfaLocationInfo(uint64_t pc, const DwarfFde* fde, dwarf_loc_regs_t* loc_regs, + bool GetCfaLocationInfo(uint64_t pc, const DwarfFde* fde, DwarfLocations* loc_regs, ArchEnum arch) override; bool Log(uint8_t indent, uint64_t pc, const DwarfFde* fde, ArchEnum arch) override; diff --git a/libunwindstack/tests/DwarfCfaLogTest.cpp b/libunwindstack/tests/DwarfCfaLogTest.cpp index 2b5a8dc..7cb51ef 100644 --- a/libunwindstack/tests/DwarfCfaLogTest.cpp +++ b/libunwindstack/tests/DwarfCfaLogTest.cpp @@ -313,7 +313,7 @@ TYPED_TEST_P(DwarfCfaLogTest, cfa_undefined) { ASSERT_EQ("", GetFakeLogBuf()); ResetLogs(); - dwarf_loc_regs_t cie_loc_regs; + DwarfLocations cie_loc_regs; this->memory_.SetMemory(0x1a00, std::vector<uint8_t>{0x07, 0x81, 0x01}); ASSERT_TRUE(this->cfa_->Log(0, this->fde_.pc_start, 0x1a00, 0x1a03)); diff --git a/libunwindstack/tests/DwarfCfaTest.cpp b/libunwindstack/tests/DwarfCfaTest.cpp index ea7e708..5ed428d 100644 --- a/libunwindstack/tests/DwarfCfaTest.cpp +++ b/libunwindstack/tests/DwarfCfaTest.cpp @@ -77,7 +77,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_illegal) { continue; } this->memory_.SetMemory(0x2000, std::vector<uint8_t>{i}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_FALSE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x2000, 0x2001, &loc_regs)); ASSERT_EQ(DWARF_ERROR_ILLEGAL_VALUE, this->cfa_->LastErrorCode()); @@ -90,7 +90,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_illegal) { TYPED_TEST_P(DwarfCfaTest, cfa_nop) { this->memory_.SetMemory(0x2000, std::vector<uint8_t>{0x00}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x2000, 0x2001, &loc_regs)); ASSERT_EQ(0x2001U, this->dmem_->cur_offset()); @@ -103,7 +103,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_nop) { // This test needs to be examined. TYPED_TEST_P(DwarfCfaTest, cfa_offset) { this->memory_.SetMemory(0x2000, std::vector<uint8_t>{0x83, 0x04}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x2000, 0x2002, &loc_regs)); ASSERT_EQ(0x2002U, this->dmem_->cur_offset()); @@ -134,7 +134,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_offset) { TYPED_TEST_P(DwarfCfaTest, cfa_offset_extended) { this->memory_.SetMemory(0x500, std::vector<uint8_t>{0x05, 0x03, 0x02}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x500, 0x503, &loc_regs)); ASSERT_EQ(0x503U, this->dmem_->cur_offset()); @@ -165,7 +165,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_offset_extended) { TYPED_TEST_P(DwarfCfaTest, cfa_offset_extended_sf) { this->memory_.SetMemory(0x500, std::vector<uint8_t>{0x11, 0x05, 0x10}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x500, 0x503, &loc_regs)); ASSERT_EQ(0x503U, this->dmem_->cur_offset()); @@ -197,7 +197,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_offset_extended_sf) { TYPED_TEST_P(DwarfCfaTest, cfa_restore) { this->memory_.SetMemory(0x2000, std::vector<uint8_t>{0xc2}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_FALSE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x2000, 0x2001, &loc_regs)); ASSERT_EQ(DWARF_ERROR_ILLEGAL_STATE, this->cfa_->LastErrorCode()); @@ -208,7 +208,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_restore) { ASSERT_EQ("", GetFakeLogBuf()); ResetLogs(); - dwarf_loc_regs_t cie_loc_regs; + DwarfLocations cie_loc_regs; cie_loc_regs[2] = {.type = DWARF_LOCATION_REGISTER, .values = {0, 0}}; this->cfa_->set_cie_loc_regs(&cie_loc_regs); this->memory_.SetMemory(0x3000, std::vector<uint8_t>{0x82, 0x04, 0xc2}); @@ -226,7 +226,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_restore) { TYPED_TEST_P(DwarfCfaTest, cfa_restore_extended) { this->memory_.SetMemory(0x4000, std::vector<uint8_t>{0x06, 0x08}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_FALSE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x4000, 0x4002, &loc_regs)); ASSERT_EQ(DWARF_ERROR_ILLEGAL_STATE, this->cfa_->LastErrorCode()); @@ -239,7 +239,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_restore_extended) { ResetLogs(); loc_regs.clear(); this->memory_.SetMemory(0x5000, std::vector<uint8_t>{0x05, 0x82, 0x02, 0x04, 0x06, 0x82, 0x02}); - dwarf_loc_regs_t cie_loc_regs; + DwarfLocations cie_loc_regs; cie_loc_regs[258] = {.type = DWARF_LOCATION_REGISTER, .values = {0, 0}}; this->cfa_->set_cie_loc_regs(&cie_loc_regs); @@ -273,7 +273,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_set_loc) { this->memory_.SetMemory(0x50, buffer, sizeof(buffer)); ResetLogs(); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE( this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x50, 0x51 + sizeof(TypeParam), &loc_regs)); ASSERT_EQ(0x51 + sizeof(TypeParam), this->dmem_->cur_offset()); @@ -303,7 +303,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_set_loc) { TYPED_TEST_P(DwarfCfaTest, cfa_advance_loc1) { this->memory_.SetMemory(0x200, std::vector<uint8_t>{0x02, 0x04}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x200, 0x202, &loc_regs)); ASSERT_EQ(0x202U, this->dmem_->cur_offset()); @@ -316,7 +316,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_advance_loc1) { TYPED_TEST_P(DwarfCfaTest, cfa_advance_loc2) { this->memory_.SetMemory(0x600, std::vector<uint8_t>{0x03, 0x04, 0x03}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x600, 0x603, &loc_regs)); ASSERT_EQ(0x603U, this->dmem_->cur_offset()); @@ -329,7 +329,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_advance_loc2) { TYPED_TEST_P(DwarfCfaTest, cfa_advance_loc4) { this->memory_.SetMemory(0x500, std::vector<uint8_t>{0x04, 0x04, 0x03, 0x02, 0x01}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x500, 0x505, &loc_regs)); ASSERT_EQ(0x505U, this->dmem_->cur_offset()); @@ -342,7 +342,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_advance_loc4) { TYPED_TEST_P(DwarfCfaTest, cfa_undefined) { this->memory_.SetMemory(0xa00, std::vector<uint8_t>{0x07, 0x09}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0xa00, 0xa02, &loc_regs)); ASSERT_EQ(0xa02U, this->dmem_->cur_offset()); @@ -371,7 +371,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_undefined) { TYPED_TEST_P(DwarfCfaTest, cfa_same) { this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x08, 0x7f}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; loc_regs[127] = {.type = DWARF_LOCATION_REGISTER, .values = {0, 0}}; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x100, 0x102, &loc_regs)); @@ -398,7 +398,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_same) { TYPED_TEST_P(DwarfCfaTest, cfa_register) { this->memory_.SetMemory(0x300, std::vector<uint8_t>{0x09, 0x02, 0x01}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x300, 0x303, &loc_regs)); ASSERT_EQ(0x303U, this->dmem_->cur_offset()); @@ -429,7 +429,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_register) { TYPED_TEST_P(DwarfCfaTest, cfa_state) { this->memory_.SetMemory(0x300, std::vector<uint8_t>{0x0a}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x300, 0x301, &loc_regs)); ASSERT_EQ(0x301U, this->dmem_->cur_offset()); @@ -516,7 +516,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_state) { // restored, the gcc unwinder does, and libunwind does too. TYPED_TEST_P(DwarfCfaTest, cfa_state_cfa_offset_restore) { this->memory_.SetMemory(0x3000, std::vector<uint8_t>{0x0a, 0x0e, 0x40, 0x0b}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; loc_regs[CFA_REG] = {.type = DWARF_LOCATION_REGISTER, .values = {5, 100}}; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x3000, 0x3004, &loc_regs)); @@ -532,7 +532,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_state_cfa_offset_restore) { TYPED_TEST_P(DwarfCfaTest, cfa_def_cfa) { this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x0c, 0x7f, 0x74}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x100, 0x103, &loc_regs)); ASSERT_EQ(0x103U, this->dmem_->cur_offset()); @@ -561,7 +561,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_def_cfa) { TYPED_TEST_P(DwarfCfaTest, cfa_def_cfa_sf) { this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x12, 0x30, 0x25}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x100, 0x103, &loc_regs)); ASSERT_EQ(0x103U, this->dmem_->cur_offset()); @@ -591,7 +591,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_def_cfa_sf) { TYPED_TEST_P(DwarfCfaTest, cfa_def_cfa_register) { this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x0d, 0x72}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; // This fails because the cfa is not defined as a register. ASSERT_FALSE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x100, 0x102, &loc_regs)); @@ -634,7 +634,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_def_cfa_register) { TYPED_TEST_P(DwarfCfaTest, cfa_def_cfa_offset) { this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x0e, 0x59}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; // This fails because the cfa is not defined as a register. ASSERT_FALSE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x100, 0x102, &loc_regs)); @@ -677,7 +677,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_def_cfa_offset) { TYPED_TEST_P(DwarfCfaTest, cfa_def_cfa_offset_sf) { this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x13, 0x23}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; // This fails because the cfa is not defined as a register. ASSERT_FALSE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x100, 0x102, &loc_regs)); @@ -720,7 +720,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_def_cfa_offset_sf) { TYPED_TEST_P(DwarfCfaTest, cfa_def_cfa_expression) { this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x0f, 0x04, 0x01, 0x02, 0x03, 0x04}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x100, 0x106, &loc_regs)); ASSERT_EQ(0x106U, this->dmem_->cur_offset()); @@ -748,7 +748,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_def_cfa_expression) { TYPED_TEST_P(DwarfCfaTest, cfa_expression) { this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x10, 0x04, 0x02, 0x40, 0x20}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x100, 0x105, &loc_regs)); ASSERT_EQ(0x105U, this->dmem_->cur_offset()); @@ -785,7 +785,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_expression) { TYPED_TEST_P(DwarfCfaTest, cfa_val_offset) { this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x14, 0x45, 0x54}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x100, 0x103, &loc_regs)); ASSERT_EQ(0x103U, this->dmem_->cur_offset()); @@ -816,7 +816,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_val_offset) { TYPED_TEST_P(DwarfCfaTest, cfa_val_offset_sf) { this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x15, 0x56, 0x12}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x100, 0x103, &loc_regs)); ASSERT_EQ(0x103U, this->dmem_->cur_offset()); @@ -848,7 +848,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_val_offset_sf) { TYPED_TEST_P(DwarfCfaTest, cfa_val_expression) { this->memory_.SetMemory(0x100, std::vector<uint8_t>{0x16, 0x05, 0x02, 0x10, 0x20}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x100, 0x105, &loc_regs)); ASSERT_EQ(0x105U, this->dmem_->cur_offset()); @@ -886,7 +886,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_val_expression) { TYPED_TEST_P(DwarfCfaTest, cfa_gnu_args_size) { this->memory_.SetMemory(0x2000, std::vector<uint8_t>{0x2e, 0x04}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x2000, 0x2002, &loc_regs)); ASSERT_EQ(0x2002U, this->dmem_->cur_offset()); @@ -909,7 +909,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_gnu_args_size) { TYPED_TEST_P(DwarfCfaTest, cfa_gnu_negative_offset_extended) { this->memory_.SetMemory(0x500, std::vector<uint8_t>{0x2f, 0x08, 0x10}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x500, 0x503, &loc_regs)); ASSERT_EQ(0x503U, this->dmem_->cur_offset()); @@ -940,7 +940,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_gnu_negative_offset_extended) { TYPED_TEST_P(DwarfCfaTest, cfa_register_override) { this->memory_.SetMemory(0x300, std::vector<uint8_t>{0x09, 0x02, 0x01, 0x09, 0x02, 0x04}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x300, 0x306, &loc_regs)); ASSERT_EQ(0x306U, this->dmem_->cur_offset()); @@ -956,7 +956,7 @@ TYPED_TEST_P(DwarfCfaTest, cfa_register_override) { TYPED_TEST_P(DwarfCfaTest, cfa_aarch64_negate_ra_state) { this->memory_.SetMemory(0x2000, std::vector<uint8_t>{0x2d}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_FALSE(this->cfa_->GetLocationInfo(this->fde_.pc_start, 0x2000, 0x2001, &loc_regs)); ASSERT_EQ(DWARF_ERROR_ILLEGAL_VALUE, this->cfa_->LastErrorCode()); diff --git a/libunwindstack/tests/DwarfSectionImplTest.cpp b/libunwindstack/tests/DwarfSectionImplTest.cpp index a08a8d0..9d047f2 100644 --- a/libunwindstack/tests/DwarfSectionImplTest.cpp +++ b/libunwindstack/tests/DwarfSectionImplTest.cpp @@ -48,7 +48,7 @@ class TestDwarfSectionImpl : public DwarfSectionImpl<TypeParam> { uint64_t AdjustPcFromFde(uint64_t) override { return 0; } - void TestSetCachedCieLocRegs(uint64_t offset, const dwarf_loc_regs_t& loc_regs) { + void TestSetCachedCieLocRegs(uint64_t offset, const DwarfLocations& loc_regs) { this->cie_loc_regs_[offset] = loc_regs; } void TestClearCachedCieLocRegs() { this->cie_loc_regs_.clear(); } @@ -98,7 +98,7 @@ TYPED_TEST_P(DwarfSectionImplTest, GetFdeFromOffset_fail_should_not_cache) { TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_expr_eval_fail) { DwarfCie cie{.version = 3, .return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -114,7 +114,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_expr_eval_fail) { TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_expr_no_stack) { DwarfCie cie{.version = 3, .return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -130,7 +130,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_expr_no_stack) { TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_expr) { DwarfCie cie{.version = 3, .return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -148,7 +148,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_expr) { TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_val_expr) { DwarfCie cie{.version = 3, .return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -166,7 +166,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_val_expr) { TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_expr_is_register) { DwarfCie cie{.version = 3, .return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -182,7 +182,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_expr_is_register) { TYPED_TEST_P(DwarfSectionImplTest, Eval_bad_regs) { DwarfCie cie{.return_address_register = 60}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; bool finished; ASSERT_FALSE(this->section_->Eval(&cie, &this->memory_, loc_regs, ®s, &finished)); @@ -192,7 +192,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_bad_regs) { TYPED_TEST_P(DwarfSectionImplTest, Eval_no_cfa) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; bool finished; ASSERT_FALSE(this->section_->Eval(&cie, &this->memory_, loc_regs, ®s, &finished)); @@ -202,7 +202,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_no_cfa) { TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_bad) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; loc_regs[CFA_REG] = DwarfLocation{DWARF_LOCATION_REGISTER, {20, 0}}; bool finished; @@ -231,7 +231,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_bad) { TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_register_prev) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -248,7 +248,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_register_prev) { TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_register_from_value) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -266,7 +266,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_cfa_register_from_value) { TYPED_TEST_P(DwarfSectionImplTest, Eval_double_indirection) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -287,7 +287,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_double_indirection) { TYPED_TEST_P(DwarfSectionImplTest, Eval_register_reference_chain) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -318,7 +318,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_register_reference_chain) { TYPED_TEST_P(DwarfSectionImplTest, Eval_dex_pc) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -337,7 +337,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_dex_pc) { TYPED_TEST_P(DwarfSectionImplTest, Eval_invalid_register) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -352,7 +352,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_invalid_register) { TYPED_TEST_P(DwarfSectionImplTest, Eval_different_reg_locations) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; if (sizeof(TypeParam) == sizeof(uint64_t)) { this->memory_.SetData64(0x2150, 0x12345678abcdef00ULL); @@ -386,7 +386,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_different_reg_locations) { TYPED_TEST_P(DwarfSectionImplTest, Eval_return_address_undefined) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -404,7 +404,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_return_address_undefined) { TYPED_TEST_P(DwarfSectionImplTest, Eval_pc_zero) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -421,7 +421,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_pc_zero) { TYPED_TEST_P(DwarfSectionImplTest, Eval_return_address) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -438,7 +438,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_return_address) { TYPED_TEST_P(DwarfSectionImplTest, Eval_ignore_large_reg_loc) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -457,7 +457,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_ignore_large_reg_loc) { TYPED_TEST_P(DwarfSectionImplTest, Eval_reg_expr) { DwarfCie cie{.version = 3, .return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -477,7 +477,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_reg_expr) { TYPED_TEST_P(DwarfSectionImplTest, Eval_reg_val_expr) { DwarfCie cie{.version = 3, .return_address_register = 5}; RegsImplFake<TypeParam> regs(10); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; regs.set_pc(0x100); regs.set_sp(0x2000); @@ -496,7 +496,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_pseudo_register_invalid) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); regs.set_pseudo_reg(11); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; loc_regs[CFA_REG] = DwarfLocation{DWARF_LOCATION_REGISTER, {8, 0}}; loc_regs[1] = DwarfLocation{DWARF_LOCATION_PSEUDO_REGISTER, {20, 0}}; @@ -515,7 +515,7 @@ TYPED_TEST_P(DwarfSectionImplTest, Eval_pseudo_register) { DwarfCie cie{.return_address_register = 5}; RegsImplFake<TypeParam> regs(10); regs.set_pseudo_reg(11); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; loc_regs[CFA_REG] = DwarfLocation{DWARF_LOCATION_REGISTER, {8, 0}}; loc_regs[11] = DwarfLocation{DWARF_LOCATION_PSEUDO_REGISTER, {20, 0}}; @@ -539,7 +539,7 @@ TYPED_TEST_P(DwarfSectionImplTest, GetCfaLocationInfo_cie_not_cached) { this->memory_.SetMemory(0x3000, std::vector<uint8_t>{0x09, 0x02, 0x01}); this->memory_.SetMemory(0x6000, std::vector<uint8_t>{0x09, 0x04, 0x03}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->section_->GetCfaLocationInfo(0x100, &fde, &loc_regs, ARCH_UNKNOWN)); ASSERT_EQ(2U, loc_regs.size()); @@ -564,12 +564,12 @@ TYPED_TEST_P(DwarfSectionImplTest, GetCfaLocationInfo_cie_cached) { fde.cfa_instructions_offset = 0x6000; fde.cfa_instructions_end = 0x6002; - dwarf_loc_regs_t cie_loc_regs; + DwarfLocations cie_loc_regs; cie_loc_regs[6] = DwarfLocation{DWARF_LOCATION_REGISTER, {4, 0}}; this->section_->TestSetCachedCieLocRegs(0x8000, cie_loc_regs); this->memory_.SetMemory(0x6000, std::vector<uint8_t>{0x09, 0x04, 0x03}); - dwarf_loc_regs_t loc_regs; + DwarfLocations loc_regs; ASSERT_TRUE(this->section_->GetCfaLocationInfo(0x100, &fde, &loc_regs, ARCH_UNKNOWN)); ASSERT_EQ(2U, loc_regs.size()); diff --git a/libunwindstack/tests/DwarfSectionTest.cpp b/libunwindstack/tests/DwarfSectionTest.cpp index e5a1aed..e1ed885 100644 --- a/libunwindstack/tests/DwarfSectionTest.cpp +++ b/libunwindstack/tests/DwarfSectionTest.cpp @@ -34,7 +34,7 @@ class MockDwarfSection : public DwarfSection { MOCK_METHOD(bool, Init, (uint64_t, uint64_t, int64_t), (override)); - MOCK_METHOD(bool, Eval, (const DwarfCie*, Memory*, const dwarf_loc_regs_t&, Regs*, bool*), + MOCK_METHOD(bool, Eval, (const DwarfCie*, Memory*, const DwarfLocations&, Regs*, bool*), (override)); MOCK_METHOD(bool, Log, (uint8_t, uint64_t, const DwarfFde*, ArchEnum arch), (override)); @@ -43,8 +43,8 @@ class MockDwarfSection : public DwarfSection { MOCK_METHOD(const DwarfFde*, GetFdeFromPc, (uint64_t), (override)); - MOCK_METHOD(bool, GetCfaLocationInfo, - (uint64_t, const DwarfFde*, dwarf_loc_regs_t*, ArchEnum arch), (override)); + MOCK_METHOD(bool, GetCfaLocationInfo, (uint64_t, const DwarfFde*, DwarfLocations*, ArchEnum arch), + (override)); MOCK_METHOD(uint64_t, GetCieOffsetFromFde32, (uint32_t), (override)); @@ -118,8 +118,8 @@ TEST_F(DwarfSectionTest, Step_pass) { ASSERT_TRUE(section_->Step(0x1000, ®s_, &process, &finished, &is_signal_frame)); } -static bool MockGetCfaLocationInfo(::testing::Unused, const DwarfFde* fde, - dwarf_loc_regs_t* loc_regs, ArchEnum) { +static bool MockGetCfaLocationInfo(::testing::Unused, const DwarfFde* fde, DwarfLocations* loc_regs, + ArchEnum) { loc_regs->pc_start = fde->pc_start; loc_regs->pc_end = fde->pc_end; return true; diff --git a/libunwindstack/tests/VerifyBionicTerminationTest.cpp b/libunwindstack/tests/VerifyBionicTerminationTest.cpp index 3e67dc9..1ef8ce4 100644 --- a/libunwindstack/tests/VerifyBionicTerminationTest.cpp +++ b/libunwindstack/tests/VerifyBionicTerminationTest.cpp @@ -54,7 +54,7 @@ static DwarfLocationEnum GetReturnAddressLocation(uint64_t rel_pc, DwarfSection* if (fde == nullptr || fde->cie == nullptr) { return DWARF_LOCATION_INVALID; } - dwarf_loc_regs_t regs; + DwarfLocations regs; if (!section->GetCfaLocationInfo(rel_pc, fde, ®s, ARCH_UNKNOWN)) { return DWARF_LOCATION_INVALID; } diff --git a/libunwindstack/tools/unwind_reg_info.cpp b/libunwindstack/tools/unwind_reg_info.cpp index 68e0273..855a0f3 100644 --- a/libunwindstack/tools/unwind_reg_info.cpp +++ b/libunwindstack/tools/unwind_reg_info.cpp @@ -72,7 +72,7 @@ void PrintRegInformation(DwarfSection* section, Memory* memory, uint64_t pc, uin return; } - dwarf_loc_regs_t regs; + DwarfLocations regs; if (!section->GetCfaLocationInfo(pc, fde, ®s, arch)) { printf(" Cannot get location information.\n"); return; |