This is an archive of the discontinued LLVM Phabricator instance.

[lldb] [gdb-remote server] Support selecting process via Hg
ClosedPublic

Authored by mgorny on Apr 11 2021, 5:03 AM.

Details

Summary

Support using the extended thread-id syntax with Hg packet to select
a subprocess. This makes it possible to start providing support for
running some of the debugger packets against another subprocesses.

Diff Detail

Event Timeline

labath added inline comments.Apr 14 2021, 11:39 AM
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
2132

Does it ever make sense to have more than one (process or thread) selected? If not, an error response may be more appropriate..

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
234 ↗(On Diff #337241)

revert

mgorny added inline comments.Apr 14 2021, 11:49 AM
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
2132

Good question.

As for PID, I don't think that the client would do something like that within foreseeable future.

However, sending all-TIDs are technically supported in our LLGS client code. I don't know whether it's actually used anywhere, though.

mgorny updated this revision to Diff 337541.Apr 14 2021, 1:44 PM
mgorny marked an inline comment as done.

Revert accidental whitespace change.

mgorny updated this revision to Diff 340310.Apr 24 2021, 1:17 PM

Add tests.

rovka added a subscriber: rovka.Apr 28 2021, 2:54 AM
rovka added inline comments.
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
2135

Just a drive-by comment: The previous behaviour was to send 0x15 when the current process ID was invalid. Should we do that here?

mgorny added inline comments.Apr 28 2021, 3:22 AM
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
2135

I've originally did that but it was kinda hackish and @labath didn't like it.

JDevlieghere accepted this revision.Jun 30 2021, 9:59 AM
JDevlieghere added a subscriber: JDevlieghere.

I'm probably not the most qualified to sign off on this, but the review has stalled and I don't see anything obviously wrong here so LGTM.

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
2126

Would it be useful to say "Malformed thread-id for process-id {}"?

This revision is now accepted and ready to land.Jun 30 2021, 9:59 AM
mgorny added inline comments.Jul 1 2021, 2:08 PM
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
2126

In this context, 'thread-id' is GDB protocol jargon for 'PID and/or TID'. So if it's malformed, then we don't really have a process ID here. I suppose I could try replacing 'thread-id' with something more verbose but I'm not sure if this is the kind of error end users will be dealing with.

JDevlieghere added inline comments.Jul 1 2021, 5:44 PM
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
2126

Fair enough. Thanks for the explanation!

This revision was landed with ongoing or failed builds.Jul 2 2021, 1:23 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 2 2021, 1:23 AM