[Lldb-commits] [PATCH] D131837: [lldb] [gdb-remote] Initial support for multiple ContinueDelegates

2022-08-13 Thread Michał Górny via Phabricator via lldb-commits
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.

Introduce the initial support for handling multiple ContinueDelegates
in GDBRemoteClientBase::SendContinuePacketAndWaitForResponse().  This
is the first step towards moving to a shared asynchronous thread serving
multiple ProcessGDBRemote instances.

The final goal is that every stop response will be passed through all
ContinueDelegates, and every delegate will decide whether it is
applicable to its process.  The additional `handled` parameter is used
to indicate that the correct delegate has been found and no further
delegates need to be invoked.

The next step is going to involve decoupling the async thread from
ProcessGDBRemote itself, and moving all the logic responsible for
updating the process status into ContinueDelegate API.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D131837

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp

Index: lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
===
--- lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
+++ lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
@@ -29,12 +29,23 @@
   unsigned stop_reply_called = 0;
   std::vector structured_data_packets;
 
-  void HandleAsyncStdout(llvm::StringRef out) override { output += out; }
-  void HandleAsyncMisc(llvm::StringRef data) override { misc_data += data; }
-  void HandleStopReply() override { ++stop_reply_called; }
+  void HandleAsyncStdout(llvm::StringRef out, bool ) override {
+output += out;
+handled = true;
+  }
+  void HandleAsyncMisc(llvm::StringRef data, bool ) override {
+misc_data += data;
+handled = true;
+  }
+  void HandleStopReply(bool ) override {
+++stop_reply_called;
+handled = true;
+  }
 
-  void HandleAsyncStructuredDataPacket(llvm::StringRef data) override {
+  void HandleAsyncStructuredDataPacket(llvm::StringRef data,
+   bool ) override {
 structured_data_packets.push_back(std::string(data));
+handled = true;
   }
 };
 
@@ -63,9 +74,8 @@
   ListenerSP listener_sp = Listener::MakeListener("listener");
 
   StateType SendCPacket(StringExtractorGDBRemote ) {
-return client.SendContinuePacketAndWaitForResponse(delegate, LinuxSignals(),
-   "c", g_timeout, 
-   response);
+return client.SendContinuePacketAndWaitForResponse(
+{}, LinuxSignals(), "c", g_timeout, response);
   }
 
   void WaitForRunEvent() {
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -425,10 +425,11 @@
lldb::user_id_t break_loc_id);
 
   // ContinueDelegate interface
-  void HandleAsyncStdout(llvm::StringRef out) override;
-  void HandleAsyncMisc(llvm::StringRef data) override;
-  void HandleStopReply() override;
-  void HandleAsyncStructuredDataPacket(llvm::StringRef data) override;
+  void HandleAsyncStdout(llvm::StringRef out, bool ) override;
+  void HandleAsyncMisc(llvm::StringRef data, bool ) override;
+  void HandleStopReply(bool ) override;
+  void HandleAsyncStructuredDataPacket(llvm::StringRef data,
+   bool ) override;
 
   void SetThreadPc(const lldb::ThreadSP _sp, uint64_t index);
   using ModuleCacheKey = std::pair;
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3484,7 +3484,7 @@
 
 StateType stop_state =
 GetGDBRemote().SendContinuePacketAndWaitForResponse(
-*this, *GetUnixSignals(),
+{this}, *GetUnixSignals(),
 llvm::StringRef(continue_cstr, continue_cstr_len),
 GetInterruptTimeout(), response);
 
@@ -4642,14 +4642,15 @@
   m_gdb_comm.ServeSymbolLookups(this);
 }
 
-void ProcessGDBRemote::HandleAsyncStdout(llvm::StringRef out) {
+void ProcessGDBRemote::HandleAsyncStdout(llvm::StringRef out, bool ) {
   AppendSTDOUT(out.data(), out.size());
+  handled = true;
 }
 
 static const char *end_delimiter = "--end--;";
 static const int 

[Lldb-commits] [PATCH] D124314: lldb: Disable unittests if llvm_gtest target does not exist

2022-08-13 Thread Michał Górny via Phabricator via lldb-commits
mgorny reopened this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

Unfortunately, this change doesn't work correctly when building LLDB through 
`LLVM_ENABLE_PROJECTS` — unittests are always disabled now.




Comment at: lldb/CMakeLists.txt:128
+set(LLDB_INCLUDE_UNITTESTS ON)
+if (NOT TARGET llvm_gtest)
+  set(LLDB_INCLUDE_UNITTESTS OFF)

If LLDB is built through `LLVM_ENABLE_PROJECTS`, then LLDB's CMakeLists are 
included before the subdirectory containing `llvm_gtest`, effectively making 
this condition always false.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124314

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


[Lldb-commits] [lldb] 115b189 - [lldb][ARC] Fix -Wtautological-bitwise-compare warning

2022-08-13 Thread Fangrui Song via lldb-commits

Author: Fangrui Song
Date: 2022-08-13T00:18:37-07:00
New Revision: 115b1899a114285981814a641587e9704c2b9eb9

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

LOG: [lldb][ARC] Fix -Wtautological-bitwise-compare warning

Added: 


Modified: 
lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp 
b/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
index a9c7af145338e..f202d581dd5f9 100644
--- a/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
+++ b/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
@@ -151,7 +151,7 @@ bool ABISysV_arc::IsRegisterFileReduced(RegisterContext 
_ctx) const {
   /*fail_value*/ 0);
 // RF_BUILD "Number of Entries" bit.
 const uint32_t rf_entries_bit = 1U << 9U;
-m_is_reg_file_reduced = (reg_value | rf_entries_bit) != 0;
+m_is_reg_file_reduced = (reg_value & rf_entries_bit) != 0;
   }
 
   return m_is_reg_file_reduced.value_or(false);



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