Skip to content

Commit 4855610

Browse files
jasonmolendalabath
andauthored
[lldb][NFC] Split RegisterContextUnwind::SavedLocationForRegister (#139817)
RegisterContextUnwind::SavedLocationForRegister is around 450 lines that first find an abstract register location (e.g. "CFA-8") for a register by looking in the UnwindPlans. Then it evaluates the abstract register location to create a concrete register location (e.g. "stored at address 0x...", "live in register at frame 0"). There are some complicated cases in the first half of the method to handle return address register architectures correctly, in particular. Looking at the two halves, they're both exactly 226 lines long and there's little involvement between them except for passing an abstract register location along. (there were some parts in the "abstract register location" code that would set the concrete register location, unnecessarily) It's also a complex enough method that there are some bits of code that aren't actually doing anything at this point. This patch adds a RegisterContextUnwind::GetAbstractRegisterLocation method, which does the first half, and has a clearly defined return values. The code to convert an AbstractRegisterLocation into a ConcreteRegisterLocation remains in SavedLocationForRegister. It's a bit of a tricky patch to visually inspect, despite it not changing functionality, the reorganizations and rewrites make the diff unreadable. Nearly all the real changes are in the "find the abstract register location" first half of the method. I think reading the new code in its new form is the easiest way to inspect this PR. With a defined interface between the two of what is expected, it's pretty easy to look at the code and reason about whether it is written correctly. (whereas before, that was very difficult, for me at least.) --------- Co-authored-by: Pavel Labath <[email protected]>
1 parent a082f66 commit 4855610

File tree

3 files changed

+280
-287
lines changed

3 files changed

+280
-287
lines changed

lldb/include/lldb/Target/RegisterContextUnwind.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ class RegisterContextUnwind : public lldb_private::RegisterContext {
151151
uint32_t lldb_regnum,
152152
lldb_private::UnwindLLDB::ConcreteRegisterLocation &regloc);
153153

154+
std::optional<UnwindPlan::Row::AbstractRegisterLocation>
155+
GetAbstractRegisterLocation(uint32_t lldb_regnum, lldb::RegisterKind &kind);
156+
154157
bool ReadRegisterValueFromRegisterLocation(
155158
lldb_private::UnwindLLDB::ConcreteRegisterLocation regloc,
156159
const lldb_private::RegisterInfo *reg_info,

0 commit comments

Comments
 (0)