[Lldb-commits] [lldb] f609b54 - Revert "[lldb] [llgs] Support multiprocess in qfThreadInfo"

2022-06-25 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2022-06-25T09:46:28+02:00
New Revision: f609b54e249a4eb9b5f68a26b3fecba87d7324c0

URL: 
https://github.com/llvm/llvm-project/commit/f609b54e249a4eb9b5f68a26b3fecba87d7324c0
DIFF: 
https://github.com/llvm/llvm-project/commit/f609b54e249a4eb9b5f68a26b3fecba87d7324c0.diff

LOG: 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.

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 9356b01a6ce8f..770edbfec2807 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 5187a953f957e..17cc321c39676 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -159,9 +159,6 @@ class GDBRemoteCommunicationServerLLGS
 
   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 d8c93b84d0ce5..b60481a9d1687 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
@@ -396,6 +396,7 @@ def test_vCont_all_processes_implicit(self

[Lldb-commits] [PATCH] D128152: [lldb] [llgs] Support multiprocess in qfThreadInfo

2022-06-25 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

I've reverted the code changes and marked my new tests xfail. I will attempt to 
find the problem in the new code later. Once again, I'm sorry for missing this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128152/new/

https://reviews.llvm.org/D128152

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D128152: [lldb] [llgs] Support multiprocess in qfThreadInfo

2022-06-25 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

Ok, apparently the changes that's breaking this is replacing the `OK` response 
with `l` when there's no debugged process.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128152/new/

https://reviews.llvm.org/D128152

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1452e2e - Reland "[lldb] [llgs] Support multiprocess in qfThreadInfo"

2022-06-25 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2022-06-25T15:15:37+02:00
New Revision: 1452e2e5cbfe69cd6622a3c9e80dd485f1fb542b

URL: 
https://github.com/llvm/llvm-project/commit/1452e2e5cbfe69cd6622a3c9e80dd485f1fb542b
DIFF: 
https://github.com/llvm/llvm-project/commit/1452e2e5cbfe69cd6622a3c9e80dd485f1fb542b.diff

LOG: Reland "[lldb] [llgs] Support multiprocess in qfThreadInfo"

Now preserving the non-standard behavior of returning "OK" response
when there is no debugged process.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D128152

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 770edbfec2807..2c009ef7fcd9a 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -1976,38 +1976,43 @@ GDBRemoteCommunicationServerLLGS::Handle_qRegisterInfo(
   return SendPacketNoLock(response.GetString());
 }
 
-GDBRemoteCommunication::PacketResult
-GDBRemoteCommunicationServerLLGS::Handle_qfThreadInfo(
-StringExtractorGDBRemote &packet) {
+void GDBRemoteCommunicationServerLLGS::AddProcessThreads(
+StreamGDBRemote &response, NativeProcessProtocol &process, bool &had_any) {
   Log *log = GetLog(LLDBLog::Thread);
 
-  // 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();
-  }
-
-  StreamGDBRemote response;
-  response.PutChar('m');
+  lldb::pid_t pid = process.GetID();
+  if (pid == LLDB_INVALID_PROCESS_ID)
+return;
 
-  LLDB_LOG(log, "starting thread iteration");
+  LLDB_LOG(log, "iterating over threads of process {0}", process.GetID());
   NativeThreadProtocol *thread;
   uint32_t 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,
+  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,
  thread->GetID());
-if (thread_index > 0)
-  response.PutChar(',');
-response.Printf("%" PRIx64, thread->GetID());
+response.PutChar(had_any ? ',' : 'm');
+AppendThreadIDToResponse(response, pid, thread->GetID());
+had_any = true;
   }
+}
 
-  LLDB_LOG(log, "finished thread iteration");
+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)
+return SendOKResponse();
   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 17cc321c39676..5187a953f957e 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -159,6 +159,9 @@ class GDBRemoteCommunicationServerLLGS
 
   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 b60481a9d1687..d8c93b84d0ce5 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
@@ -396,7 +396,6 @@ def test_vCont_all_processes_implicit(self):
 self.expect_gdbremote_sequence()
 
 @add_test_categories(["fork"])
-@expectedF