[Lldb-commits] [PATCH] D129554: [lldb] [gdb-remote] Ensure that all threads stop in non-stop mode

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 12 03:22:23 PDT 2022


mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste, jingham.
Herald added a subscriber: arichardson.
Herald added a project: All.
mgorny requested review of this revision.

Issue a `vCont;t` request after getting an asynchronous stop
notification in non-stop mode in order to ensure that all threads are
stopped.  This is needed for servers implementing thread-level non-stop
mode (e.g. gdbserver).  Unlike the current version of LLGS, these
servers do not stop all threads whenever one of them stops.

Depending on whether any threads were running at the time, the `vCont;t`
packet may or may not yield an asynchronous stop notification.  Rather
than attempting to wait on that, use a combination of `?`
and `qfThreadInfo` packets to determine whether all threads are stopped.

Issue a `?` request first in order to obtain stop reasons for all
the stopped threads.  As a bonus, this request clears the asynchronous
notification queue for any notification `vCont;t` may have produced.
Afterwards, obtain the complete thread list using `qfThreadInfo`.
If all debugged threads had stop reasons, it means that they all stopped
already and we can proceed.  Otherwise, try again.

This logic should also be handle to handle the corner case of a new
thread being started after the `vCont;t` request.

We limit the stop attempts to 25 to avoid hanging when communicating
with a broken server.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D129554

Files:
  lldb/packages/Python/lldbsuite/test/gdbclientutils.py
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestNonStop.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129554.443901.patch
Type: text/x-patch
Size: 15085 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220712/664c2d62/attachment-0001.bin>


More information about the lldb-commits mailing list