This is an archive of the discontinued LLVM Phabricator instance.

[lldb] [gdb-remote] Refactor getting remote regs to use local vector
ClosedPublic

Authored by mgorny on Sep 18 2021, 11:04 AM.

Details

Summary

Refactor remote register getters to collect them into a local
std::vector rather than adding them straight into DynamicRegisterInfo.
The purpose of this change is to lay groundwork for switching value_regs
and invalidate_regs to use local LLDB register numbers rather than
remote numbers.

Diff Detail

Event Timeline

mgorny requested review of this revision.Sep 18 2021, 11:04 AM
mgorny created this revision.

@labath, please tell me if you like this design. If it's ok, I'm going to convert the other routine to it, then move the conversion to DynamicRegisterInfo into a common function.

(also I haven't reformatted the code yet)

I like it.

lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
4318–4321

struct process_gdb_remote::RemoteRegisterInfo { should work too. Putting the declaration in the header would also be ok.

mgorny updated this revision to Diff 373530.Sep 20 2021, 2:59 AM
mgorny marked an inline comment as done.

Put the struct into the header. Put the common conversion and finalization code into a helper method. Use llvm::enumerate for local regnums. Convert qRegisterInfo getters.

mgorny edited the summary of this revision. (Show Details)Sep 20 2021, 2:59 AM
mgorny retitled this revision from [lldb] [gdb-remote] Refactor getting remote regs to use local vector [WIP] to [lldb] [gdb-remote] Refactor getting remote regs to use local vector.
labath accepted this revision.Sep 23 2021, 4:39 AM

Looks good, just be careful about sentinels.

lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
571–578

It looks like you're not doing it here.

4460–4461

Can we avoid pushing the sentinel here? I'd hope this can be done during the conversion to the "RegisterInfo" format...

4597

i.e., add a push(sentinel) here.

This revision is now accepted and ready to land.Sep 23 2021, 4:39 AM
mgorny marked 3 inline comments as done.Sep 23 2021, 7:07 AM
mgorny added inline comments.
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
4460–4461

Yes, that makes sense and reduces code duplication even more. Thanks!

4597

Hmm, actually you made me realize I'm pushing empty arrays instead of nullptr sometimes. Let's fix that as well.

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