Skip to content

Commit 6294679

Browse files
[lldb] Add isConstant mode for FA locations (#110726)
This is similar to 9fe455f, but for FA locations instead of register locations. This is useful for unwind plans that cannot create abstract unwind rules, but instead must inspect the state of the program to determine the current CFA.
1 parent a1b6dae commit 6294679

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

lldb/include/lldb/Symbol/UnwindPlan.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ class UnwindPlan {
215215
isRegisterDereferenced, // FA = [reg]
216216
isDWARFExpression, // FA = eval(dwarf_expr)
217217
isRaSearch, // FA = SP + offset + ???
218+
isConstant, // FA = constant
218219
};
219220

220221
FAValue() : m_value() {}
@@ -259,6 +260,15 @@ class UnwindPlan {
259260
m_value.expr.length = len;
260261
}
261262

263+
bool IsConstant() const { return m_type == isConstant; }
264+
265+
void SetIsConstant(uint64_t constant) {
266+
m_type = isConstant;
267+
m_value.constant = constant;
268+
}
269+
270+
uint64_t GetConstant() const { return m_value.constant; }
271+
262272
uint32_t GetRegisterNumber() const {
263273
if (m_type == isRegisterDereferenced || m_type == isRegisterPlusOffset)
264274
return m_value.reg.reg_num;
@@ -329,6 +339,8 @@ class UnwindPlan {
329339
} expr;
330340
// For m_type == isRaSearch
331341
int32_t ra_search_offset;
342+
// For m_type = isConstant
343+
uint64_t constant;
332344
} m_value;
333345
}; // class FAValue
334346

lldb/source/Symbol/UnwindPlan.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ operator==(const UnwindPlan::Row::FAValue &rhs) const {
187187
return !memcmp(m_value.expr.opcodes, rhs.m_value.expr.opcodes,
188188
m_value.expr.length);
189189
break;
190+
case isConstant:
191+
return m_value.constant == rhs.m_value.constant;
190192
}
191193
}
192194
return false;
@@ -214,6 +216,8 @@ void UnwindPlan::Row::FAValue::Dump(Stream &s, const UnwindPlan *unwind_plan,
214216
case isRaSearch:
215217
s.Printf("RaSearch@SP%+d", m_value.ra_search_offset);
216218
break;
219+
case isConstant:
220+
s.Printf("0x%" PRIx64, m_value.constant);
217221
}
218222
}
219223

lldb/source/Target/RegisterContextUnwind.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,12 @@ bool RegisterContextUnwind::ReadFrameAddress(
20882088
UnwindLogMsg("No suitable CFA found");
20892089
break;
20902090
}
2091+
case UnwindPlan::Row::FAValue::isConstant: {
2092+
address = fa.GetConstant();
2093+
address = m_thread.GetProcess()->FixDataAddress(address);
2094+
UnwindLogMsg("CFA value set by constant is 0x%" PRIx64, address);
2095+
return true;
2096+
}
20912097
default:
20922098
return false;
20932099
}

0 commit comments

Comments
 (0)