This is an archive of the discontinued LLVM Phabricator instance.

[lldb] [DynamicRegisterInfo] Add a convenience method to add suppl. registers
ClosedPublic

Authored by mgorny on Sep 18 2021, 8:35 AM.

Details

Summary

Add a convenience method to add supplementary registers that takes care
of adding invalidate_regs to all (potentially) overlapping registers.

Diff Detail

Event Timeline

mgorny requested review of this revision.Sep 18 2021, 8:35 AM
mgorny created this revision.

Currently it's still using process plugin regnums in value_regs/invalidate_regs; I'm going to try changing that next.

mgorny updated this revision to Diff 373427.Sep 18 2021, 11:08 AM

clang-format

mgorny updated this revision to Diff 373451.Sep 19 2021, 4:16 AM

Update for using local (LLDB) regnos.

mgorny added inline comments.
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
448

@labath, any suggestion how to do this nicely while not copying the terminating LLDB_INVALID_REGNUM?

labath added inline comments.Sep 20 2021, 12:39 AM
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
448

How about by making sure that LLDB_INVALID_REGNUM is not present in the firstplace (by adding it only during finalization)?

mgorny updated this revision to Diff 373515.Sep 20 2021, 1:57 AM

Rebased. Updated the code to assume dedupe and cleanup happens in Finalize(), and to use new test assertions.

mgorny marked an inline comment as done.Sep 20 2021, 1:57 AM
labath accepted this revision.Sep 27 2021, 4:14 AM

I think this is fine. The tricky thing will be deciding what to do with the x86 and arm registers which start at non-zero offsets (ah et al.)

One thing I was considering was doing this addition while were still in the original "vector of strings" form instead of this C thingy. The tricky part there is that (since this in would be the ABI classes which do this manipulation) we would need to expose the gdb-remote struct to the outside world. I don't think that would be necessarily bad (we just wouldn't call it "RemoteRegisterInfo, but something else), but it's not clear to me whether its worth the churn. Still, I think it's worth keeping this in the back of your mind as you work on this.

lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
439

Maybe call this new_invalidates? I've found it hard to track what to_add means, with all the mixing of value_regs and invalidates...

441–442

Is this still needed?

455

This would be a good use case for (const) auto, as value_type does not say much anyway.

lldb/unittests/Process/Utility/DynamicRegisterInfoTest.cpp
159–165

Could we remove ah from this test, as its offset is going to be wrong?

This revision is now accepted and ready to land.Sep 27 2021, 4:14 AM
mgorny marked 4 inline comments as done.Sep 27 2021, 6:33 AM
mgorny added inline comments.
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
439

Good idea.

441–442

Probably not indeed.

lldb/unittests/Process/Utility/DynamicRegisterInfoTest.cpp
159–165

Sure.

This revision was landed with ongoing or failed builds.Sep 27 2021, 7:01 AM
This revision was automatically updated to reflect the committed changes.
mgorny marked 3 inline comments as done.
Herald added a project: Restricted Project. · View Herald TranscriptSep 27 2021, 7:01 AM