Skip to content

[lldb][NFC] New names for the two RegisterLocation classes (#109611) #9317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lldb/include/lldb/Symbol/UnwindPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class UnwindPlan {
public:
class Row {
public:
class RegisterLocation {
class AbstractRegisterLocation {
public:
enum RestoreType {
unspecified, // not specified, we may be able to assume this
Expand All @@ -72,11 +72,11 @@ class UnwindPlan {
isConstant // reg = constant
};

RegisterLocation() : m_location() {}
AbstractRegisterLocation() : m_location() {}

bool operator==(const RegisterLocation &rhs) const;
bool operator==(const AbstractRegisterLocation &rhs) const;

bool operator!=(const RegisterLocation &rhs) const {
bool operator!=(const AbstractRegisterLocation &rhs) const {
return !(*this == rhs);
}

Expand Down Expand Up @@ -337,10 +337,10 @@ class UnwindPlan {
bool operator==(const Row &rhs) const;

bool GetRegisterInfo(uint32_t reg_num,
RegisterLocation &register_location) const;
AbstractRegisterLocation &register_location) const;

void SetRegisterInfo(uint32_t reg_num,
const RegisterLocation register_location);
const AbstractRegisterLocation register_location);

void RemoveRegisterInfo(uint32_t reg_num);

Expand Down Expand Up @@ -402,7 +402,7 @@ class UnwindPlan {
lldb::addr_t base_addr) const;

protected:
typedef std::map<uint32_t, RegisterLocation> collection;
typedef std::map<uint32_t, AbstractRegisterLocation> collection;
lldb::addr_t m_offset = 0; // Offset into the function for this row

FAValue m_cfa_value;
Expand Down
6 changes: 3 additions & 3 deletions lldb/include/lldb/Target/ABI.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ class ABI : public PluginInterface {

virtual bool RegisterIsVolatile(const RegisterInfo *reg_info) = 0;

virtual bool
GetFallbackRegisterLocation(const RegisterInfo *reg_info,
UnwindPlan::Row::RegisterLocation &unwind_regloc);
virtual bool GetFallbackRegisterLocation(
const RegisterInfo *reg_info,
UnwindPlan::Row::AbstractRegisterLocation &unwind_regloc);

// Should take a look at a call frame address (CFA) which is just the stack
// pointer value upon entry to a function. ABIs usually impose alignment
Expand Down
25 changes: 12 additions & 13 deletions lldb/include/lldb/Target/RegisterContextUnwind.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class RegisterContextUnwind : public lldb_private::RegisterContext {
// past the top (end) of the stack
};

// UnwindLLDB needs to pass around references to RegisterLocations
// UnwindLLDB needs to pass around references to ConcreteRegisterLocations
friend class UnwindLLDB;

// Returns true if we have an unwind loop -- the same stack frame unwinding
Expand Down Expand Up @@ -135,29 +135,28 @@ class RegisterContextUnwind : public lldb_private::RegisterContext {
// preserved a register that this
// function didn't modify/use.
//
// The RegisterLocation type may be set to eRegisterNotAvailable -- this will
// happen for a volatile register
// being queried mid-stack. Instead of floating frame 0's contents of that
// register up the stack (which may
// or may not be the value of that reg when the function was executing), we
// won't return any value.
// The ConcreteRegisterLocation type may be set to eRegisterNotAvailable --
// this will happen for a volatile register being queried mid-stack. Instead
// of floating frame 0's contents of that register up the stack (which may or
// may not be the value of that reg when the function was executing), we won't
// return any value.
//
// If a non-volatile register (a "preserved" register) is requested mid-stack
// and no frames "below" the requested
// stack have saved the register anywhere, it is safe to assume that frame 0's
// register values are still the same
// as the requesting frame's.
lldb_private::UnwindLLDB::RegisterSearchResult
SavedLocationForRegister(uint32_t lldb_regnum,
lldb_private::UnwindLLDB::RegisterLocation &regloc);
lldb_private::UnwindLLDB::RegisterSearchResult SavedLocationForRegister(
uint32_t lldb_regnum,
lldb_private::UnwindLLDB::ConcreteRegisterLocation &regloc);

bool ReadRegisterValueFromRegisterLocation(
lldb_private::UnwindLLDB::RegisterLocation regloc,
lldb_private::UnwindLLDB::ConcreteRegisterLocation regloc,
const lldb_private::RegisterInfo *reg_info,
lldb_private::RegisterValue &value);

bool WriteRegisterValueToRegisterLocation(
lldb_private::UnwindLLDB::RegisterLocation regloc,
lldb_private::UnwindLLDB::ConcreteRegisterLocation regloc,
const lldb_private::RegisterInfo *reg_info,
const lldb_private::RegisterValue &value);

Expand Down Expand Up @@ -249,7 +248,7 @@ class RegisterContextUnwind : public lldb_private::RegisterContext {

uint32_t m_frame_number; // What stack frame this RegisterContext is

std::map<uint32_t, lldb_private::UnwindLLDB::RegisterLocation>
std::map<uint32_t, lldb_private::UnwindLLDB::ConcreteRegisterLocation>
m_registers; // where to find reg values for this frame

lldb_private::UnwindLLDB &m_parent_unwind; // The UnwindLLDB that is creating
Expand Down
8 changes: 6 additions & 2 deletions lldb/include/lldb/Target/UnwindLLDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ class UnwindLLDB : public lldb_private::Unwind {
protected:
friend class lldb_private::RegisterContextUnwind;

struct RegisterLocation {
/// An UnwindPlan::Row::AbstractRegisterLocation, combined with the register
/// context and memory for a specific stop point, is used to create a
/// ConcreteRegisterLocation.
struct ConcreteRegisterLocation {
enum RegisterLocationTypes {
eRegisterNotSaved = 0, // register was not preserved by callee. If
// volatile reg, is unavailable
Expand Down Expand Up @@ -90,7 +93,8 @@ class UnwindLLDB : public lldb_private::Unwind {
// Iterate over the RegisterContextUnwind's in our m_frames vector, look for
// the first one that has a saved location for this reg.
bool SearchForSavedLocationForRegister(
uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation &regloc,
uint32_t lldb_regnum,
lldb_private::UnwindLLDB::ConcreteRegisterLocation &regloc,
uint32_t starting_frame_num, bool pc_register);

/// Provide the list of user-specified trap handler functions
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ bool ABISysV_s390x::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) {

bool ABISysV_s390x::GetFallbackRegisterLocation(
const RegisterInfo *reg_info,
UnwindPlan::Row::RegisterLocation &unwind_regloc) {
UnwindPlan::Row::AbstractRegisterLocation &unwind_regloc) {
// If a volatile register is being requested, we don't want to forward the
// next frame's register contents up the stack -- the register is not
// retrievable at this frame.
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class ABISysV_s390x : public lldb_private::RegInfoBasedABI {

bool GetFallbackRegisterLocation(
const lldb_private::RegisterInfo *reg_info,
lldb_private::UnwindPlan::Row::RegisterLocation &unwind_regloc) override;
lldb_private::UnwindPlan::Row::AbstractRegisterLocation &unwind_regloc)
override;

bool CallFrameAddressIsValid(lldb::addr_t cfa) override {
// Make sure the stack call frame addresses are 8 byte aligned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ bool SymbolFileBreakpad::ParseCFIUnwindRow(llvm::StringRef unwind_rules,
row.GetCFAValue().SetIsDWARFExpression(saved.data(), saved.size());
} else if (const RegisterInfo *info =
ResolveRegisterOrRA(triple, resolver, lhs)) {
UnwindPlan::Row::RegisterLocation loc;
UnwindPlan::Row::AbstractRegisterLocation loc;
loc.SetIsDWARFExpression(saved.data(), saved.size());
row.SetRegisterInfo(info->kinds[eRegisterKindLLDB], loc);
} else
Expand Down Expand Up @@ -766,7 +766,7 @@ SymbolFileBreakpad::ParseWinUnwindPlan(const Bookmark &bookmark,
}

llvm::ArrayRef<uint8_t> saved = SaveAsDWARF(*it->second);
UnwindPlan::Row::RegisterLocation loc;
UnwindPlan::Row::AbstractRegisterLocation loc;
loc.SetIsDWARFExpression(saved.data(), saved.size());
row_sp->SetRegisterInfo(info->kinds[eRegisterKindLLDB], loc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ bool UnwindAssembly_x86::AugmentUnwindPlanFromCallSite(
first_row->GetCFAValue().GetOffset() != wordsize) {
return false;
}
UnwindPlan::Row::RegisterLocation first_row_pc_loc;
UnwindPlan::Row::AbstractRegisterLocation first_row_pc_loc;
if (!first_row->GetRegisterInfo(
pc_regnum.GetAsKind(unwind_plan.GetRegisterKind()),
first_row_pc_loc) ||
Expand Down Expand Up @@ -126,7 +126,7 @@ bool UnwindAssembly_x86::AugmentUnwindPlanFromCallSite(
// Get the register locations for eip/rip from the first & last rows. Are
// they both CFA plus an offset? Is it the same offset?

UnwindPlan::Row::RegisterLocation last_row_pc_loc;
UnwindPlan::Row::AbstractRegisterLocation last_row_pc_loc;
if (last_row->GetRegisterInfo(
pc_regnum.GetAsKind(unwind_plan.GetRegisterKind()),
last_row_pc_loc)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
addr_t current_func_text_offset = 0;
int current_sp_bytes_offset_from_fa = 0;
bool is_aligned = false;
UnwindPlan::Row::RegisterLocation initial_regloc;
UnwindPlan::Row::AbstractRegisterLocation initial_regloc;
UnwindPlan::RowSP row(new UnwindPlan::Row);

unwind_plan.SetPlanValidAddressRange(func_range);
Expand Down Expand Up @@ -1051,7 +1051,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
if (nonvolatile_reg_p(machine_regno) &&
machine_regno_to_lldb_regno(machine_regno, lldb_regno) &&
!saved_registers[machine_regno]) {
UnwindPlan::Row::RegisterLocation regloc;
UnwindPlan::Row::AbstractRegisterLocation regloc;
if (is_aligned)
regloc.SetAtAFAPlusOffset(-current_sp_bytes_offset_from_fa);
else
Expand Down Expand Up @@ -1142,7 +1142,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
!saved_registers[machine_regno]) {
saved_registers[machine_regno] = true;

UnwindPlan::Row::RegisterLocation regloc;
UnwindPlan::Row::AbstractRegisterLocation regloc;

// stack_offset for 'movq %r15, -80(%rbp)' will be 80. In the Row, we
// want to express this as the offset from the FA. If the frame base is
Expand Down Expand Up @@ -1234,7 +1234,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
// determine the effcts of. Verify that the stack frame state
// has been unwound to the same as it was at function entry to avoid
// mis-identifying a JMP instruction as an epilogue.
UnwindPlan::Row::RegisterLocation sp, pc;
UnwindPlan::Row::AbstractRegisterLocation sp, pc;
if (row->GetRegisterInfo(m_lldb_sp_regnum, sp) &&
row->GetRegisterInfo(m_lldb_ip_regnum, pc)) {
// Any ret instruction variant is definitely indicative of an
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Symbol/ArmUnwindInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ bool ArmUnwindInfo::GetUnwindPlan(Target &target, const Address &addr,
}

if (!have_location_for_pc) {
UnwindPlan::Row::RegisterLocation lr_location;
UnwindPlan::Row::AbstractRegisterLocation lr_location;
if (row->GetRegisterInfo(dwarf_lr, lr_location))
row->SetRegisterInfo(dwarf_pc, lr_location);
else
Expand Down
16 changes: 8 additions & 8 deletions lldb/source/Symbol/DWARFCallFrameInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t dwarf_offset,

std::vector<UnwindPlan::RowSP> stack;

UnwindPlan::Row::RegisterLocation reg_location;
UnwindPlan::Row::AbstractRegisterLocation reg_location;
while (m_cfi_data.ValidOffset(offset) && offset < end_offset) {
uint8_t inst = m_cfi_data.GetU8(&offset);
uint8_t primary_opcode = inst & 0xC0;
Expand Down Expand Up @@ -822,7 +822,7 @@ bool DWARFCallFrameInfo::HandleCommonDwarfOpcode(uint8_t primary_opcode,
int32_t data_align,
lldb::offset_t &offset,
UnwindPlan::Row &row) {
UnwindPlan::Row::RegisterLocation reg_location;
UnwindPlan::Row::AbstractRegisterLocation reg_location;

if (primary_opcode) {
switch (primary_opcode) {
Expand Down Expand Up @@ -852,7 +852,7 @@ bool DWARFCallFrameInfo::HandleCommonDwarfOpcode(uint8_t primary_opcode,
// except for the encoding and size of the register argument.
uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
int32_t op_offset = (int32_t)m_cfi_data.GetULEB128(&offset) * data_align;
UnwindPlan::Row::RegisterLocation reg_location;
UnwindPlan::Row::AbstractRegisterLocation reg_location;
reg_location.SetAtCFAPlusOffset(op_offset);
row.SetRegisterInfo(reg_num, reg_location);
return true;
Expand All @@ -864,7 +864,7 @@ bool DWARFCallFrameInfo::HandleCommonDwarfOpcode(uint8_t primary_opcode,
// number. The required action is to set the rule for the specified
// register to undefined.
uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
UnwindPlan::Row::RegisterLocation reg_location;
UnwindPlan::Row::AbstractRegisterLocation reg_location;
reg_location.SetUndefined();
row.SetRegisterInfo(reg_num, reg_location);
return true;
Expand All @@ -876,7 +876,7 @@ bool DWARFCallFrameInfo::HandleCommonDwarfOpcode(uint8_t primary_opcode,
// number. The required action is to set the rule for the specified
// register to same value.
uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
UnwindPlan::Row::RegisterLocation reg_location;
UnwindPlan::Row::AbstractRegisterLocation reg_location;
reg_location.SetSame();
row.SetRegisterInfo(reg_num, reg_location);
return true;
Expand All @@ -889,7 +889,7 @@ bool DWARFCallFrameInfo::HandleCommonDwarfOpcode(uint8_t primary_opcode,
// second register.
uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
uint32_t other_reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
UnwindPlan::Row::RegisterLocation reg_location;
UnwindPlan::Row::AbstractRegisterLocation reg_location;
reg_location.SetInRegister(other_reg_num);
row.SetRegisterInfo(reg_num, reg_location);
return true;
Expand Down Expand Up @@ -950,7 +950,7 @@ bool DWARFCallFrameInfo::HandleCommonDwarfOpcode(uint8_t primary_opcode,
uint32_t block_len = (uint32_t)m_cfi_data.GetULEB128(&offset);
const uint8_t *block_data =
static_cast<const uint8_t *>(m_cfi_data.GetData(&offset, block_len));
UnwindPlan::Row::RegisterLocation reg_location;
UnwindPlan::Row::AbstractRegisterLocation reg_location;
reg_location.SetAtDWARFExpression(block_data, block_len);
row.SetRegisterInfo(reg_num, reg_location);
return true;
Expand All @@ -964,7 +964,7 @@ bool DWARFCallFrameInfo::HandleCommonDwarfOpcode(uint8_t primary_opcode,
// signed and factored.
uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
int32_t op_offset = (int32_t)m_cfi_data.GetSLEB128(&offset) * data_align;
UnwindPlan::Row::RegisterLocation reg_location;
UnwindPlan::Row::AbstractRegisterLocation reg_location;
reg_location.SetAtCFAPlusOffset(op_offset);
row.SetRegisterInfo(reg_num, reg_location);
return true;
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Symbol/FuncUnwinders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ LazyBool FuncUnwinders::CompareUnwindPlansForIdenticalInitialPCLocation(
UnwindPlan::RowSP b_first_row = b->GetRowAtIndex(0);

if (a_first_row.get() && b_first_row.get()) {
UnwindPlan::Row::RegisterLocation a_pc_regloc;
UnwindPlan::Row::RegisterLocation b_pc_regloc;
UnwindPlan::Row::AbstractRegisterLocation a_pc_regloc;
UnwindPlan::Row::AbstractRegisterLocation b_pc_regloc;

a_first_row->GetRegisterInfo(pc_reg_lldb_regnum, a_pc_regloc);
b_first_row->GetRegisterInfo(pc_reg_lldb_regnum, b_pc_regloc);
Expand Down
Loading