Skip to content

Commit 113357f

Browse files
[lldb][nfc] Remove no-op calls to Fix*Address (#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.
1 parent c3383d7 commit 113357f

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
@@ -361,16 +361,10 @@ void RegisterContextUnwind::InitializeNonZerothFrame() {
361361
if (log) {
362362
UnwindLogMsg("pc = 0x%" PRIx64, pc);
363363
addr_t reg_val;
364-
if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val)) {
365-
if (abi_sp)
366-
reg_val = abi_sp->FixDataAddress(reg_val);
364+
if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP, reg_val))
367365
UnwindLogMsg("fp = 0x%" PRIx64, reg_val);
368-
}
369-
if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val)) {
370-
if (abi_sp)
371-
reg_val = abi_sp->FixDataAddress(reg_val);
366+
if (ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, reg_val))
372367
UnwindLogMsg("sp = 0x%" PRIx64, reg_val);
373-
}
374368
}
375369

376370
// A pc of 0x0 means it's the end of the stack crawl unless we're above a trap
@@ -2026,30 +2020,31 @@ bool RegisterContextUnwind::ReadFrameAddress(
20262020
switch (fa.GetValueType()) {
20272021
case UnwindPlan::Row::FAValue::isRegisterDereferenced: {
20282022
UnwindLogMsg("CFA value via dereferencing reg");
2029-
RegisterNumber cfa_reg(m_thread, row_register_kind,
2030-
fa.GetRegisterNumber());
2031-
if (ReadGPRValue(cfa_reg, cfa_reg_contents)) {
2023+
RegisterNumber regnum_to_deref(m_thread, row_register_kind,
2024+
fa.GetRegisterNumber());
2025+
addr_t reg_to_deref_contents;
2026+
if (ReadGPRValue(regnum_to_deref, reg_to_deref_contents)) {
20322027
const RegisterInfo *reg_info =
2033-
GetRegisterInfoAtIndex(cfa_reg.GetAsKind(eRegisterKindLLDB));
2028+
GetRegisterInfoAtIndex(regnum_to_deref.GetAsKind(eRegisterKindLLDB));
20342029
RegisterValue reg_value;
20352030
if (reg_info) {
2036-
if (abi_sp)
2037-
cfa_reg_contents = abi_sp->FixDataAddress(cfa_reg_contents);
20382031
Status error = ReadRegisterValueFromMemory(
2039-
reg_info, cfa_reg_contents, reg_info->byte_size, reg_value);
2032+
reg_info, reg_to_deref_contents, reg_info->byte_size, reg_value);
20402033
if (error.Success()) {
20412034
address = reg_value.GetAsUInt64();
20422035
UnwindLogMsg(
20432036
"CFA value via dereferencing reg %s (%d): reg has val 0x%" PRIx64
20442037
", CFA value is 0x%" PRIx64,
2045-
cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
2046-
cfa_reg_contents, address);
2038+
regnum_to_deref.GetName(),
2039+
regnum_to_deref.GetAsKind(eRegisterKindLLDB),
2040+
reg_to_deref_contents, address);
20472041
return true;
20482042
} else {
20492043
UnwindLogMsg("Tried to deref reg %s (%d) [0x%" PRIx64
20502044
"] but memory read failed.",
2051-
cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
2052-
cfa_reg_contents);
2045+
regnum_to_deref.GetName(),
2046+
regnum_to_deref.GetAsKind(eRegisterKindLLDB),
2047+
reg_to_deref_contents);
20532048
}
20542049
}
20552050
}

0 commit comments

Comments
 (0)