From: Michał Górny Date: Sat, 25 Jun 2022 07:39:25 +0000 (+0200) Subject: Revert "[lldb] [llgs] Support multiprocess in qfThreadInfo" X-Git-Tag: upstream/15.0.7~3580 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f609b54e249a4eb9b5f68a26b3fecba87d7324c0;p=platform%2Fupstream%2Fllvm.git Revert "[lldb] [llgs] Support multiprocess in qfThreadInfo" This reverts part of commit 75757c86c695a6b4695458343637b3c4fe86def6. It broke the following test: commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py I need more time to figure it out, so I'm reverting the code changes and marking the tests depending on them xfail. --- diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 9356b01..770edbf 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -1976,43 +1976,38 @@ GDBRemoteCommunicationServerLLGS::Handle_qRegisterInfo( return SendPacketNoLock(response.GetString()); } -void GDBRemoteCommunicationServerLLGS::AddProcessThreads( - StreamGDBRemote &response, NativeProcessProtocol &process, bool &had_any) { +GDBRemoteCommunication::PacketResult +GDBRemoteCommunicationServerLLGS::Handle_qfThreadInfo( + StringExtractorGDBRemote &packet) { Log *log = GetLog(LLDBLog::Thread); - lldb::pid_t pid = process.GetID(); - if (pid == LLDB_INVALID_PROCESS_ID) - return; + // Fail if we don't have a current process. + if (!m_current_process || + (m_current_process->GetID() == LLDB_INVALID_PROCESS_ID)) { + LLDB_LOG(log, "no process ({0}), returning OK", + m_current_process ? "invalid process id" + : "null m_current_process"); + return SendOKResponse(); + } - LLDB_LOG(log, "iterating over threads of process {0}", process.GetID()); + StreamGDBRemote response; + response.PutChar('m'); + + LLDB_LOG(log, "starting thread iteration"); NativeThreadProtocol *thread; uint32_t thread_index; - for (thread_index = 0, thread = process.GetThreadAtIndex(thread_index); - thread; - ++thread_index, thread = process.GetThreadAtIndex(thread_index)) { - LLDB_LOG(log, "iterated thread {0} (tid={1})", thread_index, + for (thread_index = 0, + thread = m_current_process->GetThreadAtIndex(thread_index); + thread; ++thread_index, + thread = m_current_process->GetThreadAtIndex(thread_index)) { + LLDB_LOG(log, "iterated thread {0}(tid={2})", thread_index, thread->GetID()); - response.PutChar(had_any ? ',' : 'm'); - AppendThreadIDToResponse(response, pid, thread->GetID()); - had_any = true; + if (thread_index > 0) + response.PutChar(','); + response.Printf("%" PRIx64, thread->GetID()); } -} -GDBRemoteCommunication::PacketResult -GDBRemoteCommunicationServerLLGS::Handle_qfThreadInfo( - StringExtractorGDBRemote &packet) { - assert(m_debugged_processes.size() == 1 || - bool(m_extensions_supported & - NativeProcessProtocol::Extension::multiprocess)); - - bool had_any = false; - StreamGDBRemote response; - - for (auto &pid_ptr : m_debugged_processes) - AddProcessThreads(response, *pid_ptr.second, had_any); - - if (!had_any) - response.PutChar('l'); + LLDB_LOG(log, "finished thread iteration"); return SendPacketNoLock(response.GetString()); } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h index 5187a95..17cc321c 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h @@ -159,9 +159,6 @@ protected: PacketResult Handle_qRegisterInfo(StringExtractorGDBRemote &packet); - void AddProcessThreads(StreamGDBRemote &response, - NativeProcessProtocol &process, bool &had_any); - PacketResult Handle_qfThreadInfo(StringExtractorGDBRemote &packet); PacketResult Handle_qsThreadInfo(StringExtractorGDBRemote &packet); diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py index d8c93b8..b60481a 100644 --- a/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py +++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py @@ -396,6 +396,7 @@ class TestGdbRemoteFork(gdbremote_testcase.GdbRemoteTestCaseBase): self.expect_gdbremote_sequence() @add_test_categories(["fork"]) + @expectedFailureAll() # qfThreadInfo changes temporarily reverted def test_threadinfo(self): parent_pid, parent_tid, child_pid, child_tid = ( self.start_fork_test(["fork", "thread:new", "trap"])) @@ -528,6 +529,7 @@ class TestGdbRemoteFork(gdbremote_testcase.GdbRemoteTestCaseBase): self.reset_test_sequence() @add_test_categories(["fork"]) + @expectedFailureAll() # qfThreadInfo changes temporarily reverted def test_register_read_write(self): parent_pid, parent_tid, child_pid, child_tid = ( self.start_fork_test(["fork", "thread:new", "trap"])) @@ -624,6 +626,7 @@ class TestGdbRemoteFork(gdbremote_testcase.GdbRemoteTestCaseBase): self.assertEqual(data, old_val[1]) @add_test_categories(["fork"]) + @expectedFailureAll() # qfThreadInfo changes temporarily reverted def test_qC(self): parent_pid, parent_tid, child_pid, child_tid = ( self.start_fork_test(["fork", "thread:new", "trap"])) @@ -658,6 +661,7 @@ class TestGdbRemoteFork(gdbremote_testcase.GdbRemoteTestCaseBase): self.expect_gdbremote_sequence() @add_test_categories(["fork"]) + @expectedFailureAll() # qfThreadInfo changes temporarily reverted def test_T(self): parent_pid, parent_tid, child_pid, child_tid = ( self.start_fork_test(["fork", "thread:new", "trap"]))