Page MenuHomePhabricator

[gdb-remote server] Abstract away getting current process
ClosedPublic

Authored by mgorny on Apr 11 2021, 2:40 AM.

Details

Summary

Introduce new m_current_process and m_continue_process variables that
keep the pointers to currently selected process. At this moment, this
is equivalent to m_debugged_process_up but it lays foundations for
the future multiprocess support.

Diff Detail

Event Timeline

mgorny requested review of this revision.Apr 11 2021, 2:40 AM
mgorny created this revision.

Does this actually need to be a function? It seems like this could just be a pointer variable (or two), pointing into our pool of processes. I'd consider making a small struct to group the current process and the current thread within that process.

Does this actually need to be a function? It seems like this could just be a pointer variable (or two), pointing into our pool of processes. I'd consider making a small struct to group the current process and the current thread within that process.

I suppose a pointer might work for the proposed design. However, I'm wondering why we have the GetID() check here — can we have an invalid value of m_debugged_process_up then?

Does this actually need to be a function? It seems like this could just be a pointer variable (or two), pointing into our pool of processes. I'd consider making a small struct to group the current process and the current thread within that process.

I suppose a pointer might work for the proposed design. However, I'm wondering why we have the GetID() check here — can we have an invalid value of m_debugged_process_up then?

I think someone was just being overly cautious. I'm pretty sure the check is redundant...

mgorny updated this revision to Diff 337154.Apr 13 2021, 8:15 AM
mgorny retitled this revision from [lldb] [gdb-remote server] Abstract away getting current process to [gdb-remote server] Abstract away getting current process.
mgorny edited the summary of this revision. (Show Details)

Switched to using two pointers instead of a function. Made ReadTid() accept a default PID instead of playing with bools. Corrected Hc PID to apply only to c/C/s/vCont packets, similarly to how GDB does it.

@labath, I've left the GetID() asserts in place because I've just did a big search/replace, and replacing them would be non-trivial and I can't really spend much more time on this.

labath accepted this revision.Apr 13 2021, 8:33 AM

Looks about right.

This revision is now accepted and ready to land.Apr 13 2021, 8:33 AM
mgorny updated this revision to Diff 337188.Apr 13 2021, 9:35 AM

Rebase and make linter happier. Now let's re-test and push.

This revision was landed with ongoing or failed builds.Apr 13 2021, 9:53 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2021, 9:53 AM