Skip to content

Commit 618f944

Browse files
[lldb][nfc] Remove no-op calls to Fix*Address (llvm#159586)
The first call, in InitializeNonZerothFrame, is inside a logging branch. For that, it's better to log the real value instead of the fixed one. The second call, inside RegisterContextUnwind::ReadFrameAddress, is computing an address which is then passed to ReadRegisterValueFromMemory, which boils down to a Process::ReadMemory, which fixes the address if it wants to. The current variable names are misleading, making readers believe it is the cfa value itself that is being passed to Fix*Address; that's not the case. This commit renames the variable to make this abundantly clear. (cherry picked from commit 113357f)
1 parent 9613d7f commit 618f944

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

lldb/source/Target/RegisterContextUnwind.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -362,16 +362,10 @@ void RegisterContextUnwind::InitializeNonZerothFrame() {
362362
if (log) {
363363
UnwindLogMsg("pc = 0x%" PRIx64, pc);
364364
addr_t reg_val;
365-
if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val)) {
366-
if (abi_sp)
367-
reg_val = abi_sp->FixDataAddress(reg_val);
365+
if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val))
368366
UnwindLogMsg("fp = 0x%" PRIx64, reg_val);
369-
}
370-
if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val)) {
371-
if (abi_sp)
372-
reg_val = abi_sp->FixDataAddress(reg_val);
367+
if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val))
373368
UnwindLogMsg("sp = 0x%" PRIx64, reg_val);
374-
}
375369
}
376370

377371
// A pc of 0x0 means it's the end of the stack crawl unless we're above a trap
@@ -1989,30 +1983,31 @@ bool RegisterContextUnwind::ReadFrameAddress(
19891983

19901984
switch (fa.GetValueType()) {
19911985
case UnwindPlan::Row::FAValue::isRegisterDereferenced: {
1992-
RegisterNumber cfa_reg(m_thread, row_register_kind,
1993-
fa.GetRegisterNumber());
1994-
if (ReadGPRValue(cfa_reg, cfa_reg_contents)) {
1986+
RegisterNumber regnum_to_deref(m_thread, row_register_kind,
1987+
fa.GetRegisterNumber());
1988+
addr_t reg_to_deref_contents;
1989+
if (ReadGPRValue(regnum_to_deref, reg_to_deref_contents)) {
19951990
const RegisterInfo *reg_info =
1996-
GetRegisterInfoAtIndex(cfa_reg.GetAsKind(eRegisterKindLLDB));
1991+
GetRegisterInfoAtIndex(regnum_to_deref.GetAsKind(eRegisterKindLLDB));
19971992
RegisterValue reg_value;
19981993
if (reg_info) {
1999-
if (abi_sp)
2000-
cfa_reg_contents = abi_sp->FixDataAddress(cfa_reg_contents);
20011994
Status error = ReadRegisterValueFromMemory(
2002-
reg_info, cfa_reg_contents, reg_info->byte_size, reg_value);
1995+
reg_info, reg_to_deref_contents, reg_info->byte_size, reg_value);
20031996
if (error.Success()) {
20041997
address = reg_value.GetAsUInt64();
20051998
UnwindLogMsg(
20061999
"CFA value via dereferencing reg %s (%d): reg has val 0x%" PRIx64
20072000
", CFA value is 0x%" PRIx64,
2008-
cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
2009-
cfa_reg_contents, address);
2001+
regnum_to_deref.GetName(),
2002+
regnum_to_deref.GetAsKind(eRegisterKindLLDB),
2003+
reg_to_deref_contents, address);
20102004
return true;
20112005
} else {
20122006
UnwindLogMsg("Tried to deref reg %s (%d) [0x%" PRIx64
20132007
"] but memory read failed.",
2014-
cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
2015-
cfa_reg_contents);
2008+
regnum_to_deref.GetName(),
2009+
regnum_to_deref.GetAsKind(eRegisterKindLLDB),
2010+
reg_to_deref_contents);
20162011
}
20172012
}
20182013
}

0 commit comments

Comments
 (0)