[Lldb-commits] [lldb] [lldb-dap] Creating a common configuration structure for launch and attach requests. (PR #133960)

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


@@ -118,6 +118,81 @@ bool fromJSON(const llvm::json::Value &, 
InitializeRequestArguments &,
 /// Response to `initialize` request. The capabilities of this debug adapter.
 using InitializeResponseBody = std::optional;
 
+/// DAP Launch and Attach common configurations.
+struct DAPConfiguration {

JDevlieghere wrote:

Nit: Any reason to not call this `Configuration`? We don't prefix everything 
else here with `DAP` and it's already in the `dap::protocol` namespace. 
```suggestion
struct Configuration {
```

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


[Lldb-commits] [lldb] [lldb] Do not bump memory modificator ID when "internal" debugger memory is updated (PR #129092)

2025-04-02 Thread Mikhail Zakharov via lldb-commits

https://github.com/real-mikhail updated 
https://github.com/llvm/llvm-project/pull/129092

>From 1d2da22bceb83cbda54567e5f819e5eef4e6 Mon Sep 17 00:00:00 2001
From: Mikhail Zakharov 
Date: Thu, 27 Feb 2025 18:43:33 +0100
Subject: [PATCH 1/9] [lldb] Do not bump memory modificator ID when "internal"
 debugger memory is updated

This change prevents invalidating and updating values in 
`ValueObject::UpdateValueIfNeeded` when only "internal" debugger memory is 
updated.
Writing to "internal" debugger memory happens when, for instance, user 
expressions are evaluated by pretty printers.
For some collections getting collection size is an expensive operation (it 
requires traversal of the collection) and broken value caching (being 
invalidated after executing expressions) make things worse.
At the same time evaluating user expression with side effects (visible to 
target, not only to debugger) will still bump memory ID because:
1. If expression is evaluated via interpreter: it will cause write to 
"non-internal" memory
2. If expression is JIT-compiled: then to call the function LLDB will write to 
"non-internal" stack memory
---
 lldb/include/lldb/Target/Memory.h |  4 +-
 lldb/source/Target/Memory.cpp |  8 ++
 lldb/source/Target/Process.cpp|  7 +-
 .../Shell/Expr/TestExprWithSideEffect.cpp | 82 +++
 4 files changed, 99 insertions(+), 2 deletions(-)
 create mode 100644 lldb/test/Shell/Expr/TestExprWithSideEffect.cpp

diff --git a/lldb/include/lldb/Target/Memory.h 
b/lldb/include/lldb/Target/Memory.h
index 2d1489a2c96ea..864ef6ca00802 100644
--- a/lldb/include/lldb/Target/Memory.h
+++ b/lldb/include/lldb/Target/Memory.h
@@ -125,6 +125,8 @@ class AllocatedMemoryCache {
 
   bool DeallocateMemory(lldb::addr_t ptr);
 
+  bool IsInCache(lldb::addr_t addr) const;
+
 protected:
   typedef std::shared_ptr AllocatedBlockSP;
 
@@ -133,7 +135,7 @@ class AllocatedMemoryCache {
 
   // Classes that inherit from MemoryCache can see and modify these
   Process &m_process;
-  std::recursive_mutex m_mutex;
+  mutable std::recursive_mutex m_mutex;
   typedef std::multimap PermissionsToBlockMap;
   PermissionsToBlockMap m_memory_map;
 
diff --git a/lldb/source/Target/Memory.cpp b/lldb/source/Target/Memory.cpp
index 5cdd84f6640f0..9bfb8c349aa2c 100644
--- a/lldb/source/Target/Memory.cpp
+++ b/lldb/source/Target/Memory.cpp
@@ -433,3 +433,11 @@ bool AllocatedMemoryCache::DeallocateMemory(lldb::addr_t 
addr) {
 (uint64_t)addr, success);
   return success;
 }
+
+bool AllocatedMemoryCache::IsInCache(lldb::addr_t addr) const {
+  std::lock_guard guard(m_mutex);
+
+  return llvm::any_of(m_memory_map, [addr](const auto &block) {
+return block.second->Contains(addr);
+  });
+}
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 6db582096155f..1150fabf2d0ed 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -2267,6 +2267,7 @@ size_t Process::WriteMemoryPrivate(addr_t addr, const 
void *buf, size_t size,
   return bytes_written;
 }
 
+#define USE_ALLOCATE_MEMORY_CACHE 1
 size_t Process::WriteMemory(addr_t addr, const void *buf, size_t size,
 Status &error) {
   if (ABISP abi_sp = GetABI())
@@ -2279,7 +2280,12 @@ size_t Process::WriteMemory(addr_t addr, const void 
*buf, size_t size,
   if (buf == nullptr || size == 0)
 return 0;
 
+#if defined(USE_ALLOCATE_MEMORY_CACHE)
+  if (!m_allocated_memory_cache.IsInCache(addr))
+m_mod_id.BumpMemoryID();
+#else
   m_mod_id.BumpMemoryID();
+#endif
 
   // We need to write any data that would go where any current software traps
   // (enabled software breakpoints) any software traps (breakpoints) that we
@@ -2408,7 +2414,6 @@ Status 
Process::WriteObjectFile(std::vector entries) {
   return error;
 }
 
-#define USE_ALLOCATE_MEMORY_CACHE 1
 addr_t Process::AllocateMemory(size_t size, uint32_t permissions,
Status &error) {
   if (GetPrivateState() != eStateStopped) {
diff --git a/lldb/test/Shell/Expr/TestExprWithSideEffect.cpp 
b/lldb/test/Shell/Expr/TestExprWithSideEffect.cpp
new file mode 100644
index 0..d072fe3121031
--- /dev/null
+++ b/lldb/test/Shell/Expr/TestExprWithSideEffect.cpp
@@ -0,0 +1,82 @@
+// Tests evaluating expressions with side effects.
+// Applied side effect should be visible to the debugger.
+
+// RUN: %build %s -o %t
+// RUN: %lldb %t -o run \
+// RUN:   -o "frame variable x" \
+// RUN:   -o "expr x.inc()" \
+// RUN:   -o "frame variable x" \
+// RUN:   -o "continue" \
+// RUN:   -o "frame variable x" \
+// RUN:   -o "expr x.i = 10" \
+// RUN:   -o "frame variable x" \
+// RUN:   -o "continue" \
+// RUN:   -o "frame variable x" \
+// RUN:   -o "expr int $y = 11" \
+// RUN:   -o "expr $y" \
+// RUN:   -o "expr $y = 100" \
+// RUN:   -o "expr $y" \
+// RUN:   -o "continue" \
+// RUN:   -o "expr $y" \
+// RUN:   -o exit | FileCheck %s -dump-input=fail
+
+class X
+

[Lldb-commits] [lldb] [lldb][debugserver] Save and restore the SVE/SME register state (PR #134184)

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

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/134184

>From 7cc45f1a300b1b0f2cbb529f11a0f9e56c41ffea Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Wed, 2 Apr 2025 18:05:29 -0700
Subject: [PATCH 1/3] [lldb][debugserver] Save and restore the SVE/SME register
 state

debugserver isn't saving and restoring the SVE/SME register state
around inferior function calls.

Making arbitrary function calls while in Streaming SVE mode is
generally a poor idea because a NEON instruction can be hit and
crash the expression execution, which is how I missed this, but
they should be handled correctly if the user knows it is safe
to do.

rdar://146886210
---
 .../source/MacOSX/arm64/DNBArchImplARM64.cpp  | 30 ++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
index 34a4ee21f8502..fb23744393d43 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -2953,7 +2953,14 @@ kern_return_t DNBArchMachARM64::SetRegisterState(int 
set) {
 
   switch (set) {
   case e_regSetALL:
-return SetGPRState() | SetVFPState() | SetEXCState() | SetDBGState(false);
+  {
+kern_return_t ret = SetGPRState() | SetVFPState() | SetEXCState() | 
SetDBGState(false);
+if (CPUHasSME()) {
+  ret |= SetSVEState();
+  ret |= SetSMEState();
+}
+return ret;
+  }
   case e_regSetGPR:
 return SetGPRState();
   case e_regSetVFP:
@@ -3122,6 +3129,15 @@ uint32_t DNBArchMachARM64::SaveRegisterState() {
 DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::SaveRegisterState () "
  "error: %s regs failed to read: %u",
  "VFP", kret);
+  } else if (CPUHasSME() && (kret = SetSVEState() != KERN_SUCCESS)) {
+DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::SaveRegisterState () "
+ "error: %s regs failed to read: %u",
+ "SVE", kret);
+  }
+  else if (CPUHasSME() && (kret = SetSMEState() != KERN_SUCCESS)) {
+DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::SaveRegisterState () "
+ "error: %s regs failed to read: %u",
+ "SME", kret);
   } else {
 const uint32_t save_id = GetNextRegisterStateSaveID();
 m_saved_register_states[save_id] = m_state.context;
@@ -3149,6 +3165,18 @@ bool DNBArchMachARM64::RestoreRegisterState(uint32_t 
save_id) {
"write: %u",
save_id, "VFP", kret);
   success = false;
+} else if ((kret = SetSVEState()) != KERN_SUCCESS) {
+  DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::RestoreRegisterState "
+   "(save_id = %u) error: %s regs failed to "
+   "write: %u",
+   save_id, "SVE", kret);
+  success = false;
+} else if ((kret = SetSMEState()) != KERN_SUCCESS) {
+  DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::RestoreRegisterState "
+   "(save_id = %u) error: %s regs failed to "
+   "write: %u",
+   save_id, "SME", kret);
+  success = false;
 }
 m_saved_register_states.erase(pos);
 return success;

>From 432a68d8a85b46b7cacd6b64802a394562bc1566 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Wed, 2 Apr 2025 18:28:07 -0700
Subject: [PATCH 2/3] reformat

---
 .../source/MacOSX/arm64/DNBArchImplARM64.cpp  | 42 +++
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
index fb23744393d43..bafcb47503dec 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -2954,7 +2954,8 @@ kern_return_t DNBArchMachARM64::SetRegisterState(int set) 
{
   switch (set) {
   case e_regSetALL:
   {
-kern_return_t ret = SetGPRState() | SetVFPState() | SetEXCState() | 
SetDBGState(false);
+kern_return_t ret =
+SetGPRState() | SetVFPState() | SetEXCState() | SetDBGState(false);
 if (CPUHasSME()) {
   ret |= SetSVEState();
   ret |= SetSMEState();
@@ -3126,17 +3127,19 @@ uint32_t DNBArchMachARM64::SaveRegisterState() {
  "error: GPR regs failed to read: %u ",
  kret);
   } else if ((kret = GetVFPState(force)) != KERN_SUCCESS) {
-DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::SaveRegisterState () "
- "error: %s regs failed to read: %u",
+DNBLogThreadedIf(LOG_THREAD,
+ "DNBArchMachARM64::SaveRegisterState () "
+ "error: %s 

[Lldb-commits] [lldb] [lldb] Fix plugin manager test failure on windows (PR #134173)

2025-04-02 Thread David Peixotto via lldb-commits

dmpots wrote:

This is my guess on what is causing the test failures. Can revert this and the 
original PR if it doesn't work.

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


[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

2025-04-02 Thread via lldb-commits


@@ -0,0 +1,273 @@
+//===-- DILParser.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
+//
+// This implements the recursive descent parser for the Data Inspection
+// Language (DIL), and its helper functions, which will eventually underlie the
+// 'frame variable' command. The language that this parser recognizes is
+// described in lldb/docs/dil-expr-lang.ebnf
+//
+//===--===//
+
+#include "lldb/ValueObject/DILParser.h"
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Utility/DiagnosticsRendering.h"
+#include "lldb/ValueObject/DILAST.h"
+#include "lldb/ValueObject/DILEval.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatAdapters.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace lldb_private::dil {
+
+std::string FormatDiagnostics(llvm::StringRef text, const std::string &message,
+  uint32_t loc, uint16_t err_len) {
+  DiagnosticDetail::SourceLocation sloc = {
+  FileSpec{}, /*line=*/1, static_cast(loc + 1),
+  err_len,false,  /*in_user_input=*/true};
+  std::string arrow_str = "^";
+  std::string rendered_msg =
+  llvm::formatv(":1:{0}: {1}\n1 | {2}\n | ^",
+loc + 1, message, text);
+  DiagnosticDetail detail;
+  detail.source_location = sloc;
+  detail.severity = lldb::eSeverityError;
+  detail.message = message;
+  detail.rendered = rendered_msg;
+  std::vector diagnostics;
+  diagnostics.push_back(detail);
+  StreamString diag_stream(true);
+  RenderDiagnosticDetails(diag_stream, 7, true, diagnostics);
+  std::string ret_str = text.str() + "\n" + diag_stream.GetString().str();
+  return ret_str;
+}
+
+llvm::Expected
+DILParser::Parse(llvm::StringRef dil_input_expr, DILLexer lexer,
+ std::shared_ptr frame_sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic,
+ bool fragile_ivar, bool check_ptr_vs_member) {
+  Status error;
+  DILParser parser(dil_input_expr, lexer, frame_sp, use_dynamic, use_synthetic,
+   fragile_ivar, check_ptr_vs_member, error);
+  return parser.Run();

cmtice wrote:

Done.

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


[Lldb-commits] [lldb] [LLDB] Expose checking if the symbol file exists/is loaded via SBModule (PR #134163)

2025-04-02 Thread Jacob Lalonde via lldb-commits

Jlalond wrote:

Seems unrelated, but I will check in the morning.

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


[Lldb-commits] [lldb] [lldb] Use the "reverse video" effect when colors are disabled. (PR #134203)

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

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

When you run lldb without colors (`-X), the status line looks weird because it 
doesn't have a background. You end up with what appears to be floating text at 
the bottom of your terminal.

This patch changes the statusline to use the reverse video effect, even when 
colors are off. The effect doesn't introduce any new colors and just inverts 
the foreground and background color.

I considered an alternative approach which changes the behavior of the `-X` 
option, so that turning off colors doesn't prevent emitting non-color related 
control characters such as bold, underline, and reverse video. I decided to go 
with this more targeted fix as (1) nobody is asking for this more general 
change and (2) it introduces significant complexity to plumb this through using 
a setting and driver flag so that it can be disabled when running the tests.

Fixes #134112.

>From c5df5b2684a42f11c13efa6b03a28ea4e8ff900e Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 2 Apr 2025 22:52:39 -0700
Subject: [PATCH] [lldb] Use the "reverse video" effect when colors are
 disabled.

When you run lldb without colors (`-X), the status line looks weird
because it doesn't have a background. You end up with what appears to be
floating text at the bottom of your terminal.

This patch changes the statusline to use the reverse video effect, even
when colors are off. The effect doesn't introduce any new colors and
just inverts the foreground and background color.

I considered an alternative approach which changes the behavior of the
`-X` option, so that turning off colors doesn't prevent emitting
non-color related control characters such as bold, underline, and
reverse video. I decided to go with this more targeted fix as (1) nobody
is asking for this more general change and (2) it introduces significant
complexity to plumb this through using a setting and driver flag so that
it can be disabled when running the tests.

Fixes #134112.
---
 lldb/source/Core/Statusline.cpp   |  7 ++
 .../statusline/TestStatusline.py  | 23 +++
 2 files changed, 30 insertions(+)

diff --git a/lldb/source/Core/Statusline.cpp b/lldb/source/Core/Statusline.cpp
index c18fbb6c5561e..b7650503e16bc 100644
--- a/lldb/source/Core/Statusline.cpp
+++ b/lldb/source/Core/Statusline.cpp
@@ -27,6 +27,7 @@
 #define ANSI_CLEAR_LINE ESCAPE "[2K"
 #define ANSI_SET_SCROLL_ROWS ESCAPE "[0;%ur"
 #define ANSI_TO_START_OF_ROW ESCAPE "[%u;0f"
+#define ANSI_REVERSE_VIDEO ESCAPE "[7m"
 #define ANSI_UP_ROWS ESCAPE "[%dA"
 
 using namespace lldb;
@@ -74,6 +75,12 @@ void Statusline::Draw(std::string str) {
   locked_stream << ANSI_SAVE_CURSOR;
   locked_stream.Printf(ANSI_TO_START_OF_ROW,
static_cast(m_terminal_height));
+
+  // Use "reverse video" to make sure the statusline has a background. Only do
+  // this when colors are disabled, and rely on the statusline format 
otherwise.
+  if (!m_debugger.GetUseColor())
+locked_stream << ANSI_REVERSE_VIDEO;
+
   locked_stream << str;
   locked_stream << ANSI_NORMAL;
   locked_stream << ANSI_RESTORE_CURSOR;
diff --git a/lldb/test/API/functionalities/statusline/TestStatusline.py 
b/lldb/test/API/functionalities/statusline/TestStatusline.py
index a58dc5470ed6d..391f788b9df48 100644
--- a/lldb/test/API/functionalities/statusline/TestStatusline.py
+++ b/lldb/test/API/functionalities/statusline/TestStatusline.py
@@ -55,3 +55,26 @@ def test(self):
 self.expect(
 "set set show-statusline false", 
["\x1b[0;{}r".format(terminal_height)]
 )
+
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+def test_no_color(self):
+"""Basic test for the statusline with colors disabled."""
+self.build()
+self.launch(use_colors=False)
+self.do_setup()
+
+# Change the terminal dimensions.
+terminal_height = 10
+terminal_width = 60
+self.child.setwinsize(terminal_height, terminal_width)
+
+# Enable the statusline and check for the "reverse video" control 
character.
+self.expect(
+"set set show-statusline true",
+[
+"\x1b[7m",
+],
+)

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


[Lldb-commits] [lldb] [lldb] Use the "reverse video" effect when colors are disabled. (PR #134203)

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

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


[Lldb-commits] [lldb] [lldb] Use the "reverse video" effect when colors are disabled. (PR #134203)

2025-04-02 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r HEAD~1...HEAD 
lldb/test/API/functionalities/statusline/TestStatusline.py
``





View the diff from darker here.


``diff
--- TestStatusline.py   2025-04-03 05:52:39.00 +
+++ TestStatusline.py   2025-04-03 06:03:48.562575 +
@@ -54,11 +54,10 @@
 # Hide the statusline and check or the control character.
 self.expect(
 "set set show-statusline false", 
["\x1b[0;{}r".format(terminal_height)]
 )
 
-
 # PExpect uses many timeouts internally and doesn't play well
 # under ASAN on a loaded machine..
 @skipIfAsan
 def test_no_color(self):
 """Basic test for the statusline with colors disabled."""

``




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


[Lldb-commits] [lldb] [lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame if one exists (PR #134097)

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

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


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


[Lldb-commits] [lldb] [lldb] Clear thread name container before writing UTF8 bytes (PR #134150)

2025-04-02 Thread Karl Traunmüller via lldb-commits

ktraunmueller wrote:

Thank you!

FYI, I created a [bug 
report](https://github.com/llvm/llvm-project/issues/133904) (which can now be 
closed) for this problem, but forgot to add that information to the Swift forum 
post, sorry for that.

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


[Lldb-commits] [lldb] [lldb][NFC] Move ShouldShow/ShouldSelect logic into Stopinfo (PR #134160)

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

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


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


[Lldb-commits] [lldb] [lldb] Fix tagged-pointer info address parsing (PR #134123)

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

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


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


[Lldb-commits] [lldb] [lldb-dap] Make TestDAP_Progress more resilient (again) (PR #134157)

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

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

>From 50b4967465b16955c2ac144044680c2e889445c7 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 2 Apr 2025 15:10:25 -0700
Subject: [PATCH] [lldb-dap] Add progress events to the packet list

Before #134048, TestDAP_Progress relied on wait_for_event to block until
the progressEnd came in. However, progress events were not added to the
packet list, so this call would always time out. This PR makes it so
that packets are added to the packet list, and you can block on them.
---
 .../packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py | 2 --
 lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py   | 1 +
 2 files changed, 1 insertion(+), 2 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 01ef4b68f2653..45403e9df8525 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
@@ -255,8 +255,6 @@ def handle_recv_packet(self, packet):
 # and 'progressEnd' events. Keep these around in case test
 # cases want to verify them.
 self.progress_events.append(packet)
-# No need to add 'progress' event packets to our packets list.
-return keepGoing
 
 elif packet_type == "response":
 if packet["command"] == "disconnect":
diff --git a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py 
b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
index ffe3d38eb49a3..fee63655de0da 100755
--- a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
+++ b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
@@ -19,6 +19,7 @@ def verify_progress_events(
 expected_not_in_message=None,
 only_verify_first_update=False,
 ):
+self.dap_server.wait_for_event("progressEnd")
 self.assertTrue(len(self.dap_server.progress_events) > 0)
 start_found = False
 update_found = False

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


[Lldb-commits] [lldb] [lldb-dap] Add progress events to the packet list (PR #134157)

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

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


[Lldb-commits] [lldb] [lldb][NFC] Move ShouldShow/ShouldSelect logic into Stopinfo (PR #134160)

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

felipepiovezan wrote:

Addressed review comments

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


[Lldb-commits] [lldb] [LLDB] Expose checking if the symbol file exists/is loaded via SBModule (PR #134163)

2025-04-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)


Changes

The motivation for this patch is that in Statistics.cpp we [check to see if the 
module symfile is 
loaded](https://github.com/llvm/llvm-project/blob/990a086d9da0bc2fd53a6a4c95ecbbe23a297a83/lldb/source/Target/Statistics.cpp#L353C60-L353C75)
 to calculate how much debug info has been loaded. I have an external utility 
that only wants to look at the loaded debug info, which isn't exposed by the 
SBAPI.

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


2 Files Affected:

- (modified) lldb/include/lldb/API/SBModule.h (+3) 
- (modified) lldb/source/API/SBModule.cpp (+12) 


``diff
diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h
index 85332066ee687..651455bdb78d2 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -290,6 +290,9 @@ class LLDB_API SBModule {
   lldb::SBAddress GetObjectFileHeaderAddress() const;
   lldb::SBAddress GetObjectFileEntryPointAddress() const;
 
+  /// Get if the symbol file for this module is loaded.
+  bool IsDebugInfoLoaded() const;
+
   /// Get the number of global modules.
   static uint32_t GetNumberAllocatedModules();
 
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 985107ec68efd..4978a553f57c7 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -659,6 +659,18 @@ lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() 
const {
   return sb_addr;
 }
 
+bool SBModule::IsDebugInfoLoaded() const {
+  LLDB_INSTRUMENT_VA(this);
+
+  ModuleSP module_sp(GetSP());
+  if (module_sp) {
+SymbolFile *sym_file = module_sp->GetSymbolFile(/*create=*/false);
+return sym_file && sym_file->GetLoadDebugInfoEnabled();
+  }
+
+  return false;
+}
+
 uint32_t SBModule::GetNumberAllocatedModules() {
   LLDB_INSTRUMENT();
 

``




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


[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

2025-04-02 Thread Vy Nguyen via lldb-commits


@@ -965,6 +965,22 @@ SBTarget SBDebugger::GetDummyTarget() {
   return sb_target;
 }
 
+void SBDebugger::DispatchClientTelemetry(const lldb::SBStructuredData &entry) {
+  LLDB_INSTRUMENT_VA(this);
+  // Disable client-telemetry for SWIG.
+  // This prevent arbitrary python client (pretty printers, whatnot) from 
sending
+  // telemetry without vendors knowing.
+#ifndef SWIG

oontvoo wrote:

Hi, is there any other comment/feedback for this patch? Thanks!

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


[Lldb-commits] [lldb] 3f7ca88 - [lldb-dap] Add progress events to the packet list (#134157)

2025-04-02 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-04-02T15:33:07-07:00
New Revision: 3f7ca8826776f32526e948b89816db492435f2e2

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

LOG: [lldb-dap] Add progress events to the packet list (#134157)

Before #134048, TestDAP_Progress relied on wait_for_event to block until
the progressEnd came in. However, progress events were not added to the
packet list, so this call would always time out. This PR makes it so
that packets are added to the packet list, and you can block on them.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py

Removed: 




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 01ef4b68f2653..45403e9df8525 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
@@ -255,8 +255,6 @@ def handle_recv_packet(self, packet):
 # and 'progressEnd' events. Keep these around in case test
 # cases want to verify them.
 self.progress_events.append(packet)
-# No need to add 'progress' event packets to our packets list.
-return keepGoing
 
 elif packet_type == "response":
 if packet["command"] == "disconnect":

diff  --git a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py 
b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
index ffe3d38eb49a3..fee63655de0da 100755
--- a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
+++ b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
@@ -19,6 +19,7 @@ def verify_progress_events(
 expected_not_in_message=None,
 only_verify_first_update=False,
 ):
+self.dap_server.wait_for_event("progressEnd")
 self.assertTrue(len(self.dap_server.progress_events) > 0)
 start_found = False
 update_found = False



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


[Lldb-commits] [lldb] 93d3775 - [lldb] Fix tagged-pointer info address parsing (#134123)

2025-04-02 Thread via lldb-commits

Author: Dave Lee
Date: 2025-04-02T15:16:58-07:00
New Revision: 93d3775da8810e1542873b1cdcec2ea142704561

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

LOG: [lldb] Fix tagged-pointer info address parsing (#134123)

Change `objc tagged-pointer info` to call
`OptionArgParser::ToRawAddress`.

Previously `ToAddress` was used, but it calls `FixCodeAddress`, which
can erroneously mutate the bits of a tagged pointer.

Added: 


Modified: 

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index c91a29ace1f68..2338367302387 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -1047,7 +1047,7 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info
 continue;
 
   Status error;
-  lldb::addr_t arg_addr = OptionArgParser::ToAddress(
+  lldb::addr_t arg_addr = OptionArgParser::ToRawAddress(
   &exe_ctx, arg_str, LLDB_INVALID_ADDRESS, &error);
   if (arg_addr == 0 || arg_addr == LLDB_INVALID_ADDRESS || error.Fail()) {
 result.AppendErrorWithFormatv(

diff  --git a/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py 
b/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py
index d2519359c783b..f2f6026642d20 100644
--- a/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py
+++ b/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py
@@ -8,10 +8,22 @@ class TestTaggedPointerCommand(TestBase):
 @no_debug_info_test
 def test(self):
 self.build()
-lldbutil.run_to_source_breakpoint(
+_, _, thread, _ = lldbutil.run_to_source_breakpoint(
 self, "// break here", lldb.SBFileSpec("main.m")
 )
 
+n1 = thread.GetSelectedFrame().FindVariable("n1")
+self.expect(
+f"lang objc tagged-pointer info {n1.addr}",
+substrs=[
+f"{n1.addr} is tagged",
+"payload = 0x0012",
+"value = 0x0001",
+"info bits = 0x0002",
+"class = __NSCFNumber",
+],
+)
+
 self.expect(
 "lang objc tagged-pointer info bogus",
 error=True,



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


[Lldb-commits] [lldb] [lldb] Clear thread name container before writing UTF8 bytes (PR #134150)

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

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


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


[Lldb-commits] [lldb] [lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame if one exists (PR #134097)

2025-04-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

When using `SBFrame::EvaluateExpression` on a frame that's not the currently 
selected frame, we would sometimes run into errors such as:
```
error: error: The context has changed before we could JIT the expression!
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
```

During expression parsing, we call `RunStaticInitializers`. On our internal 
fork this happens quite frequently because any usage of, e.g., function 
pointers, will inject ptrauth fixup code into the expression.  The static 
initializers are run using `RunThreadPlan`. The `ExecutionContext::m_frame_sp` 
going into the `RunThreadPlan` is the `SBFrame` that we called 
`EvaluateExpression` on. LLDB then tries to save this frame to restore it after 
the thread-plan ran (the restore occurs by unconditionally overwriting whatever 
is in `ExecutionContext::m_frame_sp`). However, if the `selected_frame_sp` is 
not the same as the `SBFrame`, then `RunThreadPlan` would set the 
`ExecutionContext`'s frame to a different frame than what we started with. When 
we `PrepareToExecuteJITExpression`, LLDB checks whether the `ExecutionContext` 
frame changed from when we initially `EvaluateExpression`, and if did, bails 
out with the error above.

One such test-case is attached. This currently passes regardless of the fix 
because our ptrauth static initializers code isn't upstream yet. But the plan 
is to upstream it soon.

This patch addresses the issue by saving/restoring the frame of the incoming 
`ExecutionContext`, if such frame exists. Otherwise, fall back to using the 
selected frame.

rdar://147456589

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


4 Files Affected:

- (modified) lldb/source/Target/Process.cpp (+7-1) 
- (added) lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile 
(+3) 
- (added) 
lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
 (+28) 
- (added) lldb/test/API/commands/expression/expr-from-non-zero-frame/main.cpp 
(+6) 


``diff
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 369933234ccca..f4ecb0b7ea307 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5080,7 +5080,13 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
 return eExpressionSetupError;
   }
 
-  StackID ctx_frame_id = selected_frame_sp->GetStackID();
+  // If the ExecutionContext has a frame, we want to make sure to save/restore
+  // that frame into exe_ctx. This can happen when we run expressions from a
+  // non-selected SBFrame, in which case we don't want some thread-plan
+  // to overwrite the ExecutionContext frame.
+  StackID ctx_frame_id = exe_ctx.HasFrameScope()
+ ? exe_ctx.GetFrameRef().GetStackID()
+ : selected_frame_sp->GetStackID();
 
   // N.B. Running the target may unset the currently selected thread and frame.
   // We don't want to do that either, so we should arrange to reset them as
diff --git 
a/lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile 
b/lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile
new file mode 100644
index 0..8b20bcb05
--- /dev/null
+++ b/lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git 
a/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
 
b/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
new file mode 100644
index 0..692d24fd2c332
--- /dev/null
+++ 
b/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
@@ -0,0 +1,28 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ExprFromNonZeroFrame(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test(self):
+"""
+Tests that we can use SBFrame::EvaluateExpression on a frame
+that we're not stopped in, even if thread-plans run as part of
+parsing the expression (e.g., when running static initializers).
+"""
+self.build()
+
+(_, _, thread, _) = lldbutil.run_to_source_breakpoint(
+self, "Break here", lldb.SBFileSpec("main.cpp")
+)
+frame = thread.GetFrameAtIndex(1)
+
+# Using a function pointer inside the expression ensures we
+# emit a ptrauth static initializer on arm64e into the JITted
+# expression. The thread-plan that runs for this static
+# initializer should save/restore the current execution context
+# frame (which in this test is frame #1).
+frame.EvaluateExpression("void (*fptr)() = &func; fptr()")
diff --git 
a/lldb/test/API/commands/expression/expr-from-non-zero

[Lldb-commits] [lldb] b55bab2 - [lldb] Fix plugin manager test failure on windows (#134173)

2025-04-02 Thread via lldb-commits

Author: David Peixotto
Date: 2025-04-02T17:22:46-07:00
New Revision: b55bab229228218341e2f24fc8529c7aaab51e2f

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

LOG: [lldb] Fix plugin manager test failure on windows (#134173)

This is an attempt to fix a test failure from #133794 when running on
windows builds. I suspect we are running into a case where the
[ICF](https://learn.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=msvc-170)
optimization kicks in and combines the CreateSystemRuntimePlugin*
functions into a single address. This means that we cannot uniquely
unregister the plugin based on its create function address.

The fix is have each create function return a different (bogus) value.

Added: 


Modified: 
lldb/unittests/Core/PluginManagerTest.cpp

Removed: 




diff  --git a/lldb/unittests/Core/PluginManagerTest.cpp 
b/lldb/unittests/Core/PluginManagerTest.cpp
index ca1003ca9a85a..9b0ce2286d273 100644
--- a/lldb/unittests/Core/PluginManagerTest.cpp
+++ b/lldb/unittests/Core/PluginManagerTest.cpp
@@ -7,11 +7,21 @@ using namespace lldb;
 using namespace lldb_private;
 
 // Mock system runtime plugin create functions.
-SystemRuntime *CreateSystemRuntimePluginA(Process *process) { return nullptr; }
+// Make them all return 
diff erent values to avoid the ICF optimization
+// from combining them into the same function. The values returned
+// are not valid SystemRuntime pointers, but they are unique and
+// sufficient for testing.
+SystemRuntime *CreateSystemRuntimePluginA(Process *process) {
+  return (SystemRuntime *)0x1;
+}
 
-SystemRuntime *CreateSystemRuntimePluginB(Process *process) { return nullptr; }
+SystemRuntime *CreateSystemRuntimePluginB(Process *process) {
+  return (SystemRuntime *)0x2;
+}
 
-SystemRuntime *CreateSystemRuntimePluginC(Process *process) { return nullptr; }
+SystemRuntime *CreateSystemRuntimePluginC(Process *process) {
+  return (SystemRuntime *)0x3;
+}
 
 // Test class for testing the PluginManager.
 // The PluginManager modifies global state when registering new plugins. This
@@ -24,6 +34,10 @@ class PluginManagerTest : public testing::Test {
 
   // Add mock system runtime plugins for testing.
   void RegisterMockSystemRuntimePlugins() {
+// Make sure the create functions all have 
diff erent addresses.
+ASSERT_NE(CreateSystemRuntimePluginA, CreateSystemRuntimePluginB);
+ASSERT_NE(CreateSystemRuntimePluginB, CreateSystemRuntimePluginC);
+
 ASSERT_TRUE(PluginManager::RegisterPlugin("a", "test instance A",
   CreateSystemRuntimePluginA));
 ASSERT_TRUE(PluginManager::RegisterPlugin("b", "test instance B",



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


[Lldb-commits] [lldb] [lldb] Fix plugin manager test failure on windows (PR #134173)

2025-04-02 Thread David Peixotto via lldb-commits

dmpots wrote:

The windows bots are now passing on this test so I think it was ICF that was 
the problem: https://lab.llvm.org/buildbot/#/changes/32645

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


[Lldb-commits] [lldb] [lldb] Fix plugin manager test failure on windows (PR #134173)

2025-04-02 Thread David Peixotto via lldb-commits

https://github.com/dmpots created 
https://github.com/llvm/llvm-project/pull/134173

This is an attempt to fix a test failure from #133794 when running on windows 
builds. I suspect we are running into a case where the 
[ICF](https://learn.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=msvc-170)
 optimization kicks in and combines the CreateSystemRuntimePlugin* functions 
into a single address. This means that we cannot uniquely unregister the plugin 
based on its create function address.

The fix is have each create function return a different (bogus) value.

>From 99870557937f87277d62d8ec1fb511ad2e7c8aed Mon Sep 17 00:00:00 2001
From: David Peixotto 
Date: Wed, 2 Apr 2025 16:06:06 -0700
Subject: [PATCH] [lldb] Fix plugin manager test failure on windows

This is an attempt to fix a test failure from #133794 when running on
windows builds. I suspect we are running into a case where the
[ICF](https://learn.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=msvc-170)
optimization kicks in and combines the CreateSystemRuntimePlugin*
functions into a single address. This means that we cannot uniquely
unregister the plugin based on its create function address.

The fix is have each create function return a different (bogus)
value.
---
 lldb/unittests/Core/PluginManagerTest.cpp | 20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/lldb/unittests/Core/PluginManagerTest.cpp 
b/lldb/unittests/Core/PluginManagerTest.cpp
index ca1003ca9a85a..9b0ce2286d273 100644
--- a/lldb/unittests/Core/PluginManagerTest.cpp
+++ b/lldb/unittests/Core/PluginManagerTest.cpp
@@ -7,11 +7,21 @@ using namespace lldb;
 using namespace lldb_private;
 
 // Mock system runtime plugin create functions.
-SystemRuntime *CreateSystemRuntimePluginA(Process *process) { return nullptr; }
+// Make them all return different values to avoid the ICF optimization
+// from combining them into the same function. The values returned
+// are not valid SystemRuntime pointers, but they are unique and
+// sufficient for testing.
+SystemRuntime *CreateSystemRuntimePluginA(Process *process) {
+  return (SystemRuntime *)0x1;
+}
 
-SystemRuntime *CreateSystemRuntimePluginB(Process *process) { return nullptr; }
+SystemRuntime *CreateSystemRuntimePluginB(Process *process) {
+  return (SystemRuntime *)0x2;
+}
 
-SystemRuntime *CreateSystemRuntimePluginC(Process *process) { return nullptr; }
+SystemRuntime *CreateSystemRuntimePluginC(Process *process) {
+  return (SystemRuntime *)0x3;
+}
 
 // Test class for testing the PluginManager.
 // The PluginManager modifies global state when registering new plugins. This
@@ -24,6 +34,10 @@ class PluginManagerTest : public testing::Test {
 
   // Add mock system runtime plugins for testing.
   void RegisterMockSystemRuntimePlugins() {
+// Make sure the create functions all have different addresses.
+ASSERT_NE(CreateSystemRuntimePluginA, CreateSystemRuntimePluginB);
+ASSERT_NE(CreateSystemRuntimePluginB, CreateSystemRuntimePluginC);
+
 ASSERT_TRUE(PluginManager::RegisterPlugin("a", "test instance A",
   CreateSystemRuntimePluginA));
 ASSERT_TRUE(PluginManager::RegisterPlugin("b", "test instance B",

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


[Lldb-commits] [lldb] [lldb-dap] Add a -v/--version command line argument (PR #134114)

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

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


[Lldb-commits] [lldb] 4e40c7c - [lldb][debugserver] Save and restore the SVE/SME register state (#134184)

2025-04-02 Thread via lldb-commits

Author: Jason Molenda
Date: 2025-04-02T20:37:07-07:00
New Revision: 4e40c7c4bd66d98f529a807dbf410dc46444f4ca

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

LOG: [lldb][debugserver] Save and restore the SVE/SME register state (#134184)

debugserver isn't saving and restoring the SVE/SME register state around
inferior function calls.

Making arbitrary function calls while in Streaming SVE mode is generally
a poor idea because a NEON instruction can be hit and crash the
expression execution, which is how I missed this, but they should be
handled correctly if the user knows it is safe to do.

rdar://146886210

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
index 34a4ee21f8502..d32a63daa5672 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -2952,8 +2952,15 @@ kern_return_t DNBArchMachARM64::SetRegisterState(int 
set) {
 return err;
 
   switch (set) {
-  case e_regSetALL:
-return SetGPRState() | SetVFPState() | SetEXCState() | SetDBGState(false);
+  case e_regSetALL: {
+kern_return_t ret =
+SetGPRState() | SetVFPState() | SetEXCState() | SetDBGState(false);
+if (CPUHasSME()) {
+  ret |= SetSVEState();
+  ret |= SetSMEState();
+}
+return ret;
+  }
   case e_regSetGPR:
 return SetGPRState();
   case e_regSetVFP:
@@ -3119,9 +3126,20 @@ uint32_t DNBArchMachARM64::SaveRegisterState() {
  "error: GPR regs failed to read: %u ",
  kret);
   } else if ((kret = GetVFPState(force)) != KERN_SUCCESS) {
-DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::SaveRegisterState () "
- "error: %s regs failed to read: %u",
+DNBLogThreadedIf(LOG_THREAD,
+ "DNBArchMachARM64::SaveRegisterState () "
+ "error: %s regs failed to read: %u",
  "VFP", kret);
+  } else if (CPUHasSME() && (kret = SetSVEState() != KERN_SUCCESS)) {
+DNBLogThreadedIf(LOG_THREAD,
+ "DNBArchMachARM64::SaveRegisterState () "
+ "error: %s regs failed to read: %u",
+ "SVE", kret);
+  } else if (CPUHasSME() && (kret = SetSMEState() != KERN_SUCCESS)) {
+DNBLogThreadedIf(LOG_THREAD,
+ "DNBArchMachARM64::SaveRegisterState () "
+ "error: %s regs failed to read: %u",
+ "SME", kret);
   } else {
 const uint32_t save_id = GetNextRegisterStateSaveID();
 m_saved_register_states[save_id] = m_state.context;
@@ -3144,11 +3162,26 @@ bool DNBArchMachARM64::RestoreRegisterState(uint32_t 
save_id) {
save_id, kret);
   success = false;
 } else if ((kret = SetVFPState()) != KERN_SUCCESS) {
-  DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::RestoreRegisterState "
-   "(save_id = %u) error: %s regs failed to "
-   "write: %u",
+  DNBLogThreadedIf(LOG_THREAD,
+   "DNBArchMachARM64::RestoreRegisterState "
+   "(save_id = %u) error: %s regs failed to "
+   "write: %u",
save_id, "VFP", kret);
   success = false;
+} else if ((kret = SetSVEState()) != KERN_SUCCESS) {
+  DNBLogThreadedIf(LOG_THREAD,
+   "DNBArchMachARM64::RestoreRegisterState "
+   "(save_id = %u) error: %s regs failed to "
+   "write: %u",
+   save_id, "SVE", kret);
+  success = false;
+} else if ((kret = SetSMEState()) != KERN_SUCCESS) {
+  DNBLogThreadedIf(LOG_THREAD,
+   "DNBArchMachARM64::RestoreRegisterState "
+   "(save_id = %u) error: %s regs failed to "
+   "write: %u",
+   save_id, "SME", kret);
+  success = false;
 }
 m_saved_register_states.erase(pos);
 return success;



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


[Lldb-commits] [lldb] [lldb/DWARF] Remove "range lower than function low_pc" check (PR #132395)

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

labath wrote:

Ping.

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


[Lldb-commits] [lldb] [lldb] Respect LaunchInfo::SetExecutable in ProcessLauncherPosixFork (PR #133093)

2025-04-02 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Respect LaunchInfo::SetExecutable in ProcessLauncherPosixFork (PR #133093)

2025-04-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

/cherry-pick 39e7efe1e4304544289d8d1b45f4d04d11b4a791

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


[Lldb-commits] [lldb] [lldb] Respect LaunchInfo::SetExecutable in ProcessLauncherPosixFork (PR #133093)

2025-04-02 Thread via lldb-commits

llvmbot wrote:

/pull-request llvm/llvm-project#134079

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


[Lldb-commits] [lldb] [lldb] Remove UnwindPlan::Row shared_ptrs, lite (PR #134081)

2025-04-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

Replace with std::unique_ptr. Previous attempt at replacing them with values 
failed because x86AssemblyInspectionEngine was storing pointers to the rows 
while modifying the plan. Changing that is relatively easy, but I'm not sure if 
that's an improvement.

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


2 Files Affected:

- (modified) lldb/include/lldb/Symbol/UnwindPlan.h (+4-4) 
- (modified) lldb/source/Symbol/UnwindPlan.cpp (+6-6) 


``diff
diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h 
b/lldb/include/lldb/Symbol/UnwindPlan.h
index 9adda27b8f928..a0032d6e777c7 100644
--- a/lldb/include/lldb/Symbol/UnwindPlan.h
+++ b/lldb/include/lldb/Symbol/UnwindPlan.h
@@ -428,7 +428,7 @@ class UnwindPlan {
 bool m_unspecified_registers_are_undefined = false;
   }; // class Row
 
-  typedef std::shared_ptr RowSP;
+  typedef std::unique_ptr RowUP;
 
   UnwindPlan(lldb::RegisterKind reg_kind)
   : m_register_kind(reg_kind), m_return_addr_register(LLDB_INVALID_REGNUM),
@@ -449,8 +449,8 @@ class UnwindPlan {
 m_lsda_address(rhs.m_lsda_address),
 m_personality_func_addr(rhs.m_personality_func_addr) {
 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));
+for (const RowUP &row_up : rhs.m_row_list)
+  m_row_list.emplace_back(new Row(*row_up));
   }
   UnwindPlan(UnwindPlan &&rhs) = default;
   UnwindPlan &operator=(const UnwindPlan &rhs) {
@@ -570,7 +570,7 @@ class UnwindPlan {
   }
 
 private:
-  std::vector m_row_list;
+  std::vector m_row_list;
   std::vector m_plan_valid_ranges;
   lldb::RegisterKind m_register_kind; // The RegisterKind these register 
numbers
   // are in terms of - will need to be
diff --git a/lldb/source/Symbol/UnwindPlan.cpp 
b/lldb/source/Symbol/UnwindPlan.cpp
index f2846eb927bf8..6cf96e66a7771 100644
--- a/lldb/source/Symbol/UnwindPlan.cpp
+++ b/lldb/source/Symbol/UnwindPlan.cpp
@@ -392,16 +392,16 @@ bool UnwindPlan::Row::operator==(const UnwindPlan::Row 
&rhs) const {
 
 void UnwindPlan::AppendRow(Row row) {
   if (m_row_list.empty() || m_row_list.back()->GetOffset() != row.GetOffset())
-m_row_list.push_back(std::make_shared(std::move(row)));
+m_row_list.push_back(std::make_unique(std::move(row)));
   else
 *m_row_list.back() = std::move(row);
 }
 
 struct RowLess {
-  bool operator()(addr_t a, const UnwindPlan::RowSP &b) const {
+  bool operator()(addr_t a, const UnwindPlan::RowUP &b) const {
 return a < b->GetOffset();
   }
-  bool operator()(const UnwindPlan::RowSP &a, addr_t b) const {
+  bool operator()(const UnwindPlan::RowUP &a, addr_t b) const {
 return a->GetOffset() < b;
   }
 };
@@ -409,7 +409,7 @@ struct RowLess {
 void UnwindPlan::InsertRow(Row row, bool replace_existing) {
   auto it = llvm::lower_bound(m_row_list, row.GetOffset(), RowLess());
   if (it == m_row_list.end() || it->get()->GetOffset() > row.GetOffset())
-m_row_list.insert(it, std::make_shared(std::move(row)));
+m_row_list.insert(it, std::make_unique(std::move(row)));
   else {
 assert(it->get()->GetOffset() == row.GetOffset());
 if (replace_existing)
@@ -567,9 +567,9 @@ void UnwindPlan::Dump(Stream &s, Thread *thread, 
lldb::addr_t base_addr) const {
   range.Dump(&s, target_sp.get(), Address::DumpStyleSectionNameOffset);
 s.EOL();
   }
-  for (const auto &[index, row_sp] : llvm::enumerate(m_row_list)) {
+  for (const auto &[index, row_up] : llvm::enumerate(m_row_list)) {
 s.Format("row[{0}]: ", index);
-row_sp->Dump(s, this, thread, base_addr);
+row_up->Dump(s, this, thread, base_addr);
 s << "\n";
   }
 }

``




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


[Lldb-commits] [lldb] [lldb] Remove UnwindPlan::Row shared_ptrs, lite (PR #134081)

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

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

Replace with std::unique_ptr. Previous attempt at replacing them with values 
failed because x86AssemblyInspectionEngine was storing pointers to the rows 
while modifying the plan. Changing that is relatively easy, but I'm not sure if 
that's an improvement.

>From d66923f92537c61dc3fc07032e17eb88e1d474c9 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 2 Apr 2025 15:23:22 +0200
Subject: [PATCH] [lldb] Remove UnwindPlan::Row shared_ptrs, lite

Replace with std::unique_ptr. Previous attempt at replacing them with
values failed because x86AssemblyInspectionEngine was storing pointers
to the rows while modifying the plan. Changing that is relatively easy,
but I'm not sure if that's an improvement.
---
 lldb/include/lldb/Symbol/UnwindPlan.h |  8 
 lldb/source/Symbol/UnwindPlan.cpp | 12 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h 
b/lldb/include/lldb/Symbol/UnwindPlan.h
index 9adda27b8f928..a0032d6e777c7 100644
--- a/lldb/include/lldb/Symbol/UnwindPlan.h
+++ b/lldb/include/lldb/Symbol/UnwindPlan.h
@@ -428,7 +428,7 @@ class UnwindPlan {
 bool m_unspecified_registers_are_undefined = false;
   }; // class Row
 
-  typedef std::shared_ptr RowSP;
+  typedef std::unique_ptr RowUP;
 
   UnwindPlan(lldb::RegisterKind reg_kind)
   : m_register_kind(reg_kind), m_return_addr_register(LLDB_INVALID_REGNUM),
@@ -449,8 +449,8 @@ class UnwindPlan {
 m_lsda_address(rhs.m_lsda_address),
 m_personality_func_addr(rhs.m_personality_func_addr) {
 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));
+for (const RowUP &row_up : rhs.m_row_list)
+  m_row_list.emplace_back(new Row(*row_up));
   }
   UnwindPlan(UnwindPlan &&rhs) = default;
   UnwindPlan &operator=(const UnwindPlan &rhs) {
@@ -570,7 +570,7 @@ class UnwindPlan {
   }
 
 private:
-  std::vector m_row_list;
+  std::vector m_row_list;
   std::vector m_plan_valid_ranges;
   lldb::RegisterKind m_register_kind; // The RegisterKind these register 
numbers
   // are in terms of - will need to be
diff --git a/lldb/source/Symbol/UnwindPlan.cpp 
b/lldb/source/Symbol/UnwindPlan.cpp
index f2846eb927bf8..6cf96e66a7771 100644
--- a/lldb/source/Symbol/UnwindPlan.cpp
+++ b/lldb/source/Symbol/UnwindPlan.cpp
@@ -392,16 +392,16 @@ bool UnwindPlan::Row::operator==(const UnwindPlan::Row 
&rhs) const {
 
 void UnwindPlan::AppendRow(Row row) {
   if (m_row_list.empty() || m_row_list.back()->GetOffset() != row.GetOffset())
-m_row_list.push_back(std::make_shared(std::move(row)));
+m_row_list.push_back(std::make_unique(std::move(row)));
   else
 *m_row_list.back() = std::move(row);
 }
 
 struct RowLess {
-  bool operator()(addr_t a, const UnwindPlan::RowSP &b) const {
+  bool operator()(addr_t a, const UnwindPlan::RowUP &b) const {
 return a < b->GetOffset();
   }
-  bool operator()(const UnwindPlan::RowSP &a, addr_t b) const {
+  bool operator()(const UnwindPlan::RowUP &a, addr_t b) const {
 return a->GetOffset() < b;
   }
 };
@@ -409,7 +409,7 @@ struct RowLess {
 void UnwindPlan::InsertRow(Row row, bool replace_existing) {
   auto it = llvm::lower_bound(m_row_list, row.GetOffset(), RowLess());
   if (it == m_row_list.end() || it->get()->GetOffset() > row.GetOffset())
-m_row_list.insert(it, std::make_shared(std::move(row)));
+m_row_list.insert(it, std::make_unique(std::move(row)));
   else {
 assert(it->get()->GetOffset() == row.GetOffset());
 if (replace_existing)
@@ -567,9 +567,9 @@ void UnwindPlan::Dump(Stream &s, Thread *thread, 
lldb::addr_t base_addr) const {
   range.Dump(&s, target_sp.get(), Address::DumpStyleSectionNameOffset);
 s.EOL();
   }
-  for (const auto &[index, row_sp] : llvm::enumerate(m_row_list)) {
+  for (const auto &[index, row_up] : llvm::enumerate(m_row_list)) {
 s.Format("row[{0}]: ", index);
-row_sp->Dump(s, this, thread, base_addr);
+row_up->Dump(s, this, thread, base_addr);
 s << "\n";
   }
 }

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


[Lldb-commits] [lldb] [lldb] Remove UnwindPlan::Row shared_ptrs, lite (PR #134081)

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

labath wrote:

Ftr, this is what it takes to fix the use after free problem. I didn't do that 
because it strictly increases the number of copies, and the use pattern is 
reasonable, but I'd be totally fine with doing that instead (I don't expect 
anyone will notice the extra copies).

https://github.com/llvm/llvm-project/pull/134081
___
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-02 Thread Pavel Labath via lldb-commits

labath wrote:

Long term, I think we should have a different way to set/compute/retrieve these 
paths, but locally, what you're doing is correct. lldb-server doesn't have a 
way to compute the "shared library directory", nor does it have any reason to 
do that, so returning an empty file spec instead of a bogus value is definitely 
an improvement.

I'm just thinking about whether there's a way to test this. You've said that 
there's a test for the scenario where lldb-server and lldb are not in the same 
directory. Which one is it? Would it be possible to use a similar approach to 
test this scenario as well?

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] [lldb] [lldb/telemetry] Report exit status only once (PR #134078)

2025-04-02 Thread Vy Nguyen via lldb-commits

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


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


[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

2025-04-02 Thread via lldb-commits


@@ -0,0 +1,131 @@
+//===-- DILParser.h -*- C++ 
-*-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_VALUEOBJECT_DILPARSER_H
+#define LLDB_VALUEOBJECT_DILPARSER_H
+
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Utility/DiagnosticsRendering.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/ValueObject/DILAST.h"
+#include "lldb/ValueObject/DILLexer.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace lldb_private::dil {
+
+enum class ErrorCode : unsigned char {
+  kOk = 0,
+  kInvalidExpressionSyntax,
+  kUndeclaredIdentifier,
+  kUnknown,
+};
+
+// The following is modeled on class OptionParseError.
+class DILDiagnosticError
+: public llvm::ErrorInfo {
+  DiagnosticDetail m_detail;
+
+public:
+  using llvm::ErrorInfo::ErrorInfo;
+  DILDiagnosticError(DiagnosticDetail detail)
+  : ErrorInfo(make_error_code(std::errc::invalid_argument)),
+m_detail(std::move(detail)) {}
+
+  DILDiagnosticError(llvm::StringRef expr, const std::string &message,
+ uint32_t loc, uint16_t err_len);
+
+  std::unique_ptr Clone() const override {
+return std::make_unique(m_detail);
+  }
+
+  llvm::ArrayRef GetDetails() const override {
+return {m_detail};
+  }
+
+  std::string message() const override { return m_detail.rendered; }
+};
+
+// This is needed, at the moment, because the code that calls the 'frame
+// var' implementation from CommandObjectFrame ONLY passes Status in/out
+// as a way to determine if an error occurred. We probably want to change that
+// in the future.
+Status GetStatusError(DILDiagnosticError dil_error);

cmtice wrote:

Whoops this was leftover from a previous iteration working on the errors. You 
are right, it is no longer needed: I will remove it.

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


[Lldb-commits] [lldb] [lldb][NFC] Move ShouldShow/ShouldSelect logic into Stopinfo (PR #134160)

2025-04-02 Thread via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb][NFC] Move ShouldShow/ShouldSelect logic into Stopinfo (PR #134160)

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


@@ -1137,9 +1132,18 @@ class StopInfoUnixSignal : public StopInfo {
 return m_description.c_str();
   }
 
+  bool ShouldSelect() const override { return IsShouldStopSignal(); }
+
 private:
   // In siginfo_t terms, if m_value is si_signo, m_code is si_code.
   std::optional m_code;
+
+  bool IsShouldStopSignal() const {
+ThreadSP thread_sp(m_thread_wp.lock());
+if (thread_sp)
+  return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value);

JDevlieghere wrote:

```suggestion
ThreadSP thread_sp(m_thread_wp.lock());
if (ThreadSP thread_sp = m_thread_wp.lock())
  return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value);
```

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


[Lldb-commits] [lldb] [lldb][debugserver] Save and restore the SVE/SME register state (PR #134184)

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

https://github.com/jasonmolenda created 
https://github.com/llvm/llvm-project/pull/134184

debugserver isn't saving and restoring the SVE/SME register state around 
inferior function calls.

Making arbitrary function calls while in Streaming SVE mode is generally a poor 
idea because a NEON instruction can be hit and crash the expression execution, 
which is how I missed this, but they should be handled correctly if the user 
knows it is safe to do.

rdar://146886210

>From 7cc45f1a300b1b0f2cbb529f11a0f9e56c41ffea Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Wed, 2 Apr 2025 18:05:29 -0700
Subject: [PATCH] [lldb][debugserver] Save and restore the SVE/SME register
 state

debugserver isn't saving and restoring the SVE/SME register state
around inferior function calls.

Making arbitrary function calls while in Streaming SVE mode is
generally a poor idea because a NEON instruction can be hit and
crash the expression execution, which is how I missed this, but
they should be handled correctly if the user knows it is safe
to do.

rdar://146886210
---
 .../source/MacOSX/arm64/DNBArchImplARM64.cpp  | 30 ++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
index 34a4ee21f8502..fb23744393d43 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -2953,7 +2953,14 @@ kern_return_t DNBArchMachARM64::SetRegisterState(int 
set) {
 
   switch (set) {
   case e_regSetALL:
-return SetGPRState() | SetVFPState() | SetEXCState() | SetDBGState(false);
+  {
+kern_return_t ret = SetGPRState() | SetVFPState() | SetEXCState() | 
SetDBGState(false);
+if (CPUHasSME()) {
+  ret |= SetSVEState();
+  ret |= SetSMEState();
+}
+return ret;
+  }
   case e_regSetGPR:
 return SetGPRState();
   case e_regSetVFP:
@@ -3122,6 +3129,15 @@ uint32_t DNBArchMachARM64::SaveRegisterState() {
 DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::SaveRegisterState () "
  "error: %s regs failed to read: %u",
  "VFP", kret);
+  } else if (CPUHasSME() && (kret = SetSVEState() != KERN_SUCCESS)) {
+DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::SaveRegisterState () "
+ "error: %s regs failed to read: %u",
+ "SVE", kret);
+  }
+  else if (CPUHasSME() && (kret = SetSMEState() != KERN_SUCCESS)) {
+DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::SaveRegisterState () "
+ "error: %s regs failed to read: %u",
+ "SME", kret);
   } else {
 const uint32_t save_id = GetNextRegisterStateSaveID();
 m_saved_register_states[save_id] = m_state.context;
@@ -3149,6 +3165,18 @@ bool DNBArchMachARM64::RestoreRegisterState(uint32_t 
save_id) {
"write: %u",
save_id, "VFP", kret);
   success = false;
+} else if ((kret = SetSVEState()) != KERN_SUCCESS) {
+  DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::RestoreRegisterState "
+   "(save_id = %u) error: %s regs failed to "
+   "write: %u",
+   save_id, "SVE", kret);
+  success = false;
+} else if ((kret = SetSMEState()) != KERN_SUCCESS) {
+  DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::RestoreRegisterState "
+   "(save_id = %u) error: %s regs failed to "
+   "write: %u",
+   save_id, "SME", kret);
+  success = false;
 }
 m_saved_register_states.erase(pos);
 return success;

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


[Lldb-commits] [lldb] [lldb][debugserver] Save and restore the SVE/SME register state (PR #134184)

2025-04-02 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/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
index fb2374439..663d84e6a 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -2952,9 +2952,9 @@ kern_return_t DNBArchMachARM64::SetRegisterState(int set) 
{
 return err;
 
   switch (set) {
-  case e_regSetALL:
-  {
-kern_return_t ret = SetGPRState() | SetVFPState() | SetEXCState() | 
SetDBGState(false);
+  case e_regSetALL: {
+kern_return_t ret =
+SetGPRState() | SetVFPState() | SetEXCState() | SetDBGState(false);
 if (CPUHasSME()) {
   ret |= SetSVEState();
   ret |= SetSMEState();
@@ -3130,13 +3130,14 @@ uint32_t DNBArchMachARM64::SaveRegisterState() {
  "error: %s regs failed to read: %u",
  "VFP", kret);
   } else if (CPUHasSME() && (kret = SetSVEState() != KERN_SUCCESS)) {
-DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::SaveRegisterState () "
- "error: %s regs failed to read: %u",
+DNBLogThreadedIf(LOG_THREAD,
+ "DNBArchMachARM64::SaveRegisterState () "
+ "error: %s regs failed to read: %u",
  "SVE", kret);
-  }
-  else if (CPUHasSME() && (kret = SetSMEState() != KERN_SUCCESS)) {
-DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::SaveRegisterState () "
- "error: %s regs failed to read: %u",
+  } else if (CPUHasSME() && (kret = SetSMEState() != KERN_SUCCESS)) {
+DNBLogThreadedIf(LOG_THREAD,
+ "DNBArchMachARM64::SaveRegisterState () "
+ "error: %s regs failed to read: %u",
  "SME", kret);
   } else {
 const uint32_t save_id = GetNextRegisterStateSaveID();
@@ -3166,15 +3167,17 @@ bool DNBArchMachARM64::RestoreRegisterState(uint32_t 
save_id) {
save_id, "VFP", kret);
   success = false;
 } else if ((kret = SetSVEState()) != KERN_SUCCESS) {
-  DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::RestoreRegisterState "
-   "(save_id = %u) error: %s regs failed to "
-   "write: %u",
+  DNBLogThreadedIf(LOG_THREAD,
+   "DNBArchMachARM64::RestoreRegisterState "
+   "(save_id = %u) error: %s regs failed to "
+   "write: %u",
save_id, "SVE", kret);
   success = false;
 } else if ((kret = SetSMEState()) != KERN_SUCCESS) {
-  DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::RestoreRegisterState "
-   "(save_id = %u) error: %s regs failed to "
-   "write: %u",
+  DNBLogThreadedIf(LOG_THREAD,
+   "DNBArchMachARM64::RestoreRegisterState "
+   "(save_id = %u) error: %s regs failed to "
+   "write: %u",
save_id, "SME", kret);
   success = false;
 }

``




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


[Lldb-commits] [lldb] [lldb-dap] Add a -v/--version command line argument (PR #134114)

2025-04-02 Thread via lldb-commits

https://github.com/hstk30-hw approved this pull request.


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


[Lldb-commits] [lldb] 18c43d0 - [lldb-dap] Add a -v/--version command line argument (#134114)

2025-04-02 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-04-02T18:40:37-07:00
New Revision: 18c43d01fc61648369fef50999e7df62b3ec292f

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

LOG: [lldb-dap] Add a -v/--version command line argument (#134114)

Add a -v/--version command line argument to print the version of both
the lldb-dap binary and the liblldb it's linked against.

This is motivated by me trying to figure out which lldb-dap I had in my
PATH.

Added: 
lldb/test/Shell/DAP/TestHelp.test
lldb/test/Shell/DAP/TestVersion.test

Modified: 
lldb/tools/lldb-dap/Options.td
lldb/tools/lldb-dap/lldb-dap.cpp

Removed: 
lldb/test/Shell/DAP/TestOptions.test



diff  --git a/lldb/test/Shell/DAP/TestOptions.test 
b/lldb/test/Shell/DAP/TestHelp.test
similarity index 88%
rename from lldb/test/Shell/DAP/TestOptions.test
rename to lldb/test/Shell/DAP/TestHelp.test
index d290cdae590fd..6033cf15e3835 100644
--- a/lldb/test/Shell/DAP/TestOptions.test
+++ b/lldb/test/Shell/DAP/TestHelp.test
@@ -4,5 +4,5 @@
 # CHECK: --help
 # CHECK: -h
 # CHECK: --repl-mode
+# CHECK: --version
 # CHECK: --wait-for-debugger
-

diff  --git a/lldb/test/Shell/DAP/TestVersion.test 
b/lldb/test/Shell/DAP/TestVersion.test
new file mode 100644
index 0..ad3ff67e45d79
--- /dev/null
+++ b/lldb/test/Shell/DAP/TestVersion.test
@@ -0,0 +1,3 @@
+# RUN: lldb-dap --version | FileCheck %s
+# CHECK: lldb-dap:
+# CHECK: liblldb:

diff  --git a/lldb/tools/lldb-dap/Options.td b/lldb/tools/lldb-dap/Options.td
index a1baf2f0370bd..aecf91797ac70 100644
--- a/lldb/tools/lldb-dap/Options.td
+++ b/lldb/tools/lldb-dap/Options.td
@@ -11,6 +11,12 @@ def: Flag<["-"], "h">,
   Alias,
   HelpText<"Alias for --help">;
 
+def version: F<"version">,
+  HelpText<"Prints out the lldb-dap version.">;
+def: Flag<["-"], "v">,
+  Alias,
+  HelpText<"Alias for --version">;
+
 def wait_for_debugger: F<"wait-for-debugger">,
   HelpText<"Pause the program at startup.">;
 def: Flag<["-"], "g">,

diff  --git a/lldb/tools/lldb-dap/lldb-dap.cpp 
b/lldb/tools/lldb-dap/lldb-dap.cpp
index b91c62e921428..ec87db6aab330 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -31,6 +31,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/OptTable.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
@@ -177,6 +178,12 @@ static void PrintHelp(LLDBDAPOptTable &table, 
llvm::StringRef tool_name) {
 )___";
 }
 
+static void PrintVersion() {
+  llvm::outs() << "lldb-dap: ";
+  llvm::cl::PrintVersionMessage();
+  llvm::outs() << "liblldb: " << lldb::SBDebugger::GetVersionString() << '\n';
+}
+
 // If --launch-target is provided, this instance of lldb-dap becomes a
 // runInTerminal launcher. It will ultimately launch the program specified in
 // the --launch-target argument, which is the original program the user wanted
@@ -421,6 +428,11 @@ int main(int argc, char *argv[]) {
 return EXIT_SUCCESS;
   }
 
+  if (input_args.hasArg(OPT_version)) {
+PrintVersion();
+return EXIT_SUCCESS;
+  }
+
   ReplMode default_repl_mode = ReplMode::Auto;
   if (input_args.hasArg(OPT_repl_mode)) {
 llvm::opt::Arg *repl_mode = input_args.getLastArg(OPT_repl_mode);



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


[Lldb-commits] [lldb] [lldb] Fix plugin manager test failure on windows (PR #134173)

2025-04-02 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/15362


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
 (395 of 2115)
PASS: lldb-api :: functionalities/completion/TestCompletion.py (396 of 2115)
UNSUPPORTED: lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
 (397 of 2115)
PASS: lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py
 (398 of 2115)
PASS: lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py
 (399 of 2115)
PASS: lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py
 (400 of 2115)
PASS: lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/invalid/TestDataFormatterInvalidStdUniquePtr.py
 (401 of 2115)
PASS: lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
 (402 of 2115)
PASS: lldb-api :: 
functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py 
(403 of 2115)
PASS: lldb-api :: 
functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py
 (404 of 2115)
FAIL: lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py
 (405 of 2115)
 TEST 'lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.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/data-formatter/data-formatter-stl/libstdcpp/vbool
 -p TestDataFormatterStdVBool.py
--
Exit Code: -11

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

--
Command Output (stderr):
--
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_with_run_command_dsym 
(TestDataFormatterStdVBool.StdVBoolDataFormatterTestCase) (test case does not 
fall in any category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_with_run_command_dwarf 
(TestDataFormatterStdVBool.StdVBoolDataFormatterTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_with_run_command_dwo 
(TestDataFormatterStdVBool.StdVBoolDataFormatterTestCase)
--
Ran 3 tests in 0.988s

OK (skipped=1)

--


PASS: lldb-api :: 
functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py
 (406 of 2115)
UNSUPPORTED: lldb-api :: 
functionalities/data-formatter/embedded-summary/TestEmbeddedTypeSummary.py (407 
of 2115)
PASS: lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py
 (408 of 2115)
PASS: lldb-api :: 
functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py (409 of 2115)
PASS: lldb-api :: 
functionalities/data-format

[Lldb-commits] [lldb] [LLDB] Expose checking if the symbol file exists/is loaded via SBModule (PR #134163)

2025-04-02 Thread Jacob Lalonde via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Expose checking if the symbol file exists/is loaded via SBModule (PR #134163)

2025-04-02 Thread via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Revert plugin manager changes to investigate failure (PR #134183)

2025-04-02 Thread David Peixotto via lldb-commits

https://github.com/dmpots created 
https://github.com/llvm/llvm-project/pull/134183

Revert the below two commits while we investigate the test failures.

Revert "[lldb] Fix plugin manager test failure on windows (#134173)"

This reverts commit b55bab229228218341e2f24fc8529c7aaab51e2f.

Revert "Add enable/disable api for SystemRuntime plugins (#133794)"

This reverts commit 2026873fb8a1f654aa920cd5ea8074e55053973b.

>From 34ac1f25634490278de5497b59024b29aeb8557a Mon Sep 17 00:00:00 2001
From: David Peixotto 
Date: Wed, 2 Apr 2025 17:26:49 -0700
Subject: [PATCH] [lldb] Revert plugin manager changes to investigate failure

Revert the below two commits while we investigate the test failures.

Revert "[lldb] Fix plugin manager test failure on windows (#134173)"

This reverts commit b55bab229228218341e2f24fc8529c7aaab51e2f.

Revert "Add enable/disable api for SystemRuntime plugins (#133794)"

This reverts commit 2026873fb8a1f654aa920cd5ea8074e55053973b.
---
 lldb/include/lldb/Core/PluginManager.h|  13 -
 lldb/source/Core/PluginManager.cpp|  55 +---
 lldb/unittests/Core/CMakeLists.txt|   1 -
 lldb/unittests/Core/PluginManagerTest.cpp | 381 --
 4 files changed, 3 insertions(+), 447 deletions(-)
 delete mode 100644 lldb/unittests/Core/PluginManagerTest.cpp

diff --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index a6dab045adf27..e4e0c3eea67f8 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -22,7 +22,6 @@
 
 #include 
 #include 
-#include 
 
 #define LLDB_PLUGIN_DEFINE_ADV(ClassName, PluginName)  
\
   namespace lldb_private { 
\
@@ -48,12 +47,6 @@ class CommandInterpreter;
 class Debugger;
 class StringList;
 
-struct RegisteredPluginInfo {
-  llvm::StringRef name = "";
-  llvm::StringRef description = "";
-  bool enabled = false;
-};
-
 class PluginManager {
 public:
   static void Initialize();
@@ -175,12 +168,6 @@ class PluginManager {
   static SystemRuntimeCreateInstance
   GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx);
 
-  static std::vector GetSystemRuntimePluginInfo();
-
-  // Modify the enabled state of a SystemRuntime plugin.
-  // Returns false if the plugin name is not found.
-  static bool SetSystemRuntimePluginEnabled(llvm::StringRef name, bool 
enabled);
-
   // ObjectFile
   static bool
   RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
diff --git a/lldb/source/Core/PluginManager.cpp 
b/lldb/source/Core/PluginManager.cpp
index e6cb248ef31ce..95eb940efcef2 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -188,13 +188,11 @@ template  struct PluginInstance {
   PluginInstance(llvm::StringRef name, llvm::StringRef description,
  Callback create_callback,
  DebuggerInitializeCallback debugger_init_callback = nullptr)
-  : name(name), description(description), enabled(true),
-create_callback(create_callback),
+  : name(name), description(description), create_callback(create_callback),
 debugger_init_callback(debugger_init_callback) {}
 
   llvm::StringRef name;
   llvm::StringRef description;
-  bool enabled;
   Callback create_callback;
   DebuggerInitializeCallback debugger_init_callback;
 };
@@ -252,9 +250,7 @@ template  class PluginInstances {
   }
 
   void PerformDebuggerCallback(Debugger &debugger) {
-for (const auto &instance : m_instances) {
-  if (!instance.enabled)
-continue;
+for (auto &instance : m_instances) {
   if (instance.debugger_init_callback)
 instance.debugger_init_callback(debugger);
 }
@@ -264,14 +260,7 @@ template  class PluginInstances {
   // Note that this is a copy of the internal state so modifications
   // to the returned instances will not be reflected back to instances
   // stored by the PluginInstances object.
-  std::vector GetSnapshot() {
-std::vector enabled_instances;
-for (const auto &instance : m_instances) {
-  if (instance.enabled)
-enabled_instances.push_back(instance);
-}
-return enabled_instances;
-  }
+  std::vector GetSnapshot() { return m_instances; }
 
   const Instance *GetInstanceAtIndex(uint32_t idx) {
 uint32_t count = 0;
@@ -291,41 +280,12 @@ template  class PluginInstances {
   const Instance *
   FindEnabledInstance(std::function predicate) const {
 for (const auto &instance : m_instances) {
-  if (!instance.enabled)
-continue;
   if (predicate(instance))
 return &instance;
 }
 return nullptr;
   }
 
-  // Return a list of all the registered plugin instances. This includes both
-  // enabled and disabled instances. The instances are listed in the order they
-  // were registered which is the order they would be queried if they were all
-  // enabled.
-  std::vector GetPluginInfoForAllInstances() {
-// Lookup the 

[Lldb-commits] [lldb] [lldb] Clear thread name container before writing UTF8 bytes (PR #134150)

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

JDevlieghere wrote:

@z2oh Would you mind cherry-picking this to 
https://github.com/swiftlang/llvm-project/tree/stable/20240723? 

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


[Lldb-commits] [lldb] [lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame if one exists (PR #134097)

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

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


[Lldb-commits] [lldb] [lldb-dap] Add progress events to the packet list (PR #134157)

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

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


[Lldb-commits] [lldb] be3abfc - [lldb] Clear thread name container before writing UTF8 bytes (#134150)

2025-04-02 Thread via lldb-commits

Author: Jeremy Day
Date: 2025-04-02T16:35:02-07:00
New Revision: be3abfc00f37d07c641b3e2f93eef5d1a446af8e

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

LOG: [lldb] Clear thread name container before writing UTF8 bytes (#134150)

`llvm::convertUTF16ToUTF8String` opens with an assertion that the output
container is empty:
https://github.com/llvm/llvm-project/blob/3bdf9a08804a5b424fd32fef3b0089f3a6db839d/llvm/lib/Support/ConvertUTFWrapper.cpp#L83-L84

It's not clear to me why this function requires the output container to
be empty instead of just overwriting it, but the callsite in
`TargetThreadWindows::GetName` may reuse the container without clearing
it out first, resulting in an assertion failure:
```
 # Child-SP  RetAddr   Call Site
00 00d2`44b8ea48 7ff8`beefc12e ntdll!NtTerminateProcess+0x14
01 00d2`44b8ea50 7ff8`bcf518ab ntdll!RtlExitUserProcess+0x11e
02 00d2`44b8ea80 7ff8`bc0e0143 
KERNEL32!ExitProcessImplementation+0xb
03 00d2`44b8eab0 7ff8`bc0e4c49 ucrtbase!common_exit+0xc7
04 00d2`44b8eb10 7ff8`bc102ae6 ucrtbase!abort+0x69
05 00d2`44b8eb40 7ff8`bc102cc1 
ucrtbase!common_assert_to_stderr+0x6e
06 00d2`44b8eb80 7fff`b8e27a80 ucrtbase!wassert+0x71
07 00d2`44b8ebb0 7fff`b8b821e1 
liblldb!llvm::convertUTF16ToUTF8String+0x30 
[D:\r\_work\swift-build\swift-build\SourceCache\llvm-project\llvm\lib\Support\ConvertUTFWrapper.cpp
 @ 88] 
08 00d2`44b8ec30 7fff`b83e9aa2 
liblldb!lldb_private::TargetThreadWindows::GetName+0x1b1 
[D:\r\_work\swift-build\swift-build\SourceCache\llvm-project\lldb\source\Plugins\Process\Windows\Common\TargetThreadWindows.cpp
 @ 198] 
09 00d2`44b8eca0 7ff7`2a3c3c14 
liblldb!lldb::SBThread::GetName+0x102 
[D:\r\_work\swift-build\swift-build\SourceCache\llvm-project\lldb\source\API\SBThread.cpp
 @ 432] 
0a 00d2`44b8ed70 7ff7`2a3a5ac6 
lldb_dap!lldb_dap::CreateThread+0x1f4 
[S:\SourceCache\llvm-project\lldb\tools\lldb-dap\JSONUtils.cpp @ 877] 
0b 00d2`44b8ef10 7ff7`2a3b0ab5 lldb_dap!`anonymous 
namespace'::request_threads+0xa6 
[S:\SourceCache\llvm-project\lldb\tools\lldb-dap\lldb-dap.cpp @ 3906] 
0c 00d2`44b8f010 7ff7`2a3b0fe8 
lldb_dap!lldb_dap::DAP::HandleObject+0x1c5 
[S:\SourceCache\llvm-project\lldb\tools\lldb-dap\DAP.cpp @ 796] 
0d 00d2`44b8f130 7ff7`2a3a8b96 lldb_dap!lldb_dap::DAP::Loop+0x78 
[S:\SourceCache\llvm-project\lldb\tools\lldb-dap\DAP.cpp @ 812] 
0e 00d2`44b8f1d0 7ff7`2a4b5fbc lldb_dap!main+0x1096 
[S:\SourceCache\llvm-project\lldb\tools\lldb-dap\lldb-dap.cpp @ 5319] 
0f (Inline Function) ` lldb_dap!invoke_main+0x22 
[D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 78] 
10 00d2`44b8fb80 7ff8`bcf3e8d7 
lldb_dap!__scrt_common_main_seh+0x10c 
[D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 288] 
11 00d2`44b8fbc0 7ff8`beefbf6c KERNEL32!BaseThreadInitThunk+0x17
12 00d2`44b8fbf0 ` ntdll!RtlUserThreadStart+0x2c
```

This stack trace was captured from the lldb distributed in the Swift
toolchain. The issue is easy to reproduce by resuming from a breakpoint
twice in VS Code.

I've verified that clearing out the container here fixes the assertion
failure.

Added: 


Modified: 
lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
index a0d0f0ea0abc8..b2b66f2927644 100644
--- a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
@@ -192,6 +192,7 @@ const char *TargetThreadWindows::GetName() {
   if (SUCCEEDED(GetThreadDescription(
   m_host_thread.GetNativeThread().GetSystemHandle(), &pszThreadName))) 
{
 LLDB_LOGF(log, "GetThreadDescription: %ls", pszThreadName);
+m_name.clear();
 llvm::convertUTF16ToUTF8String(
 llvm::ArrayRef(reinterpret_cast(pszThreadName),
wcslen(pszThreadName) * sizeof(wchar_t)),



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


[Lldb-commits] [lldb] [lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame if one exists (PR #134097)

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

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

>From 151ad919ab6f2d87991511b293f4a9797210f82f Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 2 Apr 2025 15:48:25 +0100
Subject: [PATCH 1/3] [lldb][Target] RunThreadPlan to save/restore the
 ExecutionContext's frame if one exists

When using `SBFrame::EvaluateExpression` on a frame that's not the
currently selected frame, we would sometimes run into errors such as:
```
error: error: The context has changed before we could JIT the expression!
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
```

Durin expression parsing, we call `RunStaticInitializers`. On our internal fork 
this happens quite frequently because any usage of, e.g., function pointers, 
will inject ptrauth fixup code into the expression.  The static initializers 
are run using `RunThreadPlan`. The `ExecutionContext::m_frame_sp` going into 
the `RunThreadPlan` is the `SBFrame` that we called `EvaluateExpression` on. 
LLDB then tries to save this frame to restore it later (the restore occurs by 
unconditionally overwriting whatever is in `ExecutionContext::m_frame_sp`). 
However, if the `selected_frame_sp` is not the same as the `SBFrame`, then 
`RunThreadPlan` would set the `ExecutionContext`'s frame to a different frame 
than what we started with. When we `PrepareToExecuteJITExpression`, LLDB checks 
whether the `ExecutionContext` frame changed from when we initially 
`EvaluateExpression`, and if did, bails out with the error above.

One such test-case is attached. This currently passes regardless of the fix 
because our ptrauth static initializers code isn't upstream yet. But the plan 
is to upstream it soon.

This patch addresses the issue by saving/restoring the frame of the incoming 
`ExecutionContext`, if such frame exists. Otherwise, fall back to using the 
selected frame.
---
 lldb/source/Target/Process.cpp|  8 -
 .../expr-from-non-zero-frame/Makefile |  3 ++
 .../TestExprFromNonZeroFrame.py   | 29 +++
 .../expr-from-non-zero-frame/main.cpp |  6 
 4 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile
 create mode 100644 
lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
 create mode 100644 
lldb/test/API/commands/expression/expr-from-non-zero-frame/main.cpp

diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 369933234ccca..f4ecb0b7ea307 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5080,7 +5080,13 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
 return eExpressionSetupError;
   }
 
-  StackID ctx_frame_id = selected_frame_sp->GetStackID();
+  // If the ExecutionContext has a frame, we want to make sure to save/restore
+  // that frame into exe_ctx. This can happen when we run expressions from a
+  // non-selected SBFrame, in which case we don't want some thread-plan
+  // to overwrite the ExecutionContext frame.
+  StackID ctx_frame_id = exe_ctx.HasFrameScope()
+ ? exe_ctx.GetFrameRef().GetStackID()
+ : selected_frame_sp->GetStackID();
 
   // N.B. Running the target may unset the currently selected thread and frame.
   // We don't want to do that either, so we should arrange to reset them as
diff --git 
a/lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile 
b/lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile
new file mode 100644
index 0..8b20bcb05
--- /dev/null
+++ b/lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git 
a/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
 
b/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
new file mode 100644
index 0..e87279abde406
--- /dev/null
+++ 
b/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
@@ -0,0 +1,29 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ExprFromNonZeroFrame(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipIf(archs=no_match(["arm64e"]))
+def test(self):
+"""
+Tests that we can use SBFrame::EvaluateExpression on a frame
+that we're not stopped in, even if thread-plans run as part of
+parsing the expression (e.g., when running static initializers).
+"""
+self.build()
+
+(_, _, thread, _) = lldbutil.run_to_source_breakpoint(
+self, "Break here", lldb.SBFileSpec("main.cpp")
+)
+frame = thread.GetFrameAtIndex(1)
+
+# Using a function pointer inside the expression ensures we
+

[Lldb-commits] [lldb] Add enable/disable api for SystemRuntime plugins (PR #133794)

2025-04-02 Thread David Peixotto via lldb-commits

dmpots wrote:

I have an attempted fix for these failures in #134173. I suspect ICF is 
combining the create functions into a single address which make us unable to 
remove them based on a unique address (which the plugin manager assumes).

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


[Lldb-commits] [lldb] [lldb] Fix plugin manager test failure on windows (PR #134173)

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

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

Let's try it! 

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


[Lldb-commits] [lldb] [lldb] Fix tagged-pointer info address parsing (PR #134123)

2025-04-02 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Expose checking if the symbol file exists/is loaded via SBModule (PR #134163)

2025-04-02 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/15374


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: 
tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py 
(1223 of 2116)
PASS: lldb-api :: 
tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py (1224 of 
2116)
PASS: lldb-api :: tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py 
(1225 of 2116)
PASS: lldb-api :: tools/lldb-server/thread-name/TestGdbRemoteThreadName.py 
(1226 of 2116)
PASS: lldb-api :: 
tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py (1227 of 2116)
UNSUPPORTED: lldb-api :: tools/lldb-server/vCont-threads/TestSignal.py (1228 of 
2116)
PASS: lldb-api :: types/TestDoubleTypes.py (1229 of 2116)
PASS: lldb-api :: types/TestCharType.py (1230 of 2116)
PASS: lldb-api :: types/TestCharTypeExpr.py (1231 of 2116)
PASS: lldb-api :: tools/lldb-server/qSupported/TestGdbRemote_qSupported.py 
(1232 of 2116)
FAIL: lldb-api :: types/TestDoubleTypesExpr.py (1233 of 2116)
 TEST 'lldb-api :: types/TestDoubleTypesExpr.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/types 
-p TestDoubleTypesExpr.py
--
Exit Code: -11

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

--
Command Output (stderr):
--
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_double_type_dsym (TestDoubleTypesExpr.DoubleTypesExprTestCase) (test case 
does not fall in any category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_double_type_dwarf (TestDoubleTypesExpr.DoubleTypesExprTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_double_type_dwo (TestDoubleTypesExpr.DoubleTypesExprTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_double_type_from_block_dsym (TestDoubleTypesExpr.DoubleTypesExprTestCase) 
(test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_double_type_from_block_dwarf (TestDoubleTypesExpr.DoubleTypesExprTestCase) 
(requires one of macosx, darwin, ios, tvos, watchos, bridgeos, iphonesimulator, 
watchsimulator, appletvsimulator) 
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_double_type_from_block_dwo (TestDoubleTypesExpr.DoubleTypesExprTestCase) 
(requires one of macosx, darwin, ios, tvos, watchos, bridgeos, iphonesimulator, 
watchsimulator, appletvsimulator) 
--
Ran 6 tests in 1.011s

OK (skipped=4)

--


PASS: lldb-api :: types/TestFloatTypes.py (1234 of 2116)
PASS: lldb-api :: tools/lldb-server/TestGdbRemote_vCont.py (1235 of 2116)
PASS: lldb-api :: tools/lldb-server/vCont-threads/TestPartialResume.py (1236 of 
2116)
PASS: lldb-api :: types/TestFloatTypesExpr.py (1237 of 2116)
PASS: lldb-api :: types/TestIntegerType.py (1238 of 2116)
PASS: lld

[Lldb-commits] [lldb] b8d8405 - [LLDB] Expose checking if the symbol file exists/is loaded via SBModule (#134163)

2025-04-02 Thread via lldb-commits

Author: Jacob Lalonde
Date: 2025-04-02T21:27:44-07:00
New Revision: b8d8405238387ddd92450d6a3ad84350254e76a3

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

LOG: [LLDB] Expose checking if the symbol file exists/is loaded via SBModule 
(#134163)

The motivation for this patch is that in Statistics.cpp we [check to see
if the module symfile is
loaded](https://github.com/llvm/llvm-project/blob/990a086d9da0bc2fd53a6a4c95ecbbe23a297a83/lldb/source/Target/Statistics.cpp#L353C60-L353C75)
to calculate how much debug info has been loaded. I have an external
utility that only wants to look at the loaded debug info, which isn't
exposed by the SBAPI.

Added: 


Modified: 
lldb/include/lldb/API/SBModule.h
lldb/source/API/SBModule.cpp

Removed: 




diff  --git a/lldb/include/lldb/API/SBModule.h 
b/lldb/include/lldb/API/SBModule.h
index 85332066ee687..651455bdb78d2 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -290,6 +290,9 @@ class LLDB_API SBModule {
   lldb::SBAddress GetObjectFileHeaderAddress() const;
   lldb::SBAddress GetObjectFileEntryPointAddress() const;
 
+  /// Get if the symbol file for this module is loaded.
+  bool IsDebugInfoLoaded() const;
+
   /// Get the number of global modules.
   static uint32_t GetNumberAllocatedModules();
 

diff  --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 985107ec68efd..4978a553f57c7 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -659,6 +659,18 @@ lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() 
const {
   return sb_addr;
 }
 
+bool SBModule::IsDebugInfoLoaded() const {
+  LLDB_INSTRUMENT_VA(this);
+
+  ModuleSP module_sp(GetSP());
+  if (module_sp) {
+SymbolFile *sym_file = module_sp->GetSymbolFile(/*create=*/false);
+return sym_file && sym_file->GetLoadDebugInfoEnabled();
+  }
+
+  return false;
+}
+
 uint32_t SBModule::GetNumberAllocatedModules() {
   LLDB_INSTRUMENT();
 



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


[Lldb-commits] [lldb] [lldb] Use the "reverse video" effect when colors are disabled. (PR #134203)

2025-04-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

When you run lldb without colors (`-X`), the status line looks weird because it 
doesn't have a background. You end up with what appears to be floating text at 
the bottom of your terminal.

This patch changes the statusline to use the reverse video effect, even when 
colors are off. The effect doesn't introduce any new colors and just inverts 
the foreground and background color.

I considered an alternative approach which changes the behavior of the `-X` 
option, so that turning off colors doesn't prevent emitting non-color related 
control characters such as bold, underline, and reverse video. I decided to go 
with this more targeted fix as (1) nobody is asking for this more general 
change and (2) it introduces significant complexity to plumb this through using 
a setting and driver flag so that it can be disabled when running the tests.

Fixes #134112.

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


2 Files Affected:

- (modified) lldb/source/Core/Statusline.cpp (+7) 
- (modified) lldb/test/API/functionalities/statusline/TestStatusline.py (+23) 


``diff
diff --git a/lldb/source/Core/Statusline.cpp b/lldb/source/Core/Statusline.cpp
index c18fbb6c5561e..b7650503e16bc 100644
--- a/lldb/source/Core/Statusline.cpp
+++ b/lldb/source/Core/Statusline.cpp
@@ -27,6 +27,7 @@
 #define ANSI_CLEAR_LINE ESCAPE "[2K"
 #define ANSI_SET_SCROLL_ROWS ESCAPE "[0;%ur"
 #define ANSI_TO_START_OF_ROW ESCAPE "[%u;0f"
+#define ANSI_REVERSE_VIDEO ESCAPE "[7m"
 #define ANSI_UP_ROWS ESCAPE "[%dA"
 
 using namespace lldb;
@@ -74,6 +75,12 @@ void Statusline::Draw(std::string str) {
   locked_stream << ANSI_SAVE_CURSOR;
   locked_stream.Printf(ANSI_TO_START_OF_ROW,
static_cast(m_terminal_height));
+
+  // Use "reverse video" to make sure the statusline has a background. Only do
+  // this when colors are disabled, and rely on the statusline format 
otherwise.
+  if (!m_debugger.GetUseColor())
+locked_stream << ANSI_REVERSE_VIDEO;
+
   locked_stream << str;
   locked_stream << ANSI_NORMAL;
   locked_stream << ANSI_RESTORE_CURSOR;
diff --git a/lldb/test/API/functionalities/statusline/TestStatusline.py 
b/lldb/test/API/functionalities/statusline/TestStatusline.py
index a58dc5470ed6d..391f788b9df48 100644
--- a/lldb/test/API/functionalities/statusline/TestStatusline.py
+++ b/lldb/test/API/functionalities/statusline/TestStatusline.py
@@ -55,3 +55,26 @@ def test(self):
 self.expect(
 "set set show-statusline false", 
["\x1b[0;{}r".format(terminal_height)]
 )
+
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+def test_no_color(self):
+"""Basic test for the statusline with colors disabled."""
+self.build()
+self.launch(use_colors=False)
+self.do_setup()
+
+# Change the terminal dimensions.
+terminal_height = 10
+terminal_width = 60
+self.child.setwinsize(terminal_height, terminal_width)
+
+# Enable the statusline and check for the "reverse video" control 
character.
+self.expect(
+"set set show-statusline true",
+[
+"\x1b[7m",
+],
+)

``




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


[Lldb-commits] [lldb] [lldb] Update examples in docs/use/python-reference.rst to work with Python 3 (PR #134204)

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

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

The examples on this page were using the Python 2-style print. I ran the 
updated code examples under Python 3 to confirm they are still up-to-date.

>From a4ce285ba4921fdf43382a1c24764c1619eaf663 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 2 Apr 2025 23:24:58 -0700
Subject: [PATCH] [lldb] Update examples in docs/use/python-reference.rst to
 work with Python 3

The examples on this page were using the Python 2-style print. I ran the
updated code examples under Python 3 to confirm they are still
up-to-date.
---
 lldb/docs/use/python-reference.rst | 68 --
 1 file changed, 36 insertions(+), 32 deletions(-)

diff --git a/lldb/docs/use/python-reference.rst 
b/lldb/docs/use/python-reference.rst
index 02e09e10c0f6a..4bf0cb075064b 100644
--- a/lldb/docs/use/python-reference.rst
+++ b/lldb/docs/use/python-reference.rst
@@ -153,16 +153,16 @@ pass them to the Python print function:
 
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
-   >>> print lldb.debugger
+   >>> print(lldb.debugger)
Debugger (instance: "debugger_1", id: 1)
-   >>> print lldb.target
+   >>> print(lldb.target)
a.out
-   >>> print lldb.process
-   SBProcess: pid = 59289, state = stopped, threads = 1, executable = a.out
-   >>> print lldb.thread
-   SBThread: tid = 0x1f03
-   >>> print lldb.frame
-   frame #0: 0x00010bb6 a.out main + 54 at main.c:16
+   >>> print(lldb.process)
+   SBProcess: pid = 58842, state = stopped, threads = 1, executable = a.out
+   >>> print(lldb.thread)
+   thread #1: tid = 0x2265ce3, 0x00010334 a.out`main at t.c:2:3, queue 
= 'com.apple.main-thread', stop reason = breakpoint 1.1
+   >>> print(lldb.frame)
+   frame #0: 0x00010334 a.out`main at t.c:2:3
 
 
 Running a python script when a breakpoint gets hit
@@ -252,7 +252,7 @@ Here is the code:
> # Get the name of the function
> name = frame.GetFunctionName()
> # Print the order and the function name
-   > print '[%i] %s' % (counter, name)
+   > print('[%i] %s' % (counter, name))
> # Disable the current breakpoint location so it doesn't get hit again
> bp_loc.SetEnabled(False)
> # No need to stop here
@@ -588,7 +588,7 @@ say
 
 .. code-block:: python
 
-  print >>result, "my command does lots of cool stuff"
+  print("my command does lots of cool stuff", file=result)
 
 SBCommandReturnObject and SBStream both support this file-like behavior by
 providing write() and flush() calls at the Python layer.
@@ -712,7 +712,7 @@ your lldb.ParsedCommand subclass should implement:
 """
 
 And to handle the completion of arguments:
-
+
 .. code-block:: python
 
 def handle_argument_completion(self, args, arg_pos, cursor_pos):
@@ -826,7 +826,7 @@ a function that can be used by LLDB's python command code:
   # And the initialization code to add your commands
   def __lldb_init_module(debugger, internal_dict):
   debugger.HandleCommand('command script add -f ls.ls ls')
-  print 'The "ls" python command has been installed and is ready for use.'
+  print('The "ls" python command has been installed and is ready for use.')
 
 Now we can load the module into LLDB and use it
 
@@ -964,16 +964,18 @@ script that will launch a program from the current 
working directory called
 "a.out", set a breakpoint at "main", and then run and hit the breakpoint, and
 print the process, thread and frame objects if the process stopped:
 
-::
+.. code-block:: python
 
-  #!/usr/bin/env python
+  #!/usr/bin/env python3
 
   import lldb
   import os
 
+
   def disassemble_instructions(insts):
   for i in insts:
-  print i
+  print(i)
+
 
   # Set the path to the executable to debug
   exe = "./a.out"
@@ -983,54 +985,56 @@ print the process, thread and frame objects if the 
process stopped:
 
   # When we step or continue, don't return from the function until the process
   # stops. Otherwise we would have to handle the process events ourselves 
which, while doable is
-  #a little tricky.  We do this by setting the async mode to false.
-  debugger.SetAsync (False)
+  # a little tricky.  We do this by setting the async mode to false.
+  debugger.SetAsync(False)
 
   # Create a target from a file and arch
-  print "Creating a target for '%s'" % exe
+  print("Creating a target for '%s'" % exe)
 
-  target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT)
+  target = debugger.CreateTargetWithFileAndArch(exe, lldb.LLDB_ARCH_DEFAULT)
 
   if target:
   # If the target is valid set a breakpoint at main
-  main_bp = target.BreakpointCreateByName ("main", 
target.GetExecutable().GetFilename());
+  main_bp = target.BreakpointCreateByName(
+  "main", target.GetExecutable().GetFilename()
+  )
 
-  print main_bp
+  print(main_bp)
 
   # Launch the process. Since we specified synchronous mode, we

[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [mlir] Fix typos: paramter, parametr, parametere (PR #134092)

2025-04-02 Thread Owen Pan via lldb-commits


@@ -12304,7 +12304,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
   verifyIndependentOfContext("f(b * /* confusing comment */ ++c);");
   verifyFormat("f(* /* confusing comment */ foo);");
   verifyFormat("void (* /*deleter*/)(const Slice &key, void *value)");
-  verifyFormat("void foo(int * // this is the first paramters\n"
+  verifyFormat("void foo(int * // this is the first parameters\n"

owenca wrote:

```suggestion
  verifyFormat("void foo(int * // this is the first parameter\n"
```

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


[Lldb-commits] [lldb] [lldb] Use the "reverse video" effect when colors are disabled. (PR #134203)

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

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

>From c5df5b2684a42f11c13efa6b03a28ea4e8ff900e Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 2 Apr 2025 22:52:39 -0700
Subject: [PATCH 1/2] [lldb] Use the "reverse video" effect when colors are
 disabled.

When you run lldb without colors (`-X), the status line looks weird
because it doesn't have a background. You end up with what appears to be
floating text at the bottom of your terminal.

This patch changes the statusline to use the reverse video effect, even
when colors are off. The effect doesn't introduce any new colors and
just inverts the foreground and background color.

I considered an alternative approach which changes the behavior of the
`-X` option, so that turning off colors doesn't prevent emitting
non-color related control characters such as bold, underline, and
reverse video. I decided to go with this more targeted fix as (1) nobody
is asking for this more general change and (2) it introduces significant
complexity to plumb this through using a setting and driver flag so that
it can be disabled when running the tests.

Fixes #134112.
---
 lldb/source/Core/Statusline.cpp   |  7 ++
 .../statusline/TestStatusline.py  | 23 +++
 2 files changed, 30 insertions(+)

diff --git a/lldb/source/Core/Statusline.cpp b/lldb/source/Core/Statusline.cpp
index c18fbb6c5561e..b7650503e16bc 100644
--- a/lldb/source/Core/Statusline.cpp
+++ b/lldb/source/Core/Statusline.cpp
@@ -27,6 +27,7 @@
 #define ANSI_CLEAR_LINE ESCAPE "[2K"
 #define ANSI_SET_SCROLL_ROWS ESCAPE "[0;%ur"
 #define ANSI_TO_START_OF_ROW ESCAPE "[%u;0f"
+#define ANSI_REVERSE_VIDEO ESCAPE "[7m"
 #define ANSI_UP_ROWS ESCAPE "[%dA"
 
 using namespace lldb;
@@ -74,6 +75,12 @@ void Statusline::Draw(std::string str) {
   locked_stream << ANSI_SAVE_CURSOR;
   locked_stream.Printf(ANSI_TO_START_OF_ROW,
static_cast(m_terminal_height));
+
+  // Use "reverse video" to make sure the statusline has a background. Only do
+  // this when colors are disabled, and rely on the statusline format 
otherwise.
+  if (!m_debugger.GetUseColor())
+locked_stream << ANSI_REVERSE_VIDEO;
+
   locked_stream << str;
   locked_stream << ANSI_NORMAL;
   locked_stream << ANSI_RESTORE_CURSOR;
diff --git a/lldb/test/API/functionalities/statusline/TestStatusline.py 
b/lldb/test/API/functionalities/statusline/TestStatusline.py
index a58dc5470ed6d..391f788b9df48 100644
--- a/lldb/test/API/functionalities/statusline/TestStatusline.py
+++ b/lldb/test/API/functionalities/statusline/TestStatusline.py
@@ -55,3 +55,26 @@ def test(self):
 self.expect(
 "set set show-statusline false", 
["\x1b[0;{}r".format(terminal_height)]
 )
+
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+def test_no_color(self):
+"""Basic test for the statusline with colors disabled."""
+self.build()
+self.launch(use_colors=False)
+self.do_setup()
+
+# Change the terminal dimensions.
+terminal_height = 10
+terminal_width = 60
+self.child.setwinsize(terminal_height, terminal_width)
+
+# Enable the statusline and check for the "reverse video" control 
character.
+self.expect(
+"set set show-statusline true",
+[
+"\x1b[7m",
+],
+)

>From 0d1998dd1c8ebc6dbb687c0a23ab2562c9378d01 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 2 Apr 2025 23:30:38 -0700
Subject: [PATCH 2/2] Remove newline to appease the formatter

---
 lldb/test/API/functionalities/statusline/TestStatusline.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lldb/test/API/functionalities/statusline/TestStatusline.py 
b/lldb/test/API/functionalities/statusline/TestStatusline.py
index 391f788b9df48..747a7a14e0629 100644
--- a/lldb/test/API/functionalities/statusline/TestStatusline.py
+++ b/lldb/test/API/functionalities/statusline/TestStatusline.py
@@ -56,7 +56,6 @@ def test(self):
 "set set show-statusline false", 
["\x1b[0;{}r".format(terminal_height)]
 )
 
-
 # PExpect uses many timeouts internally and doesn't play well
 # under ASAN on a loaded machine..
 @skipIfAsan

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


[Lldb-commits] [lldb] [lldb-dap] Implement `runInTerminal` for Windows (PR #121269)

2025-04-02 Thread Hu Jialun via lldb-commits

https://github.com/SuibianP updated 
https://github.com/llvm/llvm-project/pull/121269

>From babc347b5ad20d9d155c717323dc9796fce6b756 Mon Sep 17 00:00:00 2001
From: Jialun Hu 
Date: Mon, 24 Feb 2025 22:10:17 +0800
Subject: [PATCH] [lldb-dap] Implement runInTerminal for Windows

Currently, the named pipe is passed by name and a transient ofstream is
constructed at each I/O request. This assumes,
  - Blocking semantics: FIFO I/O waits for the other side to connect.
  - Buffered semantics: Closing one side does not discard existing data.

The former can be replaced by WaitNamedPipe/ConnectNamedPipe on Win32,
but the second cannot be easily worked around. It is also impossible to
have another "keep-alive" pipe server instance, as server-client pairs
are fixed on connection on Win32 and the client may get connected to it
instead of the real one.

Refactor FifoFile[IO] to use an open file handles rather than file name.

---

Win32 provides no way to replace the process image. Under the hood exec*
actually creates a new process with a new PID. DebugActiveProcess also
cannot get notified of process creations.

Create the new process in a suspended state and resume it after attach.
---
 lldb/packages/Python/lldbsuite/test/dotest.py |   2 +-
 .../API/tools/lldb-dap/runInTerminal/Makefile |   2 +-
 .../runInTerminal/TestDAP_runInTerminal.py|   5 +-
 .../API/tools/lldb-dap/runInTerminal/main.c   |  11 --
 .../API/tools/lldb-dap/runInTerminal/main.cpp |  13 ++
 lldb/tools/lldb-dap/FifoFiles.cpp | 131 +++---
 lldb/tools/lldb-dap/FifoFiles.h   |  35 +++--
 .../tools/lldb-dap/Handler/RequestHandler.cpp |   8 +-
 lldb/tools/lldb-dap/RunInTerminal.cpp |  45 +++---
 lldb/tools/lldb-dap/RunInTerminal.h   |  11 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  63 +++--
 11 files changed, 243 insertions(+), 83 deletions(-)
 delete mode 100644 lldb/test/API/tools/lldb-dap/runInTerminal/main.c
 create mode 100644 lldb/test/API/tools/lldb-dap/runInTerminal/main.cpp

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 7cc8f2985043e..01b161733d62e 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -547,7 +547,7 @@ def setupSysPath():
 
 lldbDir = os.path.dirname(lldbtest_config.lldbExec)
 
-lldbDAPExec = os.path.join(lldbDir, "lldb-dap")
+lldbDAPExec = os.path.join(lldbDir, "lldb-dap.exe" if os.name == "nt" else 
"lldb-dap")
 if is_exe(lldbDAPExec):
 os.environ["LLDBDAP_EXEC"] = lldbDAPExec
 
diff --git a/lldb/test/API/tools/lldb-dap/runInTerminal/Makefile 
b/lldb/test/API/tools/lldb-dap/runInTerminal/Makefile
index 10495940055b6..8b20bcb05 100644
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/Makefile
+++ b/lldb/test/API/tools/lldb-dap/runInTerminal/Makefile
@@ -1,3 +1,3 @@
-C_SOURCES := main.c
+CXX_SOURCES := main.cpp
 
 include Makefile.rules
diff --git 
a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py 
b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
index 9aab7ca3293db..3a47202c5e0b6 100644
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
@@ -43,7 +43,6 @@ def isTestSupported(self):
 except:
 return False
 
-@skipIfWindows
 @skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
 def test_runInTerminal(self):
 if not self.isTestSupported():
@@ -53,7 +52,7 @@ def test_runInTerminal(self):
 launch the inferior with the correct environment variables and 
arguments.
 """
 program = self.getBuildArtifact("a.out")
-source = "main.c"
+source = "main.cpp"
 self.build_and_launch(
 program, runInTerminal=True, args=["foobar"], env=["FOO=bar"]
 )
@@ -113,7 +112,6 @@ def test_runInTerminalWithObjectEnv(self):
 self.assertIn("FOO", request_envs)
 self.assertEqual("BAR", request_envs["FOO"])
 
-@skipIfWindows
 @skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
 def test_runInTerminalInvalidTarget(self):
 if not self.isTestSupported():
@@ -132,7 +130,6 @@ def test_runInTerminalInvalidTarget(self):
 response["message"],
 )
 
-@skipIfWindows
 @skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
 def test_missingArgInRunInTerminalLauncher(self):
 if not self.isTestSupported():
diff --git a/lldb/test/API/tools/lldb-dap/runInTerminal/main.c 
b/lldb/test/API/tools/lldb-dap/runInTerminal/main.c
deleted file mode 100644
index 676bd830e657b..0
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/main.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include 
-#include 
-#include 
-
-int main(int argc, char *argv[]) {
-  const char *foo = getenv("FOO");
-  for (int counter = 1;; counter++) {
-sleep(1); // breakpoint

[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-04-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> if I start lldb with no arguments:

https://github.com/llvm/llvm-project/issues/134064

> Does not happen if I have a program file, but this is also strange:

This part appears to have been fixed.

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


[Lldb-commits] [lldb] [lldb] Return *const* UnwindPlan pointers from FuncUnwinders (PR #133247)

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

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


[Lldb-commits] [lldb] [lldb] Return *const* UnwindPlan pointers from FuncUnwinders (PR #133247)

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

slydiman wrote:

@labath 

> LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu`

[lldb-remote-linux-ubuntu](https://lab.llvm.org/buildbot/#/builders/195/builds/7046)
 is broken too.

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


[Lldb-commits] [lldb] [LLDB][NFC] Move CPlusPlusLanguage methods used in Core/Module.cpp to a separated module to break lldb-server dependencies (PR #132274)

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

labath wrote:

Okay. The last comment makes sense to me. Thank you for getting to the bottom 
of this. I fully agree this should be resolved in lldb as lldb-server has no 
good reason to depend on this code in the first place.

So as far as I am concerned (I can't speak about others), I think something 
like this could work under two conditions:
- we make some effort to me this look like other code. What I mainly mean is, 
each of our cpp files has a header which declares the things defined in that 
cpp file. I think we should create a matching .h file for the code you're 
moving here. I guess that means changing MethodName from a nested class to a 
top-level entity.
- you don't get to cry foul if some future change causes lldb-server to become 
large again. Parts of lldb (including the code you're just moving) still depend 
on clang, so it's possible that a perfectly reasonable change will cause these 
things to get pulled in again. I don't think it's likely to happen, as this 
code is pretty stable and isolated, but still... It also doesn't mean you can't 
complain if someone introduces a new plugin dependency (in fact, I encourage 
you to do that). However, I don't think it's reasonable to hold up changes to 
code which is within its right to depend on clang, just because it makes 
lldb-server larger due to these unresolved dependencies.

*That said*, I would much very much prefer to resolve this in a proper way, by 
removing the (direct) dependency on the C++ language plugin. It sounds like 
https://github.com/swiftlang/llvm-project/pull/3240 is not far from working. As 
far as I am concerned (I again don't speak for others), the plugin ordering 
thing could be handled by making sure the plugins are registered in the right 
order (in cmake).

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] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [mlir] Fix typos: paramter, parametr, parametere (PR #134092)

2025-04-02 Thread via lldb-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-format

@llvm/pr-subscribers-backend-webassembly

Author: Jay Foad (jayfoad)


Changes



---

Patch is 24.76 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/134092.diff


30 Files Affected:

- (modified) bolt/utils/bughunter.sh (+1-1) 
- (modified) clang-tools-extra/clangd/SemanticHighlighting.cpp (+1-1) 
- (modified) clang/docs/ReleaseNotes.rst (+2-2) 
- (modified) clang/include/clang/Basic/AttrDocs.td (+1-1) 
- (modified) clang/include/clang/Basic/DiagnosticASTKinds.td (+1-1) 
- (modified) clang/include/clang/Basic/arm_cde.td (+1-1) 
- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+2-1) 
- (modified) clang/lib/Analysis/UnsafeBufferUsage.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+1-1) 
- (modified) clang/lib/CodeGen/TargetBuiltins/ARM.cpp (+1-1) 
- (modified) 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp 
(+1-1) 
- (modified) clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
(+1-1) 
- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
(+1-1) 
- (modified) clang/test/Modules/odr_hash.cpp (+3-3) 
- (modified) clang/unittests/Format/FormatTest.cpp (+2-2) 
- (modified) flang/lib/Lower/OpenMP/PrivateReductionUtils.cpp (+1-1) 
- (modified) flang/lib/Optimizer/CodeGen/TypeConverter.cpp (+1-1) 
- (modified) lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp (+1-1) 
- (modified) llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp (+3-3) 
- (modified) llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h (+2-2) 
- (modified) llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/sched-movprfx.ll (+1-1) 
- (modified) 
llvm/test/CodeGen/AArch64/sve2-intrinsics-fp-int-binary-logarithm-zeroing.ll 
(+1-1) 
- (modified) llvm/test/MC/WebAssembly/block-assembly.s (+1-1) 
- (modified) llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp (+1-1) 
- (modified) mlir/include/mlir/Analysis/Presburger/PWMAFunction.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/Transform/IR/TransformOps.td (+1-1) 
- (modified) mlir/include/mlir/TableGen/Class.h (+2-2) 
- (modified) mlir/lib/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.cpp 
(+1-1) 
- (modified) mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp (+1-1) 


``diff
diff --git a/bolt/utils/bughunter.sh b/bolt/utils/bughunter.sh
index c5dddc41fb41f..d5ce0592708e2 100755
--- a/bolt/utils/bughunter.sh
+++ b/bolt/utils/bughunter.sh
@@ -28,7 +28,7 @@
 #
 #   TIMEOUT_OR_CMD- optional timeout or command on optimized binary command
 #   if the value is a number with an optional trailing 
letter
-#   [smhd] it is considered a paramter to "timeout",
+#   [smhd] it is considered a parameter to "timeout",
 #   otherwise it's a shell command that wraps the optimized
 #   binary command.
 #
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 86ca05644c703..1e9ca0ae7822d 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -876,7 +876,7 @@ class CollectExtraHighlightings
 
 if (auto *ProtoType = FD->getType()->getAs()) {
   // Iterate over the types of the function parameters.
-  // If any of them are non-const reference paramteres, add it as a
+  // If any of them are non-const reference parameteres, add it as a
   // highlighting modifier to the corresponding expression
   for (size_t I = 0;
I < std::min(size_t(ProtoType->getNumParams()), Args.size()); ++I) {
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7978df0cc71cc..881bcd7415edd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -381,12 +381,12 @@ Bug Fixes to C++ Support
   now also works if the constraint has non-type or template template 
parameters.
   (#GH131798)
 - Fixes matching of nested template template parameters. (#GH130362)
-- Correctly diagnoses template template paramters which have a pack parameter
+- Correctly diagnoses template template parameters which have a pack parameter
   not in the last position.
 - Clang now correctly parses ``if constexpr`` expressions in immediate 
function context. (#GH123524)
 - Fixed an assertion failure affecting code that uses C++23 "deducing this". 
(#GH130272)
 - Clang now properly instantiates destructors for initialized members within 
non-delegating constructors. (#GH93251)
-- Correctly diagnoses if unresolved using declarations shadows template 
paramters (#GH129411)
+- Correctly diagnoses if unresolved using declarations shadows template 
parameters (#GH129411)
 - Fixed C++20 aggregate initialization rules being incorrectly applied in 
certain contexts. (#GH131320)
 - Clang was previously coalescing vo

[Lldb-commits] [lldb] [LLDB][NFC] Move CPlusPlusLanguage methods used in Core/Module.cpp to a separated module to break lldb-server dependencies (PR #132274)

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

slydiman wrote:

@bulbazord, Do you have the opportunity to complete the patch 
https://github.com/swiftlang/llvm-project/pull/3240 (sort language plug-ins in 
cmake or hardcode the sorted list of language plug-ins)? I can try to complete 
it, if you don't mind.

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] [lldb] Use correct path for debugserver (PR #131609)

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

yuvald-sweet-security wrote:

> I'm just thinking about whether there's a way to test this. You've said that 
> there's a test for the scenario where lldb-server and lldb are not in the 
> same directory. Which one is it? Would it be possible to use a similar 
> approach to test this scenario as well?

I think all the tests for LLDB Python API indirectly test this code, when I 
tried my initial approach (always relying on `GetProgramFileSpec` for locating 
the directory of lldb-server), many tests failed due to not finding 
lldb-server, e.g.:
```
_bk;t=1742219200805  TEST 'lldb-api :: 
commands/disassemble/basic/TestDisassembleBreakpoint.py' FAILED 

_bk;t=1742219200805 Script:
_bk;t=1742219200805 --
_bk;t=1742219200805 /usr/bin/python3.10 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/build/./lib
 --env 
LLVM_INCLUDE_DIR=/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/build/include
 --env 
LLVM_TOOLS_DIR=/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/build/./bin
 --arch x86_64 --build-dir 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/build/lldb-test-build.noindex
 --lldb-module-cache-dir 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/build/./bin/lldb
 --compiler 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/build/./bin/clang
 --dsymutil 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/build/./bin/dsymutil
 --make /usr/bin/gmake --llvm-tools-dir 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/build/./bin
 --lldb-obj-root 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/build/tools/lldb
 --lldb-libs-dir 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/build/./lib
 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/lldb/test/API/commands/disassemble/basic
 -p TestDisassembleBreakpoint.py
_bk;t=1742219200806 --
_bk;t=1742219200806 Exit Code: 1
_bk;t=1742219200806 
_bk;t=1742219200806 Command Output (stdout):
_bk;t=1742219200806 --
_bk;t=1742219200806 lldb version 21.0.0git 
(https://github.com/llvm/llvm-project.git revision 
f47298e0f29a2a73d656ba5270557ca139688499)
_bk;t=1742219200806   clang revision f47298e0f29a2a73d656ba5270557ca139688499
_bk;t=1742219200806   llvm revision f47298e0f29a2a73d656ba5270557ca139688499
_bk;t=1742219200806 Skipping the following test categories: ['libc++', 'dsym', 
'gmodules', 'debugserver', 'objc']
_bk;t=1742219200806 
_bk;t=1742219200806 --
_bk;t=1742219200806 Command Output (stderr):
_bk;t=1742219200806 --
_bk;t=1742219200806 FAIL: LLDB 
(/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/build/bin/clang-x86_64)
 :: test (TestDisassembleBreakpoint.DisassemblyTestCase)
_bk;t=1742219200806 
==
_bk;t=1742219200806 FAIL: test (TestDisassembleBreakpoint.DisassemblyTestCase)
_bk;t=1742219200806 
--
_bk;t=1742219200806 Traceback (most recent call last):
_bk;t=1742219200806   File 
"/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/lldb/test/API/commands/disassemble/basic/TestDisassembleBreakpoint.py",
 line 17, in test
_bk;t=1742219200806 target, _, _, bkpt = lldbutil.run_to_source_breakpoint(
_bk;t=1742219200806   File 
"/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/lldb/packages/Python/lldbsuite/test/lldbutil.py",
 line 1016, in run_to_source_breakpoint
_bk;t=1742219200806 return run_to_breakpoint_do_run(
_bk;t=1742219200806   File 
"/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/lldb/packages/Python/lldbsuite/test/lldbutil.py",
 line 896, in run_to_breakpoint_do_run
_bk;t=1742219200806 test.assertFalse(error.Fail(), "Process launch failed: 
%s" % (error.GetCString()))
_bk;t=1742219200806 AssertionError: True is not false : Process launch failed: 
unable to locate lldb-server
_bk;t=1742219200806 
Conf

[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [mlir] Fix typos: paramter, parametr, parametere (PR #134092)

2025-04-02 Thread Jay Foad via lldb-commits

https://github.com/jayfoad created 
https://github.com/llvm/llvm-project/pull/134092

None

>From 10ab02a61b5e2ec3f58a12c78e7b3b989a349a8f Mon Sep 17 00:00:00 2001
From: Jay Foad 
Date: Wed, 2 Apr 2025 15:35:32 +0100
Subject: [PATCH] Fix typos: paramter, parametr, parametere

---
 bolt/utils/bughunter.sh | 2 +-
 clang-tools-extra/clangd/SemanticHighlighting.cpp   | 2 +-
 clang/docs/ReleaseNotes.rst | 4 ++--
 clang/include/clang/Basic/AttrDocs.td   | 2 +-
 clang/include/clang/Basic/DiagnosticASTKinds.td | 2 +-
 clang/include/clang/Basic/arm_cde.td| 2 +-
 clang/lib/AST/ByteCode/Compiler.cpp | 3 ++-
 clang/lib/Analysis/UnsafeBufferUsage.cpp| 2 +-
 clang/lib/CodeGen/CodeGenFunction.h | 2 +-
 clang/lib/CodeGen/TargetBuiltins/ARM.cpp| 2 +-
 .../Checkers/RetainCountChecker/RetainCountDiagnostics.cpp  | 2 +-
 .../StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp  | 2 +-
 .../StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp| 2 +-
 clang/test/Modules/odr_hash.cpp | 6 +++---
 clang/unittests/Format/FormatTest.cpp   | 4 ++--
 flang/lib/Lower/OpenMP/PrivateReductionUtils.cpp| 2 +-
 flang/lib/Optimizer/CodeGen/TypeConverter.cpp   | 2 +-
 lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp| 2 +-
 llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp  | 6 +++---
 llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h| 4 ++--
 llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp| 2 +-
 llvm/test/CodeGen/AArch64/sched-movprfx.ll  | 2 +-
 .../sve2-intrinsics-fp-int-binary-logarithm-zeroing.ll  | 2 +-
 llvm/test/MC/WebAssembly/block-assembly.s   | 2 +-
 llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp   | 2 +-
 mlir/include/mlir/Analysis/Presburger/PWMAFunction.h| 2 +-
 mlir/include/mlir/Dialect/Transform/IR/TransformOps.td  | 2 +-
 mlir/include/mlir/TableGen/Class.h  | 4 ++--
 .../Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.cpp  | 2 +-
 mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp | 2 +-
 30 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/bolt/utils/bughunter.sh b/bolt/utils/bughunter.sh
index c5dddc41fb41f..d5ce0592708e2 100755
--- a/bolt/utils/bughunter.sh
+++ b/bolt/utils/bughunter.sh
@@ -28,7 +28,7 @@
 #
 #   TIMEOUT_OR_CMD- optional timeout or command on optimized binary command
 #   if the value is a number with an optional trailing 
letter
-#   [smhd] it is considered a paramter to "timeout",
+#   [smhd] it is considered a parameter to "timeout",
 #   otherwise it's a shell command that wraps the optimized
 #   binary command.
 #
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 86ca05644c703..1e9ca0ae7822d 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -876,7 +876,7 @@ class CollectExtraHighlightings
 
 if (auto *ProtoType = FD->getType()->getAs()) {
   // Iterate over the types of the function parameters.
-  // If any of them are non-const reference paramteres, add it as a
+  // If any of them are non-const reference parameteres, add it as a
   // highlighting modifier to the corresponding expression
   for (size_t I = 0;
I < std::min(size_t(ProtoType->getNumParams()), Args.size()); ++I) {
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7978df0cc71cc..881bcd7415edd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -381,12 +381,12 @@ Bug Fixes to C++ Support
   now also works if the constraint has non-type or template template 
parameters.
   (#GH131798)
 - Fixes matching of nested template template parameters. (#GH130362)
-- Correctly diagnoses template template paramters which have a pack parameter
+- Correctly diagnoses template template parameters which have a pack parameter
   not in the last position.
 - Clang now correctly parses ``if constexpr`` expressions in immediate 
function context. (#GH123524)
 - Fixed an assertion failure affecting code that uses C++23 "deducing this". 
(#GH130272)
 - Clang now properly instantiates destructors for initialized members within 
non-delegating constructors. (#GH93251)
-- Correctly diagnoses if unresolved using declarations shadows template 
paramters (#GH129411)
+- Correctly diagnoses if unresolved using declarations shadows template 
parameters (#GH129411)
 - Fixed C++20 aggregate initialization rules being incorrectly applied in 
certain contexts. (#GH131320)
 - Clang was previously coale

[Lldb-commits] [lldb] [lldb] Use correct path for lldb-server executable (PR #131519)

2025-04-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

/cherry-pick 945c494e2c3c078e26ff521ef3e9455e0ff764ac

https://github.com/llvm/llvm-project/pull/131519
___
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 lldb-server executable (PR #131519)

2025-04-02 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Return *const* UnwindPlan pointers from FuncUnwinders (PR #133247)

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


@@ -36,18 +36,19 @@ class FuncUnwinders {
 
   ~FuncUnwinders();
 
-  lldb::UnwindPlanSP GetUnwindPlanAtCallSite(Target &target, Thread &thread);
+  std::shared_ptr GetUnwindPlanAtCallSite(Target &target,

labath wrote:

Heh, that seems like quite a long time ago. Well.. I guess I'm at least 
consistent :)

I didn't realize you were actually experimenting with that approach. I'm going 
to take this to mean that such an idea has a non-zero chance of being accepted 
:) (ofc, there should be an rfc for that, and ideally some semi-automated 
method/tool to do the conversion) 

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


[Lldb-commits] [lldb] [lldb-dap] Adding support for cancelling a request. (PR #130169)

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

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

Didn't look at the code all too closely but it looks okay to me. I believe my 
earlier concerns about cancellation races are resolved now.

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


[Lldb-commits] [lldb] [lldb-dap] Adding support for cancelling a request. (PR #130169)

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


@@ -778,28 +817,121 @@ llvm::Error DAP::Disconnect(bool terminateDebuggee) {
   return ToError(error);
 }
 
+bool DAP::IsCancelled(const protocol::Request &req) {
+  std::lock_guard lock(m_cancelled_requests_mutex);
+  return m_cancelled_requests.contains(req.seq);
+}
+
+void DAP::ClearCancelRequest(const CancelArguments &args) {
+  std::lock_guard cancalled_requests_lock(

labath wrote:

```suggestion
  std::lock_guard lock(
```

It matches the name you use above, and I think the function is short enough..

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


[Lldb-commits] [lldb] [lldb] Show the path to the .o instead of the containing .a in progress events (PR #133370)

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

JDevlieghere wrote:

Any concerns with this @clayborg? This pretty much does exactly what you 
suggested in https://github.com/llvm/llvm-project/pull/133211.

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


[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

2025-04-02 Thread via lldb-commits


@@ -0,0 +1,283 @@
+//===-- DILParser.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
+//
+// This implements the recursive descent parser for the Data Inspection
+// Language (DIL), and its helper functions, which will eventually underlie the
+// 'frame variable' command. The language that this parser recognizes is
+// described in lldb/docs/dil-expr-lang.ebnf
+//
+//===--===//
+
+#include "lldb/ValueObject/DILParser.h"
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Utility/DiagnosticsRendering.h"
+#include "lldb/ValueObject/DILAST.h"
+#include "lldb/ValueObject/DILEval.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatAdapters.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace lldb_private::dil {
+
+DILDiagnosticError::DILDiagnosticError(llvm::StringRef expr,
+   const std::string &message, uint32_t 
loc,
+   uint16_t err_len)
+: ErrorInfo(make_error_code(std::errc::invalid_argument)) {
+  DiagnosticDetail::SourceLocation sloc = {
+  FileSpec{}, /*line=*/1, static_cast(loc + 1),
+  err_len,false,  /*in_user_input=*/true};
+  std::string rendered_msg =
+  llvm::formatv(":1:{0}: {1}\n   1 | {2}\n | ^",
+loc + 1, message, expr);
+  DiagnosticDetail detail;
+  detail.source_location = sloc;
+  detail.severity = lldb::eSeverityError;
+  detail.message = message;
+  detail.rendered = rendered_msg;
+  m_detail = std::move(detail);
+}
+
+llvm::Expected
+DILParser::Parse(llvm::StringRef dil_input_expr, DILLexer lexer,
+ std::shared_ptr frame_sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic,
+ bool fragile_ivar, bool check_ptr_vs_member) {
+  Status lldb_error;
+  // Cannot declare an llvm::Error without initializing it to something, 
because
+  // llvm::Error::Error() constructor is protected. If there's a better way to
+  // handle this, please let me know.
+  llvm::Error error(lldb_error.takeError());
+  DILParser parser(dil_input_expr, lexer, frame_sp, use_dynamic, use_synthetic,
+   fragile_ivar, check_ptr_vs_member, error);
+
+  ASTNodeUP node_up = parser.Run();
+
+  if (error)
+return error;
+
+  return node_up;
+}
+
+DILParser::DILParser(llvm::StringRef dil_input_expr, DILLexer lexer,
+ std::shared_ptr frame_sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic,
+ bool fragile_ivar, bool check_ptr_vs_member,
+ llvm::Error &error)
+: m_ctx_scope(frame_sp), m_input_expr(dil_input_expr),
+  m_dil_lexer(std::move(lexer)), m_error(error), 
m_use_dynamic(use_dynamic),
+  m_use_synthetic(use_synthetic), m_fragile_ivar(fragile_ivar),
+  m_check_ptr_vs_member(check_ptr_vs_member) {}
+
+ASTNodeUP DILParser::Run() {
+  ASTNodeUP expr = ParseExpression();
+
+  Expect(Token::Kind::eof);
+
+  return expr;
+}
+
+// Parse an expression.
+//
+//  expression:
+//primary_expression
+//
+ASTNodeUP DILParser::ParseExpression() { return ParsePrimaryExpression(); }
+
+// Parse a primary_expression.
+//
+//  primary_expression:
+//id_expression
+//"(" expression ")"
+//
+ASTNodeUP DILParser::ParsePrimaryExpression() {
+  if (CurToken().IsOneOf({Token::coloncolon, Token::identifier})) {
+// Save the source location for the diagnostics message.
+uint32_t loc = CurToken().GetLocation();
+auto identifier = ParseIdExpression();
+
+return std::make_unique(loc, identifier, m_use_dynamic,
+m_ctx_scope);
+  }
+
+  if (CurToken().Is(Token::l_paren)) {
+m_dil_lexer.Advance();
+auto expr = ParseExpression();
+Expect(Token::r_paren);
+m_dil_lexer.Advance();
+return expr;
+  }
+
+  BailOut(ErrorCode::kInvalidExpressionSyntax,
+  llvm::formatv("Unexpected token: {0}", CurToken()),
+  CurToken().GetLocation());
+  return std::make_unique();
+}
+
+// Parse nested_name_specifier.
+//
+//  nested_name_specifier:
+//type_name "::"
+//namespace_name "::"
+//nested_name_specifier identifier "::"
+//
+std::string DILParser::ParseNestedNameSpecifier() {
+  // The first token in nested_name_specifier is always an identifier, or
+  // '(anonymous namespace)'.
+  if (CurToken().IsNot(Token::identifier) && CurToken().IsNot(Token::l_paren))
+return "";
+
+  // Anonymous namespaces need to be treated specially: They are represented
+  // the the string '(anonymous namespace)', which has a space in it (throwing
+  // off normal parsing) and is not actually proper C++> Check to see if w

[Lldb-commits] [lldb] [lldb-dap] Speed up TestDAP_Progress (PR #134048)

2025-04-02 Thread Jacob Lalonde via lldb-commits

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

LGTM! Thanks for fixing

https://github.com/llvm/llvm-project/pull/134048
___
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-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

`test_platform_process_launch_gdb_server` is worth looking into.

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] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

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


@@ -0,0 +1,131 @@
+//===-- DILParser.h -*- C++ 
-*-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_VALUEOBJECT_DILPARSER_H
+#define LLDB_VALUEOBJECT_DILPARSER_H
+
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Utility/DiagnosticsRendering.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/ValueObject/DILAST.h"
+#include "lldb/ValueObject/DILLexer.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace lldb_private::dil {
+
+enum class ErrorCode : unsigned char {
+  kOk = 0,
+  kInvalidExpressionSyntax,
+  kUndeclaredIdentifier,
+  kUnknown,
+};
+
+// The following is modeled on class OptionParseError.
+class DILDiagnosticError
+: public llvm::ErrorInfo {
+  std::vector m_details;
+
+public:
+  using llvm::ErrorInfo::ErrorInfo;
+  DILDiagnosticError(DiagnosticDetail detail)
+  : ErrorInfo(std::error_code(EINVAL, std::generic_category())),
+m_details({detail}) {}
+
+  DILDiagnosticError(ErrorCode ec, llvm::StringRef expr,

labath wrote:

Well.. kind of, but now the same question can be asked about the BailOut 
function. If you don't plan to use the error code code for anything, I think we 
should delete *all* references to it.

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


[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

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


@@ -0,0 +1,273 @@
+//===-- DILParser.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
+//
+// This implements the recursive descent parser for the Data Inspection
+// Language (DIL), and its helper functions, which will eventually underlie the
+// 'frame variable' command. The language that this parser recognizes is
+// described in lldb/docs/dil-expr-lang.ebnf
+//
+//===--===//
+
+#include "lldb/ValueObject/DILParser.h"
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Utility/DiagnosticsRendering.h"
+#include "lldb/ValueObject/DILAST.h"
+#include "lldb/ValueObject/DILEval.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatAdapters.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace lldb_private::dil {
+
+std::string FormatDiagnostics(llvm::StringRef text, const std::string &message,
+  uint32_t loc, uint16_t err_len) {
+  DiagnosticDetail::SourceLocation sloc = {
+  FileSpec{}, /*line=*/1, static_cast(loc + 1),
+  err_len,false,  /*in_user_input=*/true};
+  std::string arrow_str = "^";
+  std::string rendered_msg =
+  llvm::formatv(":1:{0}: {1}\n1 | {2}\n | ^",
+loc + 1, message, text);
+  DiagnosticDetail detail;
+  detail.source_location = sloc;
+  detail.severity = lldb::eSeverityError;
+  detail.message = message;
+  detail.rendered = rendered_msg;
+  std::vector diagnostics;
+  diagnostics.push_back(detail);
+  StreamString diag_stream(true);
+  RenderDiagnosticDetails(diag_stream, 7, true, diagnostics);
+  std::string ret_str = text.str() + "\n" + diag_stream.GetString().str();
+  return ret_str;
+}
+
+llvm::Expected
+DILParser::Parse(llvm::StringRef dil_input_expr, DILLexer lexer,
+ std::shared_ptr frame_sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic,
+ bool fragile_ivar, bool check_ptr_vs_member) {
+  Status error;
+  DILParser parser(dil_input_expr, lexer, frame_sp, use_dynamic, use_synthetic,
+   fragile_ivar, check_ptr_vs_member, error);
+  return parser.Run();

labath wrote:

You can initialize it to `llvm::Error::success()`

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


[Lldb-commits] [lldb] [lldb] Return *const* UnwindPlan pointers from FuncUnwinders (PR #133247)

2025-04-02 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/15320


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: 
commands/expression/persistent_ptr_update/TestPersistentPtrUpdate.py (112 of 
2113)
PASS: lldb-api :: commands/expression/options/TestExprOptions.py (113 of 2113)
PASS: lldb-api :: commands/expression/nested/TestNestedExpressions.py (114 of 
2113)
PASS: lldb-api :: 
commands/expression/persistent_types/TestNestedPersistentTypes.py (115 of 2113)
UNSUPPORTED: lldb-api :: 
commands/expression/po_persistent_result/TestPoPersistentResult.py (116 of 2113)
UNSUPPORTED: lldb-api :: commands/expression/po_verbosity/TestPoVerbosity.py 
(117 of 2113)
PASS: lldb-api :: commands/expression/persistent_types/TestPersistentTypes.py 
(118 of 2113)
PASS: lldb-api :: commands/expression/no-deadlock/TestExprDoesntBlock.py (119 
of 2113)
PASS: lldb-api :: 
commands/expression/persistent_variables/TestPersistentVariables.py (120 of 
2113)
PASS: lldb-api :: commands/expression/pr52257/TestExprCrash.py (121 of 2113)
FAIL: lldb-api :: commands/expression/persistent_result/TestPersistentResult.py 
(122 of 2113)
 TEST 'lldb-api :: 
commands/expression/persistent_result/TestPersistentResult.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/commands/expression/persistent_result
 -p TestPersistentResult.py
--
Exit Code: -11

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

--
Command Output (stderr):
--
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_disable_persistent_result_dsym (TestPersistentResult.TestCase) (test case 
does not fall in any category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_disable_persistent_result_dwarf (TestPersistentResult.TestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_disable_persistent_result_dwo (TestPersistentResult.TestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_enable_persistent_result_dsym (TestPersistentResult.TestCase) (test case 
does not fall in any category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_enable_persistent_result_dwarf (TestPersistentResult.TestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_enable_persistent_result_dwo (TestPersistentResult.TestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_expression_persists_result_dsym (TestPersistentResult.TestCase) (test case 
does not fall in any category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_expression_persists_result_dwarf (TestPersistentResult.TestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_expression_persists_result_dwo (TestPersistentResult.TestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/

[Lldb-commits] [lldb] [lldb] Hoist UUID generation into the UUID class (PR #133662)

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

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


[Lldb-commits] [lldb] [lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame if one exists (PR #134097)

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

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

When using `SBFrame::EvaluateExpression` on a frame that's not the currently 
selected frame, we would sometimes run into errors such as:
```
error: error: The context has changed before we could JIT the expression!
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
```

Durin expression parsing, we call `RunStaticInitializers`. On our internal fork 
this happens quite frequently because any usage of, e.g., function pointers, 
will inject ptrauth fixup code into the expression.  The static initializers 
are run using `RunThreadPlan`. The `ExecutionContext::m_frame_sp` going into 
the `RunThreadPlan` is the `SBFrame` that we called `EvaluateExpression` on. 
LLDB then tries to save this frame to restore it later (the restore occurs by 
unconditionally overwriting whatever is in `ExecutionContext::m_frame_sp`). 
However, if the `selected_frame_sp` is not the same as the `SBFrame`, then 
`RunThreadPlan` would set the `ExecutionContext`'s frame to a different frame 
than what we started with. When we `PrepareToExecuteJITExpression`, LLDB checks 
whether the `ExecutionContext` frame changed from when we initially 
`EvaluateExpression`, and if did, bails out with the error above.

One such test-case is attached. This currently passes regardless of the fix 
because our ptrauth static initializers code isn't upstream yet. But the plan 
is to upstream it soon.

This patch addresses the issue by saving/restoring the frame of the incoming 
`ExecutionContext`, if such frame exists. Otherwise, fall back to using the 
selected frame.

rdar://147456589

>From 151ad919ab6f2d87991511b293f4a9797210f82f Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 2 Apr 2025 15:48:25 +0100
Subject: [PATCH] [lldb][Target] RunThreadPlan to save/restore the
 ExecutionContext's frame if one exists

When using `SBFrame::EvaluateExpression` on a frame that's not the
currently selected frame, we would sometimes run into errors such as:
```
error: error: The context has changed before we could JIT the expression!
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
```

Durin expression parsing, we call `RunStaticInitializers`. On our internal fork 
this happens quite frequently because any usage of, e.g., function pointers, 
will inject ptrauth fixup code into the expression.  The static initializers 
are run using `RunThreadPlan`. The `ExecutionContext::m_frame_sp` going into 
the `RunThreadPlan` is the `SBFrame` that we called `EvaluateExpression` on. 
LLDB then tries to save this frame to restore it later (the restore occurs by 
unconditionally overwriting whatever is in `ExecutionContext::m_frame_sp`). 
However, if the `selected_frame_sp` is not the same as the `SBFrame`, then 
`RunThreadPlan` would set the `ExecutionContext`'s frame to a different frame 
than what we started with. When we `PrepareToExecuteJITExpression`, LLDB checks 
whether the `ExecutionContext` frame changed from when we initially 
`EvaluateExpression`, and if did, bails out with the error above.

One such test-case is attached. This currently passes regardless of the fix 
because our ptrauth static initializers code isn't upstream yet. But the plan 
is to upstream it soon.

This patch addresses the issue by saving/restoring the frame of the incoming 
`ExecutionContext`, if such frame exists. Otherwise, fall back to using the 
selected frame.
---
 lldb/source/Target/Process.cpp|  8 -
 .../expr-from-non-zero-frame/Makefile |  3 ++
 .../TestExprFromNonZeroFrame.py   | 29 +++
 .../expr-from-non-zero-frame/main.cpp |  6 
 4 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile
 create mode 100644 
lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
 create mode 100644 
lldb/test/API/commands/expression/expr-from-non-zero-frame/main.cpp

diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 369933234ccca..f4ecb0b7ea307 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5080,7 +5080,13 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
 return eExpressionSetupError;
   }
 
-  StackID ctx_frame_id = selected_frame_sp->GetStackID();
+  // If the ExecutionContext has a frame, we want to make sure to save/restore
+  // that frame into exe_ctx. This can happen when we run expressions from a
+  // non-selected SBFrame, in which case we don't want some thread-plan
+  // to overwrite the ExecutionContext frame.
+  StackID ctx_frame_id = exe_ctx.HasFrameScope()
+ ? exe_ctx.GetFrameRef().GetStackID()
+ : selected_frame_sp->GetStackID();
 
   // N.B. Running the target may unset the currently selected thread and frame.
   // We don't want to do that

[Lldb-commits] [lldb] [lldb-dap] Speed up TestDAP_Progress (PR #134048)

2025-04-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

While trying to make progress on #133782, I noticed that 
TestDAP_Progress was taking 90 seconds to complete. This patch brings that down 
to 10 seocnds by making the following changes:

1. Don't call `wait_for_event` with a 15 second timeout. By the time we call 
this, all progress events have been emitted, which means that we're just 
sitting there until we hit the timeout.

2. Don't use 10 steps (= 10 seconds) for indeterminate progress. We have two 
indeterminate progress tests so that's 6 seconds instead of 20.

3. Don't launch the process over and over. Once we have a dap session, we can 
clear the progress vector and emit new progress events.

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


2 Files Affected:

- (modified) lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py (+5-5) 
- (modified) lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py (+7-46) 


``diff
diff --git a/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py 
b/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
index 445d1bdf4e496..33dee33e28b23 100644
--- a/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
+++ b/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
@@ -38,8 +38,8 @@ def create_options(cls):
 
 parser.add_option(
 "--total",
-dest="total",
-help="Total items in this progress object. When this option is not 
specified, this will be an indeterminate progress.",
+dest="total", help="Total items in this progress object. When this
+option is not specified, this will be an indeterminate progress.",
 type="int",
 default=None,
 )
@@ -88,11 +88,11 @@ def __call__(self, debugger, command, exe_ctx, result):
 progress = lldb.SBProgress(
 "Progress tester", "Initial Detail", total, debugger
 )
-# Check to see if total is set to None to indicate an indeterminate 
progress
-# then default to 10 steps.
+# Check to see if total is set to None to indicate an indeterminate
+# progress then default to 3 steps.
 with progress:
 if total is None:
-total = 10
+total = 3
 
 for i in range(1, total):
 if cmd_options.no_details:
diff --git a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py 
b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
index f723a2d254825..ffe3d38eb49a3 100755
--- a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
+++ b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
@@ -19,7 +19,6 @@ def verify_progress_events(
 expected_not_in_message=None,
 only_verify_first_update=False,
 ):
-self.dap_server.wait_for_event("progressEnd", 15)
 self.assertTrue(len(self.dap_server.progress_events) > 0)
 start_found = False
 update_found = False
@@ -45,20 +44,18 @@ def verify_progress_events(
 self.assertTrue(start_found)
 self.assertTrue(update_found)
 self.assertTrue(end_found)
+self.dap_server.progress_events.clear()
 
 @skipIfWindows
-def test_output(self):
+def test(self):
 program = self.getBuildArtifact("a.out")
 self.build_and_launch(program)
 progress_emitter = os.path.join(os.getcwd(), "Progress_emitter.py")
-source = "main.cpp"
-breakpoint_ids = self.set_source_breakpoints(
-source, [line_number(source, "// break here")]
-)
-self.continue_to_breakpoints(breakpoint_ids)
 self.dap_server.request_evaluate(
 f"`command script import {progress_emitter}", context="repl"
 )
+
+# Test details.
 self.dap_server.request_evaluate(
 "`test-progress --total 3 --seconds 1", context="repl"
 )
@@ -68,19 +65,7 @@ def test_output(self):
 expected_not_in_message="Progress tester",
 )
 
-@skipIfWindows
-def test_output_nodetails(self):
-program = self.getBuildArtifact("a.out")
-self.build_and_launch(program)
-progress_emitter = os.path.join(os.getcwd(), "Progress_emitter.py")
-source = "main.cpp"
-breakpoint_ids = self.set_source_breakpoints(
-source, [line_number(source, "// break here")]
-)
-self.continue_to_breakpoints(breakpoint_ids)
-self.dap_server.request_evaluate(
-f"`command script import {progress_emitter}", context="repl"
-)
+# Test no details.
 self.dap_server.request_evaluate(
 "`test-progress --total 3 --seconds 1 --no-details", context="repl"
 )
@@ -90,19 +75,7 @@ def test_output_nodetails(self):
 expected_message="Initial Detail",
 )
 
-@skipIfWindows
-def test_output_inde

[Lldb-commits] [lldb] [lldb-dap] Speed up TestDAP_Progress (PR #134048)

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

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

>From 960aefe0d5f79eef7cc9cb6d4912f6075e60a816 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 2 Apr 2025 01:19:58 -0700
Subject: [PATCH] [lldb-dap] Speed up TestDAP_Progress

While trying to make progress on #133782, I noticed that
TestDAP_Progress was taking 90 seconds to complete. This patch brings
that down to 10 seocnds by making the following changes:

1. Don't call `wait_for_event` with a 15 second timeout. By the time we
   call this, all progress events have been emitted, which means that
   we're just sitting there until we hit the timeout.

2. Don't use 10 steps (= 10 seconds) for indeterminate progress. We have
   two indeterminate progress tests so that's 6 seconds instead of 20.

3. Don't launch the process over and over. Once we have a dap session,
   we can clear the progress vector and emit new progress events.
---
 .../lldb-dap/progress/Progress_emitter.py |  6 +--
 .../lldb-dap/progress/TestDAP_Progress.py | 53 +++
 2 files changed, 10 insertions(+), 49 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py 
b/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
index 445d1bdf4e496..0bf785e3201b0 100644
--- a/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
+++ b/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
@@ -88,11 +88,11 @@ def __call__(self, debugger, command, exe_ctx, result):
 progress = lldb.SBProgress(
 "Progress tester", "Initial Detail", total, debugger
 )
-# Check to see if total is set to None to indicate an indeterminate 
progress
-# then default to 10 steps.
+# Check to see if total is set to None to indicate an indeterminate
+# progress then default to 3 steps.
 with progress:
 if total is None:
-total = 10
+total = 3
 
 for i in range(1, total):
 if cmd_options.no_details:
diff --git a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py 
b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
index f723a2d254825..ffe3d38eb49a3 100755
--- a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
+++ b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
@@ -19,7 +19,6 @@ def verify_progress_events(
 expected_not_in_message=None,
 only_verify_first_update=False,
 ):
-self.dap_server.wait_for_event("progressEnd", 15)
 self.assertTrue(len(self.dap_server.progress_events) > 0)
 start_found = False
 update_found = False
@@ -45,20 +44,18 @@ def verify_progress_events(
 self.assertTrue(start_found)
 self.assertTrue(update_found)
 self.assertTrue(end_found)
+self.dap_server.progress_events.clear()
 
 @skipIfWindows
-def test_output(self):
+def test(self):
 program = self.getBuildArtifact("a.out")
 self.build_and_launch(program)
 progress_emitter = os.path.join(os.getcwd(), "Progress_emitter.py")
-source = "main.cpp"
-breakpoint_ids = self.set_source_breakpoints(
-source, [line_number(source, "// break here")]
-)
-self.continue_to_breakpoints(breakpoint_ids)
 self.dap_server.request_evaluate(
 f"`command script import {progress_emitter}", context="repl"
 )
+
+# Test details.
 self.dap_server.request_evaluate(
 "`test-progress --total 3 --seconds 1", context="repl"
 )
@@ -68,19 +65,7 @@ def test_output(self):
 expected_not_in_message="Progress tester",
 )
 
-@skipIfWindows
-def test_output_nodetails(self):
-program = self.getBuildArtifact("a.out")
-self.build_and_launch(program)
-progress_emitter = os.path.join(os.getcwd(), "Progress_emitter.py")
-source = "main.cpp"
-breakpoint_ids = self.set_source_breakpoints(
-source, [line_number(source, "// break here")]
-)
-self.continue_to_breakpoints(breakpoint_ids)
-self.dap_server.request_evaluate(
-f"`command script import {progress_emitter}", context="repl"
-)
+# Test no details.
 self.dap_server.request_evaluate(
 "`test-progress --total 3 --seconds 1 --no-details", context="repl"
 )
@@ -90,19 +75,7 @@ def test_output_nodetails(self):
 expected_message="Initial Detail",
 )
 
-@skipIfWindows
-def test_output_indeterminate(self):
-program = self.getBuildArtifact("a.out")
-self.build_and_launch(program)
-progress_emitter = os.path.join(os.getcwd(), "Progress_emitter.py")
-source = "main.cpp"
-breakpoint_ids = self.set_source_breakpoints(
-source, [line_number(source, "// break here")]
-)
-self.continue_to_breakpoint

[Lldb-commits] [lldb] [lldb] Hoist UUID generation into the UUID class (PR #133662)

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

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


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


[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

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


@@ -0,0 +1,283 @@
+//===-- DILParser.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
+//
+// This implements the recursive descent parser for the Data Inspection
+// Language (DIL), and its helper functions, which will eventually underlie the
+// 'frame variable' command. The language that this parser recognizes is
+// described in lldb/docs/dil-expr-lang.ebnf
+//
+//===--===//
+
+#include "lldb/ValueObject/DILParser.h"
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Utility/DiagnosticsRendering.h"
+#include "lldb/ValueObject/DILAST.h"
+#include "lldb/ValueObject/DILEval.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatAdapters.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace lldb_private::dil {
+
+DILDiagnosticError::DILDiagnosticError(llvm::StringRef expr,
+   const std::string &message, uint32_t 
loc,
+   uint16_t err_len)
+: ErrorInfo(make_error_code(std::errc::invalid_argument)) {
+  DiagnosticDetail::SourceLocation sloc = {
+  FileSpec{}, /*line=*/1, static_cast(loc + 1),
+  err_len,false,  /*in_user_input=*/true};
+  std::string rendered_msg =
+  llvm::formatv(":1:{0}: {1}\n   1 | {2}\n | ^",
+loc + 1, message, expr);
+  DiagnosticDetail detail;
+  detail.source_location = sloc;
+  detail.severity = lldb::eSeverityError;
+  detail.message = message;
+  detail.rendered = rendered_msg;
+  m_detail = std::move(detail);
+}
+
+llvm::Expected
+DILParser::Parse(llvm::StringRef dil_input_expr, DILLexer lexer,
+ std::shared_ptr frame_sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic,
+ bool fragile_ivar, bool check_ptr_vs_member) {
+  Status lldb_error;
+  // Cannot declare an llvm::Error without initializing it to something, 
because
+  // llvm::Error::Error() constructor is protected. If there's a better way to
+  // handle this, please let me know.
+  llvm::Error error(lldb_error.takeError());
+  DILParser parser(dil_input_expr, lexer, frame_sp, use_dynamic, use_synthetic,
+   fragile_ivar, check_ptr_vs_member, error);
+
+  ASTNodeUP node_up = parser.Run();
+
+  if (error)
+return error;
+
+  return node_up;
+}
+
+DILParser::DILParser(llvm::StringRef dil_input_expr, DILLexer lexer,
+ std::shared_ptr frame_sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic,
+ bool fragile_ivar, bool check_ptr_vs_member,
+ llvm::Error &error)
+: m_ctx_scope(frame_sp), m_input_expr(dil_input_expr),
+  m_dil_lexer(std::move(lexer)), m_error(error), 
m_use_dynamic(use_dynamic),
+  m_use_synthetic(use_synthetic), m_fragile_ivar(fragile_ivar),
+  m_check_ptr_vs_member(check_ptr_vs_member) {}
+
+ASTNodeUP DILParser::Run() {
+  ASTNodeUP expr = ParseExpression();
+
+  Expect(Token::Kind::eof);
+
+  return expr;
+}
+
+// Parse an expression.
+//
+//  expression:
+//primary_expression
+//
+ASTNodeUP DILParser::ParseExpression() { return ParsePrimaryExpression(); }
+
+// Parse a primary_expression.
+//
+//  primary_expression:
+//id_expression
+//"(" expression ")"
+//
+ASTNodeUP DILParser::ParsePrimaryExpression() {
+  if (CurToken().IsOneOf({Token::coloncolon, Token::identifier})) {
+// Save the source location for the diagnostics message.
+uint32_t loc = CurToken().GetLocation();
+auto identifier = ParseIdExpression();
+
+return std::make_unique(loc, identifier, m_use_dynamic,
+m_ctx_scope);
+  }
+
+  if (CurToken().Is(Token::l_paren)) {
+m_dil_lexer.Advance();
+auto expr = ParseExpression();
+Expect(Token::r_paren);
+m_dil_lexer.Advance();
+return expr;
+  }
+
+  BailOut(ErrorCode::kInvalidExpressionSyntax,
+  llvm::formatv("Unexpected token: {0}", CurToken()),
+  CurToken().GetLocation());
+  return std::make_unique();
+}
+
+// Parse nested_name_specifier.
+//
+//  nested_name_specifier:
+//type_name "::"
+//namespace_name "::"
+//nested_name_specifier identifier "::"
+//
+std::string DILParser::ParseNestedNameSpecifier() {
+  // The first token in nested_name_specifier is always an identifier, or
+  // '(anonymous namespace)'.
+  if (CurToken().IsNot(Token::identifier) && CurToken().IsNot(Token::l_paren))
+return "";
+
+  // Anonymous namespaces need to be treated specially: They are represented
+  // the the string '(anonymous namespace)', which has a space in it (throwing
+  // off normal parsing) and is not actually proper C++> Check to see if w

[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

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


@@ -0,0 +1,283 @@
+//===-- DILParser.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
+//
+// This implements the recursive descent parser for the Data Inspection
+// Language (DIL), and its helper functions, which will eventually underlie the
+// 'frame variable' command. The language that this parser recognizes is
+// described in lldb/docs/dil-expr-lang.ebnf
+//
+//===--===//
+
+#include "lldb/ValueObject/DILParser.h"
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Utility/DiagnosticsRendering.h"
+#include "lldb/ValueObject/DILAST.h"
+#include "lldb/ValueObject/DILEval.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatAdapters.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace lldb_private::dil {
+
+DILDiagnosticError::DILDiagnosticError(llvm::StringRef expr,
+   const std::string &message, uint32_t 
loc,
+   uint16_t err_len)
+: ErrorInfo(make_error_code(std::errc::invalid_argument)) {
+  DiagnosticDetail::SourceLocation sloc = {
+  FileSpec{}, /*line=*/1, static_cast(loc + 1),
+  err_len,false,  /*in_user_input=*/true};
+  std::string rendered_msg =
+  llvm::formatv(":1:{0}: {1}\n   1 | {2}\n | ^",
+loc + 1, message, expr);
+  DiagnosticDetail detail;
+  detail.source_location = sloc;
+  detail.severity = lldb::eSeverityError;
+  detail.message = message;
+  detail.rendered = rendered_msg;
+  m_detail = std::move(detail);
+}
+
+llvm::Expected
+DILParser::Parse(llvm::StringRef dil_input_expr, DILLexer lexer,
+ std::shared_ptr frame_sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic,
+ bool fragile_ivar, bool check_ptr_vs_member) {
+  Status lldb_error;
+  // Cannot declare an llvm::Error without initializing it to something, 
because
+  // llvm::Error::Error() constructor is protected. If there's a better way to
+  // handle this, please let me know.
+  llvm::Error error(lldb_error.takeError());
+  DILParser parser(dil_input_expr, lexer, frame_sp, use_dynamic, use_synthetic,
+   fragile_ivar, check_ptr_vs_member, error);
+
+  ASTNodeUP node_up = parser.Run();
+
+  if (error)
+return error;
+
+  return node_up;
+}
+
+DILParser::DILParser(llvm::StringRef dil_input_expr, DILLexer lexer,
+ std::shared_ptr frame_sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic,
+ bool fragile_ivar, bool check_ptr_vs_member,
+ llvm::Error &error)
+: m_ctx_scope(frame_sp), m_input_expr(dil_input_expr),
+  m_dil_lexer(std::move(lexer)), m_error(error), 
m_use_dynamic(use_dynamic),
+  m_use_synthetic(use_synthetic), m_fragile_ivar(fragile_ivar),
+  m_check_ptr_vs_member(check_ptr_vs_member) {}
+
+ASTNodeUP DILParser::Run() {
+  ASTNodeUP expr = ParseExpression();
+
+  Expect(Token::Kind::eof);
+
+  return expr;
+}
+
+// Parse an expression.
+//
+//  expression:
+//primary_expression
+//
+ASTNodeUP DILParser::ParseExpression() { return ParsePrimaryExpression(); }
+
+// Parse a primary_expression.
+//
+//  primary_expression:
+//id_expression
+//"(" expression ")"
+//
+ASTNodeUP DILParser::ParsePrimaryExpression() {
+  if (CurToken().IsOneOf({Token::coloncolon, Token::identifier})) {
+// Save the source location for the diagnostics message.
+uint32_t loc = CurToken().GetLocation();
+auto identifier = ParseIdExpression();
+
+return std::make_unique(loc, identifier, m_use_dynamic,
+m_ctx_scope);
+  }
+
+  if (CurToken().Is(Token::l_paren)) {
+m_dil_lexer.Advance();
+auto expr = ParseExpression();
+Expect(Token::r_paren);
+m_dil_lexer.Advance();
+return expr;
+  }
+
+  BailOut(ErrorCode::kInvalidExpressionSyntax,
+  llvm::formatv("Unexpected token: {0}", CurToken()),
+  CurToken().GetLocation());
+  return std::make_unique();
+}
+
+// Parse nested_name_specifier.
+//
+//  nested_name_specifier:
+//type_name "::"
+//namespace_name "::"
+//nested_name_specifier identifier "::"
+//
+std::string DILParser::ParseNestedNameSpecifier() {
+  // The first token in nested_name_specifier is always an identifier, or
+  // '(anonymous namespace)'.
+  if (CurToken().IsNot(Token::identifier) && CurToken().IsNot(Token::l_paren))
+return "";
+
+  // Anonymous namespaces need to be treated specially: They are represented
+  // the the string '(anonymous namespace)', which has a space in it (throwing
+  // off normal parsing) and is not actually proper C++> Check to see if w

[Lldb-commits] [lldb] [lldb/telemetry] Report exit status only once (PR #134078)

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

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

SetExitStatus can be called the second time when we reap the debug server 
process. This shouldn't be interesting as at that point, we've already told 
everyone that the process has exited.

I believe/hope this will also help with sporadic shutdown crashes that have 
cropped up recently. They happen because the debug server is monitored from a 
detached thread, so this code can be called after main returns (and starts 
destroying everything). This isn't a real fix for that though, as the situation 
can still happen (it's just that it usually happens after the exit status has 
already been set). I think the real fix for that is to make sure these threads 
terminate before we start shutting everything down.

>From 23b1f8a284a0affded1dca76a5d8a28a9ded883f Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 2 Apr 2025 14:36:21 +0200
Subject: [PATCH] [lldb/telemetry] Report exit status only once

SetExitStatus can be called the second time when we reap the debug
server process. This shouldn't be interesting as at that point, we've
already told everyone that the process has exited.

I believe/hope this will also help with sporadic shutdown crashes that
have cropped up recently. They happen because the debug server is
monitored from a detached thread, so this code can be called after main
returns (and starts destroying everything). This isn't a real fix for
that though, as the situation can still happen (it's just that it
usually happens after the exit status has already been set). I think the
real fix for that is to make sure these threads terminate before we
start shutting everything down.
---
 lldb/source/Target/Process.cpp | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 369933234ccca..7936cf28467b2 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1067,6 +1067,20 @@ const char *Process::GetExitDescription() {
 bool Process::SetExitStatus(int status, llvm::StringRef exit_string) {
   // Use a mutex to protect setting the exit status.
   std::lock_guard guard(m_exit_status_mutex);
+  Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
+  LLDB_LOG(log, "(plugin = {0} status = {1} ({1:x8}), description=\"{2}\")",
+   GetPluginName(), status, exit_string);
+
+  // We were already in the exited state
+  if (m_private_state.GetValue() == eStateExited) {
+LLDB_LOG(
+log,
+"(plugin = {0}) ignoring exit status because state was already set "
+"to eStateExited",
+GetPluginName());
+return false;
+  }
+
   telemetry::ScopedDispatcher helper;
 
   UUID module_uuid;
@@ -1089,20 +1103,6 @@ bool Process::SetExitStatus(int status, llvm::StringRef 
exit_string) {
 info->pid = m_pid;
   });
 
-  Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
-  LLDB_LOG(log, "(plugin = {0} status = {1} ({1:x8}), description=\"{2}\")",
-   GetPluginName(), status, exit_string);
-
-  // We were already in the exited state
-  if (m_private_state.GetValue() == eStateExited) {
-LLDB_LOG(
-log,
-"(plugin = {0}) ignoring exit status because state was already set "
-"to eStateExited",
-GetPluginName());
-return false;
-  }
-
   m_exit_status = status;
   if (!exit_string.empty())
 m_exit_string = exit_string.str();

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


[Lldb-commits] [lldb] [lldb/telemetry] Report exit status only once (PR #134078)

2025-04-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

SetExitStatus can be called the second time when we reap the debug server 
process. This shouldn't be interesting as at that point, we've already told 
everyone that the process has exited.

I believe/hope this will also help with sporadic shutdown crashes that have 
cropped up recently. They happen because the debug server is monitored from a 
detached thread, so this code can be called after main returns (and starts 
destroying everything). This isn't a real fix for that though, as the situation 
can still happen (it's just that it usually happens after the exit status has 
already been set). I think the real fix for that is to make sure these threads 
terminate before we start shutting everything down.

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


1 Files Affected:

- (modified) lldb/source/Target/Process.cpp (+14-14) 


``diff
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 369933234ccca..7936cf28467b2 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1067,6 +1067,20 @@ const char *Process::GetExitDescription() {
 bool Process::SetExitStatus(int status, llvm::StringRef exit_string) {
   // Use a mutex to protect setting the exit status.
   std::lock_guard guard(m_exit_status_mutex);
+  Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
+  LLDB_LOG(log, "(plugin = {0} status = {1} ({1:x8}), description=\"{2}\")",
+   GetPluginName(), status, exit_string);
+
+  // We were already in the exited state
+  if (m_private_state.GetValue() == eStateExited) {
+LLDB_LOG(
+log,
+"(plugin = {0}) ignoring exit status because state was already set "
+"to eStateExited",
+GetPluginName());
+return false;
+  }
+
   telemetry::ScopedDispatcher helper;
 
   UUID module_uuid;
@@ -1089,20 +1103,6 @@ bool Process::SetExitStatus(int status, llvm::StringRef 
exit_string) {
 info->pid = m_pid;
   });
 
-  Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
-  LLDB_LOG(log, "(plugin = {0} status = {1} ({1:x8}), description=\"{2}\")",
-   GetPluginName(), status, exit_string);
-
-  // We were already in the exited state
-  if (m_private_state.GetValue() == eStateExited) {
-LLDB_LOG(
-log,
-"(plugin = {0}) ignoring exit status because state was already set "
-"to eStateExited",
-GetPluginName());
-return false;
-  }
-
   m_exit_status = status;
   if (!exit_string.empty())
 m_exit_string = exit_string.str();

``




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


[Lldb-commits] [lldb] [LLDB][NFC]Move fields that might be referenced in scope-exit to beginning (PR #133785)

2025-04-02 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame if one exists (PR #134097)

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

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

>From 151ad919ab6f2d87991511b293f4a9797210f82f Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 2 Apr 2025 15:48:25 +0100
Subject: [PATCH 1/2] [lldb][Target] RunThreadPlan to save/restore the
 ExecutionContext's frame if one exists

When using `SBFrame::EvaluateExpression` on a frame that's not the
currently selected frame, we would sometimes run into errors such as:
```
error: error: The context has changed before we could JIT the expression!
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
```

Durin expression parsing, we call `RunStaticInitializers`. On our internal fork 
this happens quite frequently because any usage of, e.g., function pointers, 
will inject ptrauth fixup code into the expression.  The static initializers 
are run using `RunThreadPlan`. The `ExecutionContext::m_frame_sp` going into 
the `RunThreadPlan` is the `SBFrame` that we called `EvaluateExpression` on. 
LLDB then tries to save this frame to restore it later (the restore occurs by 
unconditionally overwriting whatever is in `ExecutionContext::m_frame_sp`). 
However, if the `selected_frame_sp` is not the same as the `SBFrame`, then 
`RunThreadPlan` would set the `ExecutionContext`'s frame to a different frame 
than what we started with. When we `PrepareToExecuteJITExpression`, LLDB checks 
whether the `ExecutionContext` frame changed from when we initially 
`EvaluateExpression`, and if did, bails out with the error above.

One such test-case is attached. This currently passes regardless of the fix 
because our ptrauth static initializers code isn't upstream yet. But the plan 
is to upstream it soon.

This patch addresses the issue by saving/restoring the frame of the incoming 
`ExecutionContext`, if such frame exists. Otherwise, fall back to using the 
selected frame.
---
 lldb/source/Target/Process.cpp|  8 -
 .../expr-from-non-zero-frame/Makefile |  3 ++
 .../TestExprFromNonZeroFrame.py   | 29 +++
 .../expr-from-non-zero-frame/main.cpp |  6 
 4 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile
 create mode 100644 
lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
 create mode 100644 
lldb/test/API/commands/expression/expr-from-non-zero-frame/main.cpp

diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 369933234ccca..f4ecb0b7ea307 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5080,7 +5080,13 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
 return eExpressionSetupError;
   }
 
-  StackID ctx_frame_id = selected_frame_sp->GetStackID();
+  // If the ExecutionContext has a frame, we want to make sure to save/restore
+  // that frame into exe_ctx. This can happen when we run expressions from a
+  // non-selected SBFrame, in which case we don't want some thread-plan
+  // to overwrite the ExecutionContext frame.
+  StackID ctx_frame_id = exe_ctx.HasFrameScope()
+ ? exe_ctx.GetFrameRef().GetStackID()
+ : selected_frame_sp->GetStackID();
 
   // N.B. Running the target may unset the currently selected thread and frame.
   // We don't want to do that either, so we should arrange to reset them as
diff --git 
a/lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile 
b/lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile
new file mode 100644
index 0..8b20bcb05
--- /dev/null
+++ b/lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git 
a/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
 
b/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
new file mode 100644
index 0..e87279abde406
--- /dev/null
+++ 
b/lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
@@ -0,0 +1,29 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ExprFromNonZeroFrame(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipIf(archs=no_match(["arm64e"]))
+def test(self):
+"""
+Tests that we can use SBFrame::EvaluateExpression on a frame
+that we're not stopped in, even if thread-plans run as part of
+parsing the expression (e.g., when running static initializers).
+"""
+self.build()
+
+(_, _, thread, _) = lldbutil.run_to_source_breakpoint(
+self, "Break here", lldb.SBFileSpec("main.cpp")
+)
+frame = thread.GetFrameAtIndex(1)
+
+# Using a function pointer inside the expression ensures we
+

[Lldb-commits] [lldb] [lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame if one exists (PR #134097)

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

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


[Lldb-commits] [lldb] [lldb] Hoist UUID generation into the UUID class (PR #133662)

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

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

>From f0a4b9bc2f20a812f7f37e5f5a2417dbbb4d45e0 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Sun, 30 Mar 2025 16:10:05 -0700
Subject: [PATCH 1/5] [lldb] Hoist UUID generation into the UUID class

Hoist UUID generation into the UUID class and add a trivial unit test.
This also changes the telemetry code to drop the double underscore if we
failed to generate a UUID and subsequently logs to the Host instead of
Object log channel.
---
 lldb/include/lldb/Utility/UUID.h| 28 
 lldb/source/Core/Telemetry.cpp  | 21 +++--
 lldb/source/Utility/UUID.cpp|  9 +
 lldb/unittests/Utility/UUIDTest.cpp | 14 --
 4 files changed, 48 insertions(+), 24 deletions(-)

diff --git a/lldb/include/lldb/Utility/UUID.h b/lldb/include/lldb/Utility/UUID.h
index bc4b4acd5a7d8..05731ea4dc090 100644
--- a/lldb/include/lldb/Utility/UUID.h
+++ b/lldb/include/lldb/Utility/UUID.h
@@ -12,26 +12,28 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Endian.h"
+#include "llvm/Support/Error.h"
 #include 
 #include 
 #include 
+#include 
 
 namespace lldb_private {
 
-  class Stream;
+class Stream;
 
+/// Represents UUID's of various sizes.  In all cases, a uuid of all zeros is
+/// treated as an "Invalid UUID" marker, and the UUID created from such data
+/// will return false for IsValid.
 class UUID {
-  // Represents UUID's of various sizes.  In all cases, a uuid of all zeros is
-  // treated as an "Invalid UUID" marker, and the UUID created from such data
-  // will return false for IsValid.
 public:
   UUID() = default;
-  
-  /// Creates a uuid from the data pointed to by the bytes argument.
+
+  /// Create a uuid from the data pointed to by the bytes argument.
   UUID(llvm::ArrayRef bytes) : m_bytes(bytes) {
 if (llvm::all_of(m_bytes, [](uint8_t b) { return b == 0; })) {
   Clear();
-   }
+}
   }
 
   // Reference:
@@ -50,13 +52,12 @@ class UUID {
   /// Create a UUID from CvRecordPdb70.
   UUID(CvRecordPdb70 debug_info);
 
-  /// Creates a UUID from the data pointed to by the bytes argument. 
+  /// Create a UUID from the data pointed to by the bytes argument.
   UUID(const void *bytes, uint32_t num_bytes) {
 if (!bytes)
   return;
-*this 
-= UUID(llvm::ArrayRef(reinterpret_cast(bytes), 
-   num_bytes));
+*this = UUID(llvm::ArrayRef(
+reinterpret_cast(bytes), num_bytes));
   }
 
   void Clear() { m_bytes.clear(); }
@@ -67,7 +68,7 @@ class UUID {
 
   explicit operator bool() const { return IsValid(); }
   bool IsValid() const { return !m_bytes.empty(); }
-  
+
   std::string GetAsString(llvm::StringRef separator = "-") const;
 
   bool SetFromStringRef(llvm::StringRef str);
@@ -88,6 +89,9 @@ class UUID {
   DecodeUUIDBytesFromString(llvm::StringRef str,
 llvm::SmallVectorImpl &uuid_bytes);
 
+  /// Create a random UUID.
+  static llvm::Expected Generate(uint32_t num_bytes = 16);
+
 private:
   // GNU ld generates 20-byte build-ids. Size chosen to avoid heap allocations
   // for this case.
diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp
index c7789d43c7899..e9ba7d1845bb4 100644
--- a/lldb/source/Core/Telemetry.cpp
+++ b/lldb/source/Core/Telemetry.cpp
@@ -9,15 +9,18 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Telemetry.h"
 #include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
 #include "lldb/Utility/UUID.h"
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-forward.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/Format.h"
 #include "llvm/Support/RandomNumberGenerator.h"
 #include "llvm/Telemetry/Telemetry.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -37,18 +40,16 @@ static uint64_t ToNanosec(const SteadyTimePoint Point) {
 // This reduces the chances of getting the same UUID, even when the same
 // user runs the two copies of binary at the same time.
 static std::string MakeUUID() {
-  uint8_t random_bytes[16];
-  std::string randomString = "_";
-  if (auto ec = llvm::getRandomBytes(random_bytes, 16)) {
-LLDB_LOG(GetLog(LLDBLog::Object),
- "Failed to generate random bytes for UUID: {0}", ec.message());
-  } else {
-randomString = UUID(random_bytes).GetAsString();
+  auto timestmap = std::chrono::steady_clock::now().time_since_epoch().count();
+
+  llvm::Expected maybe_uuid = UUID::Generate();
+  if (!maybe_uuid) {
+LLDB_LOG_ERROR(GetLog(LLDBLog::Host), maybe_uuid.takeError(),
+   "Failed to generate random bytes for UUID: {0}");
+return llvm::formatv("{0}", timestmap);
   }
 
-  return llvm::formatv(
-  "{0}_{1}", randomString,
-  std::chrono::steady_clock::now().time_since_epoch().count());
+  return llvm::formatv("{0}_{1}", maybe_uuid->GetAsString(), timestmap)

[Lldb-commits] [lldb] [lldb][NFC] Move ShouldShow/ShouldSelect logic into Stopinfo (PR #134160)

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

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

This NFC patch simplifies the main loop in HandleProcessStateChanged event by 
moving duplicated code into the StopInfo class, also allowing StopInfo 
subclasses to override behavior.

More specifically, two functions are created:

* ShouldShow: should a Thread with such StopInfo should be printed when the 
debugger stops? Currently, no StopInfo subclasses override this, but a 
subsequent patch will fix a bug by making StopInfoBreakpoint check whether the 
breakpoint is internal.

* ShouldSelect: should a Thread with such a StopInfo be selected? This is 
currently overridden by StopInfoUnixSignal but will, in the future, be 
overridden by StopInfoBreakpoint.

>From 48150d4bb0daf57b708f4fa86285f028eeff0da6 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Wed, 2 Apr 2025 09:28:56 -0700
Subject: [PATCH] [lldb][NFC] Move ShouldShow/ShouldSelect logic into Stopinfo

This NFC patch simplifies the main loop in HandleProcessStateChanged
event by moving duplicated code into the StopInfo class, also allowing
StopInfo subclasses to override behavior.

More specifically, two functions are created:

* ShouldShow: should a Thread with such StopInfo should be printed when
  the debugger stops? Currently, no StopInfo subclasses override this,
  but a subsequent patch will fix a bug by making StopInfoBreakpoint
  check whether the breakpoint is internal.

* ShouldSelect: should a Thread with such a StopInfo be selected? This
  is currently overridden by StopInfoUnixSignal but will, in the future,
  be overridden by StopInfoBreakpoint.
---
 lldb/include/lldb/Target/StopInfo.h | 13 +
 lldb/source/Target/Process.cpp  | 78 ++---
 lldb/source/Target/StopInfo.cpp | 16 +++---
 3 files changed, 37 insertions(+), 70 deletions(-)

diff --git a/lldb/include/lldb/Target/StopInfo.h 
b/lldb/include/lldb/Target/StopInfo.h
index 9a13371708be5..5fcd3784d6f1d 100644
--- a/lldb/include/lldb/Target/StopInfo.h
+++ b/lldb/include/lldb/Target/StopInfo.h
@@ -118,6 +118,19 @@ class StopInfo : public 
std::enable_shared_from_this {
 
   StructuredData::ObjectSP GetExtendedInfo() { return m_extended_info; }
 
+  /// Returns true if this is a stop reason that should be shown to a user when
+  /// stopping.
+  virtual bool ShouldShow() const { return IsValid(); }
+
+  /// Returns true if this is a stop reason that should cause a thread to be
+  /// selected when stopping.
+  virtual bool ShouldSelect() const {
+lldb::StopReason reason = GetStopReason();
+return reason != lldb::eStopReasonNone &&
+   reason != lldb::eStopReasonHistoryBoundary &&
+   reason != lldb::eStopReasonInvalid;
+  }
+
   static lldb::StopInfoSP
   CreateStopReasonWithBreakpointSiteID(Thread &thread,
lldb::break_id_t break_id);
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 369933234ccca..502f11b5628db 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -808,30 +808,11 @@ bool Process::HandleProcessStateChangedEvent(
 std::lock_guard guard(thread_list.GetMutex());
 
 ThreadSP curr_thread(thread_list.GetSelectedThread());
-ThreadSP thread;
-StopReason curr_thread_stop_reason = eStopReasonInvalid;
-bool prefer_curr_thread = false;
-if (curr_thread && curr_thread->IsValid()) {
-  curr_thread_stop_reason = curr_thread->GetStopReason();
-  switch (curr_thread_stop_reason) {
-  case eStopReasonNone:
-  case eStopReasonInvalid:
-// Don't prefer the current thread if it didn't stop for a reason.
-break;
-  case eStopReasonSignal: {
-// We need to do the same computation we do for other threads
-// below in case the current thread happens to be the one that
-// stopped for the no-stop signal.
-uint64_t signo = curr_thread->GetStopInfo()->GetValue();
-if (process_sp->GetUnixSignals()->GetShouldStop(signo))
-  prefer_curr_thread = true;
-  } break;
-  default:
-prefer_curr_thread = true;
-break;
-  }
+
+if (curr_thread && curr_thread->IsValid())
   curr_thread_stop_info_sp = curr_thread->GetStopInfo();
-}
+bool prefer_curr_thread = curr_thread_stop_info_sp &&
+  curr_thread_stop_info_sp->ShouldSelect();
 
 if (!prefer_curr_thread) {
   // Prefer a thread that has just completed its plan over another
@@ -839,54 +820,23 @@ bool Process::HandleProcessStateChangedEvent(
   ThreadSP plan_thread;
   ThreadSP other_thread;
 
-  const size_t num_threads = thread_list.GetSize();
-  size_t i;
-  for (i = 0; i < num_threads; ++i) {
-thread = thread_list.GetThreadAtIndex(i

[Lldb-commits] [lldb] [lldb-dap] Make TestDAP_Progress more resilient (again) (PR #134157)

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


@@ -12,17 +12,31 @@
 
 
 class TestDAP_progress(lldbdap_testcase.DAPTestCaseBase):
+MAX_ATTEMPS = 10

JDevlieghere wrote:

Yeah, that's a good point. Here's my understanding why how this works:

We have a packet read thread (`read_packet_thread`) which looks at incoming 
packets. Certain packets are recognized and added to lists (e.g. the 
`progress_events`) and they don't get added to the packets list, which means 
you can't wait on them:

```
elif event.startswith("progress"):
# Progress events come in as 'progressStart', 'progressUpdate',
# and 'progressEnd' events. Keep these around in case test
# cases want to verify them.
self.progress_events.append(packet)
# No need to add 'progress' event packets to our packets list.
return keepGoing
```

If we wanted to make this work with `wait_for_event`, we can remove the last 
two lines and that way, we'll block until the packet is received. I actually 
like that approach better. Let me update the PR.

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


[Lldb-commits] [lldb] [lldb-dap] Add progress events to the packet list (PR #134157)

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

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