[Lldb-commits] [lldb] [lldb-dap] Send an Invalidated event on thread stack change. (PR #163976)

2025-10-19 Thread Ebuka Ezike via lldb-commits

https://github.com/da-viper updated 
https://github.com/llvm/llvm-project/pull/163976

>From c20a05867dc386698c28d6244b88959686b29c48 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Fri, 17 Oct 2025 11:39:20 +0100
Subject: [PATCH 1/3] [lldb-dap] Send an Invalidated event on thread stack
 change.

When the user send `thread return ` command this changes
the stack length. but the UI does not update.
Send stack invalidated event to update the stack
---
 lldb/tools/lldb-dap/DAP.cpp   | 19 +++
 lldb/tools/lldb-dap/DAP.h |  1 +
 lldb/tools/lldb-dap/EventHelper.cpp   |  8 +++-
 lldb/tools/lldb-dap/EventHelper.h |  5 -
 .../lldb-dap/Protocol/ProtocolEvents.cpp  |  2 +-
 5 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index f76656e98ca01..61226cceb6db0 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -1368,6 +1368,12 @@ void DAP::EventThread() {
   broadcaster.AddListener(listener, eBroadcastBitStopEventThread);
   debugger.GetBroadcaster().AddListener(
   listener, lldb::eBroadcastBitError | lldb::eBroadcastBitWarning);
+
+  // listen for thread events.
+  listener.StartListeningForEventClass(
+  debugger, lldb::SBThread::GetBroadcasterClassName(),
+  lldb::SBThread::eBroadcastBitStackChanged);
+
   bool done = false;
   while (!done) {
 if (listener.WaitForEvent(1, event)) {
@@ -1503,6 +1509,9 @@ void DAP::EventThread() {
 SendJSON(llvm::json::Value(std::move(bp_event)));
   }
 }
+
+  } else if (lldb::SBThread::EventIsThreadEvent(event)) {
+HandleThreadEvent(event);
   } else if (event_mask & lldb::eBroadcastBitError ||
  event_mask & lldb::eBroadcastBitWarning) {
 lldb::SBStructuredData data =
@@ -1522,6 +1531,16 @@ void DAP::EventThread() {
   }
 }
 
+void DAP::HandleThreadEvent(const lldb::SBEvent &event) {
+  uint32_t event_type = event.GetType();
+
+  if (event_type & lldb::SBThread::eBroadcastBitStackChanged) {
+const lldb::SBThread evt_thread = 
lldb::SBThread::GetThreadFromEvent(event);
+SendInvalidatedEvent(*this, {InvalidatedEventBody::eAreaStacks},
+ evt_thread.GetThreadID());
+  }
+}
+
 std::vector DAP::SetSourceBreakpoints(
 const protocol::Source &source,
 const std::optional> &breakpoints) 
{
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index a90ddf59671ee..bf2c3f146a396 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -460,6 +460,7 @@ struct DAP final : public DAPTransport::MessageHandler {
   /// Event threads.
   /// @{
   void EventThread();
+  void HandleThreadEvent(const lldb::SBEvent &event);
   void ProgressEventThread();
 
   std::thread event_thread;
diff --git a/lldb/tools/lldb-dap/EventHelper.cpp 
b/lldb/tools/lldb-dap/EventHelper.cpp
index 2b9ed229405a8..04ed8a052bd76 100644
--- a/lldb/tools/lldb-dap/EventHelper.cpp
+++ b/lldb/tools/lldb-dap/EventHelper.cpp
@@ -15,6 +15,7 @@
 #include "Protocol/ProtocolRequests.h"
 #include "Protocol/ProtocolTypes.h"
 #include "lldb/API/SBFileSpec.h"
+#include "lldb/lldb-defines.h"
 #include "llvm/Support/Error.h"
 #include 
 
@@ -276,11 +277,16 @@ void SendProcessExitedEvent(DAP &dap, lldb::SBProcess 
&process) {
 }
 
 void SendInvalidatedEvent(
-DAP &dap, llvm::ArrayRef areas) {
+DAP &dap, llvm::ArrayRef areas,
+lldb::tid_t tid) {
   if (!dap.clientFeatures.contains(protocol::eClientFeatureInvalidatedEvent))
 return;
   protocol::InvalidatedEventBody body;
   body.areas = areas;
+
+  if (tid != LLDB_INVALID_THREAD_ID)
+body.threadId = tid;
+
   dap.Send(protocol::Event{"invalidated", std::move(body)});
 }
 
diff --git a/lldb/tools/lldb-dap/EventHelper.h 
b/lldb/tools/lldb-dap/EventHelper.h
index 48eb5af6bd0b9..be783d032a5ae 100644
--- a/lldb/tools/lldb-dap/EventHelper.h
+++ b/lldb/tools/lldb-dap/EventHelper.h
@@ -11,6 +11,8 @@
 
 #include "DAPForward.h"
 #include "Protocol/ProtocolEvents.h"
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-types.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/Error.h"
 
@@ -35,7 +37,8 @@ void SendContinuedEvent(DAP &dap);
 void SendProcessExitedEvent(DAP &dap, lldb::SBProcess &process);
 
 void SendInvalidatedEvent(
-DAP &dap, llvm::ArrayRef areas);
+DAP &dap, llvm::ArrayRef areas,
+lldb::tid_t tid = LLDB_INVALID_THREAD_ID);
 
 void SendMemoryEvent(DAP &dap, lldb::SBValue variable);
 
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
index b896eca817be6..df6be06637a13 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp
@@ -51,7 +51,7 @@ llvm::json::Value toJSON(const InvalidatedEventBody::Area 
&IEBA) {
 llvm::json::Value toJSON(const InvalidatedEventBody &IEB) {
   json::Object Result{{"areas",

[Lldb-commits] [lldb] [lldb] Show signal number description (PR #164176)

2025-10-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)


Changes

show information about the signal when the user presses `process handle 
`  i.e 

```sh
(lldb) process handle SIGWINCH 
NAME PASS   STOP   NOTIFY  DESCRIPTION
===  =  =  ==  ===
SIGWINCH true   false  false   window size changes
```

Wanted to use the existing `GetSignalDescription` but it is expected behaviour 
to return the signal name if no signal code is passed. It is used in stop info. 

https://github.com/llvm/llvm-project/blob/65c895dfe084860847e9e220ff9f1b283ebcb289/lldb/source/Target/StopInfo.cpp#L1192-L1195

---
Full diff: https://github.com/llvm/llvm-project/pull/164176.diff


4 Files Affected:

- (modified) lldb/include/lldb/Target/UnixSignals.h (+2) 
- (modified) lldb/source/Commands/CommandObjectProcess.cpp (+10-3) 
- (modified) lldb/source/Target/UnixSignals.cpp (+7) 
- (modified) lldb/unittests/Signals/UnixSignalsTest.cpp (+12) 


``diff
diff --git a/lldb/include/lldb/Target/UnixSignals.h 
b/lldb/include/lldb/Target/UnixSignals.h
index a1807d69f329b..590e4d1aa5208 100644
--- a/lldb/include/lldb/Target/UnixSignals.h
+++ b/lldb/include/lldb/Target/UnixSignals.h
@@ -31,6 +31,8 @@ class UnixSignals {
 
   llvm::StringRef GetSignalAsStringRef(int32_t signo) const;
 
+  llvm::StringRef GetSignalNumberDescription(int32_t signo) const;
+
   std::string
   GetSignalDescription(int32_t signo,
std::optional code = std::nullopt,
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index 7d326404a5503..1dc9d12580cbe 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -1603,8 +1603,8 @@ class CommandObjectProcessHandle : public 
CommandObjectParsed {
   Options *GetOptions() override { return &m_options; }
 
   void PrintSignalHeader(Stream &str) {
-str.Printf("NAME PASS   STOP   NOTIFY\n");
-str.Printf("===  =  =  ==\n");
+str.Printf("NAME PASS   STOP   NOTIFY  DESCRIPTION\n");
+str.Printf("===  =  =  ==  ===\n");
   }
 
   void PrintSignal(Stream &str, int32_t signo, llvm::StringRef sig_name,
@@ -1616,8 +1616,15 @@ class CommandObjectProcessHandle : public 
CommandObjectParsed {
 str.Format("{0, -11}  ", sig_name);
 if (signals_sp->GetSignalInfo(signo, suppress, stop, notify)) {
   bool pass = !suppress;
-  str.Printf("%s  %s  %s", (pass ? "true " : "false"),
+  str.Printf("%s  %s  %s  ", (pass ? "true " : "false"),
  (stop ? "true " : "false"), (notify ? "true " : "false"));
+
+  llvm::StringRef sig_description =
+  signals_sp->GetSignalNumberDescription(signo);
+  if (!sig_description.empty()) {
+str.PutCString(" ");
+str.PutCString(sig_description);
+  }
 }
 str.Printf("\n");
   }
diff --git a/lldb/source/Target/UnixSignals.cpp 
b/lldb/source/Target/UnixSignals.cpp
index 6113c6648817c..881431f4631e5 100644
--- a/lldb/source/Target/UnixSignals.cpp
+++ b/lldb/source/Target/UnixSignals.cpp
@@ -137,6 +137,13 @@ llvm::StringRef UnixSignals::GetSignalAsStringRef(int32_t 
signo) const {
   return pos->second.m_name;
 }
 
+llvm::StringRef UnixSignals::GetSignalNumberDescription(int32_t signo) const {
+  const auto pos = m_signals.find(signo);
+  if (pos == m_signals.end())
+return {};
+  return pos->second.m_description;
+}
+
 std::string UnixSignals::GetSignalDescription(
 int32_t signo, std::optional code,
 std::optional addr, std::optional lower,
diff --git a/lldb/unittests/Signals/UnixSignalsTest.cpp 
b/lldb/unittests/Signals/UnixSignalsTest.cpp
index 582e441556067..3bd4aedd600a3 100644
--- a/lldb/unittests/Signals/UnixSignalsTest.cpp
+++ b/lldb/unittests/Signals/UnixSignalsTest.cpp
@@ -148,6 +148,18 @@ TEST(UnixSignalsTest, GetAsString) {
 signals.GetSignalDescription(16, 3, 0x1233, 0x1234, 0x5678));
 }
 
+TEST(UnixSignalsTest, GetNumberDescription) {
+  TestSignals signals;
+
+  ASSERT_EQ("DESC2", signals.GetSignalNumberDescription(2));
+  ASSERT_EQ("DESC4", signals.GetSignalNumberDescription(4));
+  ASSERT_EQ("DESC8", signals.GetSignalNumberDescription(8));
+  ASSERT_EQ("DESC16", signals.GetSignalNumberDescription(16));
+
+  // Unknown signal number.
+  ASSERT_EQ("", signals.GetSignalNumberDescription(100));
+}
+
 TEST(UnixSignalsTest, VersionChange) {
   TestSignals signals;
 

``




https://github.com/llvm/llvm-project/pull/164176
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Show signal number description (PR #164176)

2025-10-19 Thread Ebuka Ezike via lldb-commits

https://github.com/da-viper created 
https://github.com/llvm/llvm-project/pull/164176

show information about the signal when the user presses `process handle 
`  i.e 

```sh
(lldb) process handle SIGWINCH 
NAME PASS   STOP   NOTIFY  DESCRIPTION
===  =  =  ==  ===
SIGWINCH true   false  false   window size changes
```

Wanted to use the existing `GetSignalDescription` but it is expected behaviour 
to return the signal name if no signal code is passed. It is used in stop info. 

https://github.com/llvm/llvm-project/blob/65c895dfe084860847e9e220ff9f1b283ebcb289/lldb/source/Target/StopInfo.cpp#L1192-L1195

>From 1639f6a9dc41a88e3289176e61b54d7cf2322cc0 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Sun, 19 Oct 2025 19:33:02 +0100
Subject: [PATCH 1/2] [lldb] show the description in process handle

when the user types `process handle` show that the signal
is used for.
---
 lldb/include/lldb/Target/UnixSignals.h|  2 ++
 lldb/source/Commands/CommandObjectProcess.cpp | 13 ++---
 lldb/source/Target/UnixSignals.cpp|  7 +++
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Target/UnixSignals.h 
b/lldb/include/lldb/Target/UnixSignals.h
index a1807d69f329b..9189a84c72614 100644
--- a/lldb/include/lldb/Target/UnixSignals.h
+++ b/lldb/include/lldb/Target/UnixSignals.h
@@ -31,6 +31,8 @@ class UnixSignals {
 
   llvm::StringRef GetSignalAsStringRef(int32_t signo) const;
 
+  llvm::StringRef GetSignalNoDescription(int32_t signo) const;
+
   std::string
   GetSignalDescription(int32_t signo,
std::optional code = std::nullopt,
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index 7d326404a5503..dfad03deef935 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -1603,8 +1603,8 @@ class CommandObjectProcessHandle : public 
CommandObjectParsed {
   Options *GetOptions() override { return &m_options; }
 
   void PrintSignalHeader(Stream &str) {
-str.Printf("NAME PASS   STOP   NOTIFY\n");
-str.Printf("===  =  =  ==\n");
+str.Printf("NAME PASS   STOP   NOTIFY  DESCRIPTION\n");
+str.Printf("===  =  =  ==  ===\n");
   }
 
   void PrintSignal(Stream &str, int32_t signo, llvm::StringRef sig_name,
@@ -1616,8 +1616,15 @@ class CommandObjectProcessHandle : public 
CommandObjectParsed {
 str.Format("{0, -11}  ", sig_name);
 if (signals_sp->GetSignalInfo(signo, suppress, stop, notify)) {
   bool pass = !suppress;
-  str.Printf("%s  %s  %s", (pass ? "true " : "false"),
+  str.Printf("%s  %s  %s  ", (pass ? "true " : "false"),
  (stop ? "true " : "false"), (notify ? "true " : "false"));
+
+  llvm::StringRef sig_description =
+  signals_sp->GetSignalNoDescription(signo);
+  if (!sig_description.empty()) {
+str.PutCString(" ");
+str.PutCString(sig_description);
+  }
 }
 str.Printf("\n");
   }
diff --git a/lldb/source/Target/UnixSignals.cpp 
b/lldb/source/Target/UnixSignals.cpp
index 6113c6648817c..56a28164100b1 100644
--- a/lldb/source/Target/UnixSignals.cpp
+++ b/lldb/source/Target/UnixSignals.cpp
@@ -137,6 +137,13 @@ llvm::StringRef UnixSignals::GetSignalAsStringRef(int32_t 
signo) const {
   return pos->second.m_name;
 }
 
+llvm::StringRef UnixSignals::GetSignalNoDescription(int32_t signo) const {
+  const auto pos = m_signals.find(signo);
+  if (pos == m_signals.end())
+return {};
+  return pos->second.m_description;
+}
+
 std::string UnixSignals::GetSignalDescription(
 int32_t signo, std::optional code,
 std::optional addr, std::optional lower,

>From 08dfa8bd933b0e445329a50fb4315364efea Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Sun, 19 Oct 2025 19:58:44 +0100
Subject: [PATCH 2/2] [lldb] add test

---
 lldb/include/lldb/Target/UnixSignals.h|  2 +-
 lldb/source/Commands/CommandObjectProcess.cpp |  2 +-
 lldb/source/Target/UnixSignals.cpp|  2 +-
 lldb/unittests/Signals/UnixSignalsTest.cpp| 12 
 4 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Target/UnixSignals.h 
b/lldb/include/lldb/Target/UnixSignals.h
index 9189a84c72614..590e4d1aa5208 100644
--- a/lldb/include/lldb/Target/UnixSignals.h
+++ b/lldb/include/lldb/Target/UnixSignals.h
@@ -31,7 +31,7 @@ class UnixSignals {
 
   llvm::StringRef GetSignalAsStringRef(int32_t signo) const;
 
-  llvm::StringRef GetSignalNoDescription(int32_t signo) const;
+  llvm::StringRef GetSignalNumberDescription(int32_t signo) const;
 
   std::string
   GetSignalDescription(int32_t signo,
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index dfad03deef935..1dc9d12580cbe 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb

[Lldb-commits] [lldb] [lldb] Implement Process::ReadMemoryRanges (PR #163651)

2025-10-19 Thread Felipe de Azevedo Piovezan via lldb-commits


@@ -1571,6 +1571,25 @@ class Process : public 
std::enable_shared_from_this,
   virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
 Status &error);
 
+  /// Read from multiple memory ranges and write the results into buffer.

felipepiovezan wrote:

That's right, it is a future PR. I'll add a comment at the top about overriding 
this.,

https://github.com/llvm/llvm-project/pull/163651
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] support attaching by name for platform android (PR #160931)

2025-10-19 Thread Emre Kultursay via lldb-commits

emrekultursay wrote:

This PR seems to have broken the `platform process list` behavior for Android: 
#164192 

https://github.com/llvm/llvm-project/pull/160931
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Implement Process::ReadMemoryRanges (PR #163651)

2025-10-19 Thread Felipe de Azevedo Piovezan via lldb-commits


@@ -225,3 +227,63 @@ TEST_F(MemoryTest, TesetMemoryCacheRead) {
// instead of using an
// old cache
 }
+
+/// A process class that reads `lower_byte(address)` for each `address` it
+/// reads.
+class DummyReaderProcess : public Process {
+public:
+  size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+  Status &error) override {
+uint8_t *buffer = static_cast(buf);
+for (size_t addr = vm_addr; addr < vm_addr + size; addr++)
+  buffer[addr - vm_addr] = addr;
+return size;
+  }
+  // Boilerplate, nothing interesting below.
+  DummyReaderProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
+  : Process(target_sp, listener_sp) {}
+  bool CanDebug(lldb::TargetSP, bool) override { return true; }
+  Status DoDestroy() override { return {}; }
+  void RefreshStateAfterStop() override {}
+  bool DoUpdateThreadList(ThreadList &, ThreadList &) override { return false; 
}
+  llvm::StringRef GetPluginName() override { return "Dummy"; }
+};
+
+TEST_F(MemoryTest, TestReadMemoryRanges) {
+  ArchSpec arch("x86_64-apple-macosx-");
+
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  TargetSP target_sp = CreateTarget(debugger_sp, arch);
+  ASSERT_TRUE(target_sp);
+
+  ListenerSP listener_sp(Listener::MakeListener("dummy"));
+  ProcessSP process_sp =
+  std::make_shared(target_sp, listener_sp);
+  ASSERT_TRUE(process_sp);
+
+  DummyProcess *process = static_cast(process_sp.get());
+  process->SetMaxReadSize(1024);
+
+  llvm::SmallVector buffer(1024, 0);
+
+  // Read 8 ranges of 128 bytes, starting at random addresses

felipepiovezan wrote:

> Random in tests rings alarm bells for me but hopefully once I read the rest 
> I'll understand why you need this.

Worth mentioning that this is deterministic, as it uses a fixed seed. So every 
platform and every run will use the exact same data.

https://github.com/llvm/llvm-project/pull/163651
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Implement Process::ReadMemoryRanges (PR #163651)

2025-10-19 Thread Felipe de Azevedo Piovezan via lldb-commits


@@ -225,3 +227,63 @@ TEST_F(MemoryTest, TesetMemoryCacheRead) {
// instead of using an
// old cache
 }
+
+/// A process class that reads `lower_byte(address)` for each `address` it
+/// reads.
+class DummyReaderProcess : public Process {
+public:
+  size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+  Status &error) override {
+uint8_t *buffer = static_cast(buf);
+for (size_t addr = vm_addr; addr < vm_addr + size; addr++)
+  buffer[addr - vm_addr] = addr;
+return size;
+  }
+  // Boilerplate, nothing interesting below.
+  DummyReaderProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
+  : Process(target_sp, listener_sp) {}
+  bool CanDebug(lldb::TargetSP, bool) override { return true; }
+  Status DoDestroy() override { return {}; }
+  void RefreshStateAfterStop() override {}
+  bool DoUpdateThreadList(ThreadList &, ThreadList &) override { return false; 
}
+  llvm::StringRef GetPluginName() override { return "Dummy"; }
+};
+
+TEST_F(MemoryTest, TestReadMemoryRanges) {
+  ArchSpec arch("x86_64-apple-macosx-");
+
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  TargetSP target_sp = CreateTarget(debugger_sp, arch);
+  ASSERT_TRUE(target_sp);
+
+  ListenerSP listener_sp(Listener::MakeListener("dummy"));
+  ProcessSP process_sp =
+  std::make_shared(target_sp, listener_sp);
+  ASSERT_TRUE(process_sp);
+
+  DummyProcess *process = static_cast(process_sp.get());
+  process->SetMaxReadSize(1024);
+
+  llvm::SmallVector buffer(1024, 0);
+
+  // Read 8 ranges of 128 bytes, starting at random addresses

felipepiovezan wrote:

I can write some arbitrary sequences instead, it was just simpler to generate 
the sequence this way

https://github.com/llvm/llvm-project/pull/163651
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Implement Process::ReadMemoryRanges (PR #163651)

2025-10-19 Thread Felipe de Azevedo Piovezan via lldb-commits


@@ -1971,6 +1971,34 @@ size_t Process::ReadMemory(addr_t addr, void *buf, 
size_t size, Status &error) {
   }
 }
 
+llvm::SmallVector>
+Process::ReadMemoryRanges(llvm::ArrayRef> ranges,
+  llvm::MutableArrayRef buffer) {
+  llvm::SmallVector> results;
+
+  for (auto [addr, len] : ranges) {
+// This is either a programmer error, or a protocol violation.
+// In production builds, gracefully fail.
+assert(buffer.size() >= len);
+if (buffer.size() < len) {
+  results.push_back(buffer.take_front(0));

felipepiovezan wrote:

Here I should have just done `emplace_back(nullptr, 0)` to be honest, would 
have made the point more evident.

https://github.com/llvm/llvm-project/pull/163651
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Remove a redundant call to std::unique_ptr::get (NFC) (PR #164191)

2025-10-19 Thread Kazu Hirata via lldb-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/164191

None

>From cf21a5bd82a0582b2a140d6f2d71615e162e93b6 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sat, 18 Oct 2025 13:22:08 -0700
Subject: [PATCH] [lldb] Remove a redundant call to std::unique_ptr::get
 (NFC)

---
 lldb/unittests/DAP/TestBase.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/unittests/DAP/TestBase.cpp b/lldb/unittests/DAP/TestBase.cpp
index 3721e09d8b699..83a303554ad6b 100644
--- a/lldb/unittests/DAP/TestBase.cpp
+++ b/lldb/unittests/DAP/TestBase.cpp
@@ -45,7 +45,7 @@ void TransportBase::SetUp() {
   /*client_name=*/"test_client",
   /*transport=*/*to_client, /*loop=*/loop);
 
-  auto server_handle = to_server->RegisterMessageHandler(loop, *dap.get());
+  auto server_handle = to_server->RegisterMessageHandler(loop, *dap);
   EXPECT_THAT_EXPECTED(server_handle, Succeeded());
   handles[0] = std::move(*server_handle);
 

___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Remove a redundant call to std::unique_ptr::get (NFC) (PR #164191)

2025-10-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Kazu Hirata (kazutakahirata)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/164191.diff


1 Files Affected:

- (modified) lldb/unittests/DAP/TestBase.cpp (+1-1) 


``diff
diff --git a/lldb/unittests/DAP/TestBase.cpp b/lldb/unittests/DAP/TestBase.cpp
index 3721e09d8b699..83a303554ad6b 100644
--- a/lldb/unittests/DAP/TestBase.cpp
+++ b/lldb/unittests/DAP/TestBase.cpp
@@ -45,7 +45,7 @@ void TransportBase::SetUp() {
   /*client_name=*/"test_client",
   /*transport=*/*to_client, /*loop=*/loop);
 
-  auto server_handle = to_server->RegisterMessageHandler(loop, *dap.get());
+  auto server_handle = to_server->RegisterMessageHandler(loop, *dap);
   EXPECT_THAT_EXPECTED(server_handle, Succeeded());
   handles[0] = std::move(*server_handle);
 

``




https://github.com/llvm/llvm-project/pull/164191
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Implement Process::ReadMemoryRanges (PR #163651)

2025-10-19 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

> What's the thinking for doing this in "ptrace style" where the caller 
> allocates a buffer and gives it to the function, vs. allocating the buffer on 
> behalf of the caller?

No real motivation other than "the other APIs in `Process` do this, so this 
must have been discussed in the past", I'll add this to the commit/PR messages. 
 (I'm assuming that's fine, as nobody objected to it in the RFC, but I have no 
strong opinions).

https://github.com/llvm/llvm-project/pull/163651
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits