[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-10 Thread Pavel Labath via lldb-commits

labath wrote:

> > We have a tests for this function in `unittests/Host/linux/HostTest.cpp` 
> > and it looks like at least some of it should apply to other systems as 
> > well. We could move it to the "posix" folder so that it applies to your 
> > code as well. Depending on the size of linux-specific parts, we could 
> > either keep them in the "linux" folder, or `#ifdef` them out
> 
> Okay, we will create new PR to either move it to posix or we can create 
> `HostTest.cpp` for aix separately. @labath or you want me to drop the 
> testcase changes in same PR ?

Let's do that here. The PR is small (as it should be) and it's good to have 
tests together with the code being tested.

https://github.com/llvm/llvm-project/pull/134354
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-10 Thread Hemang Gadhavi via lldb-commits

https://github.com/HemangGadhavi updated 
https://github.com/llvm/llvm-project/pull/134354

>From e7b3d8d95477f96b4c1b1a2bbec5cce49f4c15cd Mon Sep 17 00:00:00 2001
From: HemangGadhavi 
Date: Fri, 4 Apr 2025 00:59:17 -0500
Subject: [PATCH 1/3] [lldb][AIX] get host info for AIX

---
 lldb/source/Host/CMakeLists.txt |   1 +
 lldb/source/Host/aix/Host.cpp   | 156 +++-
 2 files changed, 156 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index a2ae6f1430c38..a02b1c104396e 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -141,6 +141,7 @@ else()
 add_host_subdirectory(aix
   aix/Host.cpp
   aix/HostInfoAIX.cpp
+  linux/Support.cpp
   )
   endif()
 endif()
diff --git a/lldb/source/Host/aix/Host.cpp b/lldb/source/Host/aix/Host.cpp
index 751c4fbcc9368..6ba3e05348df1 100644
--- a/lldb/source/Host/aix/Host.cpp
+++ b/lldb/source/Host/aix/Host.cpp
@@ -6,18 +6,172 @@
 //
 
//===--===//
 
+#include 
+#include 
+#include 
+
 #include "lldb/Host/Host.h"
+#include "lldb/Host/linux/Support.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/ProcessInfo.h"
 #include "lldb/Utility/Status.h"
+#include "llvm/BinaryFormat/XCOFF.h"
 
+using namespace llvm;
+using namespace lldb;
 using namespace lldb_private;
 
+namespace {
+enum class ProcessState {
+  Unknown,
+  Dead,
+  DiskSleep,
+  Idle,
+  Paging,
+  Parked,
+  Running,
+  Sleeping,
+  TracedOrStopped,
+  Zombie,
+};
+}
+
+static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo &ProcessInfo,
+  ProcessState &State, ::pid_t &TracerPid,
+  ::pid_t &Tgid) {
+  Log *log = GetLog(LLDBLog::Host);
+
+  auto BufferOrError = getProcFile(Pid, "status");
+  if (!BufferOrError)
+return false;
+
+  llvm::StringRef Rest = BufferOrError.get()->getBuffer();
+  while (!Rest.empty()) {
+llvm::StringRef Line;
+std::tie(Line, Rest) = Rest.split('\n');
+
+if (Line.consume_front("Gid:")) {
+  // Real, effective, saved set, and file system GIDs. Read the first two.
+  Line = Line.ltrim();
+  uint32_t RGid, EGid;
+  Line.consumeInteger(10, RGid);
+  Line = Line.ltrim();
+  Line.consumeInteger(10, EGid);
+
+  ProcessInfo.SetGroupID(RGid);
+  ProcessInfo.SetEffectiveGroupID(EGid);
+} else if (Line.consume_front("Uid:")) {
+  // Real, effective, saved set, and file system UIDs. Read the first two.
+  Line = Line.ltrim();
+  uint32_t RUid, EUid;
+  Line.consumeInteger(10, RUid);
+  Line = Line.ltrim();
+  Line.consumeInteger(10, EUid);
+
+  ProcessInfo.SetUserID(RUid);
+  ProcessInfo.SetEffectiveUserID(EUid);
+} else if (Line.consume_front("PPid:")) {
+  ::pid_t PPid;
+  Line.ltrim().consumeInteger(10, PPid);
+  ProcessInfo.SetParentProcessID(PPid);
+} else if (Line.consume_front("State:")) {
+  State = llvm::StringSwitch(Line.ltrim().take_front(1))
+  .Case("D", ProcessState::DiskSleep)
+  .Case("I", ProcessState::Idle)
+  .Case("R", ProcessState::Running)
+  .Case("S", ProcessState::Sleeping)
+  .CaseLower("T", ProcessState::TracedOrStopped)
+  .Case("W", ProcessState::Paging)
+  .Case("P", ProcessState::Parked)
+  .Case("X", ProcessState::Dead)
+  .Case("Z", ProcessState::Zombie)
+  .Default(ProcessState::Unknown);
+  if (State == ProcessState::Unknown) {
+LLDB_LOG(log, "Unknown process state {0}", Line);
+  }
+} else if (Line.consume_front("TracerPid:")) {
+  Line = Line.ltrim();
+  Line.consumeInteger(10, TracerPid);
+} else if (Line.consume_front("Tgid:")) {
+  Line = Line.ltrim();
+  Line.consumeInteger(10, Tgid);
+}
+  }
+  return true;
+}
+
+static void GetExePathAndArch(::pid_t pid, ProcessInstanceInfo &process_info) {
+  Log *log = GetLog(LLDBLog::Process);
+  std::string ExePath(PATH_MAX, '\0');
+  struct psinfo psinfoData;
+
+  // We can't use getProcFile here because proc/[pid]/exe is a symbolic link.
+  llvm::SmallString<64> ProcExe;
+  (llvm::Twine("/proc/") + llvm::Twine(pid) + "/cwd").toVector(ProcExe);
+
+  ssize_t len = readlink(ProcExe.c_str(), &ExePath[0], PATH_MAX);
+  if (len > 0) {
+ExePath.resize(len);
+
+struct stat statData;
+
+std::ostringstream oss;
+
+oss << "/proc/" << std::dec << pid << "/psinfo";
+assert(stat(oss.str().c_str(), &statData) == 0);
+
+const int fd = open(oss.str().c_str(), O_RDONLY);
+assert(fd >= 0);
+
+ssize_t readNum = read(fd, &psinfoData, sizeof(psinfoData));
+assert(readNum >= 0);
+
+close(fd);
+  } else {
+LLDB_LOG(log, "failed to read link exe link for {0}: {1}", pid,
+ Status(errno, e

[Lldb-commits] [lldb] [LLDB] Add unary operators Dereference and AddressOf to DIL (PR #134428)

2025-04-10 Thread Pavel Labath via lldb-commits

labath wrote:

> > I'm also not very convinced by this "FlowAnalysis" thingy. Is it supposed 
> > to be a performance optimization (collapsing *&foo to foo) or does it do 
> > something more?
> 
> FlowAnalysis is also used in subscript operator, to short-circuit getting an 
> address of an element: `&arr[1]`, which could be a much more common use case.

I see. So, I agree `&a[i]` is likelier than `&*a`. However, I find it hard to 
imagine how to do that correctly without making too many C-like assumptions 
about what is an "array". To do this correctly, I think the logic would have to 
be moved inside the type system, which will be a lot of work for possibly very 
little gain -- I'm also rather sceptical that something like this will be 
appreciably faster than just performing the operations in the order prescribed 
by the expression.

I would really want to suggest that you take out this feature and implement 
dereference/addressof in the simplest possible terms. Once we have all of the 
pieces in place (*), we can take a look the performance of the code and see if 
anything needs optimizing. It may turn out that that we can optimize something 
else so that `[i]` is fast and doesn't need to be optimized by addressof 
collapsing. Or it may not be a problem at all. I'm sure lldb-eval had its 
reasons to implement this, but its use case was very different from this, and 
it wasn't in a position to change lldb to make things faster. We are.

(*) My goal is to replace/delete the old "frame var" implementation as soon as 
possible. Until we do that, every line here is just adding technical debt. 
Fancy addressof handling is not required to do that. What we need is (simple) 
implementations of operations that are supported currently. Besides `&` and 
`*`, that's `.`, `->` and `[]`.

https://github.com/llvm/llvm-project/pull/134428
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Small refactor of eh_frame parsing (PR #134806)

2025-04-10 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/134806

>From f16fb6541556f5e82825207064f5f7bb6b3cd343 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Fri, 4 Apr 2025 11:37:34 +0200
Subject: [PATCH 1/4] [lldb] Support negative function offsets in UnwindPlans

These are needed for functions whose entry point is not their lowest
address.
---
 lldb/include/lldb/Symbol/UnwindPlan.h  | 10 +-
 .../UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp |  5 +++--
 lldb/source/Symbol/DWARFCallFrameInfo.cpp  |  2 +-
 lldb/source/Symbol/UnwindPlan.cpp  |  6 +++---
 lldb/unittests/Symbol/UnwindPlanTest.cpp   |  5 +
 5 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h 
b/lldb/include/lldb/Symbol/UnwindPlan.h
index 6640a23a3e868..410289851a879 100644
--- a/lldb/include/lldb/Symbol/UnwindPlan.h
+++ b/lldb/include/lldb/Symbol/UnwindPlan.h
@@ -356,11 +356,11 @@ class UnwindPlan {
 
 void RemoveRegisterInfo(uint32_t reg_num);
 
-lldb::addr_t GetOffset() const { return m_offset; }
+int64_t GetOffset() const { return m_offset; }
 
-void SetOffset(lldb::addr_t offset) { m_offset = offset; }
+void SetOffset(int64_t offset) { m_offset = offset; }
 
-void SlideOffset(lldb::addr_t offset) { m_offset += offset; }
+void SlideOffset(int64_t offset) { m_offset += offset; }
 
 const FAValue &GetCFAValue() const { return m_cfa_value; }
 FAValue &GetCFAValue() { return m_cfa_value; }
@@ -420,7 +420,7 @@ class UnwindPlan {
 
   protected:
 typedef std::map collection;
-lldb::addr_t m_offset = 0; // Offset into the function for this row
+int64_t m_offset = 0; // Offset into the function for this row
 
 FAValue m_cfa_value;
 FAValue m_afa_value;
@@ -472,7 +472,7 @@ class UnwindPlan {
   // practice, the UnwindPlan for a function with no known start address will 
be
   // the architectural default UnwindPlan which will only have one row.
   const UnwindPlan::Row *
-  GetRowForFunctionOffset(std::optional offset) const;
+  GetRowForFunctionOffset(std::optional offset) const;
 
   lldb::RegisterKind GetRegisterKind() const { return m_register_kind; }
 
diff --git 
a/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp 
b/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
index 3eaa2f33fce3e..aaff278ca31e2 100644
--- a/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
+++ b/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
@@ -1390,11 +1390,12 @@ bool 
x86AssemblyInspectionEngine::AugmentUnwindPlanFromCallSite(
 
 // If we already have one row for this instruction, we can continue.
 while (row_id < unwind_plan.GetRowCount() &&
-   unwind_plan.GetRowAtIndex(row_id)->GetOffset() <= offset) {
+   unwind_plan.GetRowAtIndex(row_id)->GetOffset() <=
+   static_cast(offset)) {
   row_id++;
 }
 const UnwindPlan::Row *original_row = unwind_plan.GetRowAtIndex(row_id - 
1);
-if (original_row->GetOffset() == offset) {
+if (original_row->GetOffset() == static_cast(offset)) {
   row = *original_row;
   continue;
 }
diff --git a/lldb/source/Symbol/DWARFCallFrameInfo.cpp 
b/lldb/source/Symbol/DWARFCallFrameInfo.cpp
index 957818e8d077f..dca3f665b0b80 100644
--- a/lldb/source/Symbol/DWARFCallFrameInfo.cpp
+++ b/lldb/source/Symbol/DWARFCallFrameInfo.cpp
@@ -765,7 +765,7 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t 
dwarf_offset,
  __FUNCTION__, dwarf_offset, startaddr.GetFileAddress());
 break;
   }
-  lldb::addr_t offset = row.GetOffset();
+  int64_t offset = row.GetOffset();
   row = std::move(stack.back());
   stack.pop_back();
   row.SetOffset(offset);
diff --git a/lldb/source/Symbol/UnwindPlan.cpp 
b/lldb/source/Symbol/UnwindPlan.cpp
index cfa8eefaa55bb..33aba0a859d5c 100644
--- a/lldb/source/Symbol/UnwindPlan.cpp
+++ b/lldb/source/Symbol/UnwindPlan.cpp
@@ -398,10 +398,10 @@ void UnwindPlan::AppendRow(Row row) {
 }
 
 struct RowLess {
-  bool operator()(addr_t a, const UnwindPlan::RowSP &b) const {
+  bool operator()(int64_t a, const UnwindPlan::RowSP &b) const {
 return a < b->GetOffset();
   }
-  bool operator()(const UnwindPlan::RowSP &a, addr_t b) const {
+  bool operator()(const UnwindPlan::RowSP &a, int64_t b) const {
 return a->GetOffset() < b;
   }
 };
@@ -418,7 +418,7 @@ void UnwindPlan::InsertRow(Row row, bool replace_existing) {
 }
 
 const UnwindPlan::Row *
-UnwindPlan::GetRowForFunctionOffset(std::optional offset) const {
+UnwindPlan::GetRowForFunctionOffset(std::optional offset) const {
   auto it = offset ? llvm::upper_bound(m_row_list, *offset, RowLess())
: m_row_list.end();
   if (it == m_row_list.begin())
diff --git a/lldb/unittests/Symbol/UnwindPlanTest.cpp 
b/lldb/unittest

[Lldb-commits] [lldb] [lldb] Use correct path for debugserver (PR #131609)

2025-04-10 Thread Pavel Labath via lldb-commits

labath wrote:

I can push the button for you if you could just update the patch description to 
what you'd like the commit message to say (in particular, I think the last 
paragraph is no longer correct).

As for cherry-picking, is this related to the lldb-server platform refactor in 
any way, or is it a separate problem that has always been there (I'm trying to 
figure out if this is a regression, at least for some cases)

https://github.com/llvm/llvm-project/pull/131609
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add frame-format option to highlight function names in backtraces (PR #131836)

2025-04-10 Thread Michael Buch via lldb-commits

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/131836
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)

2025-04-10 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/134956

>From 390942ce3a1cf6c51f95e8e2893f88807a48e745 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 8 Apr 2025 17:33:41 -0700
Subject: [PATCH 1/2] [lldb] Handle signals in a separate thread in the driver

Handle signals in a separate thread in the driver so that we can stop
worrying about signal safety of functions in libLLDB that may get called
from a signal handler.
---
 lldb/tools/driver/CMakeLists.txt |  2 +
 lldb/tools/driver/Driver.cpp | 96 +---
 2 files changed, 64 insertions(+), 34 deletions(-)

diff --git a/lldb/tools/driver/CMakeLists.txt b/lldb/tools/driver/CMakeLists.txt
index 89884ecd0601b..8b4aa92f96f0d 100644
--- a/lldb/tools/driver/CMakeLists.txt
+++ b/lldb/tools/driver/CMakeLists.txt
@@ -22,6 +22,8 @@ add_lldb_tool(lldb
 
   LINK_LIBS
 liblldb
+lldbHost
+lldbUtility
 
   LINK_COMPONENTS
 Option
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 15cb0134fec8e..fb051f198381f 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -19,7 +19,9 @@
 #include "lldb/API/SBStringList.h"
 #include "lldb/API/SBStructuredData.h"
 #include "lldb/Host/Config.h"
-
+#include "lldb/Host/MainLoop.h"
+#include "lldb/Host/MainLoopBase.h"
+#include "lldb/Utility/Status.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/InitLLVM.h"
@@ -50,6 +52,9 @@
 
 using namespace lldb;
 using namespace llvm;
+using lldb_private::MainLoop;
+using lldb_private::MainLoopBase;
+using lldb_private::Status;
 
 namespace {
 using namespace llvm::opt;
@@ -636,15 +641,12 @@ void Driver::UpdateWindowSize() {
   }
 }
 
-void sigwinch_handler(int signo) {
-  if (g_driver != nullptr)
-g_driver->UpdateWindowSize();
-}
-
 void sigint_handler(int signo) {
-#ifdef _WIN32 // Restore handler as it is not persistent on Windows
+#ifdef _WIN32
+  // Restore handler as it is not persistent on Windows.
   signal(SIGINT, sigint_handler);
 #endif
+
   static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT;
   if (g_driver != nullptr) {
 if (!g_interrupt_sent.test_and_set()) {
@@ -657,31 +659,6 @@ void sigint_handler(int signo) {
   _exit(signo);
 }
 
-#ifndef _WIN32
-static void sigtstp_handler(int signo) {
-  if (g_driver != nullptr)
-g_driver->GetDebugger().SaveInputTerminalState();
-
-  // Unblock the signal and remove our handler.
-  sigset_t set;
-  sigemptyset(&set);
-  sigaddset(&set, signo);
-  pthread_sigmask(SIG_UNBLOCK, &set, nullptr);
-  signal(signo, SIG_DFL);
-
-  // Now re-raise the signal. We will immediately suspend...
-  raise(signo);
-  // ... and resume after a SIGCONT.
-
-  // Now undo the modifications.
-  pthread_sigmask(SIG_BLOCK, &set, nullptr);
-  signal(signo, sigtstp_handler);
-
-  if (g_driver != nullptr)
-g_driver->GetDebugger().RestoreInputTerminalState();
-}
-#endif
-
 static void printHelp(LLDBOptTable &table, llvm::StringRef tool_name) {
   std::string usage_str = tool_name.str() + " [options]";
   table.printHelp(llvm::outs(), usage_str.c_str(), "LLDB", false);
@@ -787,11 +764,56 @@ int main(int argc, char const *argv[]) {
   // Setup LLDB signal handlers once the debugger has been initialized.
   SBDebugger::PrintDiagnosticsOnError();
 
+  //  FIXME: Migrate the SIGINT handler to be handled by the signal loop below.
   signal(SIGINT, sigint_handler);
 #if !defined(_WIN32)
   signal(SIGPIPE, SIG_IGN);
-  signal(SIGWINCH, sigwinch_handler);
-  signal(SIGTSTP, sigtstp_handler);
+
+  // Handle signals in a MainLoop running on a separate thread.
+  MainLoop signal_loop;
+  Status signal_status;
+
+  auto sigwinch_handler = signal_loop.RegisterSignal(
+  SIGWINCH,
+  [&](MainLoopBase &) {
+if (g_driver)
+  g_driver->UpdateWindowSize();
+  },
+  signal_status);
+  assert(sigwinch_handler && signal_status.Success());
+
+  auto sigtstp_handler = signal_loop.RegisterSignal(
+  SIGTSTP,
+  [&](MainLoopBase &) {
+if (g_driver)
+  g_driver->GetDebugger().SaveInputTerminalState();
+
+struct sigaction old_action;
+struct sigaction new_action;
+
+memset(&new_action, 0, sizeof(new_action));
+new_action.sa_handler = SIG_DFL;
+new_action.sa_flags = SA_SIGINFO;
+sigemptyset(&new_action.sa_mask);
+sigaddset(&new_action.sa_mask, SIGTSTP);
+
+int ret = sigaction(SIGTSTP, &new_action, &old_action);
+UNUSED_IF_ASSERT_DISABLED(ret);
+assert(ret == 0 && "sigaction failed");
+
+raise(SIGTSTP);
+
+ret = sigaction(SIGTSTP, &old_action, nullptr);
+UNUSED_IF_ASSERT_DISABLED(ret);
+assert(ret == 0 && "sigaction failed");
+
+if (g_driver)
+  g_driver->GetDebugger().RestoreInputTerminalState();
+  },
+  signal_status);
+  assert(sigtstp_handler && signal_status.Success());
+
+  std::thread signal_thr

[Lldb-commits] [lldb] [lldb] Small refactor of eh_frame parsing (PR #134806)

2025-04-10 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/134806

>From eeaad560a727ea2b113ab3eff218f66a46e30c83 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Fri, 4 Apr 2025 13:36:06 +0200
Subject: [PATCH 1/2] [lldb] Small refactor of eh_frame parsing

.. which prepares us for handling of discontinuous functions. The main
change there is that we can have multiple FDEs contributing towards an
unwind plan of a single function. This patch separates the logic for
parsing of a single FDE from the construction of an UnwindPlan (so that
another patch can change the latter to combine several unwind plans).
---
 lldb/include/lldb/Symbol/DWARFCallFrameInfo.h | 10 ++-
 lldb/source/Symbol/DWARFCallFrameInfo.cpp | 87 ++-
 2 files changed, 53 insertions(+), 44 deletions(-)

diff --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h 
b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
index 6cc24a02de257..526f322a770e4 100644
--- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
+++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
@@ -128,8 +128,14 @@ class DWARFCallFrameInfo {
 
   void GetFDEIndex();
 
-  bool FDEToUnwindPlan(dw_offset_t offset, Address startaddr,
-   UnwindPlan &unwind_plan);
+  // Parsed representation of a Frame Descriptor Entry.
+  struct FDE {
+AddressRange range;
+bool for_signal_trap = false;
+uint32_t return_addr_reg_num = LLDB_INVALID_REGNUM;
+std::vector rows;
+  };
+  std::optional ParseFDE(dw_offset_t offset, const Address &startaddr);
 
   const CIE *GetCIE(dw_offset_t cie_offset);
 
diff --git a/lldb/source/Symbol/DWARFCallFrameInfo.cpp 
b/lldb/source/Symbol/DWARFCallFrameInfo.cpp
index dac4cd9745f96..fb57c61d413aa 100644
--- a/lldb/source/Symbol/DWARFCallFrameInfo.cpp
+++ b/lldb/source/Symbol/DWARFCallFrameInfo.cpp
@@ -168,9 +168,32 @@ bool DWARFCallFrameInfo::GetUnwindPlan(const AddressRange 
&range,
   module_sp->GetObjectFile() != &m_objfile)
 return false;
 
-  if (std::optional entry = GetFirstFDEEntryInRange(range))
-return FDEToUnwindPlan(entry->data, addr, unwind_plan);
-  return false;
+  std::optional entry = GetFirstFDEEntryInRange(range);
+  if (!entry)
+return false;
+
+  std::optional fde = ParseFDE(entry->data, addr);
+  if (!fde)
+return false;
+
+  unwind_plan.SetSourceName(m_type == EH ? "eh_frame CFI" : "DWARF CFI");
+  // In theory the debug_frame info should be valid at all call sites
+  // ("asynchronous unwind info" as it is sometimes called) but in practice
+  // gcc et al all emit call frame info for the prologue and call sites, but
+  // not for the epilogue or all the other locations during the function
+  // reliably.
+  unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+  unwind_plan.SetSourcedFromCompiler(eLazyBoolYes);
+  unwind_plan.SetRegisterKind(GetRegisterKind());
+
+  unwind_plan.SetPlanValidAddressRanges({fde->range});
+  unwind_plan.SetUnwindPlanForSignalTrap(fde->for_signal_trap ? eLazyBoolYes
+  : eLazyBoolNo);
+  unwind_plan.SetReturnAddressRegister(fde->return_addr_reg_num);
+  for (UnwindPlan::Row &row : fde->rows)
+unwind_plan.AppendRow(std::move(row));
+
+  return true;
 }
 
 bool DWARFCallFrameInfo::GetAddressRange(Address addr, AddressRange &range) {
@@ -522,15 +545,15 @@ void DWARFCallFrameInfo::GetFDEIndex() {
   m_fde_index_initialized = true;
 }
 
-bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t dwarf_offset,
- Address startaddr,
- UnwindPlan &unwind_plan) {
+std::optional
+DWARFCallFrameInfo::ParseFDE(dw_offset_t dwarf_offset,
+ const Address &startaddr) {
   Log *log = GetLog(LLDBLog::Unwind);
   lldb::offset_t offset = dwarf_offset;
   lldb::offset_t current_entry = offset;
 
-  if (m_section_sp.get() == nullptr || m_section_sp->IsEncrypted())
-return false;
+  if (!m_section_sp || m_section_sp->IsEncrypted())
+return std::nullopt;
 
   if (!m_cfi_data_initialized)
 GetCFIData();
@@ -550,20 +573,8 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t 
dwarf_offset,
 
   // Translate the CIE_id from the eh_frame format, which is relative to the
   // FDE offset, into a __eh_frame section offset
-  if (m_type == EH) {
-unwind_plan.SetSourceName("eh_frame CFI");
+  if (m_type == EH)
 cie_offset = current_entry + (is_64bit ? 12 : 4) - cie_offset;
-unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
-  } else {
-unwind_plan.SetSourceName("DWARF CFI");
-// In theory the debug_frame info should be valid at all call sites
-// ("asynchronous unwind info" as it is sometimes called) but in practice
-// gcc et al all emit call frame info for the prologue and call sites, but
-// not for the epilogue or all the other locations during the function
-// reliably.
-unwind_plan.SetUnwindPlanValidAtAllInstructio

[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add frame-format option to highlight function names in backtraces (PR #131836)

2025-04-10 Thread Michael Buch via lldb-commits


@@ -2074,6 +2076,64 @@ static const Definition *FindEntry(const llvm::StringRef 
&format_str,
   return parent;
 }
 
+/// Parses a single highlighting format specifier.
+///
+/// Example syntax for such specifier:
+/// \code
+/// ${function.name-with-args:%highlight_basename(ansi.fg.green)}

Michael137 wrote:

> Keep the variable as function.name, but then add another (per-language) 
> setting defining how exactly to format a "function name" for the given 
> language?

I like this idea. So we'd have something like `${function.name}` in the 
`frame-format` setting that would default to `${function.name-with-args}` as 
before but could be "overriden" using a new setting like `frame-format-cxx` 
(per language) which could be `${function.basename}${function.arguments}` 
(etc.) and handled by the individual language plugins?

> Open question: whether that setting should apply only to backtraces or if 
> should/could be used in other contexts as well.
Good question. TBH even the frame status/thread status can become pretty noisy 
with long demangled names. So I'd see myself wanting the format to apply to 
both. But I don't have a strong opinion on that

https://github.com/llvm/llvm-project/pull/131836
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Use correct path for debugserver (PR #131609)

2025-04-10 Thread Yuval Deutscher via lldb-commits

https://github.com/yuvald-sweet-security updated 
https://github.com/llvm/llvm-project/pull/131609

>From 6f2d070facaced221295a5b0c48ccb3a41a5048d Mon Sep 17 00:00:00 2001
From: Yuval Deutscher 
Date: Mon, 17 Mar 2025 14:37:26 +0200
Subject: [PATCH 1/2] [lldb] Use correct path for debugserver

---
 lldb/tools/lldb-server/SystemInitializerLLGS.h | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-server/SystemInitializerLLGS.h 
b/lldb/tools/lldb-server/SystemInitializerLLGS.h
index 4469a8ba5f60a..c6020b0dd37da 100644
--- a/lldb/tools/lldb-server/SystemInitializerLLGS.h
+++ b/lldb/tools/lldb-server/SystemInitializerLLGS.h
@@ -11,10 +11,17 @@
 
 #include "lldb/Initialization/SystemInitializer.h"
 #include "lldb/Initialization/SystemInitializerCommon.h"
+#include "lldb/Utility/FileSpec.h"
 
 class SystemInitializerLLGS : public lldb_private::SystemInitializerCommon {
 public:
-  SystemInitializerLLGS() : SystemInitializerCommon(nullptr) {}
+  SystemInitializerLLGS()
+  : SystemInitializerCommon(
+// Finding the shared libraries directory on lldb-server is broken
+// since lldb-server isn't dynamically linked with liblldb.so.
+// Clearing the filespec here causes GetShlibDir to fail and
+// GetSupportExeDir to fall-back to using the binary path instead.
+[](lldb_private::FileSpec &file) { file.Clear(); }) {}
 
   llvm::Error Initialize() override;
   void Terminate() override;

>From e6bd01eddae880b1f61c9c05f23b9ea4661a86be Mon Sep 17 00:00:00 2001
From: Yuval Deutscher 
Date: Thu, 3 Apr 2025 14:52:43 +0300
Subject: [PATCH 2/2] [lldb] Test running lldb-server through symlink

---
 .../TestPlatformLaunchGDBServer.py| 39 +++
 1 file changed, 39 insertions(+)

diff --git 
a/lldb/test/API/commands/platform/launchgdbserver/TestPlatformLaunchGDBServer.py
 
b/lldb/test/API/commands/platform/launchgdbserver/TestPlatformLaunchGDBServer.py
index c365bc993e338..ea846149e4983 100644
--- 
a/lldb/test/API/commands/platform/launchgdbserver/TestPlatformLaunchGDBServer.py
+++ 
b/lldb/test/API/commands/platform/launchgdbserver/TestPlatformLaunchGDBServer.py
@@ -58,3 +58,42 @@ def test_platform_process_launch_gdb_server(self):
 
 self.runCmd("target create {}".format(self.getBuildArtifact("a.out")))
 self.expect("run", substrs=["unable to launch a GDB server on"], 
error=True)
+
+@skipIfRemote
+@skipUnlessPlatform(["linux"])
+@add_test_categories(["lldb-server"])
+def test_lldb_server_weird_symlinks(self):
+self.build()
+
+hostname = socket.getaddrinfo("localhost", 0, 
proto=socket.IPPROTO_TCP)[0][4][0]
+listen_url = "[%s]:0" % hostname
+
+port_file = self.getBuildArtifact("port")
+commandline_args = [
+"platform",
+"--listen",
+listen_url,
+"--socket-file",
+port_file,
+]
+
+# Run lldb-server from a symlink without any binary called 
"lldb-server" in the directory.
+new_lldb_server = self.getBuildArtifact(
+"lldb-server-with-an-unconventional-name"
+)
+os.symlink(lldbgdbserverutils.get_lldb_server_exe(), new_lldb_server)
+
+proc = self.spawnSubprocess(new_lldb_server, commandline_args)
+socket_id = lldbutil.wait_for_file_on_target(self, port_file)
+
+new_platform = lldb.SBPlatform("remote-" + self.getPlatform())
+self.dbg.SetSelectedPlatform(new_platform)
+
+connect_url = "connect://[%s]:%s" % (hostname, socket_id)
+self.runCmd("platform connect %s" % connect_url)
+self.runCmd("target create {}".format(self.getBuildArtifact("a.out")))
+self.runCmd("run")
+self.expect(
+"process status",
+patterns=["Process .* exited with status = 0"],
+)

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


[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add frame-format option to highlight function names in backtraces (PR #131836)

2025-04-10 Thread Michael Buch via lldb-commits


@@ -2074,6 +2076,64 @@ static const Definition *FindEntry(const llvm::StringRef 
&format_str,
   return parent;
 }
 
+/// Parses a single highlighting format specifier.
+///
+/// Example syntax for such specifier:
+/// \code
+/// ${function.name-with-args:%highlight_basename(ansi.fg.green)}

Michael137 wrote:

Oh looks like we already have a `${function.name}`, which just displays the raw 
demangled name (keeping the arguments not pretty-printed). Maybe we can hijack 
it

https://github.com/llvm/llvm-project/pull/131836
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-10 Thread Hemang Gadhavi via lldb-commits


@@ -141,6 +141,7 @@ else()
 add_host_subdirectory(aix
   aix/Host.cpp
   aix/HostInfoAIX.cpp
+  linux/Support.cpp

HemangGadhavi wrote:

@labath This is a great suggestion. Thanks for suggestion.
we will create the new PR for the same and create the common Support.cpp under 
`posix` .


https://github.com/llvm/llvm-project/pull/134354
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-10 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- 
lldb/source/Host/aix/Host.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Host/aix/Host.cpp b/lldb/source/Host/aix/Host.cpp
index 6f2b2ac16..4defd6686 100644
--- a/lldb/source/Host/aix/Host.cpp
+++ b/lldb/source/Host/aix/Host.cpp
@@ -6,9 +6,6 @@
 //
 
//===--===//
 
-#include 
-#include 
-#include 
 #include "lldb/Host/Host.h"
 #include "lldb/Host/linux/Support.h"
 #include "lldb/Utility/LLDBLog.h"
@@ -16,6 +13,9 @@
 #include "lldb/Utility/ProcessInfo.h"
 #include "lldb/Utility/Status.h"
 #include "llvm/BinaryFormat/XCOFF.h"
+#include 
+#include 
+#include 
 
 using namespace llvm;
 using namespace lldb;
@@ -101,12 +101,12 @@ static bool GetExePathAndArch(::pid_t pid, 
ProcessInstanceInfo &process_info) {
   auto BufferOrError = getProcFile(pid, "psinfo");
   if (!BufferOrError)
 return false;
-  
+
   std::unique_ptr PsinfoBuffer = std::move(*BufferOrError);
   // Ensure there's enough data for psinfoData
-  if(PsinfoBuffer->getBufferSize() < sizeof(psinfoData))  
+  if (PsinfoBuffer->getBufferSize() < sizeof(psinfoData))
 return false;
-  
+
   std::memcpy(&psinfoData, PsinfoBuffer->getBufferStart(), sizeof(psinfoData));
   llvm::StringRef PathRef(&(psinfoData.pr_psargs[0]));
   if (!PathRef.empty()) {
@@ -128,7 +128,7 @@ static bool GetProcessAndStatInfo(::pid_t pid,
   process_info.Clear();
   process_info.SetProcessID(pid);
 
-  if(!GetExePathAndArch(pid, process_info))
+  if (!GetExePathAndArch(pid, process_info))
 return false;
   // Get User and Group IDs and get tracer pid.
   if (!GetStatusInfo(pid, process_info, State, tracerpid, tgid))

``




https://github.com/llvm/llvm-project/pull/134354
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-10 Thread Dhruv Srivastava via lldb-commits

DhruvSrivastavaX wrote:

Please re-run clang-format on the changes.

https://github.com/llvm/llvm-project/pull/134354
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-10 Thread Hemang Gadhavi via lldb-commits

HemangGadhavi wrote:

> We have a tests for this function in `unittests/Host/linux/HostTest.cpp` and 
> it looks like at least some of it should apply to other systems as well. We 
> could move it to the "posix" folder so that it applies to your code as well. 
> Depending on the size of linux-specific parts, we could either keep them in 
> the "linux" folder, or `#ifdef` them out

Okay, we will create new PR to either move it to posix or we can create 
`HostTest.cpp` for aix separately.  @labath or you want me to drop the tescase 
in same PR ?

https://github.com/llvm/llvm-project/pull/134354
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Reapply refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #135033)

2025-04-10 Thread Vladislav Dzhidzhoev via lldb-commits

dzhidzhoev wrote:

With the last commit, I observe no test regressions on macOS (on my pretty 
default build config).

https://github.com/llvm/llvm-project/pull/135033
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add download time for each module in statistics (PR #134563)

2025-04-10 Thread via lldb-commits

https://github.com/youngd007 edited 
https://github.com/llvm/llvm-project/pull/134563
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)

2025-04-10 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

Yeah, I'm afraid this isn't the right way to use the MainLoop with signals. 
`AddPendingCallback` is not signal-safe. You need to actually let the main loop 
handle the signals (MainLoopPosix::RegisterSignal), as it knows how to do that 
safely. The function is not available on windows, so you'd need to `#ifdef` it, 
but that should be fine because the current code is conditionalized anyway.

The main exception to that is `SIGINT`, which is currently used on windows, 
although I'm not sure it actually works (I have a feeling that ^C just 
terminated my lldb process). For now, I think you could leave that alone, as I 
think it's not something that's needed for the status line code. The right way 
to fix that would probably be to add some generic MainLoop function, which maps 
to SIGINT on posix and `SetConsoleCtrlHandler` on windows.

With this setup, I also think the main loop doesn't have to be a global. I 
think it should be possible to declare it in the main function and then let it 
clean up after itself before `main` returns.

https://github.com/llvm/llvm-project/pull/134956
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix SBTarget::ReadInstruction with flavor (PR #134626)

2025-04-10 Thread via lldb-commits

https://github.com/jimingham approved this pull request.

LGTM, thanks for fixing this!

https://github.com/llvm/llvm-project/pull/134626
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (PR #134354)

2025-04-10 Thread Pavel Labath via lldb-commits


@@ -141,6 +141,7 @@ else()
 add_host_subdirectory(aix
   aix/Host.cpp
   aix/HostInfoAIX.cpp
+  linux/Support.cpp

labath wrote:

This PR is small enough, so I think you can just do it here. At least it will 
have context for why you're doing this.

https://github.com/llvm/llvm-project/pull/134354
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-04-10 Thread Greg Clayton via lldb-commits


@@ -46,12 +49,333 @@ class CommandObjectPluginLoad : public CommandObjectParsed 
{
   }
 };
 
+namespace {
+#define LLDB_OPTIONS_plugin_list
+#include "CommandOptions.inc"
+
+// These option definitions are shared by the plugin list/enable/disable
+// commands.
+class PluginListCommandOptions : public Options {
+public:
+  PluginListCommandOptions() = default;
+
+  ~PluginListCommandOptions() override = default;
+
+  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ExecutionContext *execution_context) override {
+Status error;
+const int short_option = m_getopt_table[option_idx].val;
+
+switch (short_option) {
+case 'x':
+  m_exact_name_match = true;
+  break;
+default:
+  llvm_unreachable("Unimplemented option");
+}
+
+return error;
+  }
+
+  void OptionParsingStarting(ExecutionContext *execution_context) override {
+m_exact_name_match = false;
+  }
+
+  llvm::ArrayRef GetDefinitions() override {
+return llvm::ArrayRef(g_plugin_list_options);
+  }
+
+  // Instance variables to hold the values for command options.
+  bool m_exact_name_match = false;
+};
+
+// Define some data structures to describe known plugin "namespaces".
+// The PluginManager is organized into a series of static functions
+// that operate on different types of plugin. For example SystemRuntime
+// and ObjectFile plugins.
+//
+// The namespace name is used a prefix when matching plugin names. For example,
+// if we have an "elf" plugin in the "object-file" namespace then we will
+// match a plugin name pattern against the "object-file.elf" name.
+//
+// The plugin namespace here is used so we can operate on all the plugins
+// of a given type so it is easy to enable or disable them as a group.
+using GetPluginInfo = std::function()>;
+using SetPluginEnabled = std::function;
+struct PluginNamespace {
+  llvm::StringRef name;
+  GetPluginInfo get_info;
+  SetPluginEnabled set_enabled;
+};
+
+// Currently supported set of plugin namespaces. This will be expanded
+// over time.
+PluginNamespace PluginNamespaces[] = {
+{"system-runtime", PluginManager::GetSystemRuntimePluginInfo,
+ PluginManager::SetSystemRuntimePluginEnabled}};
+
+// Helper function to perform an action on each matching plugin.
+// The action callback is given the containing namespace along with plugin info
+// for each matching plugin.
+static int ActOnMatchingPlugins(
+llvm::GlobPattern pattern,
+std::function &plugin_info)>
+action) {
+  int num_matching = 0;
+
+  for (const PluginNamespace &plugin_namespace : PluginNamespaces) {
+std::vector matching_plugins;
+for (const RegisteredPluginInfo &plugin_info :
+ plugin_namespace.get_info()) {
+  std::string qualified_name =
+  (plugin_namespace.name + "." + plugin_info.name).str();
+  if (pattern.match(qualified_name))
+matching_plugins.push_back(plugin_info);
+}
+
+if (!matching_plugins.empty()) {
+  num_matching += matching_plugins.size();
+  action(plugin_namespace, matching_plugins);
+}
+  }
+
+  return num_matching;
+}
+
+// Return a string in glob syntax for matching plugins.
+static std::string GetPluginNamePatternString(llvm::StringRef user_input,
+  bool add_default_glob) {
+  std::string pattern_str = user_input.empty() ? "*" : user_input.str();
+
+  if (add_default_glob && pattern_str != "*")
+pattern_str = "*" + pattern_str + "*";
+
+  return pattern_str;
+}
+
+// Attempts to create a glob pattern for a plugin name based on plugin command
+// input. Writes an error message to the `result` object if the glob cannot be
+// created successfully.
+//
+// The `glob_storage` is used to hold the string data for the glob pattern. The
+// llvm::GlobPattern only contains pointers into the string data so we need a
+// stable location that can outlive the glob pattern itself.
+std::optional
+TryCreatePluginPattern(const char *plugin_command_name, const Args &command,
+   const PluginListCommandOptions &options,
+   CommandReturnObject &result, std::string &glob_storage) 
{
+  size_t argc = command.GetArgumentCount();
+  if (argc > 1) {
+result.AppendErrorWithFormat("'%s' requires one argument",
+ plugin_command_name);
+return {};
+  }
+
+  llvm::StringRef user_pattern = argc == 1 ? command[0].ref() : "";
+
+  glob_storage =
+  GetPluginNamePatternString(user_pattern, !options.m_exact_name_match);
+
+  auto glob_pattern = llvm::GlobPattern::create(glob_storage);
+
+  if (auto error = glob_pattern.takeError()) {
+std::string error_message =
+(llvm::Twine("Invalid plugin glob pattern: '") + glob_storage +
+ "': " + llvm::toString(std::move(error)))
+.str();
+result.AppendError(error_message);
+return {};
+  }
+
+  return *glob_pattern;
+}
+
+// Call the "SetEnable"

[Lldb-commits] [lldb] [RFC][lldb-dap] Always stop on enrty for attaching (PR #134339)

2025-04-10 Thread via lldb-commits

kusmour wrote:

> I wonder if we should add a test about the things we DON'T hand out when a 
> process is running just so we claim the behavior concretely.

Unit tests on the SB API or DAP API tests? I am happy to add tests as follow-ups

https://github.com/llvm/llvm-project/pull/134339
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][debugserver] Fix an off-by-one error in watchpoint identification (PR #134314)

2025-04-10 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-remote-linux-win` 
running on `as-builder-10` while building `lldb` at step 17 
"test-check-lldb-api".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/197/builds/3684


Here is the relevant piece of the build log for the reference

```
Step 17 (test-check-lldb-api) failure: Test just built components: 
check-lldb-api completed (failure)
 TEST 'lldb-api :: 
functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py'
 FAILED 
Script:
--
C:/Python312/python.exe 
C:/buildbot/as-builder-10/lldb-x-aarch64/llvm-project/lldb\test\API\dotest.py 
-u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=C:/buildbot/as-builder-10/lldb-x-aarch64/build/./lib --env 
LLVM_INCLUDE_DIR=C:/buildbot/as-builder-10/lldb-x-aarch64/build/include --env 
LLVM_TOOLS_DIR=C:/buildbot/as-builder-10/lldb-x-aarch64/build/./bin --arch 
aarch64 --build-dir 
C:/buildbot/as-builder-10/lldb-x-aarch64/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
C:/buildbot/as-builder-10/lldb-x-aarch64/build/lldb-test-build.noindex/module-cache-lldb\lldb-api
 --clang-module-cache-dir 
C:/buildbot/as-builder-10/lldb-x-aarch64/build/lldb-test-build.noindex/module-cache-clang\lldb-api
 --executable C:/buildbot/as-builder-10/lldb-x-aarch64/build/./bin/lldb.exe 
--compiler C:/buildbot/as-builder-10/lldb-x-aarch64/build/./bin/clang.exe 
--dsymutil C:/buildbot/as-builder-10/lldb-x-aarch64/build/./bin/dsymutil.exe 
--make C:/ninja/make.exe --llvm-tools-dir 
C:/buildbot/as-builder-10/lldb-x-aarch64/build/./bin --lldb-obj-root 
C:/buildbot/as-builder-10/lldb-x-aarch64/build/tools/lldb --lldb-libs-dir 
C:/buildbot/as-builder-10/lldb-x-aarch64/build/./lib --platform-url 
connect://jetson-agx-0086.lab.llvm.org:1234 --platform-working-dir 
/home/ubuntu/lldb-tests --sysroot c:/buildbot/fs/jetson-agx-ubuntu --env 
ARCH_CFLAGS=-mcpu=cortex-a78 --platform-name remote-linux 
--skip-category=lldb-server 
C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\test\API\functionalities\watchpoint\consecutive-watchpoints
 -p TestConsecutiveWatchpoints.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
21d912121c9f41385b165a736be787527f5bd7c2)
  clang revision 21d912121c9f41385b165a736be787527f5bd7c2
  llvm revision 21d912121c9f41385b165a736be787527f5bd7c2
Setting up remote platform 'remote-linux'

Connecting to remote platform 'remote-linux' at 
'connect://jetson-agx-0086.lab.llvm.org:1234'...

Connected.

Setting remote platform working directory to '/home/ubuntu/lldb-tests'...

Skipping the following test categories: ['lldb-server', 'dsym', 'gmodules', 
'debugserver', 'objc', 'lldb-dap']


--
Command Output (stderr):
--
FAIL: LLDB 
(C:\buildbot\as-builder-10\lldb-x-aarch64\build\bin\clang.exe-aarch64) :: 
test_large_watchpoint 
(TestConsecutiveWatchpoints.ConsecutiveWatchpointsTestCase.test_large_watchpoint)

==

FAIL: test_large_watchpoint 
(TestConsecutiveWatchpoints.ConsecutiveWatchpointsTestCase.test_large_watchpoint)

   Test watchpoint that covers a large region of memory.

--

Traceback (most recent call last):

  File 
"C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\test\API\functionalities\watchpoint\consecutive-watchpoints\TestConsecutiveWatchpoints.py",
 line 58, in test_large_watchpoint

self.assertTrue(field4_wp.IsValid())

AssertionError: False is not true

Config=aarch64-C:\buildbot\as-builder-10\lldb-x-aarch64\build\bin\clang.exe

--

Ran 1 test in 0.810s

...

```



https://github.com/llvm/llvm-project/pull/134314
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #132274)

2025-04-10 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

I'm looking on it.

https://github.com/llvm/llvm-project/pull/132274
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add option to highlight function names in backtraces (PR #131836)

2025-04-10 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/131836

>From 65aab6b727cc430a9e826c7eeda67259e041a462 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 7 Apr 2025 13:21:25 +0100
Subject: [PATCH 1/5] [ItaniumDemangle] Add printLeft/printRight APIs to
 OutputBuffer

This patch includes the necessary changes for the LLDB feature proposed in 
https://discourse.llvm.org/t/rfc-lldb-highlighting-function-names-in-lldb-backtraces/85309.
 The TL;DR is that we want to track where certain parts of a demangled name 
begin/end so we can highlight them in backtraces.

We introduce a new `printLeft`/`printRight` API that a client (in our case 
LLDB) can implement to track state while printing the demangle tree. This 
requires redirecting all calls to to `printLeft`/`printRight` to the 
`OutputBuffer`. One quirk with the new API is that `Utility.h` would now depend 
on `ItaniumDemangle.h` and vice-versa. To keep these files header-only I made 
the definitions `inline` and implement the new APIs in `ItaniumDemangle.h` (so 
the definition of `Node` is available to them).
---
 libcxxabi/src/demangle/ItaniumDemangle.h | 64 +++-
 libcxxabi/src/demangle/Utility.h |  7 +++
 llvm/include/llvm/Demangle/ItaniumDemangle.h | 64 +++-
 llvm/include/llvm/Demangle/Utility.h |  7 +++
 4 files changed, 86 insertions(+), 56 deletions(-)

diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h 
b/libcxxabi/src/demangle/ItaniumDemangle.h
index 3df41b5f4d7d0..89a24def830f2 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -281,9 +281,9 @@ class Node {
   }
 
   void print(OutputBuffer &OB) const {
-printLeft(OB);
+OB.printLeft(*this);
 if (RHSComponentCache != Cache::No)
-  printRight(OB);
+  OB.printRight(*this);
   }
 
   // Print the "left" side of this Node into OutputBuffer.
@@ -458,11 +458,11 @@ class QualType final : public Node {
   }
 
   void printLeft(OutputBuffer &OB) const override {
-Child->printLeft(OB);
+OB.printLeft(*Child);
 printQuals(OB);
   }
 
-  void printRight(OutputBuffer &OB) const override { Child->printRight(OB); }
+  void printRight(OutputBuffer &OB) const override { OB.printRight(*Child); }
 };
 
 class ConversionOperatorType final : public Node {
@@ -491,7 +491,7 @@ class PostfixQualifiedType final : public Node {
   template void match(Fn F) const { F(Ty, Postfix); }
 
   void printLeft(OutputBuffer &OB) const override {
-Ty->printLeft(OB);
+OB.printLeft(*Ty);
 OB += Postfix;
   }
 };
@@ -577,7 +577,7 @@ struct AbiTagAttr : Node {
   std::string_view getBaseName() const override { return Base->getBaseName(); }
 
   void printLeft(OutputBuffer &OB) const override {
-Base->printLeft(OB);
+OB.printLeft(*Base);
 OB += "[abi:";
 OB += Tag;
 OB += "]";
@@ -644,7 +644,7 @@ class PointerType final : public Node {
 // We rewrite objc_object* into id.
 if (Pointee->getKind() != KObjCProtoName ||
 !static_cast(Pointee)->isObjCObject()) {
-  Pointee->printLeft(OB);
+  OB.printLeft(*Pointee);
   if (Pointee->hasArray(OB))
 OB += " ";
   if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
@@ -663,7 +663,7 @@ class PointerType final : public Node {
 !static_cast(Pointee)->isObjCObject()) {
   if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
 OB += ")";
-  Pointee->printRight(OB);
+  OB.printRight(*Pointee);
 }
   }
 };
@@ -729,7 +729,7 @@ class ReferenceType : public Node {
 std::pair Collapsed = collapse(OB);
 if (!Collapsed.second)
   return;
-Collapsed.second->printLeft(OB);
+OB.printLeft(*Collapsed.second);
 if (Collapsed.second->hasArray(OB))
   OB += " ";
 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
@@ -746,7 +746,7 @@ class ReferenceType : public Node {
   return;
 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
   OB += ")";
-Collapsed.second->printRight(OB);
+OB.printRight(*Collapsed.second);
   }
 };
 
@@ -766,7 +766,7 @@ class PointerToMemberType final : public Node {
   }
 
   void printLeft(OutputBuffer &OB) const override {
-MemberType->printLeft(OB);
+OB.printLeft(*MemberType);
 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
   OB += "(";
 else
@@ -778,7 +778,7 @@ class PointerToMemberType final : public Node {
   void printRight(OutputBuffer &OB) const override {
 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
   OB += ")";
-MemberType->printRight(OB);
+OB.printRight(*MemberType);
   }
 };
 
@@ -798,7 +798,7 @@ class ArrayType final : public Node {
   bool hasRHSComponentSlow(OutputBuffer &) const override { return true; }
   bool hasArraySlow(OutputBuffer &) const override { return true; }
 
-  void printLeft(OutputBuffer &OB) const override { Base->print

[Lldb-commits] [lldb] [llvm] [dsymutil] Avoid copying binary swiftmodules built from textual (PR #134719)

2025-04-10 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `polly-x86_64-linux-shared` 
running on `polly-x86_64-gce2` while building `lldb,llvm` at step 5 "build".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/97/builds/5912


Here is the relevant piece of the build log for the reference

```
Step 5 (build) failure: 'ninja' (failure)
...
[3828/4371] Building Options.inc...
[3829/4371] Building CXX object 
tools/llvm-dwarfdump/CMakeFiles/llvm-dwarfdump.dir/llvm-dwarfdump.cpp.o
[3830/4371] Linking CXX executable bin/llvm-dwarfdump
[3831/4371] Building CXX object 
tools/llvm-dwarfutil/CMakeFiles/llvm-dwarfutil.dir/DebugInfoLinker.cpp.o
[3832/4371] Building CXX object 
tools/llvm-dwarfutil/CMakeFiles/llvm-dwarfutil.dir/llvm-dwarfutil.cpp.o
[3833/4371] Building CXX object 
tools/llvm-dwp/CMakeFiles/llvm-dwp.dir/llvm-dwp-driver.cpp.o
[3834/4371] Building CXX object 
tools/dsymutil/CMakeFiles/dsymutil.dir/DwarfLinkerForBinary.cpp.o
[3835/4371] Building CXX object 
tools/llvm-dwp/CMakeFiles/llvm-dwp.dir/llvm-dwp.cpp.o
[3836/4371] Linking CXX executable bin/llvm-dwarfutil
[3837/4371] Linking CXX executable bin/dsymutil
FAILED: bin/dsymutil 
: && /usr/bin/c++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess 
-Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
-Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG -fuse-ld=lld 
-Wl,--color-diagnostics -Wl,--gc-sections 
tools/dsymutil/CMakeFiles/dsymutil.dir/dsymutil.cpp.o 
tools/dsymutil/CMakeFiles/dsymutil.dir/BinaryHolder.cpp.o 
tools/dsymutil/CMakeFiles/dsymutil.dir/CFBundle.cpp.o 
tools/dsymutil/CMakeFiles/dsymutil.dir/DebugMap.cpp.o 
tools/dsymutil/CMakeFiles/dsymutil.dir/DwarfLinkerForBinary.cpp.o 
tools/dsymutil/CMakeFiles/dsymutil.dir/MachODebugMapParser.cpp.o 
tools/dsymutil/CMakeFiles/dsymutil.dir/MachOUtils.cpp.o 
tools/dsymutil/CMakeFiles/dsymutil.dir/Reproducer.cpp.o 
tools/dsymutil/CMakeFiles/dsymutil.dir/RelocationMap.cpp.o 
tools/dsymutil/CMakeFiles/dsymutil.dir/SwiftModule.cpp.o 
tools/dsymutil/CMakeFiles/dsymutil.dir/dsymutil-driver.cpp.o -o bin/dsymutil  
-Wl,-rpath,"\$ORIGIN/../lib:/home/worker/buildbot-workers/polly-x86_64-gce2/rundir/llvm.obj/lib:"
  lib/libLLVMX86CodeGen.so.21.0git  lib/libLLVMNVPTXCodeGen.so.21.0git  
lib/libLLVMX86Desc.so.21.0git  lib/libLLVMNVPTXDesc.so.21.0git  
lib/libLLVMX86Info.so.21.0git  lib/libLLVMNVPTXInfo.so.21.0git  
lib/libLLVMDWARFLinkerClassic.so.21.0git  
lib/libLLVMDWARFLinkerParallel.so.21.0git  lib/libLLVMOption.so.21.0git  
lib/libLLVMAsmPrinter.so.21.0git  lib/libLLVMDWARFLinker.so.21.0git  
lib/libLLVMCodeGen.so.21.0git  lib/libLLVMCodeGenTypes.so.21.0git  
lib/libLLVMTarget.so.21.0git  lib/libLLVMDebugInfoDWARF.so.21.0git  
lib/libLLVMObject.so.21.0git  lib/libLLVMMC.so.21.0git  
lib/libLLVMRemarks.so.21.0git  lib/libLLVMTargetParser.so.21.0git  
lib/libLLVMSupport.so.21.0git  
-Wl,-rpath-link,/home/worker/buildbot-workers/polly-x86_64-gce2/rundir/llvm.obj/lib
 && :
ld.lld: error: undefined symbol: llvm::BitstreamCursor::ReadAbbrevRecord()
>>> referenced by SwiftModule.cpp
>>>   
>>> tools/dsymutil/CMakeFiles/dsymutil.dir/SwiftModule.cpp.o:(llvm::BitstreamCursor::advance(unsigned
>>>  int))

ld.lld: error: undefined symbol: llvm::BitstreamCursor::EnterSubBlock(unsigned 
int, unsigned int*)
>>> referenced by SwiftModule.cpp
>>>   
>>> tools/dsymutil/CMakeFiles/dsymutil.dir/SwiftModule.cpp.o:((anonymous 
>>> namespace)::enterTopLevelModuleBlock(llvm::BitstreamCursor&, unsigned int) 
>>> (.constprop.0))
>>> referenced by SwiftModule.cpp
>>>   
>>> tools/dsymutil/CMakeFiles/dsymutil.dir/SwiftModule.cpp.o:(IsBuiltFromSwiftInterface(llvm::StringRef))
>>> referenced by SwiftModule.cpp
>>>   
>>> tools/dsymutil/CMakeFiles/dsymutil.dir/SwiftModule.cpp.o:(IsBuiltFromSwiftInterface(llvm::StringRef))

ld.lld: error: undefined symbol: llvm::BitstreamCursor::readRecord(unsigned 
int, llvm::SmallVectorImpl&, llvm::StringRef*)
>>> referenced by SwiftModule.cpp
>>>   
>>> tools/dsymutil/CMakeFiles/dsymutil.dir/SwiftModule.cpp.o:(IsBuiltFromSwiftInterface(llvm::StringRef))
>>> referenced by SwiftModule.cpp
>>>   
>>> tools/dsymutil/CMakeFiles/dsymutil.dir/SwiftModule.cpp.o:(IsBuiltFromSwiftInterface(llvm::StringRef))
collect2: error: ld returned 1 exit status
[3838/4371] Linking CXX executable bin/llvm-dwp
[3839/4371] Building CXX object 
tools/llvm-exegesis/CMakeFiles/llvm-exegesis.dir/llvm-exegesis.cpp.o
ninja: build stopped: subcommand failed.

```



https://github.com/llvm/llvm-project/pull/134719
_

[Lldb-commits] [lldb] 8877b91 - [LLDB][MIPS] Fix signal SIGBUS number mismatch error on mips target (#132688)

2025-04-10 Thread via lldb-commits

Author: yingopq
Date: 2025-04-09T10:53:47+02:00
New Revision: 8877b913ae88c6ae43e859316489fe0469293131

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

LOG: [LLDB][MIPS] Fix signal SIGBUS number mismatch error on mips target 
(#132688)

Now, because we do not support mips debugging, if we compile LLVM on
mips target, would report error `static assertion failed:Value mismatch
for signal number SIGBUS`, so add this condition to avoid error.

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/LinuxSignals.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp 
b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
index eaecc84df15d4..9c4fe55147a28 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
+++ b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
@@ -8,7 +8,11 @@
 
 #include "LinuxSignals.h"
 
-#ifdef __linux__
+// mips-linux debugging is not supported and mips uses 
diff erent numbers for
+// some signals (e.g. SIGBUS) on linux, so we skip the static checks below. The
+// definitions here can be used for debugging non-mips targets on a mips-hosted
+// lldb.
+#if defined(__linux__) && !defined(__mips__)
 #include 
 
 #ifndef SEGV_BNDERR
@@ -33,7 +37,7 @@
 #else
 #define ADD_SIGCODE(signal_name, signal_value, code_name, code_value, ...) 
\
   AddSignalCode(signal_value, code_value, __VA_ARGS__)
-#endif /* ifdef __linux__ */
+#endif /* if defined(__linux__) && !defined(__mips__) */
 
 using namespace lldb_private;
 



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


[Lldb-commits] [lldb] 6493345 - [lldb] Handle signals in a separate thread in the driver (#134956)

2025-04-10 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-04-10T11:04:05-07:00
New Revision: 6493345c5ab96f60ab5ee38272fb6635f2083318

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

LOG: [lldb] Handle signals in a separate thread in the driver (#134956)

Handle signals in a separate thread in the driver so that we can stop
worrying about signal safety of functions in libLLDB that may get called
from a signal handler.

Added: 


Modified: 
lldb/tools/driver/CMakeLists.txt
lldb/tools/driver/Driver.cpp

Removed: 




diff  --git a/lldb/tools/driver/CMakeLists.txt 
b/lldb/tools/driver/CMakeLists.txt
index 89884ecd0601b..8b4aa92f96f0d 100644
--- a/lldb/tools/driver/CMakeLists.txt
+++ b/lldb/tools/driver/CMakeLists.txt
@@ -22,6 +22,8 @@ add_lldb_tool(lldb
 
   LINK_LIBS
 liblldb
+lldbHost
+lldbUtility
 
   LINK_COMPONENTS
 Option

diff  --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 15cb0134fec8e..e19fded051941 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -19,7 +19,9 @@
 #include "lldb/API/SBStringList.h"
 #include "lldb/API/SBStructuredData.h"
 #include "lldb/Host/Config.h"
-
+#include "lldb/Host/MainLoop.h"
+#include "lldb/Host/MainLoopBase.h"
+#include "lldb/Utility/Status.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/InitLLVM.h"
@@ -50,6 +52,9 @@
 
 using namespace lldb;
 using namespace llvm;
+using lldb_private::MainLoop;
+using lldb_private::MainLoopBase;
+using lldb_private::Status;
 
 namespace {
 using namespace llvm::opt;
@@ -636,15 +641,12 @@ void Driver::UpdateWindowSize() {
   }
 }
 
-void sigwinch_handler(int signo) {
-  if (g_driver != nullptr)
-g_driver->UpdateWindowSize();
-}
-
 void sigint_handler(int signo) {
-#ifdef _WIN32 // Restore handler as it is not persistent on Windows
+#ifdef _WIN32
+  // Restore handler as it is not persistent on Windows.
   signal(SIGINT, sigint_handler);
 #endif
+
   static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT;
   if (g_driver != nullptr) {
 if (!g_interrupt_sent.test_and_set()) {
@@ -657,31 +659,6 @@ void sigint_handler(int signo) {
   _exit(signo);
 }
 
-#ifndef _WIN32
-static void sigtstp_handler(int signo) {
-  if (g_driver != nullptr)
-g_driver->GetDebugger().SaveInputTerminalState();
-
-  // Unblock the signal and remove our handler.
-  sigset_t set;
-  sigemptyset(&set);
-  sigaddset(&set, signo);
-  pthread_sigmask(SIG_UNBLOCK, &set, nullptr);
-  signal(signo, SIG_DFL);
-
-  // Now re-raise the signal. We will immediately suspend...
-  raise(signo);
-  // ... and resume after a SIGCONT.
-
-  // Now undo the modifications.
-  pthread_sigmask(SIG_BLOCK, &set, nullptr);
-  signal(signo, sigtstp_handler);
-
-  if (g_driver != nullptr)
-g_driver->GetDebugger().RestoreInputTerminalState();
-}
-#endif
-
 static void printHelp(LLDBOptTable &table, llvm::StringRef tool_name) {
   std::string usage_str = tool_name.str() + " [options]";
   table.printHelp(llvm::outs(), usage_str.c_str(), "LLDB", false);
@@ -787,11 +764,53 @@ int main(int argc, char const *argv[]) {
   // Setup LLDB signal handlers once the debugger has been initialized.
   SBDebugger::PrintDiagnosticsOnError();
 
+  //  FIXME: Migrate the SIGINT handler to be handled by the signal loop below.
   signal(SIGINT, sigint_handler);
 #if !defined(_WIN32)
   signal(SIGPIPE, SIG_IGN);
-  signal(SIGWINCH, sigwinch_handler);
-  signal(SIGTSTP, sigtstp_handler);
+
+  // Handle signals in a MainLoop running on a separate thread.
+  MainLoop signal_loop;
+  Status signal_status;
+
+  auto sigwinch_handler = signal_loop.RegisterSignal(
+  SIGWINCH,
+  [&](MainLoopBase &) {
+if (g_driver)
+  g_driver->UpdateWindowSize();
+  },
+  signal_status);
+  assert(sigwinch_handler && signal_status.Success());
+
+  auto sigtstp_handler = signal_loop.RegisterSignal(
+  SIGTSTP,
+  [&](MainLoopBase &) {
+if (g_driver)
+  g_driver->GetDebugger().SaveInputTerminalState();
+
+struct sigaction old_action;
+struct sigaction new_action = {};
+new_action.sa_handler = SIG_DFL;
+sigemptyset(&new_action.sa_mask);
+sigaddset(&new_action.sa_mask, SIGTSTP);
+
+int ret = sigaction(SIGTSTP, &new_action, &old_action);
+UNUSED_IF_ASSERT_DISABLED(ret);
+assert(ret == 0 && "sigaction failed");
+
+raise(SIGTSTP);
+
+ret = sigaction(SIGTSTP, &old_action, nullptr);
+UNUSED_IF_ASSERT_DISABLED(ret);
+assert(ret == 0 && "sigaction failed");
+
+if (g_driver)
+  g_driver->GetDebugger().RestoreInputTerminalState();
+  },
+  signal_status);
+  assert(sigtstp_handler && signal_status.Success());
+
+  std::thread si

[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)

2025-04-10 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere closed 
https://github.com/llvm/llvm-project/pull/134956
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)

2025-04-10 Thread Greg Clayton via lldb-commits

clayborg wrote:

Signals can be listened for via a file descriptor as well. Not sure if this 
improves the ability to do things in signal handlers as the default way of 
catching signals has all sorts of limitations. If it does improve the safety 
and ability to do things in the signal handler, we might want to look into 
using signalfd?

https://man7.org/linux/man-pages/man2/signalfd.2.html

https://github.com/llvm/llvm-project/pull/134956
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RFC][lldb-dap] Always stop on enrty for attaching (PR #134339)

2025-04-10 Thread via lldb-commits

jimingham wrote:

That code has been there at least since the dread reformatting.  

I have no idea why past one of us thought it was a good idea to return the 
previous number of threads or the old thread list when you weren't stopped.  We 
don't do that with most anything else you ask about threads, and I can't think 
of any way that would be useful.

Whatever we do with DAP, we should stop doing this in SBThread...

https://github.com/llvm/llvm-project/pull/134339
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add unary operators Dereference and AddressOf to DIL (PR #134428)

2025-04-10 Thread Pavel Labath via lldb-commits

labath wrote:

> Is it a general consensus that people shouldn't use unit tests anymore?

They shouldn't use unit tests for building debug subjects.

https://github.com/llvm/llvm-project/pull/134428
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [dsymutil] Avoid copying binary swiftmodules built from textual (PR #134719)

2025-04-10 Thread Jan Patrick Lehr via lldb-commits

jplehr wrote:

Hi @adrian-prantl  can this be forward fixed or better revert in the meantime?
Thanks!

https://github.com/llvm/llvm-project/pull/134719
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Synchronize access to m_statusline in the Debugger (PR #134759)

2025-04-10 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

Rebased on top of https://github.com/llvm/llvm-project/pull/134956 which means 
we can now safely lock everywhere we access `m_statusline`. 

https://github.com/llvm/llvm-project/pull/134759
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Synchronize access to m_statusline in the Debugger (PR #134759)

2025-04-10 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere edited 
https://github.com/llvm/llvm-project/pull/134759
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Synchronize access to m_statusline in the Debugger (PR #134759)

2025-04-10 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/134759

>From 9fcc1c89ff0361d9262abefe951b43dd37555fea Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 10 Apr 2025 11:13:12 -0700
Subject: [PATCH] [lldb] Synchronize access to m_statusline in the Debugger

Eliminate the potential for a race between the main thread, the default
event handler thread and the signal handling thread, when accessing the
m_statusline member.
---
 lldb/include/lldb/Core/Debugger.h |  2 ++
 lldb/source/Core/Debugger.cpp | 46 +++
 2 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index c79a75ab61564..5932454f366b8 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -751,6 +751,8 @@ class Debugger : public 
std::enable_shared_from_this,
   IOHandlerStack m_io_handler_stack;
   std::recursive_mutex m_io_handler_synchronous_mutex;
 
+  /// Mutex protecting the m_statusline member.
+  std::mutex m_statusline_mutex;
   std::optional m_statusline;
 
   llvm::StringMap> m_stream_handlers;
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 51029f91eb12d..5e5918a6091d9 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -251,6 +251,7 @@ Status Debugger::SetPropertyValue(const ExecutionContext 
*exe_ctx,
g_debugger_properties[ePropertyShowStatusline].name) {
   // Statusline setting changed. If we have a statusline instance, update 
it
   // now. Otherwise it will get created in the default event handler.
+  std::lock_guard guard(m_statusline_mutex);
   if (StatuslineSupported())
 m_statusline.emplace(*this);
   else
@@ -391,8 +392,12 @@ bool Debugger::SetTerminalWidth(uint64_t term_width) {
 
   if (auto handler_sp = m_io_handler_stack.Top())
 handler_sp->TerminalSizeChanged();
-  if (m_statusline)
-m_statusline->TerminalSizeChanged();
+
+  {
+std::lock_guard guard(m_statusline_mutex);
+if (m_statusline)
+  m_statusline->TerminalSizeChanged();
+  }
 
   return success;
 }
@@ -409,8 +414,12 @@ bool Debugger::SetTerminalHeight(uint64_t term_height) {
 
   if (auto handler_sp = m_io_handler_stack.Top())
 handler_sp->TerminalSizeChanged();
-  if (m_statusline)
-m_statusline->TerminalSizeChanged();
+
+  {
+std::lock_guard guard(m_statusline_mutex);
+if (m_statusline)
+  m_statusline->TerminalSizeChanged();
+  }
 
   return success;
 }
@@ -1141,8 +1150,11 @@ void Debugger::SetErrorFile(FileSP file_sp) {
 }
 
 void Debugger::SaveInputTerminalState() {
-  if (m_statusline)
-m_statusline->Disable();
+  {
+std::lock_guard guard(m_statusline_mutex);
+if (m_statusline)
+  m_statusline->Disable();
+  }
   int fd = GetInputFile().GetDescriptor();
   if (fd != File::kInvalidDescriptor)
 m_terminal_state.Save(fd, true);
@@ -1150,11 +1162,15 @@ void Debugger::SaveInputTerminalState() {
 
 void Debugger::RestoreInputTerminalState() {
   m_terminal_state.Restore();
-  if (m_statusline)
-m_statusline->Enable();
+  {
+std::lock_guard guard(m_statusline_mutex);
+if (m_statusline)
+  m_statusline->Enable();
+  }
 }
 
 void Debugger::RedrawStatusline(bool update) {
+  std::lock_guard guard(m_statusline_mutex);
   if (m_statusline)
 m_statusline->Redraw(update);
 }
@@ -2032,8 +2048,11 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
   // are now listening to all required events so no events get missed
   m_sync_broadcaster.BroadcastEvent(eBroadcastBitEventThreadIsListening);
 
-  if (!m_statusline && StatuslineSupported())
-m_statusline.emplace(*this);
+  if (StatuslineSupported()) {
+std::lock_guard guard(m_statusline_mutex);
+if (!m_statusline)
+  m_statusline.emplace(*this);
+  }
 
   bool done = false;
   while (!done) {
@@ -2094,8 +2113,11 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
 }
   }
 
-  if (m_statusline)
-m_statusline.reset();
+  {
+std::lock_guard guard(m_statusline_mutex);
+if (m_statusline)
+  m_statusline.reset();
+  }
 
   return {};
 }

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


[Lldb-commits] [lldb] [lldb] Support programmatically setting the statusline format (NFC) (PR #135250)

2025-04-10 Thread via lldb-commits

https://github.com/jimingham approved this pull request.

Seems reasonable to me.

https://github.com/llvm/llvm-project/pull/135250
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add download time for each module in statistics (PR #134563)

2025-04-10 Thread via lldb-commits


@@ -345,6 +347,10 @@ llvm::json::Value DebuggerStats::ReportStatistics(
 ++debug_index_saved;
   module_stat.debug_index_time = sym_file->GetDebugInfoIndexTime().count();
   module_stat.debug_parse_time = sym_file->GetDebugInfoParseTime().count();
+  module_stat.symbol_download_time += sym_file->GetSymbolDownloadTime();
+  if (sym_file->GetObjectFile() != module->GetObjectFile())
+module_stat.symbol_download_time +=
+module->GetObjectFile()->GetFileSpec().GetDownloadTime();

GeorgeHuyubo wrote:

Done.

https://github.com/llvm/llvm-project/pull/134563
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add download time for each module in statistics (PR #134563)

2025-04-10 Thread via lldb-commits


@@ -72,6 +72,12 @@ FileSpec::FileSpec(llvm::StringRef path, Style style) : 
m_style(style) {
   SetFile(path, style);
 }
 
+FileSpec::FileSpec(llvm::StringRef path, const double download_time,
+   Style style)
+: m_download_time(download_time) {
+  SetFile(path, style);
+}
+

GeorgeHuyubo wrote:

removed.

https://github.com/llvm/llvm-project/pull/134563
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Support programmatically setting the statusline format (NFC) (PR #135250)

2025-04-10 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/135250

Support programmatically setting the statusline format. I want to use this API 
downstream, to change the statusline format for the Swift REPL.

>From 30b5cfbce089ffccec1e2519c6cd4dd21a9d0b79 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 10 Apr 2025 13:28:25 -0700
Subject: [PATCH] [lldb] Support programmatically setting the statusline format
 (NFC)

Support programmatically setting the statusline format. I want to use
this API downstream, to change the statusline format for the Swift REPL.
---
 lldb/include/lldb/Core/Debugger.h   |  1 +
 lldb/include/lldb/Interpreter/OptionValue.h | 10 +++-
 lldb/source/Core/Debugger.cpp   |  5 ++
 lldb/source/Interpreter/OptionValue.cpp |  9 
 lldb/unittests/Core/CMakeLists.txt  |  1 +
 lldb/unittests/Core/DebuggerTest.cpp| 52 +
 6 files changed, 76 insertions(+), 2 deletions(-)
 create mode 100644 lldb/unittests/Core/DebuggerTest.cpp

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index c79a75ab61564..448e8d6a8fc6a 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -307,6 +307,7 @@ class Debugger : public 
std::enable_shared_from_this,
   bool GetShowStatusline() const;
 
   const FormatEntity::Entry *GetStatuslineFormat() const;
+  bool SetStatuslineFormat(const FormatEntity::Entry &format);
 
   llvm::StringRef GetShowProgressAnsiPrefix() const;
 
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index d19c8b8fab622..ebc438517a7b1 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -72,7 +72,7 @@ class OptionValue {
   virtual ~OptionValue() = default;
 
   OptionValue(const OptionValue &other);
-  
+
   OptionValue& operator=(const OptionValue &other);
 
   // Subclasses should override these functions
@@ -330,6 +330,10 @@ class OptionValue {
 
   bool SetValueAs(ArchSpec v) { return SetArchSpecValue(v); }
 
+  bool SetValueAs(const FormatEntity::Entry &v) {
+return SetFormatEntityValue(v);
+  }
+
   template , bool> = true>
   bool SetValueAs(T t) {
 return SetEnumerationValue(t);
@@ -387,8 +391,10 @@ class OptionValue {
   bool SetUUIDValue(const UUID &uuid);
 
   const FormatEntity::Entry *GetFormatEntity() const;
+  bool SetFormatEntityValue(const FormatEntity::Entry &entry);
+
   const RegularExpression *GetRegexValue() const;
-  
+
   mutable std::mutex m_mutex;
 };
 
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 51029f91eb12d..bfec1fa64ea52 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -484,6 +484,11 @@ const FormatEntity::Entry *Debugger::GetStatuslineFormat() 
const {
   return GetPropertyAtIndexAs(idx);
 }
 
+bool Debugger::SetStatuslineFormat(const FormatEntity::Entry &format) {
+  constexpr uint32_t idx = ePropertyStatuslineFormat;
+  return SetPropertyAtIndex(idx, format);
+}
+
 bool Debugger::GetUseAutosuggestion() const {
   const uint32_t idx = ePropertyShowAutosuggestion;
   return GetPropertyAtIndexAs(
diff --git a/lldb/source/Interpreter/OptionValue.cpp 
b/lldb/source/Interpreter/OptionValue.cpp
index b95f4fec33949..28bc57a07ac71 100644
--- a/lldb/source/Interpreter/OptionValue.cpp
+++ b/lldb/source/Interpreter/OptionValue.cpp
@@ -474,6 +474,15 @@ bool OptionValue::SetArchSpecValue(ArchSpec arch_spec) {
   return false;
 }
 
+bool OptionValue::SetFormatEntityValue(const FormatEntity::Entry &entry) {
+  std::lock_guard lock(m_mutex);
+  if (OptionValueFormatEntity *option_value = GetAsFormatEntity()) {
+option_value->SetCurrentValue(entry);
+return true;
+  }
+  return false;
+}
+
 const char *OptionValue::GetBuiltinTypeAsCString(Type t) {
   switch (t) {
   case eTypeInvalid:
diff --git a/lldb/unittests/Core/CMakeLists.txt 
b/lldb/unittests/Core/CMakeLists.txt
index 8580f5887ea2b..dc9c0577aa546 100644
--- a/lldb/unittests/Core/CMakeLists.txt
+++ b/lldb/unittests/Core/CMakeLists.txt
@@ -1,5 +1,6 @@
 
 add_lldb_unittest(LLDBCoreTests
+  DebuggerTest.cpp
   CommunicationTest.cpp
   DiagnosticEventTest.cpp
   DumpDataExtractorTest.cpp
diff --git a/lldb/unittests/Core/DebuggerTest.cpp 
b/lldb/unittests/Core/DebuggerTest.cpp
new file mode 100644
index 0..df7d999788553
--- /dev/null
+++ b/lldb/unittests/Core/DebuggerTest.cpp
@@ -0,0 +1,52 @@
+//===-- DebuggerTest.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Core/Debugger.h"
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#includ

[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add frame-format option to highlight function names in backtraces (PR #131836)

2025-04-10 Thread Michael Buch via lldb-commits


@@ -2074,6 +2076,64 @@ static const Definition *FindEntry(const llvm::StringRef 
&format_str,
   return parent;
 }
 
+/// Parses a single highlighting format specifier.
+///
+/// Example syntax for such specifier:
+/// \code
+/// ${function.name-with-args:%highlight_basename(ansi.fg.green)}

Michael137 wrote:

The tricky part here is how to handle things like function reference/CV 
qualifiers (do we have a dedicated variable for those too? are they part of the 
argument list?)
And how do we handle some of the more exotic function type syntax (e.g., 
functions returning function pointers).

https://github.com/llvm/llvm-project/pull/131836
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Synchronize access to m_statusline in the Debugger (PR #134759)

2025-04-10 Thread Alex Langford via lldb-commits

https://github.com/bulbazord approved this pull request.

LGTM! :)

https://github.com/llvm/llvm-project/pull/134759
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] a62b9b3 - [lldb] Calling Debugger::SetStatuslineFormat should redraw the statusline

2025-04-10 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2025-04-10T16:55:59-07:00
New Revision: a62b9b387fab85ae8ad63992b002c333069d87ae

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

LOG: [lldb] Calling Debugger::SetStatuslineFormat should redraw the statusline

Added: 


Modified: 
lldb/source/Core/Debugger.cpp

Removed: 




diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index bfec1fa64ea52..e65d71ddf6960 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -486,7 +486,9 @@ const FormatEntity::Entry *Debugger::GetStatuslineFormat() 
const {
 
 bool Debugger::SetStatuslineFormat(const FormatEntity::Entry &format) {
   constexpr uint32_t idx = ePropertyStatuslineFormat;
-  return SetPropertyAtIndex(idx, format);
+  bool ret = SetPropertyAtIndex(idx, format);
+  RedrawStatusline();
+  return ret;
 }
 
 bool Debugger::GetUseAutosuggestion() const {



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


[Lldb-commits] [lldb] [LLDB][Minidump]Update MinidumpFileBuilder to read and write in chunks (PR #129307)

2025-04-10 Thread Greg Clayton via lldb-commits


@@ -969,6 +969,64 @@ Status MinidumpFileBuilder::DumpDirectories() const {
   return error;
 }
 
+Status MinidumpFileBuilder::ReadWriteMemoryInChunks(
+lldb_private::DataBufferHeap &data_buffer,
+const lldb_private::CoreFileMemoryRange &range, uint64_t &bytes_read) {
+
+  Log *log = GetLog(LLDBLog::Object);
+  Status addDataError;
+  Process::ReadMemoryChunkCallback callback =
+  [&](Status &error, DataBufferHeap &data, lldb::addr_t current_addr,
+  uint64_t bytes_to_read,
+  uint64_t bytes_read_for_chunk) -> lldb_private::IterationAction {
+if (error.Fail() || bytes_read_for_chunk == 0) {
+  LLDB_LOGF(log,
+"Failed to read memory region at: %" PRIx64
+". Bytes read: %zu, error: %s",
+current_addr, bytes_read_for_chunk, error.AsCString());
+
+  // If we failed in a memory read, we would normally want to skip
+  // this entire region, if we had already written to the minidump
+  // file, we can't easily rewind that state.
+  //
+  // So if we do encounter an error while reading, we just return
+  // immediately, any prior bytes read will still be included but
+  // any bytes partially read before the error are ignored.
+  return lldb_private::IterationAction::Stop;
+}
+
+// Write to the minidump file with the chunk potentially flushing to
+// disk.
+// This error will be captured by the outer scope and is considered fatal.
+// If we get an error writing to disk we can't easily guarauntee that we
+// won't corrupt the minidump.
+addDataError = AddData(data_buffer.GetBytes(), bytes_read_for_chunk);
+if (addDataError.Fail())
+  return lldb_private::IterationAction::Stop;
+
+if (bytes_read_for_chunk != bytes_to_read) {

clayborg wrote:

You will pass in a chunk_size which can be captured in the lambda and you 
compare the "bytes_size" to your "chunk_size".

https://github.com/llvm/llvm-project/pull/129307
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Reland "[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (#134397)" (PR #135296)

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

https://github.com/felipepiovezan edited 
https://github.com/llvm/llvm-project/pull/135296
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Reland "[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (#134397)" (PR #135296)

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

https://github.com/felipepiovezan edited 
https://github.com/llvm/llvm-project/pull/135296
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][FormatEntity][NFCI] Refactor FunctionNameWithArgs into helper functions and use LLVM style (PR #135031)

2025-04-10 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/135031

I've always found this hard to read. Some upcoming changes make similar 
computations, so I thought it's a good time to factor out this logic into 
re-usable helpers and clean it up using LLVM's preferred early-return style.

>From d73ea6e309e89495713e472853fa827287d028fa Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 9 Apr 2025 15:18:50 +0100
Subject: [PATCH] [lldb][FormatEntity][NFCI] Refactor FunctionNameWithArgs into
 helper functions and use LLVM style

---
 lldb/source/Core/FormatEntity.cpp | 118 +-
 1 file changed, 69 insertions(+), 49 deletions(-)

diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 04dea7efde54d..a9370595c11e7 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -1160,6 +1160,64 @@ static void FormatInlinedBlock(Stream &out_stream, Block 
*block) {
   }
 }
 
+static VariableListSP GetFunctionVariableList(const SymbolContext &sc) {
+  assert(sc.function);
+
+  if (sc.block)
+if (Block *inline_block = sc.block->GetContainingInlinedBlock())
+  return inline_block->GetBlockVariableList(true);
+
+  return sc.function->GetBlock(true).GetBlockVariableList(true);
+}
+
+static char const *GetInlinedFunctionName(const SymbolContext &sc) {
+  if (!sc.block)
+return nullptr;
+
+  const Block *inline_block = sc.block->GetContainingInlinedBlock();
+  if (!inline_block)
+return nullptr;
+
+  const InlineFunctionInfo *inline_info =
+  inline_block->GetInlinedFunctionInfo();
+  if (!inline_info)
+return nullptr;
+
+  return inline_info->GetName().AsCString(nullptr);
+}
+
+static bool PrintFunctionNameWithArgs(Stream &s,
+  const ExecutionContext *exe_ctx,
+  const SymbolContext &sc) {
+  assert(sc.function);
+
+  ExecutionContextScope *exe_scope =
+  exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr;
+
+  const char *cstr = sc.function->GetName().AsCString(nullptr);
+  if (!cstr)
+return false;
+
+  if (const char *inlined_name = GetInlinedFunctionName(sc)) {
+s.PutCString(cstr);
+s.PutCString(" [inlined] ");
+cstr = inlined_name;
+  }
+
+  VariableList args;
+  if (auto variable_list_sp = GetFunctionVariableList(sc))
+variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument,
+   args);
+
+  if (args.GetSize() > 0) {
+PrettyPrintFunctionNameWithArgs(s, cstr, exe_scope, args);
+  } else {
+s.PutCString(cstr);
+  }
+
+  return true;
+}
+
 bool FormatEntity::FormatStringRef(const llvm::StringRef &format_str, Stream 
&s,
const SymbolContext *sc,
const ExecutionContext *exe_ctx,
@@ -1736,59 +1794,21 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
 if (language_plugin_handled) {
   s << ss.GetString();
   return true;
-} else {
-  // Print the function name with arguments in it
-  if (sc->function) {
-ExecutionContextScope *exe_scope =
-exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr;
-const char *cstr = sc->function->GetName().AsCString(nullptr);
-if (cstr) {
-  const InlineFunctionInfo *inline_info = nullptr;
-  VariableListSP variable_list_sp;
-  bool get_function_vars = true;
-  if (sc->block) {
-Block *inline_block = sc->block->GetContainingInlinedBlock();
-
-if (inline_block) {
-  get_function_vars = false;
-  inline_info = inline_block->GetInlinedFunctionInfo();
-  if (inline_info)
-variable_list_sp = inline_block->GetBlockVariableList(true);
-}
-  }
+}
 
-  if (get_function_vars) {
-variable_list_sp =
-sc->function->GetBlock(true).GetBlockVariableList(true);
-  }
+if (sc->function)
+  return PrintFunctionNameWithArgs(s, exe_ctx, *sc);
 
-  if (inline_info) {
-s.PutCString(cstr);
-s.PutCString(" [inlined] ");
-cstr = inline_info->GetName().GetCString();
-  }
+if (!sc->symbol)
+  return false;
 
-  VariableList args;
-  if (variable_list_sp)
-variable_list_sp->AppendVariablesWithScope(
-eValueTypeVariableArgument, args);
-  if (args.GetSize() > 0) {
-PrettyPrintFunctionNameWithArgs(s, cstr, exe_scope, args);
-  } else {
-s.PutCString(cstr);
-  }
-  return true;
-}
-  } else if (sc->symbol) {
-const char *cstr = sc->symbol->GetName().AsCString(nullptr);
-if (cstr) {
-  s.PutCString(cstr);
-  return true;
-}
-  }
-}
+const char *cstr = sc->symbol->GetName()

[Lldb-commits] [lldb] [lldb] Make sure the process is stopped when computing the symbol context (PR #134757)

2025-04-10 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

Thanks for the report, @cmtice. I haven't seen this issue and I'm pretty 
baffled. I wonder if it has something to do with the implementation of 
GetRunLock:

```
ProcessRunLock &Process::GetRunLock() {
  if (m_private_state_thread.EqualsThread(Host::GetCurrentThread()))
return m_private_run_lock;
  else
return m_public_run_lock;
}
```

I presume that somehow we end up in situation where one is locked and the other 
is not. I'll try to do some investigating. 

https://github.com/llvm/llvm-project/pull/134757
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Reland "[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (#134397)" (PR #135296)

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

https://github.com/felipepiovezan created 
https://github.com/llvm/llvm-project/pull/135296



This reapplies commit 232525f06942adb3b9977632e38dcd5f08c0642d.

The original commit triggered a sanitizer failure when Target was destroyed. In 
Target::Destroy, `DeleteCurrentProcess` was called, but it did not destroy the 
thread creation breakpoints for the underlying ProcessGDBRemote, because said 
method would not call `ProcessGDBRemote::Clear`.
Target then proceeded to destroy its breakpoints, which resulted in a call to 
the destructor a std::vector containing the breakpoints. Through a sequence of 
complicated events, destroying breakpoints caused the reference count of the 
underlying to finally reach zero. This, in turn, called 
`ProcessGDBRemote::Clear`, which attempted to destroy the breakpoints. To do 
that, it would query back into the Target vector of breakpoint, which we are in 
the middle of destroying.

We solve this by moving the breakpoint deletion into `Process:DoDestroy`, which 
is a virtual Process method that will be called much earlier.

>From ae63d5b00fe1fd3734de7181661e155820681d37 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Wed, 9 Apr 2025 07:38:13 -0700
Subject: [PATCH] Reland "[lldb] Clear thread-creation breakpoints in
 ProcessGDBRemote::Clear (#134397)"

This reapplies commit 232525f06942adb3b9977632e38dcd5f08c0642d.

The original commit triggered a sanitizer failure when Target was
destroyed. In Target::Destroy, `DeleteCurrentProcess` was called, but it
did not destroy the thread creation breakpoints for the underlying
ProcessGDBRemote, because said method would not call
`ProcessGDBRemote::Clear`.
Target then proceeded to destroy its breakpoints, which resulted in a
call to the destructor a std::vector containing the breakpoints. Through
a sequence of complicated events, destroying breakpoints caused the
reference count of the underlying to finally reach zero. This, in
turn, called `ProcessGDBRemote::Clear`, which attempted to destroy the
breakpoints. To do that, it would query back into the Target vector of
breakpoint, which we are in the middle of destroying.

We solve this by moving the breakpoint deletion into
`Process:DoDestroy`, which is a virtual Process method that will be
called much earlier.
---
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  9 +
 .../Process/gdb-remote/ProcessGDBRemote.h |  3 +++
 .../TestBreakpointsThreadInit.py  | 20 +++
 3 files changed, 32 insertions(+)

diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 68360788c96e6..b616e99be83b2 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2571,9 +2571,18 @@ Status ProcessGDBRemote::DoDestroy() {
 
   StopAsyncThread();
   KillDebugserverProcess();
+  RemoveNewThreadBreakpoints();
   return Status();
 }
 
+void ProcessGDBRemote::RemoveNewThreadBreakpoints() {
+  if (m_thread_create_bp_sp) {
+if (TargetSP target_sp = m_target_wp.lock())
+  target_sp->RemoveBreakpointByID(m_thread_create_bp_sp->GetID());
+m_thread_create_bp_sp.reset();
+  }
+}
+
 void ProcessGDBRemote::SetLastStopPacket(
 const StringExtractorGDBRemote &response) {
   const bool did_exec =
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index 1cbd1e82b381d..20d7fc0801eb3 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -436,6 +436,9 @@ class ProcessGDBRemote : public Process,
lldb::user_id_t break_id,
lldb::user_id_t break_loc_id);
 
+  /// Remove the breakpoints associated with thread creation from the Target.
+  void RemoveNewThreadBreakpoints();
+
   // ContinueDelegate interface
   void HandleAsyncStdout(llvm::StringRef out) override;
   void HandleAsyncMisc(llvm::StringRef data) override;
diff --git a/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py 
b/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
index 1c6fd4f91c73e..bf667f6f7d336 100644
--- a/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
+++ b/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
@@ -35,3 +35,23 @@ def test_internal_bps_resolved(self):
 for bp in bps:
 num_resolved += bp.GetNumResolvedLocations()
 self.assertGreater(num_resolved, 0)
+
+@skipUnlessDarwin
+def test_internal_bps_deleted_on_relaunch(self):
+self.build()
+
+source_file = lldb.SBFileSpec("main.c")
+target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+self, "initial hello", source_file
+)
+
+self.runCmd("break list --int

[Lldb-commits] [lldb] Reland "[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (#134397)" (PR #135296)

2025-04-10 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)


Changes



This reapplies commit 232525f06942adb3b9977632e38dcd5f08c0642d.

The original commit triggered a sanitizer failure when Target was destroyed. In 
Target::Destroy, `DeleteCurrentProcess` was called, but it did not destroy the 
thread creation breakpoints for the underlying ProcessGDBRemote, because said 
method would not call `ProcessGDBRemote::Clear`.
Target then proceeded to destroy its breakpoints, which resulted in a call to 
the destructor a std::vector containing the breakpoints. Through a sequence of 
complicated events, destroying breakpoints caused the reference count of the 
underlying to finally reach zero. This, in turn, called 
`ProcessGDBRemote::Clear`, which attempted to destroy the breakpoints. To do 
that, it would query back into the Target vector of breakpoint, which we are in 
the middle of destroying.

We solve this by moving the breakpoint deletion into `Process:DoDestroy`, which 
is a virtual Process method that will be called much earlier.

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


3 Files Affected:

- (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+9) 
- (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (+3) 
- (modified) lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py 
(+20) 


``diff
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 68360788c96e6..b616e99be83b2 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2571,9 +2571,18 @@ Status ProcessGDBRemote::DoDestroy() {
 
   StopAsyncThread();
   KillDebugserverProcess();
+  RemoveNewThreadBreakpoints();
   return Status();
 }
 
+void ProcessGDBRemote::RemoveNewThreadBreakpoints() {
+  if (m_thread_create_bp_sp) {
+if (TargetSP target_sp = m_target_wp.lock())
+  target_sp->RemoveBreakpointByID(m_thread_create_bp_sp->GetID());
+m_thread_create_bp_sp.reset();
+  }
+}
+
 void ProcessGDBRemote::SetLastStopPacket(
 const StringExtractorGDBRemote &response) {
   const bool did_exec =
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index 1cbd1e82b381d..20d7fc0801eb3 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -436,6 +436,9 @@ class ProcessGDBRemote : public Process,
lldb::user_id_t break_id,
lldb::user_id_t break_loc_id);
 
+  /// Remove the breakpoints associated with thread creation from the Target.
+  void RemoveNewThreadBreakpoints();
+
   // ContinueDelegate interface
   void HandleAsyncStdout(llvm::StringRef out) override;
   void HandleAsyncMisc(llvm::StringRef data) override;
diff --git a/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py 
b/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
index 1c6fd4f91c73e..bf667f6f7d336 100644
--- a/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
+++ b/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
@@ -35,3 +35,23 @@ def test_internal_bps_resolved(self):
 for bp in bps:
 num_resolved += bp.GetNumResolvedLocations()
 self.assertGreater(num_resolved, 0)
+
+@skipUnlessDarwin
+def test_internal_bps_deleted_on_relaunch(self):
+self.build()
+
+source_file = lldb.SBFileSpec("main.c")
+target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+self, "initial hello", source_file
+)
+
+self.runCmd("break list --internal")
+output = self.res.GetOutput()
+self.assertEqual(output.count("thread-creation"), 1)
+
+process.Kill()
+self.runCmd("run", RUN_SUCCEEDED)
+
+self.runCmd("break list --internal")
+output = self.res.GetOutput()
+self.assertEqual(output.count("thread-creation"), 1)

``




https://github.com/llvm/llvm-project/pull/135296
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Reland "[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (#134397)" (PR #135296)

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

https://github.com/felipepiovezan updated 
https://github.com/llvm/llvm-project/pull/135296

>From b24dc5da70443eb15819c6134ddd38c84f86a5e5 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Wed, 9 Apr 2025 07:38:13 -0700
Subject: [PATCH] Reland "[lldb] Clear thread-creation breakpoints in
 ProcessGDBRemote::Clear (#134397)"

This reapplies commit 232525f06942adb3b9977632e38dcd5f08c0642d.

The original commit triggered a sanitizer failure when `Target` was
destroyed. In `Target::Destroy`, `DeleteCurrentProcess` was called, but
it did not destroy the thread creation breakpoints for the underlying
`ProcessGDBRemote` because `ProcessGDBRemote::Clear` was not called in
that path.

`Target `then proceeded to destroy its breakpoints, which resulted in a
call to the destructor of a `std::vector` containing the breakpoints.
Through a sequence of complicated events, destroying breakpoints caused
the reference count of the underlying `ProcessGDBRemote` to finally
reach zero. This, in turn, called `ProcessGDBRemote::Clear`, which
attempted to destroy the breakpoints. To do that, it would go back into
the Target's vector of breakpoints, which we are in the middle of
destroying.

We solve this by moving the breakpoint deletion into
`Process:DoDestroy`, which is a virtual Process method that will be
called much earlier.
---
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  9 +
 .../Process/gdb-remote/ProcessGDBRemote.h |  3 +++
 .../TestBreakpointsThreadInit.py  | 20 +++
 3 files changed, 32 insertions(+)

diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 68360788c96e6..b616e99be83b2 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2571,9 +2571,18 @@ Status ProcessGDBRemote::DoDestroy() {
 
   StopAsyncThread();
   KillDebugserverProcess();
+  RemoveNewThreadBreakpoints();
   return Status();
 }
 
+void ProcessGDBRemote::RemoveNewThreadBreakpoints() {
+  if (m_thread_create_bp_sp) {
+if (TargetSP target_sp = m_target_wp.lock())
+  target_sp->RemoveBreakpointByID(m_thread_create_bp_sp->GetID());
+m_thread_create_bp_sp.reset();
+  }
+}
+
 void ProcessGDBRemote::SetLastStopPacket(
 const StringExtractorGDBRemote &response) {
   const bool did_exec =
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index 1cbd1e82b381d..20d7fc0801eb3 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -436,6 +436,9 @@ class ProcessGDBRemote : public Process,
lldb::user_id_t break_id,
lldb::user_id_t break_loc_id);
 
+  /// Remove the breakpoints associated with thread creation from the Target.
+  void RemoveNewThreadBreakpoints();
+
   // ContinueDelegate interface
   void HandleAsyncStdout(llvm::StringRef out) override;
   void HandleAsyncMisc(llvm::StringRef data) override;
diff --git a/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py 
b/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
index 1c6fd4f91c73e..bf667f6f7d336 100644
--- a/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
+++ b/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
@@ -35,3 +35,23 @@ def test_internal_bps_resolved(self):
 for bp in bps:
 num_resolved += bp.GetNumResolvedLocations()
 self.assertGreater(num_resolved, 0)
+
+@skipUnlessDarwin
+def test_internal_bps_deleted_on_relaunch(self):
+self.build()
+
+source_file = lldb.SBFileSpec("main.c")
+target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+self, "initial hello", source_file
+)
+
+self.runCmd("break list --internal")
+output = self.res.GetOutput()
+self.assertEqual(output.count("thread-creation"), 1)
+
+process.Kill()
+self.runCmd("run", RUN_SUCCEEDED)
+
+self.runCmd("break list --internal")
+output = self.res.GetOutput()
+self.assertEqual(output.count("thread-creation"), 1)

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


[Lldb-commits] [lldb] Reland "[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (#134397)" (PR #135296)

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

https://github.com/felipepiovezan edited 
https://github.com/llvm/llvm-project/pull/135296
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Reland "[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (#134397)" (PR #135296)

2025-04-10 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda approved this pull request.

Nice debugging on this one, it can be a little unclear of the intended jobs for 
each of the reset/clear/terminate methods.  This looks good to me.

https://github.com/llvm/llvm-project/pull/135296
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Reland "[lldb] Clear thread-creation breakpoints in ProcessGDBRemote::Clear (#134397)" (PR #135296)

2025-04-10 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda edited 
https://github.com/llvm/llvm-project/pull/135296
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add download time for each module in statistics (PR #134563)

2025-04-10 Thread via lldb-commits


@@ -111,7 +111,7 @@ struct ModuleStats {
   std::string uuid;
   std::string triple;
   // Path separate debug info file, or empty if none.
-  std::string symfile_path;
+  std::vector symfile_path;

GeorgeHuyubo wrote:

removed

https://github.com/llvm/llvm-project/pull/134563
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add download time for each module in statistics (PR #134563)

2025-04-10 Thread via lldb-commits


@@ -4267,6 +4269,8 @@ const std::shared_ptr 
&SymbolFileDWARF::GetDwpSymbolFile() {
   // find the correct DWP file, as the Debuginfod plugin uses *only* this
   // data to correctly match the DWP file with the binary.
   module_spec.GetUUID() = m_objfile_sp->GetUUID();
+  duration.reset();

GeorgeHuyubo wrote:

In the latest version, I kind of switched back for the pure download time only 
for performance measurement instead of the whole locating time. In this 
specific case I feel like we probably should ignore the duration of the first 
PluginManager::LocateExecutableSymbolFile call since without setting the UUID 
the debuginfod Symbol locator should not work at all.

https://github.com/llvm/llvm-project/pull/134563
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add download time for each module in statistics (PR #134563)

2025-04-10 Thread via lldb-commits


@@ -355,6 +355,8 @@ class SymbolFile : public PluginInterface {
   virtual const ObjectFile *GetObjectFile() const = 0;
   virtual ObjectFile *GetMainObjectFile() = 0;
 
+  virtual std::vector GetAllObjectFiles();
+

GeorgeHuyubo wrote:

removed

https://github.com/llvm/llvm-project/pull/134563
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)

2025-04-10 Thread via lldb-commits


@@ -4267,6 +4269,8 @@ const std::shared_ptr 
&SymbolFileDWARF::GetDwpSymbolFile() {
   // find the correct DWP file, as the Debuginfod plugin uses *only* this
   // data to correctly match the DWP file with the binary.
   module_spec.GetUUID() = m_objfile_sp->GetUUID();
+  duration.reset();

GeorgeHuyubo wrote:

Yeah this one is tricky. Originally I only want the download time which is the 
strict network time, but right now it kind of turn into locate time(time to 
find the file we want).

https://github.com/llvm/llvm-project/pull/134563
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Support programmatically setting the statusline format (NFC) (PR #135250)

2025-04-10 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Support programmatically setting the statusline format. I want to use this API 
downstream, to change the statusline format for the Swift REPL.

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


6 Files Affected:

- (modified) lldb/include/lldb/Core/Debugger.h (+1) 
- (modified) lldb/include/lldb/Interpreter/OptionValue.h (+8-2) 
- (modified) lldb/source/Core/Debugger.cpp (+5) 
- (modified) lldb/source/Interpreter/OptionValue.cpp (+9) 
- (modified) lldb/unittests/Core/CMakeLists.txt (+1) 
- (added) lldb/unittests/Core/DebuggerTest.cpp (+52) 


``diff
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index c79a75ab61564..448e8d6a8fc6a 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -307,6 +307,7 @@ class Debugger : public 
std::enable_shared_from_this,
   bool GetShowStatusline() const;
 
   const FormatEntity::Entry *GetStatuslineFormat() const;
+  bool SetStatuslineFormat(const FormatEntity::Entry &format);
 
   llvm::StringRef GetShowProgressAnsiPrefix() const;
 
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index d19c8b8fab622..ebc438517a7b1 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -72,7 +72,7 @@ class OptionValue {
   virtual ~OptionValue() = default;
 
   OptionValue(const OptionValue &other);
-  
+
   OptionValue& operator=(const OptionValue &other);
 
   // Subclasses should override these functions
@@ -330,6 +330,10 @@ class OptionValue {
 
   bool SetValueAs(ArchSpec v) { return SetArchSpecValue(v); }
 
+  bool SetValueAs(const FormatEntity::Entry &v) {
+return SetFormatEntityValue(v);
+  }
+
   template , bool> = true>
   bool SetValueAs(T t) {
 return SetEnumerationValue(t);
@@ -387,8 +391,10 @@ class OptionValue {
   bool SetUUIDValue(const UUID &uuid);
 
   const FormatEntity::Entry *GetFormatEntity() const;
+  bool SetFormatEntityValue(const FormatEntity::Entry &entry);
+
   const RegularExpression *GetRegexValue() const;
-  
+
   mutable std::mutex m_mutex;
 };
 
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 51029f91eb12d..bfec1fa64ea52 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -484,6 +484,11 @@ const FormatEntity::Entry *Debugger::GetStatuslineFormat() 
const {
   return GetPropertyAtIndexAs(idx);
 }
 
+bool Debugger::SetStatuslineFormat(const FormatEntity::Entry &format) {
+  constexpr uint32_t idx = ePropertyStatuslineFormat;
+  return SetPropertyAtIndex(idx, format);
+}
+
 bool Debugger::GetUseAutosuggestion() const {
   const uint32_t idx = ePropertyShowAutosuggestion;
   return GetPropertyAtIndexAs(
diff --git a/lldb/source/Interpreter/OptionValue.cpp 
b/lldb/source/Interpreter/OptionValue.cpp
index b95f4fec33949..28bc57a07ac71 100644
--- a/lldb/source/Interpreter/OptionValue.cpp
+++ b/lldb/source/Interpreter/OptionValue.cpp
@@ -474,6 +474,15 @@ bool OptionValue::SetArchSpecValue(ArchSpec arch_spec) {
   return false;
 }
 
+bool OptionValue::SetFormatEntityValue(const FormatEntity::Entry &entry) {
+  std::lock_guard lock(m_mutex);
+  if (OptionValueFormatEntity *option_value = GetAsFormatEntity()) {
+option_value->SetCurrentValue(entry);
+return true;
+  }
+  return false;
+}
+
 const char *OptionValue::GetBuiltinTypeAsCString(Type t) {
   switch (t) {
   case eTypeInvalid:
diff --git a/lldb/unittests/Core/CMakeLists.txt 
b/lldb/unittests/Core/CMakeLists.txt
index 8580f5887ea2b..dc9c0577aa546 100644
--- a/lldb/unittests/Core/CMakeLists.txt
+++ b/lldb/unittests/Core/CMakeLists.txt
@@ -1,5 +1,6 @@
 
 add_lldb_unittest(LLDBCoreTests
+  DebuggerTest.cpp
   CommunicationTest.cpp
   DiagnosticEventTest.cpp
   DumpDataExtractorTest.cpp
diff --git a/lldb/unittests/Core/DebuggerTest.cpp 
b/lldb/unittests/Core/DebuggerTest.cpp
new file mode 100644
index 0..df7d999788553
--- /dev/null
+++ b/lldb/unittests/Core/DebuggerTest.cpp
@@ -0,0 +1,52 @@
+//===-- DebuggerTest.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Core/Debugger.h"
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "TestingSupport/TestUtilities.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class DebuggerTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize

[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)

2025-04-10 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/134563

>From 85bee8e66fcbc7b2001e2c06499b3458a197be25 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Tue, 8 Apr 2025 18:12:29 -0700
Subject: [PATCH 1/2] Add locate time for each module in statistics

---
 lldb/include/lldb/Symbol/ObjectFile.h  |  4 
 lldb/include/lldb/Symbol/SymbolFile.h  |  5 +
 lldb/include/lldb/Target/Statistics.h  |  1 +
 lldb/source/Core/ModuleList.cpp| 11 ---
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp   | 13 +
 .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.h |  3 +++
 .../SymbolVendor/ELF/SymbolVendorELF.cpp   | 18 ++
 lldb/source/Target/Statistics.cpp  |  8 
 8 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/lldb/include/lldb/Symbol/ObjectFile.h 
b/lldb/include/lldb/Symbol/ObjectFile.h
index cfcca04a76de8..0a782f28dc947 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -13,6 +13,7 @@
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/Symbol/Symtab.h"
 #include "lldb/Symbol/UnwindTable.h"
+#include "lldb/Target/Statistics.h"
 #include "lldb/Utility/AddressableBits.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/Endian.h"
@@ -589,6 +590,8 @@ class ObjectFile : public 
std::enable_shared_from_this,
   /// this routine to set eTypeDebugInfo when loading debug link files.
   virtual void SetType(Type type) { m_type = type; }
 
+  virtual StatsDuration &GetLocateTime() { return m_locate_time; }
+
   /// The object file should be able to calculate the strata of the object
   /// file.
   ///
@@ -752,6 +755,7 @@ class ObjectFile : public 
std::enable_shared_from_this,
 
 protected:
   // Member variables.
+  StatsDuration m_locate_time; ///< Time to locate the object file
   FileSpec m_file;
   Type m_type;
   Strata m_strata;
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index f35d3ee9f22ae..6bea7c3e90a77 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -422,6 +422,11 @@ class SymbolFile : public PluginInterface {
   /// hasn't been indexed yet, or a valid duration if it has.
   virtual StatsDuration::Duration GetDebugInfoIndexTime() { return {}; }
 
+  /// Return the time it took to locate any extra symbol files.
+  ///
+  /// \returns 0.0 if no extra symbol files need to be located
+  virtual StatsDuration::Duration GetSymbolLocateTime() { return {}; }
+
   /// Reset the statistics for the symbol file.
   virtual void ResetStatistics() {}
 
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index ee365357fcf31..1fbd3c57efaa6 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -122,6 +122,7 @@ struct ModuleStats {
   double symtab_index_time = 0.0;
   double debug_parse_time = 0.0;
   double debug_index_time = 0.0;
+  double symbol_locate_time = 0.0;
   uint64_t debug_info_size = 0;
   bool symtab_loaded_from_cache = false;
   bool symtab_saved_to_cache = false;
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 2b8ccab2406c6..45dbaf4c014c9 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -917,9 +917,13 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, 
ModuleSP &module_sp,
 
   // Fixup the incoming path in case the path points to a valid file, yet the
   // arch or UUID (if one was passed in) don't match.
-  ModuleSpec located_binary_modulespec =
-  PluginManager::LocateExecutableObjectFile(module_spec);
-
+  ModuleSpec located_binary_modulespec;
+  StatsDuration locate_duration;
+  {
+ElapsedTime elapsed(locate_duration);
+located_binary_modulespec =
+PluginManager::LocateExecutableObjectFile(module_spec);
+  }
   // Don't look for the file if it appears to be the same one we already
   // checked for above...
   if (located_binary_modulespec.GetFileSpec() != module_file_spec) {
@@ -992,6 +996,7 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, 
ModuleSP &module_sp,
   // By getting the object file we can guarantee that the architecture
   // matches
   if (module_sp && module_sp->GetObjectFile()) {
+module_sp->GetObjectFile()->GetLocateTime() += locate_duration;
 if (module_sp->GetObjectFile()->GetType() ==
 ObjectFile::eTypeStubLibrary) {
   module_sp.reset();
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index b95159d882bc7..a3c809945d9ce 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -4250,11 +4250,13 @@ const std::shared_ptr 
&SymbolFileDWARF::GetDwpSymbolFile() {
 ModuleSpec module_spec;
  

[Lldb-commits] [lldb] [LLDB][NFC]Also includes the error in log msg. (PR #134922)

2025-04-10 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vy Nguyen (oontvoo)


Changes



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


1 Files Affected:

- (modified) lldb/include/lldb/Core/Telemetry.h (+2-1) 


``diff
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 28897f283dc55..022f40b1d2f2f 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -272,7 +272,8 @@ template  struct ScopedDispatcher {
 // And then we dispatch.
 if (llvm::Error er = manager->dispatch(&info)) {
   LLDB_LOG_ERROR(GetLog(LLDBLog::Object), std::move(er),
- "Failed to dispatch entry of type: {0}", info.getKind());
+ "{0} Failed to dispatch entry of type: {1}",
+ info.getKind());
 }
   }
 

``




https://github.com/llvm/llvm-project/pull/134922
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)

2025-04-10 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

We should talk about the new API you want to add:
```
virtual std::vector SymbolFile::GetAllObjectFiles();
```


https://github.com/llvm/llvm-project/pull/134563
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Fix warnings in DIL. (PR #134778)

2025-04-10 Thread via lldb-commits

https://github.com/cmtice closed 
https://github.com/llvm/llvm-project/pull/134778
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #132274)

2025-04-10 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman updated 
https://github.com/llvm/llvm-project/pull/132274

>From 40d69ed7386c3f8169b324bd3b7591a46e34ff4d Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 20 Mar 2025 21:50:51 +0400
Subject: [PATCH 1/3] [LLDB] Refactored CPlusPlusLanguage::MethodName to break
 lldb-server dependencies

This patch addresses the issue #129543.
After this patch the size of lldb-server is reduced by 9MB.

Co-authored-by: @bulbazord Alex Langford
---
 lldb/include/lldb/Core/Mangled.h  |   2 +
 lldb/include/lldb/Core/RichManglingContext.h  |  16 +-
 lldb/include/lldb/Target/Language.h   |  98 
 lldb/source/Core/CMakeLists.txt   |   2 -
 lldb/source/Core/Mangled.cpp  |   5 +
 lldb/source/Core/Module.cpp   | 151 --
 lldb/source/Core/RichManglingContext.cpp  |  22 ++-
 .../Clang/ClangExpressionDeclMap.cpp  |   9 +-
 lldb/source/Plugins/Language/CMakeLists.txt   |   2 +
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 128 ++-
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  58 ++-
 .../Plugins/Language/ObjC/ObjCLanguage.cpp|  15 ++
 .../Plugins/Language/ObjC/ObjCLanguage.h  |   3 +
 .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp  |   4 +-
 lldb/unittests/Core/CMakeLists.txt|   1 +
 .../Core/RichManglingContextTest.cpp  |   7 +
 .../CPlusPlus/CPlusPlusLanguageTest.cpp   |  22 +--
 17 files changed, 286 insertions(+), 259 deletions(-)

diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h
index 5988d919a89b8..d5b1d4ff7149a 100644
--- a/lldb/include/lldb/Core/Mangled.h
+++ b/lldb/include/lldb/Core/Mangled.h
@@ -246,6 +246,8 @@ class Mangled {
   /// for s, otherwise the enumerator for the mangling scheme detected.
   static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name);
 
+  static bool IsCPPMangledName(llvm::StringRef name);
+
   /// Decode a serialized version of this object from data.
   ///
   /// \param data
diff --git a/lldb/include/lldb/Core/RichManglingContext.h 
b/lldb/include/lldb/Core/RichManglingContext.h
index 3b79924e88a9a..50ec2ae361098 100644
--- a/lldb/include/lldb/Core/RichManglingContext.h
+++ b/lldb/include/lldb/Core/RichManglingContext.h
@@ -12,6 +12,7 @@
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private.h"
 
+#include "lldb/Target/Language.h"
 #include "lldb/Utility/ConstString.h"
 
 #include "llvm/ADT/Any.h"
@@ -67,11 +68,7 @@ class RichManglingContext {
   char *m_ipd_buf;
   size_t m_ipd_buf_size = 2048;
 
-  /// Members for PluginCxxLanguage
-  /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The
-  /// respective header is in Plugins and including it from here causes cyclic
-  /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp.
-  llvm::Any m_cxx_method_parser;
+  std::unique_ptr m_cxx_method_parser;
 
   /// Clean up memory when using PluginCxxLanguage
   void ResetCxxMethodParser();
@@ -81,15 +78,6 @@ class RichManglingContext {
 
   /// Uniform handling of string buffers for ItaniumPartialDemangler.
   llvm::StringRef processIPDStrResult(char *ipd_res, size_t res_len);
-
-  /// Cast the given parser to the given type. Ideally we would have a type
-  /// trait to deduce \a ParserT from a given InfoProvider, but unfortunately 
we
-  /// can't access CPlusPlusLanguage::MethodName from within the header.
-  template  static ParserT *get(llvm::Any parser) {
-assert(parser.has_value());
-assert(llvm::any_cast(&parser));
-return *llvm::any_cast(&parser);
-  }
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index b699a90aff8e4..d46969cb3b4e4 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -214,6 +214,104 @@ class Language : public PluginInterface {
 return std::vector();
   };
 
+  class MethodName {
+  public:
+MethodName() {}
+
+MethodName(ConstString full)
+: m_full(full), m_basename(), m_context(), m_arguments(),
+  m_qualifiers(), m_return_type(), m_scope_qualified(), 
m_parsed(false),
+  m_parse_error(false) {}
+
+virtual ~MethodName() {};
+
+void Clear() {
+  m_full.Clear();
+  m_basename = llvm::StringRef();
+  m_context = llvm::StringRef();
+  m_arguments = llvm::StringRef();
+  m_qualifiers = llvm::StringRef();
+  m_return_type = llvm::StringRef();
+  m_scope_qualified.clear();
+  m_parsed = false;
+  m_parse_error = false;
+}
+
+bool IsValid() {
+  if (!m_parsed)
+Parse();
+  if (m_parse_error)
+return false;
+  return (bool)m_full;
+}
+
+ConstString GetFullName() const { return m_full; }
+
+llvm::StringRef GetBasename() {
+  if (!m_parsed)
+Parse();
+  return m_basename;
+}
+
+llvm::StringRef GetContext() {
+  if (!m_parsed)

[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add option to highlight function names in backtraces (PR #131836)

2025-04-10 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/131836

>From 65aab6b727cc430a9e826c7eeda67259e041a462 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 7 Apr 2025 13:21:25 +0100
Subject: [PATCH 1/5] [ItaniumDemangle] Add printLeft/printRight APIs to
 OutputBuffer

This patch includes the necessary changes for the LLDB feature proposed in 
https://discourse.llvm.org/t/rfc-lldb-highlighting-function-names-in-lldb-backtraces/85309.
 The TL;DR is that we want to track where certain parts of a demangled name 
begin/end so we can highlight them in backtraces.

We introduce a new `printLeft`/`printRight` API that a client (in our case 
LLDB) can implement to track state while printing the demangle tree. This 
requires redirecting all calls to to `printLeft`/`printRight` to the 
`OutputBuffer`. One quirk with the new API is that `Utility.h` would now depend 
on `ItaniumDemangle.h` and vice-versa. To keep these files header-only I made 
the definitions `inline` and implement the new APIs in `ItaniumDemangle.h` (so 
the definition of `Node` is available to them).
---
 libcxxabi/src/demangle/ItaniumDemangle.h | 64 +++-
 libcxxabi/src/demangle/Utility.h |  7 +++
 llvm/include/llvm/Demangle/ItaniumDemangle.h | 64 +++-
 llvm/include/llvm/Demangle/Utility.h |  7 +++
 4 files changed, 86 insertions(+), 56 deletions(-)

diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h 
b/libcxxabi/src/demangle/ItaniumDemangle.h
index 3df41b5f4d7d0..89a24def830f2 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -281,9 +281,9 @@ class Node {
   }
 
   void print(OutputBuffer &OB) const {
-printLeft(OB);
+OB.printLeft(*this);
 if (RHSComponentCache != Cache::No)
-  printRight(OB);
+  OB.printRight(*this);
   }
 
   // Print the "left" side of this Node into OutputBuffer.
@@ -458,11 +458,11 @@ class QualType final : public Node {
   }
 
   void printLeft(OutputBuffer &OB) const override {
-Child->printLeft(OB);
+OB.printLeft(*Child);
 printQuals(OB);
   }
 
-  void printRight(OutputBuffer &OB) const override { Child->printRight(OB); }
+  void printRight(OutputBuffer &OB) const override { OB.printRight(*Child); }
 };
 
 class ConversionOperatorType final : public Node {
@@ -491,7 +491,7 @@ class PostfixQualifiedType final : public Node {
   template void match(Fn F) const { F(Ty, Postfix); }
 
   void printLeft(OutputBuffer &OB) const override {
-Ty->printLeft(OB);
+OB.printLeft(*Ty);
 OB += Postfix;
   }
 };
@@ -577,7 +577,7 @@ struct AbiTagAttr : Node {
   std::string_view getBaseName() const override { return Base->getBaseName(); }
 
   void printLeft(OutputBuffer &OB) const override {
-Base->printLeft(OB);
+OB.printLeft(*Base);
 OB += "[abi:";
 OB += Tag;
 OB += "]";
@@ -644,7 +644,7 @@ class PointerType final : public Node {
 // We rewrite objc_object* into id.
 if (Pointee->getKind() != KObjCProtoName ||
 !static_cast(Pointee)->isObjCObject()) {
-  Pointee->printLeft(OB);
+  OB.printLeft(*Pointee);
   if (Pointee->hasArray(OB))
 OB += " ";
   if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
@@ -663,7 +663,7 @@ class PointerType final : public Node {
 !static_cast(Pointee)->isObjCObject()) {
   if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
 OB += ")";
-  Pointee->printRight(OB);
+  OB.printRight(*Pointee);
 }
   }
 };
@@ -729,7 +729,7 @@ class ReferenceType : public Node {
 std::pair Collapsed = collapse(OB);
 if (!Collapsed.second)
   return;
-Collapsed.second->printLeft(OB);
+OB.printLeft(*Collapsed.second);
 if (Collapsed.second->hasArray(OB))
   OB += " ";
 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
@@ -746,7 +746,7 @@ class ReferenceType : public Node {
   return;
 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
   OB += ")";
-Collapsed.second->printRight(OB);
+OB.printRight(*Collapsed.second);
   }
 };
 
@@ -766,7 +766,7 @@ class PointerToMemberType final : public Node {
   }
 
   void printLeft(OutputBuffer &OB) const override {
-MemberType->printLeft(OB);
+OB.printLeft(*MemberType);
 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
   OB += "(";
 else
@@ -778,7 +778,7 @@ class PointerToMemberType final : public Node {
   void printRight(OutputBuffer &OB) const override {
 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
   OB += ")";
-MemberType->printRight(OB);
+OB.printRight(*MemberType);
   }
 };
 
@@ -798,7 +798,7 @@ class ArrayType final : public Node {
   bool hasRHSComponentSlow(OutputBuffer &) const override { return true; }
   bool hasArraySlow(OutputBuffer &) const override { return true; }
 
-  void printLeft(OutputBuffer &OB) const override { Base->print

[Lldb-commits] [lldb] [lldb] Synchronize access to m_statusline in the Debugger (PR #134759)

2025-04-10 Thread Alex Langford via lldb-commits

https://github.com/bulbazord requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/134759
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)

2025-04-10 Thread Pavel Labath via lldb-commits


@@ -824,5 +834,11 @@ int main(int argc, char const *argv[]) {
 future.wait();
   }
 
+  // Stop the signal handler thread. Do this after calling 
SBDebugger::Terminate
+  // so that impatient users can send a SIGSTOP if they don't want to wait for

labath wrote:

SIGSTOP will not terminate the process. Maybe you meant SIGQUIT (aka `^\`)? But 
that won't actually matter here because we don't have a handler for that 
signal, so I'm not sure what you're trying to achieve here..

https://github.com/llvm/llvm-project/pull/134956
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #132274)

2025-04-10 Thread Michael Buch via lldb-commits

Michael137 wrote:

FYI, this also broke the `TestObjCBreakpoints.py` test on `arm64` macOS:
```
FAIL: LLDB 
(/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang-arm64)
 :: test_break_dwarf (TestObjCBreakpoints.TestObjCBreakpoints)
UNSUPPORTED: LLDB 
(/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang-arm64)
 :: test_break_dwo (TestObjCBreakpoints.TestObjCBreakpoints) (test case does 
not fall in any category of interest for this run) 
Restore dir to: 
/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/tools/lldb/test
==
FAIL: test_break_dsym (TestObjCBreakpoints.TestObjCBreakpoints)
   Test setting Objective-C specific breakpoints (DWARF in .o files).
--
Traceback (most recent call last):
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 1804, in test_method
return attrvalue(self)
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/breakpoint/objc/TestObjCBreakpoints.py",
 line 21, in test_break
self.check_objc_breakpoints(False)
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/breakpoint/objc/TestObjCBreakpoints.py",
 line 100, in check_objc_breakpoints
self.assertGreaterEqual(
AssertionError: 10 not greater than or equal to 87 : Make sure we get at least 
the same amount of breakpoints if not more when setting by name "count"
Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang
==
FAIL: test_break_dwarf (TestObjCBreakpoints.TestObjCBreakpoints)
   Test setting Objective-C specific breakpoints (DWARF in .o files).
--
Traceback (most recent call last):
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 1804, in test_method
return attrvalue(self)
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/breakpoint/objc/TestObjCBreakpoints.py",
 line 21, in test_break
self.check_objc_breakpoints(False)
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/breakpoint/objc/TestObjCBreakpoints.py",
 line 100, in check_objc_breakpoints
self.assertGreaterEqual(
AssertionError: 10 not greater than or equal to 86 : Make sure we get at least 
the same amount of breakpoints if not more when setting by name "count"
Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang
--
Ran 3 tests in 1.064s
```

https://github.com/llvm/llvm-project/pull/132274
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [compiler-rt] [libcxxabi] [lldb] [llvm] [lldb] Add option to highlight function names in backtraces (PR #131836)

2025-04-10 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/131836

>From 65aab6b727cc430a9e826c7eeda67259e041a462 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 7 Apr 2025 13:21:25 +0100
Subject: [PATCH 1/6] [ItaniumDemangle] Add printLeft/printRight APIs to
 OutputBuffer

This patch includes the necessary changes for the LLDB feature proposed in 
https://discourse.llvm.org/t/rfc-lldb-highlighting-function-names-in-lldb-backtraces/85309.
 The TL;DR is that we want to track where certain parts of a demangled name 
begin/end so we can highlight them in backtraces.

We introduce a new `printLeft`/`printRight` API that a client (in our case 
LLDB) can implement to track state while printing the demangle tree. This 
requires redirecting all calls to to `printLeft`/`printRight` to the 
`OutputBuffer`. One quirk with the new API is that `Utility.h` would now depend 
on `ItaniumDemangle.h` and vice-versa. To keep these files header-only I made 
the definitions `inline` and implement the new APIs in `ItaniumDemangle.h` (so 
the definition of `Node` is available to them).
---
 libcxxabi/src/demangle/ItaniumDemangle.h | 64 +++-
 libcxxabi/src/demangle/Utility.h |  7 +++
 llvm/include/llvm/Demangle/ItaniumDemangle.h | 64 +++-
 llvm/include/llvm/Demangle/Utility.h |  7 +++
 4 files changed, 86 insertions(+), 56 deletions(-)

diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h 
b/libcxxabi/src/demangle/ItaniumDemangle.h
index 3df41b5f4d7d0..89a24def830f2 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -281,9 +281,9 @@ class Node {
   }
 
   void print(OutputBuffer &OB) const {
-printLeft(OB);
+OB.printLeft(*this);
 if (RHSComponentCache != Cache::No)
-  printRight(OB);
+  OB.printRight(*this);
   }
 
   // Print the "left" side of this Node into OutputBuffer.
@@ -458,11 +458,11 @@ class QualType final : public Node {
   }
 
   void printLeft(OutputBuffer &OB) const override {
-Child->printLeft(OB);
+OB.printLeft(*Child);
 printQuals(OB);
   }
 
-  void printRight(OutputBuffer &OB) const override { Child->printRight(OB); }
+  void printRight(OutputBuffer &OB) const override { OB.printRight(*Child); }
 };
 
 class ConversionOperatorType final : public Node {
@@ -491,7 +491,7 @@ class PostfixQualifiedType final : public Node {
   template void match(Fn F) const { F(Ty, Postfix); }
 
   void printLeft(OutputBuffer &OB) const override {
-Ty->printLeft(OB);
+OB.printLeft(*Ty);
 OB += Postfix;
   }
 };
@@ -577,7 +577,7 @@ struct AbiTagAttr : Node {
   std::string_view getBaseName() const override { return Base->getBaseName(); }
 
   void printLeft(OutputBuffer &OB) const override {
-Base->printLeft(OB);
+OB.printLeft(*Base);
 OB += "[abi:";
 OB += Tag;
 OB += "]";
@@ -644,7 +644,7 @@ class PointerType final : public Node {
 // We rewrite objc_object* into id.
 if (Pointee->getKind() != KObjCProtoName ||
 !static_cast(Pointee)->isObjCObject()) {
-  Pointee->printLeft(OB);
+  OB.printLeft(*Pointee);
   if (Pointee->hasArray(OB))
 OB += " ";
   if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
@@ -663,7 +663,7 @@ class PointerType final : public Node {
 !static_cast(Pointee)->isObjCObject()) {
   if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
 OB += ")";
-  Pointee->printRight(OB);
+  OB.printRight(*Pointee);
 }
   }
 };
@@ -729,7 +729,7 @@ class ReferenceType : public Node {
 std::pair Collapsed = collapse(OB);
 if (!Collapsed.second)
   return;
-Collapsed.second->printLeft(OB);
+OB.printLeft(*Collapsed.second);
 if (Collapsed.second->hasArray(OB))
   OB += " ";
 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
@@ -746,7 +746,7 @@ class ReferenceType : public Node {
   return;
 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
   OB += ")";
-Collapsed.second->printRight(OB);
+OB.printRight(*Collapsed.second);
   }
 };
 
@@ -766,7 +766,7 @@ class PointerToMemberType final : public Node {
   }
 
   void printLeft(OutputBuffer &OB) const override {
-MemberType->printLeft(OB);
+OB.printLeft(*MemberType);
 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
   OB += "(";
 else
@@ -778,7 +778,7 @@ class PointerToMemberType final : public Node {
   void printRight(OutputBuffer &OB) const override {
 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
   OB += ")";
-MemberType->printRight(OB);
+OB.printRight(*MemberType);
   }
 };
 
@@ -798,7 +798,7 @@ class ArrayType final : public Node {
   bool hasRHSComponentSlow(OutputBuffer &) const override { return true; }
   bool hasArraySlow(OutputBuffer &) const override { return true; }
 
-  void printLeft(OutputBuffer &OB) const override { Base->print

[Lldb-commits] [lldb] [LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #132274)

2025-04-10 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

Maybe rename `CPlusPlusLanguage::CPPMethodName` to 
`CPlusPlusLanguage::CxxMethodName`?
Any preferences?

https://github.com/llvm/llvm-project/pull/132274
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] e84a804 - [lldb] Make sure the process is stopped when computing the symbol context (#134757)

2025-04-10 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-04-08T11:06:05-07:00
New Revision: e84a80408523a48d6eaacd795f1615e821ffb233

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

LOG: [lldb] Make sure the process is stopped when computing the symbol context 
(#134757)

Make sure the process is stopped when computing the symbol context. Both
Adrian and Felipe reported a handful of crashes in GetSymbolContext
called from Statusline::Redraw on the default event thread.

Given that we're handling a StackFrameSP, it's not clear to me how that
could have gotten invalidated, but Jim points out that it doesn't make
sense to compute the symbol context for the frame when the process isn't
stopped.

Added: 


Modified: 
lldb/source/Core/Statusline.cpp

Removed: 




diff  --git a/lldb/source/Core/Statusline.cpp b/lldb/source/Core/Statusline.cpp
index b7650503e16bc..e14691e2538a2 100644
--- a/lldb/source/Core/Statusline.cpp
+++ b/lldb/source/Core/Statusline.cpp
@@ -12,6 +12,7 @@
 #include "lldb/Host/StreamFile.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/Process.h"
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/StreamString.h"
@@ -126,9 +127,7 @@ void Statusline::Redraw(bool update) {
 return;
   }
 
-  StreamString stream;
-  ExecutionContext exe_ctx =
-  m_debugger.GetCommandInterpreter().GetExecutionContext();
+  ExecutionContext exe_ctx = m_debugger.GetSelectedExecutionContext();
 
   // For colors and progress events, the format entity needs access to the
   // debugger, which requires a target in the execution context.
@@ -136,9 +135,17 @@ void Statusline::Redraw(bool update) {
 exe_ctx.SetTargetPtr(&m_debugger.GetSelectedOrDummyTarget());
 
   SymbolContext symbol_ctx;
-  if (auto frame_sp = exe_ctx.GetFrameSP())
-symbol_ctx = frame_sp->GetSymbolContext(eSymbolContextEverything);
+  if (ProcessSP process_sp = exe_ctx.GetProcessSP()) {
+// Check if the process is stopped, and if it is, make sure it remains
+// stopped until we've computed the symbol context.
+Process::StopLocker stop_locker;
+if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+  if (auto frame_sp = exe_ctx.GetFrameSP())
+symbol_ctx = frame_sp->GetSymbolContext(eSymbolContextEverything);
+}
+  }
 
+  StreamString stream;
   if (auto *format = m_debugger.GetStatuslineFormat())
 FormatEntity::Format(*format, stream, &symbol_ctx, &exe_ctx, nullptr,
  nullptr, false, false);



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


[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add option to highlight function names in backtraces (PR #131836)

2025-04-10 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/131836

>From 65aab6b727cc430a9e826c7eeda67259e041a462 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 7 Apr 2025 13:21:25 +0100
Subject: [PATCH 1/5] [ItaniumDemangle] Add printLeft/printRight APIs to
 OutputBuffer

This patch includes the necessary changes for the LLDB feature proposed in 
https://discourse.llvm.org/t/rfc-lldb-highlighting-function-names-in-lldb-backtraces/85309.
 The TL;DR is that we want to track where certain parts of a demangled name 
begin/end so we can highlight them in backtraces.

We introduce a new `printLeft`/`printRight` API that a client (in our case 
LLDB) can implement to track state while printing the demangle tree. This 
requires redirecting all calls to to `printLeft`/`printRight` to the 
`OutputBuffer`. One quirk with the new API is that `Utility.h` would now depend 
on `ItaniumDemangle.h` and vice-versa. To keep these files header-only I made 
the definitions `inline` and implement the new APIs in `ItaniumDemangle.h` (so 
the definition of `Node` is available to them).
---
 libcxxabi/src/demangle/ItaniumDemangle.h | 64 +++-
 libcxxabi/src/demangle/Utility.h |  7 +++
 llvm/include/llvm/Demangle/ItaniumDemangle.h | 64 +++-
 llvm/include/llvm/Demangle/Utility.h |  7 +++
 4 files changed, 86 insertions(+), 56 deletions(-)

diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h 
b/libcxxabi/src/demangle/ItaniumDemangle.h
index 3df41b5f4d7d0..89a24def830f2 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -281,9 +281,9 @@ class Node {
   }
 
   void print(OutputBuffer &OB) const {
-printLeft(OB);
+OB.printLeft(*this);
 if (RHSComponentCache != Cache::No)
-  printRight(OB);
+  OB.printRight(*this);
   }
 
   // Print the "left" side of this Node into OutputBuffer.
@@ -458,11 +458,11 @@ class QualType final : public Node {
   }
 
   void printLeft(OutputBuffer &OB) const override {
-Child->printLeft(OB);
+OB.printLeft(*Child);
 printQuals(OB);
   }
 
-  void printRight(OutputBuffer &OB) const override { Child->printRight(OB); }
+  void printRight(OutputBuffer &OB) const override { OB.printRight(*Child); }
 };
 
 class ConversionOperatorType final : public Node {
@@ -491,7 +491,7 @@ class PostfixQualifiedType final : public Node {
   template void match(Fn F) const { F(Ty, Postfix); }
 
   void printLeft(OutputBuffer &OB) const override {
-Ty->printLeft(OB);
+OB.printLeft(*Ty);
 OB += Postfix;
   }
 };
@@ -577,7 +577,7 @@ struct AbiTagAttr : Node {
   std::string_view getBaseName() const override { return Base->getBaseName(); }
 
   void printLeft(OutputBuffer &OB) const override {
-Base->printLeft(OB);
+OB.printLeft(*Base);
 OB += "[abi:";
 OB += Tag;
 OB += "]";
@@ -644,7 +644,7 @@ class PointerType final : public Node {
 // We rewrite objc_object* into id.
 if (Pointee->getKind() != KObjCProtoName ||
 !static_cast(Pointee)->isObjCObject()) {
-  Pointee->printLeft(OB);
+  OB.printLeft(*Pointee);
   if (Pointee->hasArray(OB))
 OB += " ";
   if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
@@ -663,7 +663,7 @@ class PointerType final : public Node {
 !static_cast(Pointee)->isObjCObject()) {
   if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
 OB += ")";
-  Pointee->printRight(OB);
+  OB.printRight(*Pointee);
 }
   }
 };
@@ -729,7 +729,7 @@ class ReferenceType : public Node {
 std::pair Collapsed = collapse(OB);
 if (!Collapsed.second)
   return;
-Collapsed.second->printLeft(OB);
+OB.printLeft(*Collapsed.second);
 if (Collapsed.second->hasArray(OB))
   OB += " ";
 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
@@ -746,7 +746,7 @@ class ReferenceType : public Node {
   return;
 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
   OB += ")";
-Collapsed.second->printRight(OB);
+OB.printRight(*Collapsed.second);
   }
 };
 
@@ -766,7 +766,7 @@ class PointerToMemberType final : public Node {
   }
 
   void printLeft(OutputBuffer &OB) const override {
-MemberType->printLeft(OB);
+OB.printLeft(*MemberType);
 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
   OB += "(";
 else
@@ -778,7 +778,7 @@ class PointerToMemberType final : public Node {
   void printRight(OutputBuffer &OB) const override {
 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
   OB += ")";
-MemberType->printRight(OB);
+OB.printRight(*MemberType);
   }
 };
 
@@ -798,7 +798,7 @@ class ArrayType final : public Node {
   bool hasRHSComponentSlow(OutputBuffer &) const override { return true; }
   bool hasArraySlow(OutputBuffer &) const override { return true; }
 
-  void printLeft(OutputBuffer &OB) const override { Base->print

[Lldb-commits] [lldb] [llvm] Revert "[dsymutil] Avoid copying binary swiftmodules built from textual" (PR #134872)

2025-04-10 Thread Jan Patrick Lehr via lldb-commits

jplehr wrote:

Already reverted.

https://github.com/llvm/llvm-project/pull/134872
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Make SBProcess thread related actions listen to StopLocker (PR #134339)

2025-04-10 Thread via lldb-commits


@@ -52,8 +64,14 @@ void ConfigurationDoneRequestHandler::operator()(
   dap.configuration_done_sent = true;
   if (dap.stop_at_entry)
 SendThreadStoppedEvent(dap);
-  else
+  else {
+// Client requests the baseline of currently existing threads after
+// a successful launch or attach.
+// A 'threads' request will be sent after configurationDone response
+// Obtain the list of threads before we resume the process

kusmour wrote:

As for the `continued` event, VSCode will ignore the threadID if 
`allThreadsContinued: true`. Looks like can send an invalid threadID if 
resuming all threads

https://github.com/llvm/llvm-project/pull/134339
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Make SBProcess thread related actions listen to StopLocker (PR #134339)

2025-04-10 Thread via lldb-commits


@@ -52,8 +64,14 @@ void ConfigurationDoneRequestHandler::operator()(
   dap.configuration_done_sent = true;
   if (dap.stop_at_entry)
 SendThreadStoppedEvent(dap);
-  else
+  else {
+// Client requests the baseline of currently existing threads after
+// a successful launch or attach.
+// A 'threads' request will be sent after configurationDone response
+// Obtain the list of threads before we resume the process

kusmour wrote:

The pause button relies on having some threads informations and it always send 
the `threadID` in the pause request. I have also checked the [VSCode source 
code](https://github.com/microsoft/vscode/blob/0b0be005fb90314a4659b7ca2a9c5d5dd2dd4378/src/vs/workbench/contrib/debug/browser/debugSession.ts#L1041)
 about fetching threads. If no threads are returned in the threads response 
then VSCode won't update the know thread list.

Which means, we really just need to return the baseline of threads for the 
debug session to carry on.

https://github.com/llvm/llvm-project/pull/134339
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Make SBProcess thread related actions listen to StopLocker (PR #134339)

2025-04-10 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/134339

>From 0c4f6ca21ba6ae37e3a884f4bcc356b6f741ede7 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Thu, 3 Apr 2025 22:29:13 -0700
Subject: [PATCH 1/2] [lldb] Make SBProcess thread related actions listen to
 StopLocker

---
 lldb/source/API/SBProcess.cpp | 20 ++-
 .../tools/lldb-dap/attach/TestDAP_attach.py   |  2 +-
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp
index 23ea449b30cca..ba77b2beed5ea 100644
--- a/lldb/source/API/SBProcess.cpp
+++ b/lldb/source/API/SBProcess.cpp
@@ -193,10 +193,11 @@ uint32_t SBProcess::GetNumThreads() {
   if (process_sp) {
 Process::StopLocker stop_locker;
 
-const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
-std::lock_guard guard(
-process_sp->GetTarget().GetAPIMutex());
-num_threads = process_sp->GetThreadList().GetSize(can_update);
+if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+  std::lock_guard guard(
+  process_sp->GetTarget().GetAPIMutex());
+  num_threads = process_sp->GetThreadList().GetSize();
+}
   }
 
   return num_threads;
@@ -393,11 +394,12 @@ SBThread SBProcess::GetThreadAtIndex(size_t index) {
   ProcessSP process_sp(GetSP());
   if (process_sp) {
 Process::StopLocker stop_locker;
-const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
-std::lock_guard guard(
-process_sp->GetTarget().GetAPIMutex());
-thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, 
can_update);
-sb_thread.SetThread(thread_sp);
+if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+  std::lock_guard guard(
+  process_sp->GetTarget().GetAPIMutex());
+  thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, false);
+  sb_thread.SetThread(thread_sp);
+}
   }
 
   return sb_thread;
diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py 
b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
index 9df44cc454d5d..b9fbf2c8d14f9 100644
--- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
+++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
@@ -1,5 +1,5 @@
 """
-Test lldb-dap setBreakpoints request
+Test lldb-dap attach request
 """
 
 

>From 44af671d401189ce652a92dbe1620c12dc861ed4 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Tue, 8 Apr 2025 22:52:19 -0700
Subject: [PATCH 2/2] [lldb-dap] Client expects initial threads request not
 empty

---
 .../test/tools/lldb-dap/dap_server.py  |  6 +-
 lldb/tools/lldb-dap/DAP.h  |  3 +++
 .../ConfigurationDoneRequestHandler.cpp| 10 +-
 .../lldb-dap/Handler/ThreadsRequestHandler.cpp | 18 --
 lldb/tools/lldb-dap/JSONUtils.cpp  | 10 ++
 lldb/tools/lldb-dap/JSONUtils.h|  2 ++
 6 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 45403e9df8525..6dbfc9dd84afa 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -649,13 +649,17 @@ def request_configurationDone(self):
 response = self.send_recv(command_dict)
 if response:
 self.configuration_done_sent = True
+# Client requests the baseline of currently existing threads after
+# a successful launch or attach.
+# Kick off the threads request that follows
+self.request_threads()
 return response
 
 def _process_stopped(self):
 self.threads = None
 self.frame_scopes = {}
 
-def request_continue(self, threadId=None):
+def  request_continue(self, threadId=None):
 if self.exit_status is not None:
 raise ValueError("request_continue called after process exited")
 # If we have launched or attached, then the first continue is done by
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index fc43d988f3a09..feeb040546c76 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -207,6 +207,9 @@ struct DAP {
   /// The set of features supported by the connected client.
   llvm::DenseSet clientFeatures;
 
+  /// The initial thread list upon attaching
+  std::optional initial_thread_list;
+
   /// Creates a new DAP sessions.
   ///
   /// \param[in] log
diff --git a/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp
index cd120e1fdfaba..f39bbdefdbb95 100644
--- a/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp
@@ -44,6 +44,7 @@ namespace lldb_dap {
 // just a

[Lldb-commits] [lldb] [lldb] Make SBProcess thread related actions listen to StopLocker (PR #134339)

2025-04-10 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/134339

>From 0c4f6ca21ba6ae37e3a884f4bcc356b6f741ede7 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Thu, 3 Apr 2025 22:29:13 -0700
Subject: [PATCH 1/2] [lldb] Make SBProcess thread related actions listen to
 StopLocker

---
 lldb/source/API/SBProcess.cpp | 20 ++-
 .../tools/lldb-dap/attach/TestDAP_attach.py   |  2 +-
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp
index 23ea449b30cca..ba77b2beed5ea 100644
--- a/lldb/source/API/SBProcess.cpp
+++ b/lldb/source/API/SBProcess.cpp
@@ -193,10 +193,11 @@ uint32_t SBProcess::GetNumThreads() {
   if (process_sp) {
 Process::StopLocker stop_locker;
 
-const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
-std::lock_guard guard(
-process_sp->GetTarget().GetAPIMutex());
-num_threads = process_sp->GetThreadList().GetSize(can_update);
+if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+  std::lock_guard guard(
+  process_sp->GetTarget().GetAPIMutex());
+  num_threads = process_sp->GetThreadList().GetSize();
+}
   }
 
   return num_threads;
@@ -393,11 +394,12 @@ SBThread SBProcess::GetThreadAtIndex(size_t index) {
   ProcessSP process_sp(GetSP());
   if (process_sp) {
 Process::StopLocker stop_locker;
-const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
-std::lock_guard guard(
-process_sp->GetTarget().GetAPIMutex());
-thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, 
can_update);
-sb_thread.SetThread(thread_sp);
+if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+  std::lock_guard guard(
+  process_sp->GetTarget().GetAPIMutex());
+  thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, false);
+  sb_thread.SetThread(thread_sp);
+}
   }
 
   return sb_thread;
diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py 
b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
index 9df44cc454d5d..b9fbf2c8d14f9 100644
--- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
+++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
@@ -1,5 +1,5 @@
 """
-Test lldb-dap setBreakpoints request
+Test lldb-dap attach request
 """
 
 

>From 931b3fbf9c31e4ea4e2c3bfe822ce0784c714c5a Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Tue, 8 Apr 2025 22:52:19 -0700
Subject: [PATCH 2/2] [lldb-dap] Client expects initial threads request not
 empty

---
 .../test/tools/lldb-dap/dap_server.py  |  4 
 lldb/tools/lldb-dap/DAP.h  |  3 +++
 .../ConfigurationDoneRequestHandler.cpp| 10 +-
 .../lldb-dap/Handler/ThreadsRequestHandler.cpp | 18 --
 lldb/tools/lldb-dap/JSONUtils.cpp  | 10 ++
 lldb/tools/lldb-dap/JSONUtils.h|  2 ++
 6 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 45403e9df8525..61d7fa94479b8 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -649,6 +649,10 @@ def request_configurationDone(self):
 response = self.send_recv(command_dict)
 if response:
 self.configuration_done_sent = True
+# Client requests the baseline of currently existing threads after
+# a successful launch or attach.
+# Kick off the threads request that follows
+self.request_threads()
 return response
 
 def _process_stopped(self):
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index fc43d988f3a09..feeb040546c76 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -207,6 +207,9 @@ struct DAP {
   /// The set of features supported by the connected client.
   llvm::DenseSet clientFeatures;
 
+  /// The initial thread list upon attaching
+  std::optional initial_thread_list;
+
   /// Creates a new DAP sessions.
   ///
   /// \param[in] log
diff --git a/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp
index cd120e1fdfaba..f39bbdefdbb95 100644
--- a/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp
@@ -44,6 +44,7 @@ namespace lldb_dap {
 // just an acknowledgement, so no body field is required."
 // }]
 // },
+
 void ConfigurationDoneRequestHandler::operator()(
 const llvm::json::Object &request) const {
   llvm::json::Object response;
@@ -52,8 +53,15 @@ void ConfigurationDoneRequestHandler::operator()(
   dap.configuration_done_sent = true;
   if (dap.stop_at_entry)
 SendThreadStop

[Lldb-commits] [lldb] [lldb] Handle signals in a separate thread in the driver (PR #134956)

2025-04-10 Thread Pavel Labath via lldb-commits

labath wrote:

I kinda like signalfd(2), although the implementation makes it kinda hard to 
use in environments you don't fully control. For one, it requires that the 
signal you're listening to is blocked on *all* threads in the process. If any 
thread unblocks it for any reason, you will miss the signal. And of course, 
it's linux extension, so we'd still need a fallback for other operating 
systems. The current MainLoop implementation is basically that -- the signal 
handler writes to the pipe to wake up the reading thread (it just write a 
single byte, not the actual `siginfo` structure, though we could change that if 
it was necessary).

https://github.com/llvm/llvm-project/pull/134956
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Support negative function offsets in UnwindPlans (PR #134662)

2025-04-10 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/134662

These are needed for functions whose entry point is not their lowest address.

>From 10a1029d776bf5dcae5fe69a72883916de7c4b5f Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Fri, 4 Apr 2025 11:37:34 +0200
Subject: [PATCH] [lldb] Support negative function offsets in UnwindPlans

These are needed for functions whose entry point is not their lowest
address.
---
 lldb/include/lldb/Symbol/UnwindPlan.h  | 10 +-
 .../UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp |  5 +++--
 lldb/source/Symbol/DWARFCallFrameInfo.cpp  |  2 +-
 lldb/source/Symbol/UnwindPlan.cpp  |  6 +++---
 lldb/unittests/Symbol/UnwindPlanTest.cpp   |  5 +
 5 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h 
b/lldb/include/lldb/Symbol/UnwindPlan.h
index 6640a23a3e868..410289851a879 100644
--- a/lldb/include/lldb/Symbol/UnwindPlan.h
+++ b/lldb/include/lldb/Symbol/UnwindPlan.h
@@ -356,11 +356,11 @@ class UnwindPlan {
 
 void RemoveRegisterInfo(uint32_t reg_num);
 
-lldb::addr_t GetOffset() const { return m_offset; }
+int64_t GetOffset() const { return m_offset; }
 
-void SetOffset(lldb::addr_t offset) { m_offset = offset; }
+void SetOffset(int64_t offset) { m_offset = offset; }
 
-void SlideOffset(lldb::addr_t offset) { m_offset += offset; }
+void SlideOffset(int64_t offset) { m_offset += offset; }
 
 const FAValue &GetCFAValue() const { return m_cfa_value; }
 FAValue &GetCFAValue() { return m_cfa_value; }
@@ -420,7 +420,7 @@ class UnwindPlan {
 
   protected:
 typedef std::map collection;
-lldb::addr_t m_offset = 0; // Offset into the function for this row
+int64_t m_offset = 0; // Offset into the function for this row
 
 FAValue m_cfa_value;
 FAValue m_afa_value;
@@ -472,7 +472,7 @@ class UnwindPlan {
   // practice, the UnwindPlan for a function with no known start address will 
be
   // the architectural default UnwindPlan which will only have one row.
   const UnwindPlan::Row *
-  GetRowForFunctionOffset(std::optional offset) const;
+  GetRowForFunctionOffset(std::optional offset) const;
 
   lldb::RegisterKind GetRegisterKind() const { return m_register_kind; }
 
diff --git 
a/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp 
b/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
index 3eaa2f33fce3e..aaff278ca31e2 100644
--- a/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
+++ b/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
@@ -1390,11 +1390,12 @@ bool 
x86AssemblyInspectionEngine::AugmentUnwindPlanFromCallSite(
 
 // If we already have one row for this instruction, we can continue.
 while (row_id < unwind_plan.GetRowCount() &&
-   unwind_plan.GetRowAtIndex(row_id)->GetOffset() <= offset) {
+   unwind_plan.GetRowAtIndex(row_id)->GetOffset() <=
+   static_cast(offset)) {
   row_id++;
 }
 const UnwindPlan::Row *original_row = unwind_plan.GetRowAtIndex(row_id - 
1);
-if (original_row->GetOffset() == offset) {
+if (original_row->GetOffset() == static_cast(offset)) {
   row = *original_row;
   continue;
 }
diff --git a/lldb/source/Symbol/DWARFCallFrameInfo.cpp 
b/lldb/source/Symbol/DWARFCallFrameInfo.cpp
index 957818e8d077f..dca3f665b0b80 100644
--- a/lldb/source/Symbol/DWARFCallFrameInfo.cpp
+++ b/lldb/source/Symbol/DWARFCallFrameInfo.cpp
@@ -765,7 +765,7 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t 
dwarf_offset,
  __FUNCTION__, dwarf_offset, startaddr.GetFileAddress());
 break;
   }
-  lldb::addr_t offset = row.GetOffset();
+  int64_t offset = row.GetOffset();
   row = std::move(stack.back());
   stack.pop_back();
   row.SetOffset(offset);
diff --git a/lldb/source/Symbol/UnwindPlan.cpp 
b/lldb/source/Symbol/UnwindPlan.cpp
index cfa8eefaa55bb..33aba0a859d5c 100644
--- a/lldb/source/Symbol/UnwindPlan.cpp
+++ b/lldb/source/Symbol/UnwindPlan.cpp
@@ -398,10 +398,10 @@ void UnwindPlan::AppendRow(Row row) {
 }
 
 struct RowLess {
-  bool operator()(addr_t a, const UnwindPlan::RowSP &b) const {
+  bool operator()(int64_t a, const UnwindPlan::RowSP &b) const {
 return a < b->GetOffset();
   }
-  bool operator()(const UnwindPlan::RowSP &a, addr_t b) const {
+  bool operator()(const UnwindPlan::RowSP &a, int64_t b) const {
 return a->GetOffset() < b;
   }
 };
@@ -418,7 +418,7 @@ void UnwindPlan::InsertRow(Row row, bool replace_existing) {
 }
 
 const UnwindPlan::Row *
-UnwindPlan::GetRowForFunctionOffset(std::optional offset) const {
+UnwindPlan::GetRowForFunctionOffset(std::optional offset) const {
   auto it = offset ? llvm::upper_bound(m_row_list, *offset, RowLess())
: m_row_list.end();
   if (it == m_row_list.begi

[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-04-10 Thread Greg Clayton via lldb-commits


@@ -46,12 +49,333 @@ class CommandObjectPluginLoad : public CommandObjectParsed 
{
   }
 };
 
+namespace {
+#define LLDB_OPTIONS_plugin_list
+#include "CommandOptions.inc"
+
+// These option definitions are shared by the plugin list/enable/disable
+// commands.
+class PluginListCommandOptions : public Options {
+public:
+  PluginListCommandOptions() = default;
+
+  ~PluginListCommandOptions() override = default;
+
+  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ExecutionContext *execution_context) override {
+Status error;
+const int short_option = m_getopt_table[option_idx].val;
+
+switch (short_option) {
+case 'x':
+  m_exact_name_match = true;
+  break;
+default:
+  llvm_unreachable("Unimplemented option");
+}
+
+return error;
+  }
+
+  void OptionParsingStarting(ExecutionContext *execution_context) override {
+m_exact_name_match = false;
+  }
+
+  llvm::ArrayRef GetDefinitions() override {
+return llvm::ArrayRef(g_plugin_list_options);
+  }
+
+  // Instance variables to hold the values for command options.
+  bool m_exact_name_match = false;
+};
+
+// Define some data structures to describe known plugin "namespaces".
+// The PluginManager is organized into a series of static functions
+// that operate on different types of plugin. For example SystemRuntime
+// and ObjectFile plugins.
+//
+// The namespace name is used a prefix when matching plugin names. For example,
+// if we have an "elf" plugin in the "object-file" namespace then we will
+// match a plugin name pattern against the "object-file.elf" name.
+//
+// The plugin namespace here is used so we can operate on all the plugins
+// of a given type so it is easy to enable or disable them as a group.
+using GetPluginInfo = std::function()>;
+using SetPluginEnabled = std::function;
+struct PluginNamespace {
+  llvm::StringRef name;
+  GetPluginInfo get_info;
+  SetPluginEnabled set_enabled;
+};
+
+// Currently supported set of plugin namespaces. This will be expanded
+// over time.
+PluginNamespace PluginNamespaces[] = {
+{"system-runtime", PluginManager::GetSystemRuntimePluginInfo,
+ PluginManager::SetSystemRuntimePluginEnabled}};
+
+// Helper function to perform an action on each matching plugin.
+// The action callback is given the containing namespace along with plugin info
+// for each matching plugin.
+static int ActOnMatchingPlugins(
+llvm::GlobPattern pattern,
+std::function &plugin_info)>
+action) {
+  int num_matching = 0;
+
+  for (const PluginNamespace &plugin_namespace : PluginNamespaces) {
+std::vector matching_plugins;
+for (const RegisteredPluginInfo &plugin_info :
+ plugin_namespace.get_info()) {
+  std::string qualified_name =
+  (plugin_namespace.name + "." + plugin_info.name).str();
+  if (pattern.match(qualified_name))
+matching_plugins.push_back(plugin_info);
+}
+
+if (!matching_plugins.empty()) {
+  num_matching += matching_plugins.size();
+  action(plugin_namespace, matching_plugins);
+}
+  }
+
+  return num_matching;
+}
+
+// Return a string in glob syntax for matching plugins.
+static std::string GetPluginNamePatternString(llvm::StringRef user_input,
+  bool add_default_glob) {
+  std::string pattern_str = user_input.empty() ? "*" : user_input.str();
+
+  if (add_default_glob && pattern_str != "*")
+pattern_str = "*" + pattern_str + "*";
+
+  return pattern_str;
+}
+
+// Attempts to create a glob pattern for a plugin name based on plugin command
+// input. Writes an error message to the `result` object if the glob cannot be
+// created successfully.
+//
+// The `glob_storage` is used to hold the string data for the glob pattern. The
+// llvm::GlobPattern only contains pointers into the string data so we need a
+// stable location that can outlive the glob pattern itself.
+std::optional
+TryCreatePluginPattern(const char *plugin_command_name, const Args &command,
+   const PluginListCommandOptions &options,
+   CommandReturnObject &result, std::string &glob_storage) 
{
+  size_t argc = command.GetArgumentCount();
+  if (argc > 1) {
+result.AppendErrorWithFormat("'%s' requires one argument",
+ plugin_command_name);
+return {};
+  }
+
+  llvm::StringRef user_pattern = argc == 1 ? command[0].ref() : "";
+
+  glob_storage =
+  GetPluginNamePatternString(user_pattern, !options.m_exact_name_match);
+
+  auto glob_pattern = llvm::GlobPattern::create(glob_storage);
+
+  if (auto error = glob_pattern.takeError()) {
+std::string error_message =
+(llvm::Twine("Invalid plugin glob pattern: '") + glob_storage +
+ "': " + llvm::toString(std::move(error)))
+.str();
+result.AppendError(error_message);
+return {};
+  }
+
+  return *glob_pattern;
+}
+
+// Call the "SetEnable"

[Lldb-commits] [lldb] [LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #132274)

2025-04-10 Thread Jonas Devlieghere via lldb-commits


@@ -246,6 +246,8 @@ class Mangled {
   /// for s, otherwise the enumerator for the mangling scheme detected.
   static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name);
 
+  static bool IsCPPMangledName(llvm::StringRef name);

JDevlieghere wrote:

How about calling this `IsMangledName` and. dropping the CPP/Cxx part 
altogether? Confusingly the implementation isn't actually checking if the 
mangling scheme is Itanium, so. this will fire too for Rust and Swift.  Maybe 
something (like Rust) is relying on that, I don't know. 
```suggestion
  static bool IsMangledName(llvm::StringRef name);
```
That would also provide some parity with this oddly named helper function:
```
static inline bool cstring_is_mangled(llvm::StringRef s) {
  return Mangled::GetManglingScheme(s) != Mangled::eManglingSchemeNone;
}
```

The current name makes it look like it should really belong in the C++ language 
plugin, where it was previously. 

https://github.com/llvm/llvm-project/pull/132274
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add frame-format option to highlight function names in backtraces (PR #131836)

2025-04-10 Thread Michael Buch via lldb-commits

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/131836
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][debugserver] Fix an off-by-one error in watchpoint identification (PR #134314)

2025-04-10 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-remote-linux-ubuntu` 
running on `as-builder-9` while building `lldb` at step 16 
"test-check-lldb-api".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/195/builds/7267


Here is the relevant piece of the build log for the reference

```
Step 16 (test-check-lldb-api) failure: Test just built components: 
check-lldb-api completed (failure)
 TEST 'lldb-api :: 
functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py'
 FAILED 
Script:
--
/usr/bin/python3.12 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib
 --env 
LLVM_INCLUDE_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include
 --env 
LLVM_TOOLS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin
 --libcxx-include-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/c++/v1
 --libcxx-include-target-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/aarch64-unknown-linux-gnu/c++/v1
 --libcxx-library-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib/aarch64-unknown-linux-gnu
 --arch aarch64 --build-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex
 --lldb-module-cache-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/lldb 
--compiler 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang 
--dsymutil 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/dsymutil
 --make /usr/bin/gmake --llvm-tools-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin 
--lldb-obj-root 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb 
--lldb-libs-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib 
--platform-url connect://jetson-agx-2198.lab.llvm.org:1234 
--platform-working-dir /home/ubuntu/lldb-tests --sysroot 
/mnt/fs/jetson-agx-ubuntu --env ARCH_CFLAGS=-mcpu=cortex-a78 --platform-name 
remote-linux --skip-category=lldb-server 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints
 -p TestConsecutiveWatchpoints.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
21d912121c9f41385b165a736be787527f5bd7c2)
  clang revision 21d912121c9f41385b165a736be787527f5bd7c2
  llvm revision 21d912121c9f41385b165a736be787527f5bd7c2
Setting up remote platform 'remote-linux'
Connecting to remote platform 'remote-linux' at 
'connect://jetson-agx-2198.lab.llvm.org:1234'...
Connected.
Setting remote platform working directory to '/home/ubuntu/lldb-tests'...
Skipping the following test categories: ['lldb-server', 'dsym', 'gmodules', 
'debugserver', 'objc', 'lldb-dap']

--
Command Output (stderr):
--
WARNING:root:Custom libc++ is not supported for remote runs: ignoring --libcxx 
arguments
FAIL: LLDB 
(/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang-aarch64)
 :: test_large_watchpoint 
(TestConsecutiveWatchpoints.ConsecutiveWatchpointsTestCase.test_large_watchpoint)
==
FAIL: test_large_watchpoint 
(TestConsecutiveWatchpoints.ConsecutiveWatchpointsTestCase.test_large_watchpoint)
   Test watchpoint that covers a large region of memory.
--
Traceback (most recent call last):
  File 
"/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py",
 line 58, in test_large_watchpoint
self.assertTrue(field4_wp.IsValid())
AssertionError: False is not true
Config=aarch64-/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang
--
Ran 1 test in 0.595s

FAILED (failures=1)

--




```



https://github.com/llvm/llvm-project/pull/134314
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-04-10 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

I do like the ability to enable/disable any plug-in, but we should only add 
support for enabling and disabling plug-ins that are optional. This patch adds 
the ability to enable/disable system runtime plug-ins so that is good. 

A few things to think about:

Do we want a separate command for this, or should we do this with "settings 
set"? It might make more sense to enable this via the "settings set" command 
and "settings show" command, but that doesn't allow for us to see ordering of 
the plug-ins. We already have a manual setting for 
"plugin.jit-loader.gdb.enable", but this should be a template for how we do 
enabling and disabling of plug-ins:
```
(lldb) settings set plugin.jit-loader.gdb.enable false
(lldb) settings set plugin.system-runtime.macosx.enable false
(lldb) settings set plugin.object-file.elf.enable false
(lldb) settings set plugin.object-file.pe-coff.enable false
```
The "SystemRuntimeMacOSX" currently has its name set to "systemruntime-macosx", 
but it should just be "macosx". The above are just for showing how it could 
look, we may not want to enable/disable object file plug-ins, but maybe we do...

So we could do the enable/disable via "settings set" if that makes more sense?


Having a separate command for listing the plug-ins does allow ordering to be 
displayed, so maybe that is preferable? Or maybe we add just the "plugins list" 
command so we can show the ordering, but set the enabled/disabled state via 
"settings set"?

The nice thing about having dedicated commands, it allows us to enable or 
disable all plug-ins in a plug-in namespace with one command and as new 
plug-ins get added, they can be disabled. If we use the "settings set" to 
enable/disable, then we lose this ability unless we have a category setting 
that would allow us to enable/disable all plug-ins in a namespace. For example:

```
(lldb) settings set plugin.jit-loader.enable = false
```

This could enable/disable all plug-ins in a namespace using a setting that we 
would add?

@JDevlieghere @jimingham let us know your thoughts?

https://github.com/llvm/llvm-project/pull/134418
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][debugserver] Fix an off-by-one error in watchpoint identification (PR #134314)

2025-04-10 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` 
running on `linaro-lldb-aarch64-ubuntu` while building `lldb` at step 6 "test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/59/builds/15581


Here is the relevant piece of the build log for the reference

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: 
functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py (687 of 
2121)
UNSUPPORTED: lldb-api :: functionalities/unwind/sigtramp/TestSigtrampUnwind.py 
(688 of 2121)
PASS: lldb-api :: 
functionalities/unused-inlined-parameters/TestUnusedInlinedParameters.py (689 
of 2121)
PASS: lldb-api :: 
functionalities/unwind/aarch64_unwind_pac/TestAArch64UnwindPAC.py (690 of 2121)
PASS: lldb-api :: functionalities/unwind/noreturn/TestNoreturnUnwind.py (691 of 
2121)
PASS: lldb-api :: functionalities/thread/state/TestThreadStates.py (692 of 2121)
PASS: lldb-api :: functionalities/unwind/zeroth_frame/TestZerothFrame.py (693 
of 2121)
PASS: lldb-api :: functionalities/value_md5_crash/TestValueMD5Crash.py (694 of 
2121)
PASS: lldb-api :: functionalities/valobj_errors/TestValueObjectErrors.py (695 
of 2121)
PASS: lldb-api :: functionalities/var_path/TestVarPath.py (696 of 2121)
FAIL: lldb-api :: 
functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py
 (697 of 2121)
 TEST 'lldb-api :: 
functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py'
 FAILED 
Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
--env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--arch aarch64 --build-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil 
--make /usr/bin/gmake --llvm-tools-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints
 -p TestConsecutiveWatchpoints.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
21d912121c9f41385b165a736be787527f5bd7c2)
  clang revision 21d912121c9f41385b165a736be787527f5bd7c2
  llvm revision 21d912121c9f41385b165a736be787527f5bd7c2
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
FAIL: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_large_watchpoint 
(TestConsecutiveWatchpoints.ConsecutiveWatchpointsTestCase)
==
FAIL: test_large_watchpoint 
(TestConsecutiveWatchpoints.ConsecutiveWatchpointsTestCase)
   Test watchpoint that covers a large region of memory.
--
Traceback (most recent call last):
  File 
"/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py",
 line 58, in test_large_watchpoint
self.assertTrue(field4_wp.IsValid())
AssertionError: False is not true
Config=aarch64-/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang
--
Ran 1 test in 0.298s

FAILED (failures=1)

--


UNSUPPORTED: lldb-api :: 
functionalities/watchpoint/large-watchpoint/TestLargeWatchpoint.py (698 of 2121)
UNSUPPORTED: lldb-api :: 
functionalities/watchpoint/unaligned-spanning-two-dwords/TestUnalignedSpanningDwords.py
 (699 of 2121)
PASS: lldb-api :: functionalities/wrong_commands/TestWrongCommands.py (700 of 
2121)

```



https://github.com/llvm/llvm-project/pull/134314
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)

2025-04-10 Thread via lldb-commits


@@ -422,6 +424,11 @@ class SymbolFile : public PluginInterface {
   /// hasn't been indexed yet, or a valid duration if it has.
   virtual StatsDuration::Duration GetDebugInfoIndexTime() { return {}; }
 
+  /// Return the time it took to locate any extra symbol files.
+  ///
+  /// \returns 0.0 if no extra symbol files need to be located
+  virtual StatsDuration::Duration GetSymbolLocateTime() { return {}; }
+

GeorgeHuyubo wrote:

> move to `lldb_private::Module`

I think we still need this at Symbol File level right? Thinking of 
SymbolFileDWARF scenario we still want to calculate the locate time for dwp 
files.

https://github.com/llvm/llvm-project/pull/134563
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Remove unused UnwindPlan functions (PR #134630)

2025-04-10 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/134630

`GetLSDAAddress` and `GetPersonalityRoutinePtrAddress` are unused and they 
create a bit of a problem for discontinuous functions, because the unwind plan 
for these consists of multiple eh_frame descriptors and (at least in theory) 
each of them could have a different value for these entities.

We could say we only support functions for which these are always the same, or 
create some sort of a Address2LSDA lookup map, but I think it's better to leave 
this question to someone who actually needs this.

>From ab6dc42c00fd52a0551ec59cfddb012bc56da277 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Fri, 4 Apr 2025 12:05:18 +0200
Subject: [PATCH] [lldb] Remove unused UnwindPlan functions

`GetLSDAAddress` and `GetPersonalityRoutinePtrAddress` are unused and
they create a bit of a problem for discontinuous functions, because the
unwind plan for these consists of multiple eh_frame descriptors and (at
least in theory) each of them could have a different value for these
entities.

We could say we only support functions for which these are always the
same, or create some sort of a Address2LSDA lookup map, but I think it's
better to leave this question to someone who actually needs this.
---
 lldb/include/lldb/Symbol/FuncUnwinders.h  | 13 
 lldb/include/lldb/Symbol/UnwindPlan.h | 23 +-
 lldb/source/Symbol/CompactUnwindInfo.cpp  | 12 ---
 lldb/source/Symbol/DWARFCallFrameInfo.cpp | 38 +++
 lldb/source/Symbol/FuncUnwinders.cpp  | 36 -
 lldb/source/Symbol/UnwindPlan.cpp | 13 
 6 files changed, 5 insertions(+), 130 deletions(-)

diff --git a/lldb/include/lldb/Symbol/FuncUnwinders.h 
b/lldb/include/lldb/Symbol/FuncUnwinders.h
index 479ccf87b6e2c..c21a1af5c56a2 100644
--- a/lldb/include/lldb/Symbol/FuncUnwinders.h
+++ b/lldb/include/lldb/Symbol/FuncUnwinders.h
@@ -61,19 +61,6 @@ class FuncUnwinders {
 });
   }
 
-  // A function may have a Language Specific Data Area specified -- a block of
-  // data in
-  // the object file which is used in the processing of an exception throw /
-  // catch. If any of the UnwindPlans have the address of the LSDA region for
-  // this function, this will return it.
-  Address GetLSDAAddress(Target &target);
-
-  // A function may have a Personality Routine associated with it -- used in 
the
-  // processing of throwing an exception.  If any of the UnwindPlans have the
-  // address of the personality routine, this will return it.  Read the target-
-  // pointer at this address to get the personality function address.
-  Address GetPersonalityRoutinePtrAddress(Target &target);
-
   // The following methods to retrieve specific unwind plans should rarely be
   // used. Instead, clients should ask for the *behavior* they are looking for,
   // using one of the above UnwindPlan retrieval methods.
diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h 
b/lldb/include/lldb/Symbol/UnwindPlan.h
index 6640a23a3e868..eee932492a550 100644
--- a/lldb/include/lldb/Symbol/UnwindPlan.h
+++ b/lldb/include/lldb/Symbol/UnwindPlan.h
@@ -445,9 +445,7 @@ class UnwindPlan {
 m_plan_is_sourced_from_compiler(rhs.m_plan_is_sourced_from_compiler),
 m_plan_is_valid_at_all_instruction_locations(
 rhs.m_plan_is_valid_at_all_instruction_locations),
-m_plan_is_for_signal_trap(rhs.m_plan_is_for_signal_trap),
-m_lsda_address(rhs.m_lsda_address),
-m_personality_func_addr(rhs.m_personality_func_addr) {
+m_plan_is_for_signal_trap(rhs.m_plan_is_for_signal_trap) {
 m_row_list.reserve(rhs.m_row_list.size());
 for (const RowSP &row_sp : rhs.m_row_list)
   m_row_list.emplace_back(new Row(*row_sp));
@@ -553,22 +551,10 @@ class UnwindPlan {
 m_plan_is_sourced_from_compiler = eLazyBoolCalculate;
 m_plan_is_valid_at_all_instruction_locations = eLazyBoolCalculate;
 m_plan_is_for_signal_trap = eLazyBoolCalculate;
-m_lsda_address.Clear();
-m_personality_func_addr.Clear();
   }
 
   const RegisterInfo *GetRegisterInfo(Thread *thread, uint32_t reg_num) const;
 
-  Address GetLSDAAddress() const { return m_lsda_address; }
-
-  void SetLSDAAddress(Address lsda_addr) { m_lsda_address = lsda_addr; }
-
-  Address GetPersonalityFunctionPtr() const { return m_personality_func_addr; }
-
-  void SetPersonalityFunctionPtr(Address presonality_func_ptr) {
-m_personality_func_addr = presonality_func_ptr;
-  }
-
 private:
   std::vector m_row_list;
   std::vector m_plan_valid_ranges;
@@ -583,13 +569,6 @@ class UnwindPlan {
   lldb_private::LazyBool m_plan_is_sourced_from_compiler;
   lldb_private::LazyBool m_plan_is_valid_at_all_instruction_locations;
   lldb_private::LazyBool m_plan_is_for_signal_trap;
-
-  Address m_lsda_address; // Where the language specific data area exists in 
the
-  // module - used
-  // in exception handling.

[Lldb-commits] [lldb] 369c773 - Revert "[lldb][debugserver] Fix an off-by-one error in watchpoint identification (#134314)"

2025-04-10 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2025-04-07T11:21:58-07:00
New Revision: 369c7739d0853b7931410037843d5a63f50bc0a1

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

LOG: Revert "[lldb][debugserver] Fix an off-by-one error in watchpoint 
identification (#134314)"

This reverts commit 21d912121c9f41385b165a736be787527f5bd7c2.

Failure on the aarch64 ubuntu bot when setting the 4th watchpoint;
may be a hardware limitation on that bot.  I thought creating four
watchpoints would be generally safe, but I don't need to do that
for my test, will re-land without it.

Added: 


Modified: 
lldb/tools/debugserver/source/DNBBreakpoint.cpp

Removed: 
lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/Makefile

lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py
lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/main.c



diff  --git 
a/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/Makefile 
b/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/Makefile
deleted file mode 100644
index 10495940055b6..0
--- a/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := main.c
-
-include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py
 
b/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py
deleted file mode 100644
index 229172e6ce0aa..0
--- 
a/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py
+++ /dev/null
@@ -1,87 +0,0 @@
-"""
-Watch contiguous memory regions with separate watchpoints, check that lldb
-correctly detect which watchpoint was hit for each one.
-"""
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class ConsecutiveWatchpointsTestCase(TestBase):
-NO_DEBUG_INFO_TESTCASE = True
-
-def continue_and_report_stop_reason(self, process, iter_str):
-process.Continue()
-self.assertIn(
-process.GetState(), [lldb.eStateStopped, lldb.eStateExited], 
iter_str
-)
-thread = process.GetSelectedThread()
-return thread.GetStopReason()
-
-# debugserver only gained the ability to watch larger regions
-# with this patch.
-def test_large_watchpoint(self):
-"""Test watchpoint that covers a large region of memory."""
-self.build()
-self.main_source_file = lldb.SBFileSpec("main.c")
-(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
-self, "break here", self.main_source_file
-)
-
-frame = thread.GetFrameAtIndex(0)
-
-field2_wp = (
-frame.locals["var"][0]
-.GetChildMemberWithName("field2")
-.Watch(True, False, True)
-)
-field3_wp = (
-frame.locals["var"][0]
-.GetChildMemberWithName("field3")
-.Watch(True, False, True)
-)
-field4_wp = (
-frame.locals["var"][0]
-.GetChildMemberWithName("field4")
-.Watch(True, False, True)
-)
-field5_wp = (
-frame.locals["var"][0]
-.GetChildMemberWithName("field5")
-.Watch(True, False, True)
-)
-
-self.assertTrue(field2_wp.IsValid())
-self.assertTrue(field3_wp.IsValid())
-self.assertTrue(field4_wp.IsValid())
-self.assertTrue(field5_wp.IsValid())
-
-reason = self.continue_and_report_stop_reason(process, "continue to 
field2 wp")
-self.assertEqual(reason, lldb.eStopReasonWatchpoint)
-stop_reason_watchpoint_id = (
-process.GetSelectedThread().GetStopReasonDataAtIndex(0)
-)
-self.assertEqual(stop_reason_watchpoint_id, field2_wp.GetID())
-
-reason = self.continue_and_report_stop_reason(process, "continue to 
field3 wp")
-self.assertEqual(reason, lldb.eStopReasonWatchpoint)
-stop_reason_watchpoint_id = (
-process.GetSelectedThread().GetStopReasonDataAtIndex(0)
-)
-self.assertEqual(stop_reason_watchpoint_id, field3_wp.GetID())
-
-reason = self.continue_and_report_stop_reason(process, "continue to 
field4 wp")
-self.assertEqual(reason, lldb.eStopReasonWatchpoint)
-stop_reason_watchpoint_id = (
-process.GetSelectedThread().GetStopReasonDataAtIndex(0)
-)
-self.assertEqual(stop_reason_watchpoint_id, field4_wp.GetID())
-
-reason = self.continue_and_report_stop_reason(process, "continue to 
field5 wp")
-self.a

[Lldb-commits] [lldb] [LLDB] Refactored CPlusPlusLanguage::MethodName to break lldb-server dependencies (PR #132274)

2025-04-10 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman updated 
https://github.com/llvm/llvm-project/pull/132274

>From 40d69ed7386c3f8169b324bd3b7591a46e34ff4d Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 20 Mar 2025 21:50:51 +0400
Subject: [PATCH 1/3] [LLDB] Refactored CPlusPlusLanguage::MethodName to break
 lldb-server dependencies

This patch addresses the issue #129543.
After this patch the size of lldb-server is reduced by 9MB.

Co-authored-by: @bulbazord Alex Langford
---
 lldb/include/lldb/Core/Mangled.h  |   2 +
 lldb/include/lldb/Core/RichManglingContext.h  |  16 +-
 lldb/include/lldb/Target/Language.h   |  98 
 lldb/source/Core/CMakeLists.txt   |   2 -
 lldb/source/Core/Mangled.cpp  |   5 +
 lldb/source/Core/Module.cpp   | 151 --
 lldb/source/Core/RichManglingContext.cpp  |  22 ++-
 .../Clang/ClangExpressionDeclMap.cpp  |   9 +-
 lldb/source/Plugins/Language/CMakeLists.txt   |   2 +
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 128 ++-
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  58 ++-
 .../Plugins/Language/ObjC/ObjCLanguage.cpp|  15 ++
 .../Plugins/Language/ObjC/ObjCLanguage.h  |   3 +
 .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp  |   4 +-
 lldb/unittests/Core/CMakeLists.txt|   1 +
 .../Core/RichManglingContextTest.cpp  |   7 +
 .../CPlusPlus/CPlusPlusLanguageTest.cpp   |  22 +--
 17 files changed, 286 insertions(+), 259 deletions(-)

diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h
index 5988d919a89b8..d5b1d4ff7149a 100644
--- a/lldb/include/lldb/Core/Mangled.h
+++ b/lldb/include/lldb/Core/Mangled.h
@@ -246,6 +246,8 @@ class Mangled {
   /// for s, otherwise the enumerator for the mangling scheme detected.
   static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name);
 
+  static bool IsCPPMangledName(llvm::StringRef name);
+
   /// Decode a serialized version of this object from data.
   ///
   /// \param data
diff --git a/lldb/include/lldb/Core/RichManglingContext.h 
b/lldb/include/lldb/Core/RichManglingContext.h
index 3b79924e88a9a..50ec2ae361098 100644
--- a/lldb/include/lldb/Core/RichManglingContext.h
+++ b/lldb/include/lldb/Core/RichManglingContext.h
@@ -12,6 +12,7 @@
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private.h"
 
+#include "lldb/Target/Language.h"
 #include "lldb/Utility/ConstString.h"
 
 #include "llvm/ADT/Any.h"
@@ -67,11 +68,7 @@ class RichManglingContext {
   char *m_ipd_buf;
   size_t m_ipd_buf_size = 2048;
 
-  /// Members for PluginCxxLanguage
-  /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The
-  /// respective header is in Plugins and including it from here causes cyclic
-  /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp.
-  llvm::Any m_cxx_method_parser;
+  std::unique_ptr m_cxx_method_parser;
 
   /// Clean up memory when using PluginCxxLanguage
   void ResetCxxMethodParser();
@@ -81,15 +78,6 @@ class RichManglingContext {
 
   /// Uniform handling of string buffers for ItaniumPartialDemangler.
   llvm::StringRef processIPDStrResult(char *ipd_res, size_t res_len);
-
-  /// Cast the given parser to the given type. Ideally we would have a type
-  /// trait to deduce \a ParserT from a given InfoProvider, but unfortunately 
we
-  /// can't access CPlusPlusLanguage::MethodName from within the header.
-  template  static ParserT *get(llvm::Any parser) {
-assert(parser.has_value());
-assert(llvm::any_cast(&parser));
-return *llvm::any_cast(&parser);
-  }
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index b699a90aff8e4..d46969cb3b4e4 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -214,6 +214,104 @@ class Language : public PluginInterface {
 return std::vector();
   };
 
+  class MethodName {
+  public:
+MethodName() {}
+
+MethodName(ConstString full)
+: m_full(full), m_basename(), m_context(), m_arguments(),
+  m_qualifiers(), m_return_type(), m_scope_qualified(), 
m_parsed(false),
+  m_parse_error(false) {}
+
+virtual ~MethodName() {};
+
+void Clear() {
+  m_full.Clear();
+  m_basename = llvm::StringRef();
+  m_context = llvm::StringRef();
+  m_arguments = llvm::StringRef();
+  m_qualifiers = llvm::StringRef();
+  m_return_type = llvm::StringRef();
+  m_scope_qualified.clear();
+  m_parsed = false;
+  m_parse_error = false;
+}
+
+bool IsValid() {
+  if (!m_parsed)
+Parse();
+  if (m_parse_error)
+return false;
+  return (bool)m_full;
+}
+
+ConstString GetFullName() const { return m_full; }
+
+llvm::StringRef GetBasename() {
+  if (!m_parsed)
+Parse();
+  return m_basename;
+}
+
+llvm::StringRef GetContext() {
+  if (!m_parsed)

[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-04-10 Thread Greg Clayton via lldb-commits


@@ -46,12 +49,333 @@ class CommandObjectPluginLoad : public CommandObjectParsed 
{
   }
 };
 
+namespace {
+#define LLDB_OPTIONS_plugin_list
+#include "CommandOptions.inc"
+
+// These option definitions are shared by the plugin list/enable/disable
+// commands.
+class PluginListCommandOptions : public Options {
+public:
+  PluginListCommandOptions() = default;
+
+  ~PluginListCommandOptions() override = default;
+
+  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ExecutionContext *execution_context) override {
+Status error;
+const int short_option = m_getopt_table[option_idx].val;
+
+switch (short_option) {
+case 'x':
+  m_exact_name_match = true;
+  break;
+default:
+  llvm_unreachable("Unimplemented option");
+}
+
+return error;
+  }
+
+  void OptionParsingStarting(ExecutionContext *execution_context) override {
+m_exact_name_match = false;
+  }
+
+  llvm::ArrayRef GetDefinitions() override {
+return llvm::ArrayRef(g_plugin_list_options);
+  }
+
+  // Instance variables to hold the values for command options.
+  bool m_exact_name_match = false;
+};
+
+// Define some data structures to describe known plugin "namespaces".
+// The PluginManager is organized into a series of static functions
+// that operate on different types of plugin. For example SystemRuntime
+// and ObjectFile plugins.
+//
+// The namespace name is used a prefix when matching plugin names. For example,
+// if we have an "elf" plugin in the "object-file" namespace then we will
+// match a plugin name pattern against the "object-file.elf" name.
+//
+// The plugin namespace here is used so we can operate on all the plugins
+// of a given type so it is easy to enable or disable them as a group.
+using GetPluginInfo = std::function()>;
+using SetPluginEnabled = std::function;
+struct PluginNamespace {
+  llvm::StringRef name;
+  GetPluginInfo get_info;
+  SetPluginEnabled set_enabled;
+};
+
+// Currently supported set of plugin namespaces. This will be expanded
+// over time.
+PluginNamespace PluginNamespaces[] = {
+{"system-runtime", PluginManager::GetSystemRuntimePluginInfo,
+ PluginManager::SetSystemRuntimePluginEnabled}};
+
+// Helper function to perform an action on each matching plugin.
+// The action callback is given the containing namespace along with plugin info
+// for each matching plugin.
+static int ActOnMatchingPlugins(
+llvm::GlobPattern pattern,
+std::function &plugin_info)>
+action) {
+  int num_matching = 0;
+
+  for (const PluginNamespace &plugin_namespace : PluginNamespaces) {
+std::vector matching_plugins;
+for (const RegisteredPluginInfo &plugin_info :
+ plugin_namespace.get_info()) {
+  std::string qualified_name =
+  (plugin_namespace.name + "." + plugin_info.name).str();
+  if (pattern.match(qualified_name))
+matching_plugins.push_back(plugin_info);
+}
+
+if (!matching_plugins.empty()) {
+  num_matching += matching_plugins.size();
+  action(plugin_namespace, matching_plugins);
+}
+  }
+
+  return num_matching;
+}
+
+// Return a string in glob syntax for matching plugins.
+static std::string GetPluginNamePatternString(llvm::StringRef user_input,
+  bool add_default_glob) {
+  std::string pattern_str = user_input.empty() ? "*" : user_input.str();
+
+  if (add_default_glob && pattern_str != "*")
+pattern_str = "*" + pattern_str + "*";
+
+  return pattern_str;
+}
+
+// Attempts to create a glob pattern for a plugin name based on plugin command
+// input. Writes an error message to the `result` object if the glob cannot be
+// created successfully.
+//
+// The `glob_storage` is used to hold the string data for the glob pattern. The
+// llvm::GlobPattern only contains pointers into the string data so we need a
+// stable location that can outlive the glob pattern itself.
+std::optional
+TryCreatePluginPattern(const char *plugin_command_name, const Args &command,
+   const PluginListCommandOptions &options,
+   CommandReturnObject &result, std::string &glob_storage) 
{
+  size_t argc = command.GetArgumentCount();
+  if (argc > 1) {
+result.AppendErrorWithFormat("'%s' requires one argument",
+ plugin_command_name);
+return {};
+  }
+
+  llvm::StringRef user_pattern = argc == 1 ? command[0].ref() : "";
+
+  glob_storage =
+  GetPluginNamePatternString(user_pattern, !options.m_exact_name_match);
+
+  auto glob_pattern = llvm::GlobPattern::create(glob_storage);
+
+  if (auto error = glob_pattern.takeError()) {
+std::string error_message =
+(llvm::Twine("Invalid plugin glob pattern: '") + glob_storage +
+ "': " + llvm::toString(std::move(error)))
+.str();
+result.AppendError(error_message);
+return {};
+  }
+
+  return *glob_pattern;
+}
+
+// Call the "SetEnable"

[Lldb-commits] [lldb] [llvm] Revert "[dsymutil] Avoid copying binary swiftmodules built from textual" (PR #134872)

2025-04-10 Thread Jan Patrick Lehr via lldb-commits

https://github.com/jplehr created 
https://github.com/llvm/llvm-project/pull/134872

Reverts llvm/llvm-project#134719

This broke many buildbots

>From d96389666d37d0bdd898e2f1812e89b277a3fb74 Mon Sep 17 00:00:00 2001
From: Jan Patrick Lehr 
Date: Tue, 8 Apr 2025 17:52:11 +0200
Subject: [PATCH] =?UTF-8?q?Revert=20"[dsymutil]=20Avoid=20copying=20binary?=
 =?UTF-8?q?=20swiftmodules=20built=20from=20textual=20(#134=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 561506144531cf0a760bb437fd74c683931c60ae.
---
 lldb/source/Core/Statusline.cpp   |  15 +-
 .../tools/dsymutil/Inputs/Binary.swiftmodule  | Bin 17192 -> 0 bytes
 .../dsymutil/Inputs/FromInterface.swiftmodule | Bin 17028 -> 0 bytes
 llvm/test/tools/dsymutil/swiftmodule.test |  29 ---
 .../dsymutil/yaml-object-address-rewrite.test |   3 -
 llvm/tools/dsymutil/CMakeLists.txt|   1 -
 llvm/tools/dsymutil/DebugMap.cpp  |   8 +-
 llvm/tools/dsymutil/DwarfLinkerForBinary.cpp  |  16 --
 llvm/tools/dsymutil/RelocationMap.h   |   1 -
 llvm/tools/dsymutil/SwiftModule.cpp   | 192 --
 llvm/tools/dsymutil/SwiftModule.h |  15 --
 11 files changed, 8 insertions(+), 272 deletions(-)
 delete mode 100644 llvm/test/tools/dsymutil/Inputs/Binary.swiftmodule
 delete mode 100644 llvm/test/tools/dsymutil/Inputs/FromInterface.swiftmodule
 delete mode 100644 llvm/test/tools/dsymutil/swiftmodule.test
 delete mode 100644 llvm/tools/dsymutil/SwiftModule.cpp
 delete mode 100644 llvm/tools/dsymutil/SwiftModule.h

diff --git a/lldb/source/Core/Statusline.cpp b/lldb/source/Core/Statusline.cpp
index a2ecebbefbfb1..b7650503e16bc 100644
--- a/lldb/source/Core/Statusline.cpp
+++ b/lldb/source/Core/Statusline.cpp
@@ -12,7 +12,6 @@
 #include "lldb/Host/StreamFile.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Target/Process.h"
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/StreamString.h"
@@ -127,7 +126,9 @@ void Statusline::Redraw(bool update) {
 return;
   }
 
-  ExecutionContext exe_ctx = m_debugger.GetSelectedExecutionContext();
+  StreamString stream;
+  ExecutionContext exe_ctx =
+  m_debugger.GetCommandInterpreter().GetExecutionContext();
 
   // For colors and progress events, the format entity needs access to the
   // debugger, which requires a target in the execution context.
@@ -135,15 +136,9 @@ void Statusline::Redraw(bool update) {
 exe_ctx.SetTargetPtr(&m_debugger.GetSelectedOrDummyTarget());
 
   SymbolContext symbol_ctx;
-  if (ProcessSP process_sp = exe_ctx.GetProcessSP()) {
-Process::StopLocker stop_locker;
-if (stop_locker.TryLock(&process_sp->GetRunLock())) {
-  if (auto frame_sp = exe_ctx.GetFrameSP())
-symbol_ctx = frame_sp->GetSymbolContext(eSymbolContextEverything);
-}
-  }
+  if (auto frame_sp = exe_ctx.GetFrameSP())
+symbol_ctx = frame_sp->GetSymbolContext(eSymbolContextEverything);
 
-  StreamString stream;
   if (auto *format = m_debugger.GetStatuslineFormat())
 FormatEntity::Format(*format, stream, &symbol_ctx, &exe_ctx, nullptr,
  nullptr, false, false);
diff --git a/llvm/test/tools/dsymutil/Inputs/Binary.swiftmodule 
b/llvm/test/tools/dsymutil/Inputs/Binary.swiftmodule
deleted file mode 100644
index 
7ba817b22b707a23387b728923ae764699578561..
GIT binary patch
literal 0
HcmV?d1

literal 17192
zcmbt*4Rl-8mF~5q_~+iBd*dYFKqirm2P9i|WRnCtmXoV12MmN(A?Bwu%v1>u4Q&At
zLJO~LDoY9o#>l{q22pcHZ6JZ!Re2xSw3YaYY4#v7vais?SPw+z);dqRH(ZUa;_=8biydlZ=$wIHp_o7Y3ijSuFh({Rk@GnmA
zy?B@MEgX{gK_B%JOX`G3H2X$fGU(x-SNRhvO)Q4@@+VTlaffh1;>EWX@dGjbxKHTC
zN|?;S52$<}mQM-CB>t#}7mMrpeu+Oe!S}^@aZ^2;*emo|1Z}#af}!My!JbsAMgrAi
z@l|0%^+?=05ORj%wLZ30EDjW~CMB?_DI7V7AxHG;g
zil+g4C}5w82XE_9tmxRI*hZD=E<;TuZbjEF1zK7aGSti%sw07FEOIx^q1c83)-Hoh
zRctCIkJm&3wq$%&R=G~c^|WeIv5gsOLeR8gb9%z|uDCsdc@*1l+}ee4hMG|l#kOCm
zb^30wj>0Mi`>0a&HhVgwR1F#IBLRDotvIY$u~RJS^xa64N0jOqCW~7mB%N(4P#sd}
zD}b;4&hLswu3jwtlP
zN;sI}k8;A17!M=7=-~%}6j&oAz-*coBPnjp>@bNxpk}e)Ydqo*U}XT|phv(^3_7UN
zlYS53tWV~}@qgxz%lt{qpAw=HJ?#aovVgdBeD-ypUx=poL0NcFBB9fexzz+<3Wrtx
zSV}nIfl$IhKmTHikIKT46dp>2rBxv^zIDP-o83Q91TDZmWEDfrRD4wzw8+e*#uIDz
z7^>kSzl*OLj#m%ISHV1h5io;J&}Ar2${UN@ojb;9nur23SAD>2h<5{ubw57m8bf}Q
ztquShYy`ddssXZu&AI7P`#7yin9O2mh8eUg?k>CY1nl4?2RQ;af%?6CuY=Sx$1J%X
z(lHnXT4PELQ1cRR&47c>wvAuTVNVhse%PM4K?rx`0LZN3(SQxTnPT!6LoYLthVoxE%a1Q;r1(Jmd~T3~+FqBMgjM
zKd~Fw1$kM7BM$yWS$KgHG*}OU-ZGPkZ^?WgUSNI?e++0&@_kAE0F0aMamgfqJjui4
zm_IX3bjgrMh%!G(FZNTHaFPS~vt0zR=1^*4`5}*R%s~>u@iN0xmN`#3aIgR>7r*u!
zjq1~~rlsUU$ZIs0zsPG}
zBQ^xxKvnPn&9f14G_9s3{THJ!n8Irw9x;&d3&b0+7jyr#1;yp2^o}tB*{4S!!MQnu
z(^GD4WWYEK+reZi*3B&O)~+1md#T^SJRue>B?9dw3KS6f
z4$hj6yETIET6azB>3#aXG3enBVI{1`JRfp_fi;p$3;gD-!Z8bf99GAc=0V_u7ly!2
z0EZkv`L;h#Dp$4sTIlAd|rTEhB^^KRxh*YPi4Lf}*z9pevWRdM<4Iu*i<
zGE$1U*1P>$Hh(7ZfDo`GoCVs=;LPy|Vm

[Lldb-commits] [lldb] df28c81 - [lldb][debugserver] Fix an off-by-one error in watchpoint identification (#134314)

2025-04-10 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2025-04-07T13:50:31-07:00
New Revision: df28c81f5a2b61a3b5ad1e6274dd27697a9367ac

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

LOG: [lldb][debugserver] Fix an off-by-one error in watchpoint identification 
(#134314)

debugserver takes the address of a watchpoint exception and calculates
which watchpoint was responsible for it. There was an off-by-one error
in the range calculation which causes two watchpoints on consecutive
ranges to not correctly identify hits to the second watchpoint. The
result is that lldb wouldn't show the second watchpoint as ever being
hit.

Re-landing this test with a modification to only require two
watchpoints in the test, instead of four.  If four watchpoints can
be set, it will test them.

rdar://145107575

Added: 
lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/Makefile

lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py
lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/main.c

Modified: 
lldb/tools/debugserver/source/DNBBreakpoint.cpp

Removed: 




diff  --git 
a/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/Makefile 
b/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/Makefile
new file mode 100644
index 0..10495940055b6
--- /dev/null
+++ b/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py
 
b/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py
new file mode 100644
index 0..bb73acc8fc35f
--- /dev/null
+++ 
b/lldb/test/API/functionalities/watchpoint/consecutive-watchpoints/TestConsecutiveWatchpoints.py
@@ -0,0 +1,96 @@
+"""
+Watch contiguous memory regions with separate watchpoints, check that lldb
+correctly detect which watchpoint was hit for each one.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ConsecutiveWatchpointsTestCase(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def continue_and_report_stop_reason(self, process, iter_str):
+process.Continue()
+self.assertIn(
+process.GetState(), [lldb.eStateStopped, lldb.eStateExited], 
iter_str
+)
+thread = process.GetSelectedThread()
+return thread.GetStopReason()
+
+# debugserver only gained the ability to watch larger regions
+# with this patch.
+def test_consecutive_watchpoints(self):
+"""Test watchpoint that covers a large region of memory."""
+self.build()
+self.main_source_file = lldb.SBFileSpec("main.c")
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "break here", self.main_source_file
+)
+
+frame = thread.GetFrameAtIndex(0)
+
+field2_wp = (
+frame.locals["var"][0]
+.GetChildMemberWithName("field2")
+.Watch(True, False, True)
+)
+field3_wp = (
+frame.locals["var"][0]
+.GetChildMemberWithName("field3")
+.Watch(True, False, True)
+)
+field4_wp = (
+frame.locals["var"][0]
+.GetChildMemberWithName("field4")
+.Watch(True, False, True)
+)
+field5_wp = (
+frame.locals["var"][0]
+.GetChildMemberWithName("field5")
+.Watch(True, False, True)
+)
+
+# Require that the first two watchpoints
+# are set -- hopefully every machine running
+# the testsuite can support two watchpoints.
+self.assertTrue(field2_wp.IsValid())
+self.assertTrue(field3_wp.IsValid())
+
+reason = self.continue_and_report_stop_reason(process, "continue to 
field2 wp")
+self.assertEqual(reason, lldb.eStopReasonWatchpoint)
+stop_reason_watchpoint_id = (
+process.GetSelectedThread().GetStopReasonDataAtIndex(0)
+)
+self.assertEqual(stop_reason_watchpoint_id, field2_wp.GetID())
+
+reason = self.continue_and_report_stop_reason(process, "continue to 
field3 wp")
+self.assertEqual(reason, lldb.eStopReasonWatchpoint)
+stop_reason_watchpoint_id = (
+process.GetSelectedThread().GetStopReasonDataAtIndex(0)
+)
+self.assertEqual(stop_reason_watchpoint_id, field3_wp.GetID())
+
+# If we were able to set the second two watchpoints,
+# check that they are hit.  Some CI bots can only
+# create two watchpoints.
+i

[Lldb-commits] [lldb] [LLDB][MIPS] Fix signal SIGBUS number mismatch error on mips target (PR #132688)

2025-04-10 Thread Pavel Labath via lldb-commits

https://github.com/labath closed 
https://github.com/llvm/llvm-project/pull/132688
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [clang-tools-extra] [lldb] Reland: [clang] preserve class type sugar when taking pointer to member (PR #132401)

2025-04-10 Thread Matheus Izvekov via lldb-commits

mizvekov wrote:

> We are now seeing non-determinism in `.pcm` files that root-causes to this 
> commit.
> 
> @mizvekov - might it be something obvious, like pointer-keyed containers or 
> similar?

I don't see anything obvious. The only parts of the patch which touch anything 
similar to pointer-keyed containers are the type properties cache changes, like 
the linkage computation.

https://github.com/llvm/llvm-project/pull/132401
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 2b984fd - [lldb] Support programmatically setting the statusline format (NFC) (#135250)

2025-04-10 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-04-10T15:36:28-07:00
New Revision: 2b984fd0e396fe6ab30cd823ea2f65f33f75409c

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

LOG: [lldb] Support programmatically setting the statusline format (NFC) 
(#135250)

Support programmatically setting the statusline format. I want to use
this API downstream, to change the statusline format for the Swift REPL.

Added: 
lldb/unittests/Core/DebuggerTest.cpp

Modified: 
lldb/include/lldb/Core/Debugger.h
lldb/include/lldb/Interpreter/OptionValue.h
lldb/source/Core/Debugger.cpp
lldb/source/Interpreter/OptionValue.cpp
lldb/unittests/Core/CMakeLists.txt

Removed: 




diff  --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index c79a75ab61564..448e8d6a8fc6a 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -307,6 +307,7 @@ class Debugger : public 
std::enable_shared_from_this,
   bool GetShowStatusline() const;
 
   const FormatEntity::Entry *GetStatuslineFormat() const;
+  bool SetStatuslineFormat(const FormatEntity::Entry &format);
 
   llvm::StringRef GetShowProgressAnsiPrefix() const;
 

diff  --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index d19c8b8fab622..ebc438517a7b1 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -72,7 +72,7 @@ class OptionValue {
   virtual ~OptionValue() = default;
 
   OptionValue(const OptionValue &other);
-  
+
   OptionValue& operator=(const OptionValue &other);
 
   // Subclasses should override these functions
@@ -330,6 +330,10 @@ class OptionValue {
 
   bool SetValueAs(ArchSpec v) { return SetArchSpecValue(v); }
 
+  bool SetValueAs(const FormatEntity::Entry &v) {
+return SetFormatEntityValue(v);
+  }
+
   template , bool> = true>
   bool SetValueAs(T t) {
 return SetEnumerationValue(t);
@@ -387,8 +391,10 @@ class OptionValue {
   bool SetUUIDValue(const UUID &uuid);
 
   const FormatEntity::Entry *GetFormatEntity() const;
+  bool SetFormatEntityValue(const FormatEntity::Entry &entry);
+
   const RegularExpression *GetRegexValue() const;
-  
+
   mutable std::mutex m_mutex;
 };
 

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 51029f91eb12d..bfec1fa64ea52 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -484,6 +484,11 @@ const FormatEntity::Entry *Debugger::GetStatuslineFormat() 
const {
   return GetPropertyAtIndexAs(idx);
 }
 
+bool Debugger::SetStatuslineFormat(const FormatEntity::Entry &format) {
+  constexpr uint32_t idx = ePropertyStatuslineFormat;
+  return SetPropertyAtIndex(idx, format);
+}
+
 bool Debugger::GetUseAutosuggestion() const {
   const uint32_t idx = ePropertyShowAutosuggestion;
   return GetPropertyAtIndexAs(

diff  --git a/lldb/source/Interpreter/OptionValue.cpp 
b/lldb/source/Interpreter/OptionValue.cpp
index b95f4fec33949..28bc57a07ac71 100644
--- a/lldb/source/Interpreter/OptionValue.cpp
+++ b/lldb/source/Interpreter/OptionValue.cpp
@@ -474,6 +474,15 @@ bool OptionValue::SetArchSpecValue(ArchSpec arch_spec) {
   return false;
 }
 
+bool OptionValue::SetFormatEntityValue(const FormatEntity::Entry &entry) {
+  std::lock_guard lock(m_mutex);
+  if (OptionValueFormatEntity *option_value = GetAsFormatEntity()) {
+option_value->SetCurrentValue(entry);
+return true;
+  }
+  return false;
+}
+
 const char *OptionValue::GetBuiltinTypeAsCString(Type t) {
   switch (t) {
   case eTypeInvalid:

diff  --git a/lldb/unittests/Core/CMakeLists.txt 
b/lldb/unittests/Core/CMakeLists.txt
index 8580f5887ea2b..dc9c0577aa546 100644
--- a/lldb/unittests/Core/CMakeLists.txt
+++ b/lldb/unittests/Core/CMakeLists.txt
@@ -1,5 +1,6 @@
 
 add_lldb_unittest(LLDBCoreTests
+  DebuggerTest.cpp
   CommunicationTest.cpp
   DiagnosticEventTest.cpp
   DumpDataExtractorTest.cpp

diff  --git a/lldb/unittests/Core/DebuggerTest.cpp 
b/lldb/unittests/Core/DebuggerTest.cpp
new file mode 100644
index 0..df7d999788553
--- /dev/null
+++ b/lldb/unittests/Core/DebuggerTest.cpp
@@ -0,0 +1,52 @@
+//===-- DebuggerTest.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Core/Debugger.h"
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "TestingSupport/TestUtilities.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Ho

[Lldb-commits] [lldb] [lldb] Support programmatically setting the statusline format (NFC) (PR #135250)

2025-04-10 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere closed 
https://github.com/llvm/llvm-project/pull/135250
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [clang-tools-extra] [lldb] Reland: [clang] preserve class type sugar when taking pointer to member (PR #132401)

2025-04-10 Thread Arthur Eubanks via lldb-commits

aeubanks wrote:

@mizvekov we're seeing pcm non-determinism after this reland, does anything 
jump out at you?

https://github.com/llvm/llvm-project/pull/132401
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add unary operators Dereference and AddressOf to DIL (PR #134428)

2025-04-10 Thread Ilia Kuklin via lldb-commits


@@ -18,6 +18,22 @@
 
 namespace lldb_private::dil {
 
+static lldb::ValueObjectSP
+ArrayToPointerConversion(lldb::ValueObjectSP valobj,
+ std::shared_ptr ctx) {
+  assert(valobj->IsArrayType() &&
+ "an argument to array-to-pointer conversion must be an array");
+
+  uint64_t addr = valobj->GetLoadAddress();
+  llvm::StringRef name = "result";
+  ExecutionContext exe_ctx;
+  ctx->CalculateExecutionContext(exe_ctx);
+  return ValueObject::CreateValueObjectFromAddress(
+  name, addr, exe_ctx,
+  
valobj->GetCompilerType().GetArrayElementType(ctx.get()).GetPointerType(),
+  /* do_deref */ false);
+}
+

kuilpd wrote:

I'm not quite sure here, how would we go about implementing something like 
array to pointer conversion for C only (or any other language specific thing)? 
Do we just add an `if (Language::LanguageIsCFamily()` check 
`ValueObject::Dereference` or is there a better way to delegate it to 
TypeSystemClang?

https://github.com/llvm/llvm-project/pull/134428
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)

2025-04-10 Thread via lldb-commits

https://github.com/GeorgeHuyubo reopened 
https://github.com/llvm/llvm-project/pull/134563
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add locate time and all symbol file path for each module in statistics (PR #134563)

2025-04-10 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/134563

>From 4c4a2bf0883fee1939ed6dd4c55826688d75466c Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Thu, 10 Apr 2025 13:03:43 -0700
Subject: [PATCH] Add download time for each module in statistics

---
 lldb/include/lldb/Core/PluginManager.h|  7 ++--
 lldb/include/lldb/Symbol/ObjectFile.h |  4 +++
 lldb/include/lldb/Symbol/SymbolFile.h |  5 +++
 lldb/include/lldb/Target/Statistics.h |  1 +
 lldb/source/Core/DynamicLoader.cpp| 36 ---
 lldb/source/Core/ModuleList.cpp   | 14 ++--
 lldb/source/Core/PluginManager.cpp| 16 ++---
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 28 ---
 .../SymbolFile/DWARF/SymbolFileDWARF.h|  3 ++
 .../SymbolVendor/ELF/SymbolVendorELF.cpp  | 24 ++---
 lldb/source/Target/Statistics.cpp |  9 +
 11 files changed, 125 insertions(+), 22 deletions(-)

diff --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index a6dab045adf27..dfa7bfa6eb9da 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -377,11 +377,14 @@ class PluginManager {
   static SymbolLocatorCreateInstance
   GetSymbolLocatorCreateCallbackAtIndex(uint32_t idx);
 
-  static ModuleSpec LocateExecutableObjectFile(const ModuleSpec &module_spec);
+  static ModuleSpec
+  LocateExecutableObjectFile(const ModuleSpec &module_spec,
+ std::string *locator_name = nullptr);
 
   static FileSpec
   LocateExecutableSymbolFile(const ModuleSpec &module_spec,
- const FileSpecList &default_search_paths);
+ const FileSpecList &default_search_paths,
+ std::string *locator_name = nullptr);
 
   static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec,
   Status &error,
diff --git a/lldb/include/lldb/Symbol/ObjectFile.h 
b/lldb/include/lldb/Symbol/ObjectFile.h
index cfcca04a76de8..27357b5b4194d 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -13,6 +13,7 @@
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/Symbol/Symtab.h"
 #include "lldb/Symbol/UnwindTable.h"
+#include "lldb/Target/Statistics.h"
 #include "lldb/Utility/AddressableBits.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/Endian.h"
@@ -589,6 +590,8 @@ class ObjectFile : public 
std::enable_shared_from_this,
   /// this routine to set eTypeDebugInfo when loading debug link files.
   virtual void SetType(Type type) { m_type = type; }
 
+  virtual StatsDuration &GetDownloadTime() { return m_download_time; }
+
   /// The object file should be able to calculate the strata of the object
   /// file.
   ///
@@ -752,6 +755,7 @@ class ObjectFile : public 
std::enable_shared_from_this,
 
 protected:
   // Member variables.
+  StatsDuration m_download_time; ///< Time to download the object file
   FileSpec m_file;
   Type m_type;
   Strata m_strata;
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index f35d3ee9f22ae..2e69acbe34c21 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -422,6 +422,11 @@ class SymbolFile : public PluginInterface {
   /// hasn't been indexed yet, or a valid duration if it has.
   virtual StatsDuration::Duration GetDebugInfoIndexTime() { return {}; }
 
+  /// Return the time it took to download any extra symbol files.
+  ///
+  /// \returns 0.0 if no extra symbol files need to be downloaded
+  virtual StatsDuration::Duration GetSymbolDownloadTime() { return {}; }
+
   /// Reset the statistics for the symbol file.
   virtual void ResetStatistics() {}
 
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index ee365357fcf31..2d3a7fcceec53 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -122,6 +122,7 @@ struct ModuleStats {
   double symtab_index_time = 0.0;
   double debug_parse_time = 0.0;
   double debug_index_time = 0.0;
+  double symbol_download_time = 0.0;
   uint64_t debug_info_size = 0;
   bool symtab_loaded_from_cache = false;
   bool symtab_saved_to_cache = false;
diff --git a/lldb/source/Core/DynamicLoader.cpp 
b/lldb/source/Core/DynamicLoader.cpp
index 76c71d2a49a48..cd9a92db50be4 100644
--- a/lldb/source/Core/DynamicLoader.cpp
+++ b/lldb/source/Core/DynamicLoader.cpp
@@ -16,6 +16,7 @@
 #include "lldb/Core/Progress.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
@@ -25,6 +26,8 @@
 #include "lldb/Utility/Log.h"
 #include "lldb/lldb-private-interfaces.h"
 
+#include "Plugins/Symbo

  1   2   >