[lldb] [Process/FreeBSDRemote] Fix attaching via lldb-server
authorMichał Górny <mgorny@moritz.systems>
Sat, 31 Oct 2020 09:30:13 +0000 (10:30 +0100)
committerMichał Górny <mgorny@moritz.systems>
Tue, 3 Nov 2020 08:45:50 +0000 (09:45 +0100)
commit8e6bcbb41758b3a6c23f1b448fcef6f67fd8c6d0
treee53bb1284eb6160e3f3aaadcb29a14bb6ae91f3a
parentf893b2939781910fd52ad70a30484255a3cf0f6e
[lldb] [Process/FreeBSDRemote] Fix attaching via lldb-server

Fix two bugs that caused attaching to a process in a pre-connected
lldb-server to fail.  These are:

1. Prematurely reporting status in NativeProcessFreeBSD::Attach().
   The SetState() call defaulted to notify the process, and LLGS tried
   to send the stopped packet before the process instance was assigned
   to it.  While at it, add an assert for that in LLGS.

2. Duplicate call to ReinitializeThreads() (via SetupTrace()) that
   overwrote the stopped status in threads.  Now SetupTrace() is called
   directly by NativeProcessFreeBSD::Attach() (not the Factory) in place
   of ReinitializeThreads().

This fixes at least commands/process/attach/TestProcessAttach.py
and python_api/hello_world/TestHelloWorld.py.

Differential Revision: https://reviews.llvm.org/D90525
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp