[Lldb-commits] [PATCH] D101933: If an interrupt fails, don't try to fetch any more packets from the server

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed May 5 11:49:45 PDT 2021


jingham created this revision.
jingham added reviewers: clayborg, JDevlieghere, labath.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

When a gdb-remote plugin process doesn't respond to an interrupt, it returns from
SendContinuePacketAndWaitForResponse with eStateInvalid.  The AsyncThread
code responds to this return by setting the state to eStateExited.  But it doesn't
immediately exit the ProcessGDBRemote::AsyncThread's packet fetch loop.

      

This looks like just an oversight in the AsyncThread function. It's important not to
go back to wait for another packet.  If it arrives while you are tearing down the
process, the internal-state-thread might try to handle it when the process in not
in a good state.

We weren't going to do anything useful with the extra packet anyway, we've already
declared the process exited.  So rather than put more checks into all the shutdown paths 
to make sure this extra packet doesn't cause problems, just don't fetch it.

      

The main part of the patch is setting "done = true" when we get the eStateInvalid.
I also added a check at the beginning of the while(done) loop to prevent another error
from getting us to fetch packets for an exited process.

      

I also added a test case to ensure that if an Interrupt fails, we call the process
exited.  I can't test exactly the error I'm fixing, there's no good way to know
that the stop reply for the failed interrupt wasn't fetched.  But at least this
asserts that the overall behavior is correct.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101933

Files:
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestHaltFails.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101933.343131.patch
Type: text/x-patch
Size: 3939 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210505/5d970e57/attachment.bin>


More information about the lldb-commits mailing list