[Lldb-commits] [lldb] [lldb] Support riscv32 corefiles (PR #115408)

2025-04-24 Thread Alexey Merzlyakov via lldb-commits

AlexeyMerzlyakov wrote:

@JDevlieghere, to get coredump file, I've used 
[make-core.sh](https://github.com/llvm/llvm-project/blob/main/lldb/test/API/functionalities/postmortem/elf-core/make-core.sh)
 script on the target H/W. Generated file should be minimal, so you can set 
`coredump_filter` (https://man7.org/linux/man-pages/man5/core.5.html) on the 
target before getting core-file in order to reduce the number of unnecessary 
mappings written. Something like `echo 0x7 > /proc/self/coredump_filter`. I've 
used to choose minimal necessary bitset empirically, by trying setting 
different bits to 0 unless the test won't broken.

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


[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #136121)

2025-04-24 Thread via lldb-commits

dyung wrote:

Maybe I'm missing something, but was either this change or the original one 
approved for submit by someone? I don't see any review/approval in this commit, 
and the original PR doesn't seem to have been approved.

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


[Lldb-commits] [lldb] [lldb-dap] fix wrong assembly line number x64 (PR #136486)

2025-04-24 Thread John Harrison via lldb-commits

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


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


[Lldb-commits] [lldb] [llvm] [lldb] Implement CLI support for reverse-continue (PR #132783)

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

DavidSpickett wrote:

Likely won't find the fix today, but I suspect that the Windows process class 
just doesn't know that it doesn't support reverse execution:
```
(lldb) process continue --reverse
Process 3108 resuming
(lldb) process status
Process 5360 stopped
```
The process being stopped is probably due to us failing to continue properly.

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


[Lldb-commits] [lldb] [lldb-dap] fix wrong assembly line number x64 (PR #136486)

2025-04-24 Thread Ely Ronnen via lldb-commits


@@ -0,0 +1,64 @@
+"""
+Test lldb-dap stack trace containing x86 assembly
+"""
+
+import lldbdap_testcase
+from lldbsuite.test.decorators import skipUnlessArch, skipUnlessPlatform
+from lldbsuite.test.lldbtest import line_number
+
+
+class TestDAP_stacktrace_x86(lldbdap_testcase.DAPTestCaseBase):
+@skipUnlessArch("x86_64")
+@skipUnlessPlatform(["linux"])
+def test_stacktrace_x86(self):
+"""
+Tests that lldb-dap steps through correctly and the source lines are 
correct in x86 assembly.
+"""
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(
+program,
+initCommands=[
+"settings set target.process.thread.step-in-avoid-nodebug 
false"
+],
+)
+
+source = "main.c"
+breakpoint_ids = self.set_source_breakpoints(
+source,
+[line_number(source, "// Break here")],
+)
+self.continue_to_breakpoints(breakpoint_ids)
+self.stepIn()
+
+frame = self.get_stackFrames()[0]
+self.assertEqual(
+frame["name"],
+"no_branch_func",
+"verify we are in the no_branch_func function",
+)
+
+self.assertEqual(frame["line"], 1, "verify we are at the start of the 
function")
+minimum_assembly_lines = (
+line_number(source, "Assembly end")
+- line_number(source, "Assembly start")
++ 1
+)
+self.assertLessEqual(
+10,
+minimum_assembly_lines,
+"verify we have a reasonable number of assembly lines",
+)
+
+for i in range(2, minimum_assembly_lines):
+self.stepIn()

eronnen wrote:

It should be the same because it's a function without debug symbols so each 
step should execute one instruction

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


[Lldb-commits] [lldb] [llvm] [lldb] Implement CLI support for reverse-continue (PR #132783)

2025-04-24 Thread Leandro Lupori via lldb-commits

luporl wrote:

It seems this broke lldb-aarch64-windows bot: 
https://lab.llvm.org/buildbot/#/builders/141/builds/8149

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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

2025-04-24 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 h,cpp -- 
lldb/include/lldb/DataFormatters/TypeSynthetic.h 
lldb/include/lldb/DataFormatters/VectorIterator.h 
lldb/include/lldb/Interpreter/ScriptInterpreter.h 
lldb/include/lldb/Symbol/CompilerType.h lldb/include/lldb/Symbol/TypeSystem.h 
lldb/include/lldb/ValueObject/ValueObject.h 
lldb/include/lldb/ValueObject/ValueObjectRegister.h 
lldb/include/lldb/ValueObject/ValueObjectSyntheticFilter.h 
lldb/source/API/SBValue.cpp lldb/source/DataFormatters/FormatterBytecode.cpp 
lldb/source/DataFormatters/TypeSynthetic.cpp 
lldb/source/DataFormatters/VectorType.cpp 
lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp 
lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
lldb/source/Plugins/Language/CPlusPlus/Coroutines.h 
lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp 
lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxx.h 
lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxProxyArray.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp 
lldb/source/Plugins/Language/ObjC/Cocoa.cpp 
lldb/source/Plugins/Language/ObjC/NSArray.cpp 
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp 
lldb/source/Plugins/Language/ObjC/NSError.cpp 
lldb/source/Plugins/Language/ObjC/NSException.cpp 
lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp 
lldb/source/Plugins/Language/ObjC/NSSet.cpp 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
lldb/source/Symbol/CompilerType.cpp lldb/source/ValueObject/ValueObject.cpp 
lldb/source/ValueObject/ValueObjectRegister.cpp 
lldb/source/ValueObject/ValueObjectSyntheticFilter.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index c8382a87f..5f486b91b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -178,7 +178,8 @@ bool lldb_private::formatters::BlockPointerSummaryProvider(
   synthetic_children->GetIndexOfChildWithName(s_FuncPtr_name);
 
   if (!index_or_err) {
-LLDB_LOG_ERROR(GetLog(LLDBLog::DataFormatters), index_or_err.takeError(), 
"{0}");
+LLDB_LOG_ERROR(GetLog(LLDBLog::DataFormatters), index_or_err.takeError(),
+   "{0}");
 return false;
   }
 

``




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


[Lldb-commits] [lldb] Ptrace seize dead process (PR #137041)

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

labath wrote:

We already have one piece of "status" parsing code in 
`source/Host/linux/Host.cpp`. I think it'd be better to reuse that one. I'm 
slightly torn as to whether reuse Host::GetProcessInfo for this (and add a new 
field to ProcessInstanceInfo -- or possibly expand on IsZombie), or whether to 
create a new linux-specific entry point which will return this data.

> Some caveats that I need to address before we publish this PR is how to 
> prevent LLDB from running any expressions or really anything that trys to 
> SIGCONT, because that will immediately terminate the process, I would like 
> this behavior to mimic how we inform the user post mortem processes can't run 
> expressions.

I don't know the answer to that, but I can say that I don't think this feature 
needs to be (or should be) specific to this use case. One of the things that I 
would like to be able to do is to stop a process right before it exits 
(regardless of whether that's through the exit syscall, or a fatal signal, 
etc.). `PTRACE_O_TRACEEXIT` lets you do that, but it means the process will end 
up in the same "almost a zombie" state, where any attempt to resume it will 
cause it to disappear. If we had a mechanism to prevent this, we could use it 
in this case as well. (and this case, unlike this "dead" state, is actually 
testable).

I think the tricky part is that (in both cases) the user might legitimately 
want to let the process exit, and "continue" is the normal way to do that, so I 
don't think we'd want to just error out of the continue command (or from the 
`vCont` packet). I think what we'd want is to make sure that the process 
doesn't accidentally exit while running an expression (possibly from within a 
data formatter), and for that I guess we'd need to let lldb know that running 
expressions is "dangerous". We already have `Thread::SafeToCallFunctions`, even 
though it's used for a slightly different purpose, but *maybe* it could be 
extended to handle this as well?

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


[Lldb-commits] [lldb] bcdafc1 - [lldb] Disable reverse continue command test on Windows

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

Author: David Spickett
Date: 2025-04-24T12:16:29Z
New Revision: bcdafc107e1fb68893036cfba14e761c7b37b0e9

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

LOG: [lldb] Disable reverse continue command test on Windows

The new test added in https://github.com/llvm/llvm-project/pull/132783
is timing out on our Windows on Arm bot
https://lab.llvm.org/buildbot/#/builders/141/builds/8149

Disable it there while I figure out the problem.

Added: 


Modified: 

lldb/test/API/commands/process/reverse-continue/TestReverseContinueNotSupported.py

Removed: 




diff  --git 
a/lldb/test/API/commands/process/reverse-continue/TestReverseContinueNotSupported.py
 
b/lldb/test/API/commands/process/reverse-continue/TestReverseContinueNotSupported.py
index 3d318120b55cd..54d757dc4b98b 100644
--- 
a/lldb/test/API/commands/process/reverse-continue/TestReverseContinueNotSupported.py
+++ 
b/lldb/test/API/commands/process/reverse-continue/TestReverseContinueNotSupported.py
@@ -11,6 +11,7 @@
 
 
 class TestReverseContinueNotSupported(TestBase):
+@skipIfWindows
 def test_reverse_continue_not_supported(self):
 target = self.connect()
 



___
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-24 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/129728

>From 21103adacdf9c08cee4065f8a6b90ff812fefbb3 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 4 Mar 2025 11:01:46 -0500
Subject: [PATCH 01/23] [LLDB][Telemetry] Collect telemetry from client when
 allowed.

This patch is slightly different from other impl in that we dispatch 
client-telemetry via a different helper method.
This is to make it easier for vendor to opt-out (simply by overriding the 
method to do nothing).
There is also a configuration option to disallow collecting client telemetry.
---
 lldb/include/lldb/API/SBDebugger.h|  3 +
 lldb/include/lldb/Core/Debugger.h |  5 ++
 lldb/include/lldb/Core/Telemetry.h| 89 +---
 lldb/source/API/SBDebugger.cpp| 11 +++
 lldb/source/Core/Debugger.cpp |  6 ++
 lldb/source/Core/Telemetry.cpp| 99 +++
 lldb/tools/lldb-dap/DAP.cpp   |  5 +-
 lldb/tools/lldb-dap/LLDBUtils.h   | 34 +
 lldb/unittests/Core/TelemetryTest.cpp |  2 +-
 9 files changed, 214 insertions(+), 40 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index e0819f1684f8b..28f92f2095951 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -249,6 +250,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void DispatchClientTelemetry(const lldb::SBStructuredData &data);
+
   // Return true if target is deleted from the target list of the debugger.
   bool DeleteTarget(lldb::SBTarget &target);
 
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ebc6147800e1..e40666d5ceec7 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -19,6 +19,8 @@
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/SourceManager.h"
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/StreamFile.h"
@@ -31,6 +33,7 @@
 #include "lldb/Utility/Diagnostics.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
+#include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-enumerations.h"
@@ -127,6 +130,8 @@ class Debugger : public 
std::enable_shared_from_this,
 
   void Clear();
 
+  void DispatchClientTelemetry(const lldb_private::StructuredDataImpl &entry);
+
   bool GetAsyncExecution();
 
   void SetAsyncExecution(bool async);
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 7d8716f1659b5..cad4a4a6c9048 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Telemetry/Telemetry.h"
+#include 
 #include 
 #include 
 #include 
@@ -28,6 +29,23 @@
 namespace lldb_private {
 namespace telemetry {
 
+struct LLDBConfig : public ::llvm::telemetry::Config {
+  // If true, we will collect full details about a debug command (eg., args and
+  // original command). Note: This may contain PII, hence can only be enabled 
by
+  // the vendor while creating the Manager.
+  const bool m_detailed_command_telemetry;
+  // If true, we will collect telemetry from LLDB's clients (eg., lldb-dap) via
+  // the SB interface. Must also be enabled by the vendor while creating the
+  // manager.
+  const bool m_enable_client_telemetry;
+
+  explicit LLDBConfig(bool enable_telemetry, bool detailed_command_telemetry,
+  bool enable_client_telemetry)
+  : ::llvm::telemetry::Config(enable_telemetry),
+m_detailed_command_telemetry(detailed_command_telemetry),
+m_enable_client_telemetry(enable_client_telemetry) {}
+};
+
 // We expect each (direct) subclass of LLDBTelemetryInfo to
 // have an LLDBEntryKind in the form 0b11
 // Specifically:
@@ -37,6 +55,7 @@ namespace telemetry {
 // must have their LLDBEntryKind in the similar form (ie., share common prefix)
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
   static const llvm::telemetry::KindType BaseInfo = 0b1100;
+  static const llvm::telemetry::KindType ClientInfo = 0b1110;
   static const llvm::telemetry::KindType DebuggerInfo = 0b11000100;
 };
 
@@ -86,6 +105,11 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+struct ClientInfo : public LLDBBaseTelemetryInfo {
+  std::string request_name;
+  std::optional error_msg;
+};
+
 /// The base Telemetry manager instance in LL

[Lldb-commits] [lldb] [lldb] Fix crash after second run when set a previous watchpoint. (PR #136682)

2025-04-24 Thread via lldb-commits

https://github.com/hapee updated 
https://github.com/llvm/llvm-project/pull/136682

>From 2b8cce2ca76287d4620801878079f5dad453cc9a Mon Sep 17 00:00:00 2001
From: hapee <623151...@qq.com>
Date: Tue, 22 Apr 2025 11:34:38 +0800
Subject: [PATCH] [lldb] Fix crash after second run when set a previous
 watchpoint.

---
 lldb/source/Breakpoint/Watchpoint.cpp |  9 
 .../ReuseWatchpointAfterReExecProcess.test| 21 +++
 2 files changed, 30 insertions(+)
 create mode 100644 
lldb/test/Shell/Watchpoint/ReuseWatchpointAfterReExecProcess.test

diff --git a/lldb/source/Breakpoint/Watchpoint.cpp 
b/lldb/source/Breakpoint/Watchpoint.cpp
index 2df848aaa0576..0fcc9b90c0ab5 100644
--- a/lldb/source/Breakpoint/Watchpoint.cpp
+++ b/lldb/source/Breakpoint/Watchpoint.cpp
@@ -409,6 +409,15 @@ bool Watchpoint::IsDisabledDuringEphemeralMode() {
 }
 
 void Watchpoint::SetEnabled(bool enabled, bool notify) {
+  // Whenever setting the enabled state of a watchpoint, we need to ensure
+  // that `m_new_value_sp` exists to avoid crash when reading old_data later.
+  // See https://github.com/llvm/llvm-project/issues/135590.
+  if (!m_new_value_sp) {
+ExecutionContext exe_ctx;
+m_target.GetProcessSP()->CalculateExecutionContext(exe_ctx);
+CaptureWatchedValue(exe_ctx);
+  }
+
   if (!enabled) {
 if (m_is_ephemeral)
   ++m_disabled_count;
diff --git a/lldb/test/Shell/Watchpoint/ReuseWatchpointAfterReExecProcess.test 
b/lldb/test/Shell/Watchpoint/ReuseWatchpointAfterReExecProcess.test
new file mode 100644
index 0..6af27856e6ee6
--- /dev/null
+++ b/lldb/test/Shell/Watchpoint/ReuseWatchpointAfterReExecProcess.test
@@ -0,0 +1,21 @@
+# RUN: %clangxx_host %p/Inputs/languages.cpp -g -o %t.out
+# RUN: %lldb -b -o 'settings set interpreter.stop-command-source-on-error 
false' -s %s %t.out 2>&1 | FileCheck %s
+
+b main
+run
+# CHECK: stopped
+# CHECK-NEXT: stop reason = breakpoint
+
+watchpoint set variable val
+# CHECK: Watchpoint created:
+
+kill
+run
+# CHECK: stopped
+# CHECK-NEXT: stop reason = breakpoint
+
+watchpoint set variable val
+# CHECK: Watchpoint created:
+
+continue
+# CHECK: Watchpoint 1 hit:
\ No newline at end of file

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


[Lldb-commits] [lldb] [lldb] Fix crash after second run when set a previous watchpoint. (PR #136682)

2025-04-24 Thread via lldb-commits

https://github.com/hapee updated 
https://github.com/llvm/llvm-project/pull/136682

>From 563cbddfe9b7da394c818a03e05924c0f7d39d5f Mon Sep 17 00:00:00 2001
From: hapee <623151...@qq.com>
Date: Tue, 22 Apr 2025 11:34:38 +0800
Subject: [PATCH 1/3] [lldb] Fix crash after second run when set a previous
 watchpoint.

---
 lldb/source/Breakpoint/Watchpoint.cpp | 9 +
 1 file changed, 9 insertions(+)

diff --git a/lldb/source/Breakpoint/Watchpoint.cpp 
b/lldb/source/Breakpoint/Watchpoint.cpp
index 2df848aaa0576..0fcc9b90c0ab5 100644
--- a/lldb/source/Breakpoint/Watchpoint.cpp
+++ b/lldb/source/Breakpoint/Watchpoint.cpp
@@ -409,6 +409,15 @@ bool Watchpoint::IsDisabledDuringEphemeralMode() {
 }
 
 void Watchpoint::SetEnabled(bool enabled, bool notify) {
+  // Whenever setting the enabled state of a watchpoint, we need to ensure
+  // that `m_new_value_sp` exists to avoid crash when reading old_data later.
+  // See https://github.com/llvm/llvm-project/issues/135590.
+  if (!m_new_value_sp) {
+ExecutionContext exe_ctx;
+m_target.GetProcessSP()->CalculateExecutionContext(exe_ctx);
+CaptureWatchedValue(exe_ctx);
+  }
+
   if (!enabled) {
 if (m_is_ephemeral)
   ++m_disabled_count;

>From 980c9bc97011fa4fbce4f67688c3539f3d518a42 Mon Sep 17 00:00:00 2001
From: hapee <623151...@qq.com>
Date: Wed, 23 Apr 2025 21:33:32 +0800
Subject: [PATCH 2/3] add testcase

---
 .../Makefile  |  3 +
 .../TestReuseWatchpointAfterReExecProcess.py  | 71 +++
 .../main.c|  5 ++
 3 files changed, 79 insertions(+)
 create mode 100644 
lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/Makefile
 create mode 100644 
lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/TestReuseWatchpointAfterReExecProcess.py
 create mode 100644 
lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/main.c

diff --git 
a/lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/Makefile
 
b/lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/Makefile
new file mode 100644
index 0..10495940055b6
--- /dev/null
+++ 
b/lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/TestReuseWatchpointAfterReExecProcess.py
 
b/lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/TestReuseWatchpointAfterReExecProcess.py
new file mode 100644
index 0..d4b4afd538cde
--- /dev/null
+++ 
b/lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/TestReuseWatchpointAfterReExecProcess.py
@@ -0,0 +1,71 @@
+"""
+Set a watchpoint on a variable, then kill the process and restart it with the 
same watchpoint. 
+Check whether LLDB crashes due to a dangling pointer.
+"""
+
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestReuseWatchpointAfterReExecProcess(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def continue_and_report_stop_reason(self, process, iter_str):
+process.Continue()
+self.assertIn(
+process.GetState(), [lldb.eStateStopped, lldb.eStateExited], 
iter_str
+)
+thread = process.GetSelectedThread()
+return thread.GetStopReason()
+
+# debugserver only gained the ability to watch larger regions
+# with this patch.
+def test_reuse_watchpoint_after_re_exec_process(self):
+"""Test watchpoint that covers a large region of memory."""
+self.build()
+self.main_source_file = lldb.SBFileSpec("main.c")
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "break here", self.main_source_file
+)
+
+frame = thread.GetFrameAtIndex(0)
+var_wp = (
+frame.locals["var"][0]
+.Watch(True, False, True)
+)
+self.assertTrue(var_wp.IsValid())
+
+# Kill the process and restart it with the same watchpoint.
+process.Kill()
+process = target.LaunchSimple(None, None, os.getcwd())
+bkpt = target.BreakpointCreateBySourceRegex(
+"break here", self.main_source_file, None
+)
+
+threads = lldbutil.get_threads_stopped_at_breakpoint(process, bkpt)
+thread = threads[0]
+frame = thread.GetFrameAtIndex(0)
+
+var_reused_wp = (
+frame.locals["var"][0]
+.Watch(True, False, True)
+)
+
+self.assertTrue(var_reused_wp.IsValid())
+process.Continue()
+reason = self.continue_and_report_stop_reason(process, "continue to 
reused var wp")
+self.assertEqual(reason, lldb.eStopReasonW

[Lldb-commits] [lldb] [lldb-dap] fix wrong assembly line number x64 (PR #136486)

2025-04-24 Thread John Harrison via lldb-commits


@@ -0,0 +1,64 @@
+"""
+Test lldb-dap stack trace containing x86 assembly
+"""
+
+import lldbdap_testcase
+from lldbsuite.test.decorators import skipUnlessArch, skipUnlessPlatform
+from lldbsuite.test.lldbtest import line_number
+
+
+class TestDAP_stacktrace_x86(lldbdap_testcase.DAPTestCaseBase):
+@skipUnlessArch("x86_64")
+@skipUnlessPlatform(["linux"])
+def test_stacktrace_x86(self):
+"""
+Tests that lldb-dap steps through correctly and the source lines are 
correct in x86 assembly.
+"""
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(
+program,
+initCommands=[
+"settings set target.process.thread.step-in-avoid-nodebug 
false"
+],
+)
+
+source = "main.c"
+breakpoint_ids = self.set_source_breakpoints(
+source,
+[line_number(source, "// Break here")],
+)
+self.continue_to_breakpoints(breakpoint_ids)
+self.stepIn()
+
+frame = self.get_stackFrames()[0]
+self.assertEqual(
+frame["name"],
+"no_branch_func",
+"verify we are in the no_branch_func function",
+)
+
+self.assertEqual(frame["line"], 1, "verify we are at the start of the 
function")
+minimum_assembly_lines = (
+line_number(source, "Assembly end")
+- line_number(source, "Assembly start")
++ 1
+)
+self.assertLessEqual(
+10,
+minimum_assembly_lines,
+"verify we have a reasonable number of assembly lines",
+)
+
+for i in range(2, minimum_assembly_lines):
+self.stepIn()

ashgti wrote:

Should we explicitly step with `granularity='instruction'`?

https://github.com/llvm/llvm-project/pull/136486
___
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] [openmp] [polly] [Documentation] Always use SVG for dot-generated doxygen images. (PR #136843)

2025-04-24 Thread Aaron Ballman via lldb-commits

https://github.com/AaronBallman commented:

I think the changes LG, but please wait for our CMake experts (@petrhosek and 
@Ericson2314) to review before landing.

https://github.com/llvm/llvm-project/pull/136843
___
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] [openmp] [polly] [Documentation] Always use SVG for dot-generated doxygen images. (PR #136843)

2025-04-24 Thread Aaron Ballman via lldb-commits


@@ -48,14 +48,6 @@ if (LLVM_ENABLE_DOXYGEN)
 set(bolt_doxygen_qhp_cust_filter_attrs "")
   endif()
 
-  option(LLVM_DOXYGEN_SVG

AaronBallman wrote:

Awesome, thanks!

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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

2025-04-24 Thread Charles Zablit via lldb-commits


@@ -1202,13 +1225,16 @@ lldb_private::formatters::Foundation1100::
   m_data_64 = nullptr;
 }
 
-size_t
-lldb_private::formatters::Foundation1100::
-  NSDictionaryMSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
+llvm::Expected lldb_private::formatters::Foundation1100::
+NSDictionaryMSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
   const char *item_name = name.GetCString();
   uint32_t idx = ExtractIndexFromString(item_name);
-  if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors())
-return UINT32_MAX;
+  if (idx == UINT32_MAX ||
+  (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()))

charles-zablit wrote:

Added it to the list of things to do in separate PRs in this PR's description.

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


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow arrays to be dereferenced in C/C++. (PR #135843)

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

labath wrote:

> The problem I encountered is that Dereference has 2 separate checks: the 
> first one checks if the type is a pointer or a reference, the second is done 
> if the first one succeeds and checks if a child with a type is actually found 
> by GetChildCompilerTypeAtIndex

Why does it need to do that? Is it so to control which error message gets  
printed? If so, I think we could tweak that text so that we don't need that. 
The string "not a pointer or reference type" is not correct anymore anyway 
since we don't know what is the criteria that a type system will use to 
determine if something is dereferencable. Maybe the type system should return 
an llvm::Error/Expected, and then caller figures out how (and whether) to print 
that?

Also, could we reduce the number of arguments to that function? I'd hope that 
we don't need all of them since this is a very specific operation. E.g, I think 
the caller should be able to assume that the returned object is a "dereference" 
(whatever that means) of the parent instead of passing that via 
`child_is_deref_of_parent`.

> I think the change in logic is allowing an array type pass the type check and 
> calling GetChildCompilerTypeAtIndex instead of checking for $$dereference$$ 
> synthetic value for the array type.

I see. I'm still not worried about that because it means the array gets the 
same treatment as pointers. I think it's reasonable (though probably not very 
useful) that if a user registers a data formatter for `Foo*`, they should be 
able to provide a custom dereference operation that's different than 
"dereferencing the pointer". It doesn't work now, but if we ever wanted to make 
that possible, I don't think we'd need to (or should) treat pointers and arrays 
differently.

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


[Lldb-commits] [lldb] [lldb] Fix offset computation in RegisterContextUnwind (PR #137155)

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

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

AddressFunctionScope was always returning the first address range of the
function (assuming it was the only one). This doesn't work for
RegisterContextUnwind (it's only caller), when the function doesn't
start at the lowest address because it throws off the 'how many bytes
"into" a function I am' computation. This patch replaces the result with
a call to (recently introduced)
SymbolContext::GetFunctionOrSymbolAddress.

Note to reviewers: This patch consists of two commits. The first one is 
equivalent to #137006. The two PRs are functionally independent, but without 
the other PR, unwinding would be so broken there wouldn't be anything to test. 
When reviewing, I recommend viewing only the second commit in the PR.

>From bae70dbaaa0bbc06be304e99f63120dad1e93470 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 23 Apr 2025 17:17:45 +0200
Subject: [PATCH 1/2] [lldb] Parse DWARF CFI for discontinuous functions

This patch uses the previously build infrastructure to parse multiple
FDE entries into a single unwind plan. There is one catch though: we
parse only one FDE entry per unwind range. This is not fully correct
because lldb coalesces adjecant address ranges, which means that
something that originally looked like two separate address ranges (and
two FDE entries) may get merged into one because if the linker decides
to put the two ranges next to each other. In this case, we will ignore
the second FDE entry.

It would be more correct to try to parse another entry when the one we
found turns out to be short, but I'm not doing this (yet), because:
- this is how we've done things so far (although, monolithic functions
  are unlikely to have more than one FDE entry)
- in cases where we don't have debug info or (full) symbol tables, we
  can end up with "symbols" which appear to span many megabytes
  (potentially, the whole module). If we tried to fill short FDE
  entries, we could end up parsing the entire eh_frame section in a
  single go. In a way, this would be more correct, but it would also
  probably be very slow.

I haven't quite decided what to do about this case yet, though it's not
particularly likely to happen in the "production" cases as typically the
functions are split into two parts (hot/cold) instead of one part per
basic block.
---
 lldb/include/lldb/Symbol/DWARFCallFrameInfo.h |  9 ++-
 lldb/source/Symbol/DWARFCallFrameInfo.cpp | 64 ++-
 lldb/source/Symbol/FuncUnwinders.cpp  | 21 ++
 lldb/source/Symbol/UnwindTable.cpp| 27 
 lldb/source/Target/RegisterContextUnwind.cpp  | 20 +++---
 .../Inputs/basic-block-sections-with-dwarf.s  | 54 +---
 ...asic-block-sections-with-dwarf-static.test | 37 +++
 .../Symbol/TestDWARFCallFrameInfo.cpp | 13 ++--
 8 files changed, 131 insertions(+), 114 deletions(-)

diff --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h 
b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
index 679f652c7f2e0..c214ed1f60919 100644
--- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
+++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
@@ -47,12 +47,15 @@ class DWARFCallFrameInfo {
   /// Return an UnwindPlan based on the call frame information encoded in the
   /// FDE of this DWARFCallFrameInfo section. The returned plan will be valid
   /// (at least) for the given address.
-  bool GetUnwindPlan(const Address &addr, UnwindPlan &unwind_plan);
+  std::unique_ptr GetUnwindPlan(const Address &addr);
 
   /// Return an UnwindPlan based on the call frame information encoded in the
   /// FDE of this DWARFCallFrameInfo section. The returned plan will be valid
-  /// (at least) for some address in the given range.
-  bool GetUnwindPlan(const AddressRange &range, UnwindPlan &unwind_plan);
+  /// (at least) for some address in the given ranges. If no unwind information
+  /// is found, nullptr is returned. \a addr represents the entry point of the
+  /// function. It corresponds to the offset zero in the returned UnwindPlan.
+  std::unique_ptr GetUnwindPlan(llvm::ArrayRef 
ranges,
+const Address &addr);
 
   typedef RangeVector FunctionAddressAndSizeVector;
 
diff --git a/lldb/source/Symbol/DWARFCallFrameInfo.cpp 
b/lldb/source/Symbol/DWARFCallFrameInfo.cpp
index a763acb1fdf9e..cb8aa8a26c3f1 100644
--- a/lldb/source/Symbol/DWARFCallFrameInfo.cpp
+++ b/lldb/source/Symbol/DWARFCallFrameInfo.cpp
@@ -151,53 +151,57 @@ DWARFCallFrameInfo::DWARFCallFrameInfo(ObjectFile 
&objfile,
SectionSP §ion_sp, Type type)
 : m_objfile(objfile), m_section_sp(section_sp), m_type(type) {}
 
-bool DWARFCallFrameInfo::GetUnwindPlan(const Address &addr,
-   UnwindPlan &unwind_plan) {
-  return GetUnwindPlan(AddressRange(addr, 1), unwind_plan);
+std::unique_ptr
+DWARFCallFrameInfo::GetUnwindPlan(const Address &addr) {
+  return G

[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

2025-04-24 Thread Charles Zablit via lldb-commits


@@ -28,7 +28,7 @@ class GenericBitsetFrontEnd : public 
SyntheticChildrenFrontEnd {
 
   GenericBitsetFrontEnd(ValueObject &valobj, StdLib stdlib);
 
-  size_t GetIndexOfChildWithName(ConstString name) override {
+  llvm::Expected GetIndexOfChildWithName(ConstString name) override {
 return formatters::ExtractIndexFromString(name.GetCString());
   }

charles-zablit wrote:

Added to the list of tasks to do in another PR, in this PR's description.

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


[Lldb-commits] [lldb] [lldb] Fix offset computation in RegisterContextUnwind (PR #137155)

2025-04-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

AddressFunctionScope was always returning the first address range of the
function (assuming it was the only one). This doesn't work for
RegisterContextUnwind (it's only caller), when the function doesn't
start at the lowest address because it throws off the 'how many bytes
"into" a function I am' computation. This patch replaces the result with
a call to (recently introduced)
SymbolContext::GetFunctionOrSymbolAddress.

Note to reviewers: This patch consists of two commits. The first one is 
equivalent to #137006. The two PRs are functionally independent, but 
without the other PR, unwinding would be so broken there wouldn't be anything 
to test. When reviewing, I recommend viewing only the second commit in the PR.

---

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


10 Files Affected:

- (modified) lldb/include/lldb/Core/Address.h (+3-10) 
- (modified) lldb/include/lldb/Symbol/DWARFCallFrameInfo.h (+6-3) 
- (modified) lldb/source/Core/Address.cpp (+2-13) 
- (modified) lldb/source/Symbol/DWARFCallFrameInfo.cpp (+34-30) 
- (modified) lldb/source/Symbol/FuncUnwinders.cpp (+7-14) 
- (modified) lldb/source/Symbol/UnwindTable.cpp (+15-12) 
- (modified) lldb/source/Target/RegisterContextUnwind.cpp (+25-35) 
- (modified) lldb/test/Shell/Unwind/Inputs/basic-block-sections-with-dwarf.s 
(+52-43) 
- (modified) lldb/test/Shell/Unwind/basic-block-sections-with-dwarf-static.test 
(+25-14) 
- (modified) lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp (+7-6) 


``diff
diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h
index 9b5874f8b1fbe..85b2ab7bb3cfe 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -371,22 +371,15 @@ class Address {
   bool ResolveAddressUsingFileSections(lldb::addr_t addr,
const SectionList *sections);
 
-  /// Resolve this address to its containing function and optionally get
-  /// that function's address range.
+  /// Resolve this address to its containing function.
   ///
   /// \param[out] sym_ctx
   /// The symbol context describing the function in which this address lies
   ///
-  /// \parm[out] addr_range_ptr
-  /// Pointer to the AddressRange to fill in with the function's address
-  /// range.  Caller may pass null if they don't need the address range.
-  ///
   /// \return
-  /// Returns \b false if the function/symbol could not be resolved
-  /// or if the address range was requested and could not be resolved;
+  /// Returns \b false if the function/symbol could not be resolved;
   /// returns \b true otherwise.
-  bool ResolveFunctionScope(lldb_private::SymbolContext &sym_ctx,
-lldb_private::AddressRange *addr_range_ptr = 
nullptr);
+  bool ResolveFunctionScope(lldb_private::SymbolContext &sym_ctx);
 
   /// Set the address to represent \a load_addr.
   ///
diff --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h 
b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
index 679f652c7f2e0..c214ed1f60919 100644
--- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
+++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
@@ -47,12 +47,15 @@ class DWARFCallFrameInfo {
   /// Return an UnwindPlan based on the call frame information encoded in the
   /// FDE of this DWARFCallFrameInfo section. The returned plan will be valid
   /// (at least) for the given address.
-  bool GetUnwindPlan(const Address &addr, UnwindPlan &unwind_plan);
+  std::unique_ptr GetUnwindPlan(const Address &addr);
 
   /// Return an UnwindPlan based on the call frame information encoded in the
   /// FDE of this DWARFCallFrameInfo section. The returned plan will be valid
-  /// (at least) for some address in the given range.
-  bool GetUnwindPlan(const AddressRange &range, UnwindPlan &unwind_plan);
+  /// (at least) for some address in the given ranges. If no unwind information
+  /// is found, nullptr is returned. \a addr represents the entry point of the
+  /// function. It corresponds to the offset zero in the returned UnwindPlan.
+  std::unique_ptr GetUnwindPlan(llvm::ArrayRef 
ranges,
+const Address &addr);
 
   typedef RangeVector FunctionAddressAndSizeVector;
 
diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp
index 1dab874a96583..a967bf5491211 100644
--- a/lldb/source/Core/Address.cpp
+++ b/lldb/source/Core/Address.cpp
@@ -263,22 +263,11 @@ bool Address::ResolveAddressUsingFileSections(addr_t 
file_addr,
   return false; // Failed to resolve this address to a section offset value
 }
 
-/// if "addr_range_ptr" is not NULL, then fill in with the address range of 
the function.
-bool Address::ResolveFunctionScope(SymbolContext &sym_ctx,
-   AddressRange *addr_range_ptr) {
+bool Address::ResolveFunctionS

[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

2025-04-24 Thread Charles Zablit via lldb-commits

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


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

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

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


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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

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


@@ -319,40 +319,49 @@ 
ValueObjectSynthetic::GetChildMemberWithName(llvm::StringRef name,
  bool can_create) {
   UpdateValueIfNeeded();
 
-  uint32_t index = GetIndexOfChildWithName(name);
+  auto index_or_err = GetIndexOfChildWithName(name);
 
-  if (index == UINT32_MAX)
+  if (!index_or_err) {
+llvm::consumeError(index_or_err.takeError());
 return lldb::ValueObjectSP();
+  }
 
-  return GetChildAtIndex(index, can_create);
+  return GetChildAtIndex(*index_or_err, can_create);
 }
 
-size_t ValueObjectSynthetic::GetIndexOfChildWithName(llvm::StringRef name_ref) 
{
+llvm::Expected
+ValueObjectSynthetic::GetIndexOfChildWithName(llvm::StringRef name_ref) {
   UpdateValueIfNeeded();
 
   ConstString name(name_ref);
 
-  uint32_t found_index = UINT32_MAX;
-  bool did_find;
+  std::optional found_index = std::nullopt;
   {
 std::lock_guard guard(m_child_mutex);
 auto name_to_index = m_name_toindex.find(name.GetCString());
-did_find = name_to_index != m_name_toindex.end();
-if (did_find)
+if (name_to_index != m_name_toindex.end())
   found_index = name_to_index->second;
   }
 
-  if (!did_find && m_synth_filter_up != nullptr) {
-uint32_t index = m_synth_filter_up->GetIndexOfChildWithName(name);
-if (index == UINT32_MAX)
-  return index;
+  if (!found_index && m_synth_filter_up != nullptr) {
+auto index_or_err = m_synth_filter_up->GetIndexOfChildWithName(name);
+if (!index_or_err)
+  return index_or_err.takeError();
 std::lock_guard guard(m_child_mutex);
-m_name_toindex[name.GetCString()] = index;
-return index;
-  } else if (!did_find && m_synth_filter_up == nullptr)
-return UINT32_MAX;
-  else /*if (iter != m_name_toindex.end())*/
-return found_index;
+m_name_toindex[name.GetCString()] = *index_or_err;
+return *index_or_err;
+  } else if (!found_index && m_synth_filter_up == nullptr) {
+return llvm::createStringError(
+"'SyntheticChildrenFrontEnd::ValueObjectSynthetic' cannot find index "
+"of child '%s'. m_synth_filter_up is null.",
+name.AsCString());
+  } else if (found_index) {
+return *found_index;
+  } else /*if (iter != m_name_toindex.end())*/
+return llvm::createStringError(
+"'SyntheticChildrenFrontEnd::ValueObjectSynthetic' cannot find index "
+"of child '%s'",
+name.AsCString());

Michael137 wrote:

```suggestion
  }
  
  return llvm::createStringError(
  "'SyntheticChildrenFrontEnd::ValueObjectSynthetic' cannot find index "
  "of child '%s'",
  name.AsCString());
```

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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

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


@@ -319,40 +319,49 @@ 
ValueObjectSynthetic::GetChildMemberWithName(llvm::StringRef name,
  bool can_create) {
   UpdateValueIfNeeded();
 
-  uint32_t index = GetIndexOfChildWithName(name);
+  auto index_or_err = GetIndexOfChildWithName(name);
 
-  if (index == UINT32_MAX)
+  if (!index_or_err) {
+llvm::consumeError(index_or_err.takeError());
 return lldb::ValueObjectSP();
+  }
 
-  return GetChildAtIndex(index, can_create);
+  return GetChildAtIndex(*index_or_err, can_create);
 }
 
-size_t ValueObjectSynthetic::GetIndexOfChildWithName(llvm::StringRef name_ref) 
{
+llvm::Expected
+ValueObjectSynthetic::GetIndexOfChildWithName(llvm::StringRef name_ref) {
   UpdateValueIfNeeded();
 
   ConstString name(name_ref);
 
-  uint32_t found_index = UINT32_MAX;
-  bool did_find;
+  std::optional found_index = std::nullopt;
   {
 std::lock_guard guard(m_child_mutex);
 auto name_to_index = m_name_toindex.find(name.GetCString());
-did_find = name_to_index != m_name_toindex.end();
-if (did_find)
+if (name_to_index != m_name_toindex.end())
   found_index = name_to_index->second;
   }
 
-  if (!did_find && m_synth_filter_up != nullptr) {
-uint32_t index = m_synth_filter_up->GetIndexOfChildWithName(name);
-if (index == UINT32_MAX)
-  return index;
+  if (!found_index && m_synth_filter_up != nullptr) {
+auto index_or_err = m_synth_filter_up->GetIndexOfChildWithName(name);
+if (!index_or_err)
+  return index_or_err.takeError();
 std::lock_guard guard(m_child_mutex);
-m_name_toindex[name.GetCString()] = index;
-return index;
-  } else if (!did_find && m_synth_filter_up == nullptr)
-return UINT32_MAX;
-  else /*if (iter != m_name_toindex.end())*/
-return found_index;
+m_name_toindex[name.GetCString()] = *index_or_err;
+return *index_or_err;
+  } else if (!found_index && m_synth_filter_up == nullptr) {
+return llvm::createStringError(
+"'SyntheticChildrenFrontEnd::ValueObjectSynthetic' cannot find index "
+"of child '%s'. m_synth_filter_up is null.",
+name.AsCString());
+  } else if (found_index)
+return *found_index;
+
+  return llvm::createStringError(
+  "'SyntheticChildrenFrontEnd::ValueObjectSynthetic' cannot find index "

Michael137 wrote:

```suggestion
  "'ValueObjectSynthetic' cannot find index "
```

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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

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


@@ -316,8 +316,10 @@ 
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
 return 0;
   if (name == "$$dereference$$")
 return 1;
-  return llvm::createStringError("Cannot find index of child '%s'",
- name.AsCString());
+  return llvm::createStringError(
+  "'SyntheticChildrenFrontend::LibcxxSharedPtrSyntheticFrontEnd' cannot "

Michael137 wrote:

```suggestion
  "'LibcxxSharedPtrSyntheticFrontEnd' cannot "
```

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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

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


@@ -103,9 +103,20 @@ 
lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::Update() {
 llvm::Expected
 lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
 GetIndexOfChildWithName(ConstString name) {
-  if (!m_start)
-return UINT32_MAX;
-  return ExtractIndexFromString(name.GetCString());
+  if (!m_start) {
+return llvm::createStringError(
+"'SyntheticChildrenFrontend::LibcxxInitializerListSyntheticFrontEnd' "
+"cannot find index of child '%s': Invalid start pointer.",
+name.AsCString());
+  }
+  size_t idx = ExtractIndexFromString(name.GetCString());
+  if (idx == UINT32_MAX) {
+return llvm::createStringError(
+"'SyntheticChildrenFrontend::LibcxxInitializerListSyntheticFrontEnd' "

Michael137 wrote:

```suggestion
"'LibcxxInitializerListSyntheticFrontEnd' "
```
(and above too)

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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

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

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

LGTM

I left some remaining comments. Should be good to go once those are addressed

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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

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


@@ -418,8 +420,10 @@ 
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
 return 1;
   if (name == "$$dereference$$")
 return 2;
-  return llvm::createStringError("Cannot find index of child '%s'",
- name.AsCString());
+  return llvm::createStringError(
+  "'ScriptedSyntheticChildren::LibcxxUniquePtrSyntheticFrontEnd' cannot "

Michael137 wrote:

```suggestion
  "'LibcxxUniquePtrSyntheticFrontEnd' cannot "
```

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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

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


@@ -107,7 +107,14 @@ class ListIterator {
 class AbstractListFrontEnd : public SyntheticChildrenFrontEnd {
 public:
   llvm::Expected GetIndexOfChildWithName(ConstString name) override {
-return ExtractIndexFromString(name.GetCString());
+size_t idx = ExtractIndexFromString(name.GetCString());
+if (idx == UINT32_MAX) {
+  return llvm::createStringError(
+  "'SyntheticChildrenFrontend::AbstractListFrontEnd' cannot find index 
"

Michael137 wrote:

Lets omit the `SyntheticChildrenFrontend::` part everywhere

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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

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


@@ -1202,13 +1225,16 @@ lldb_private::formatters::Foundation1100::
   m_data_64 = nullptr;
 }
 
-size_t
-lldb_private::formatters::Foundation1100::
-  NSDictionaryMSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
+llvm::Expected lldb_private::formatters::Foundation1100::
+NSDictionaryMSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
   const char *item_name = name.GetCString();
   uint32_t idx = ExtractIndexFromString(item_name);
-  if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors())
-return UINT32_MAX;
+  if (idx == UINT32_MAX ||
+  (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()))
+return llvm::createStringError(
+"'SyntheticChildrenFrontEnd::NSDictionaryMSyntheticFrontEnd' cannot "
+"find index of child '%s'. (idx='%d')",

Michael137 wrote:

Lets change all the index logging to:
```suggestion
"find index of child '%s'. (idx='%" PRIu32 "')",
```

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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

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

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


[Lldb-commits] [lldb] e35cc2d - [lldb][TypeSystemClang][NFC] Clean up TypeSystemClang::DeclGetMangledName to LLVM-style

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

Author: Michael Buch
Date: 2025-04-24T12:45:19+01:00
New Revision: e35cc2d387e170d0e1f6ef647f17423262feb1ea

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

LOG: [lldb][TypeSystemClang][NFC] Clean up TypeSystemClang::DeclGetMangledName 
to LLVM-style

Will make upcoming changes in this area easier to read.

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index ed6297cc6f3e0..59292f4b24af3 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9164,33 +9164,36 @@ ConstString TypeSystemClang::DeclGetName(void 
*opaque_decl) {
 }
 
 ConstString TypeSystemClang::DeclGetMangledName(void *opaque_decl) {
-  if (opaque_decl) {
-clang::NamedDecl *nd =
-llvm::dyn_cast((clang::Decl *)opaque_decl);
-if (nd != nullptr && !llvm::isa(nd)) {
-  clang::MangleContext *mc = getMangleContext();
-  if (mc && mc->shouldMangleCXXName(nd)) {
-llvm::SmallVector buf;
-llvm::raw_svector_ostream llvm_ostrm(buf);
-if (llvm::isa(nd)) {
-  mc->mangleName(
-  clang::GlobalDecl(llvm::dyn_cast(nd),
-Ctor_Complete),
-  llvm_ostrm);
-} else if (llvm::isa(nd)) {
-  mc->mangleName(
-  clang::GlobalDecl(llvm::dyn_cast(nd),
-Dtor_Complete),
-  llvm_ostrm);
-} else {
-  mc->mangleName(nd, llvm_ostrm);
-}
-if (buf.size() > 0)
-  return ConstString(buf.data(), buf.size());
-  }
-}
+  clang::NamedDecl *nd = llvm::dyn_cast_or_null(
+  static_cast(opaque_decl));
+
+  if (!nd || llvm::isa(nd))
+return {};
+
+  clang::MangleContext *mc = getMangleContext();
+  if (!mc || !mc->shouldMangleCXXName(nd))
+return {};
+
+  llvm::SmallVector buf;
+  llvm::raw_svector_ostream llvm_ostrm(buf);
+  if (llvm::isa(nd)) {
+mc->mangleName(
+clang::GlobalDecl(llvm::dyn_cast(nd),
+  Ctor_Complete),
+llvm_ostrm);
+  } else if (llvm::isa(nd)) {
+mc->mangleName(
+clang::GlobalDecl(llvm::dyn_cast(nd),
+  Dtor_Complete),
+llvm_ostrm);
+  } else {
+mc->mangleName(nd, llvm_ostrm);
   }
-  return ConstString();
+
+  if (buf.size() > 0)
+return ConstString(buf.data(), buf.size());
+
+  return {};
 }
 
 CompilerDeclContext TypeSystemClang::DeclGetDeclContext(void *opaque_decl) {



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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

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


@@ -123,11 +123,22 @@ 
lldb_private::formatters::LibcxxStdValarraySyntheticFrontEnd::Update() {
   return ChildCacheState::eRefetch;
 }
 
-size_t lldb_private::formatters::LibcxxStdValarraySyntheticFrontEnd::
+llvm::Expected
+lldb_private::formatters::LibcxxStdValarraySyntheticFrontEnd::
 GetIndexOfChildWithName(ConstString name) {
   if (!m_start || !m_finish)
-return std::numeric_limits::max();
-  return ExtractIndexFromString(name.GetCString());
+return llvm::createStringError(
+"'SyntheticChildrenFrontEnd::LibcxxStdValarraySyntheticFrontEnd' "
+"cannot find index of child '%s'. (m_start='" PRIu32
+"', m_finish='" PRIu32 "')",

Michael137 wrote:

```suggestion
"cannot find index of child '%s'. (m_start='%p', m_finish='%p')",
```

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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

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


@@ -259,14 +272,23 @@ 
lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::Update() {
   return lldb::ChildCacheState::eRefetch;
 }
 
-size_t lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
+llvm::Expected
+lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
 GetIndexOfChildWithName(ConstString name) {
   if (!m_count || !m_base_data_address)
-return UINT32_MAX;
+return llvm::createStringError(
+"'SyntheticChildrenFrontEnd::LibcxxVectorBoolSyntheticFrontEnd' cannot 
"
+"find index of child '%s'. (m_count='" PRIu32
+"', m_base_data_address='" PRIu32 "')",

Michael137 wrote:

```suggestion
"find index of child '%s'. (m_count='" PRIu64
"', m_base_data_address='" PRIu64 "')",
```

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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

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


@@ -163,11 +163,24 @@ 
lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update() {
   return lldb::ChildCacheState::eRefetch;
 }
 
-size_t lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
+llvm::Expected
+lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
 GetIndexOfChildWithName(ConstString name) {
   if (!m_start || !m_finish)
-return UINT32_MAX;
-  return ExtractIndexFromString(name.GetCString());
+return llvm::createStringError(
+"'SyntheticChildrenFrontEnd::LibcxxStdVectorSyntheticFrontEnd' cannot "
+"find index of child '%s'. (m_start='" PRIu32 "', m_finish='" PRIu32
+"')",
+name.AsCString(), m_start, m_finish);

Michael137 wrote:

```suggestion
"find index of child '%s'. (m_start='%p', m_finish='%p')",
name.AsCString(), m_start, m_finish);
```

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


[Lldb-commits] [lldb] [llvm] [lldb] Prefer `DW_AT_bit_size` over `DW_AT_byte_size` in `GetDIEBitSizeAndSign` (PR #137123)

2025-04-24 Thread Tom Tromey via lldb-commits

tromey wrote:

> `DW_AT_bit_size` will be ignored by lldb if `DW_AT_byte_size` is available 
> and non-zero. Unfortunately, gdb crashes when `DW_AT_byte_size` does not 
> exist or is set to zero. So I decided to change lldb to match gdb's behavior 
> :(

Can you file a gdb bug report with an executable showing this behavior?  Or 
even just email it to me?

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


[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #136121)

2025-04-24 Thread via lldb-commits

anjenner wrote:

The original PR (https://github.com/llvm/llvm-project/pull/115331) was approved 
and merged, but later reverted due an unstable test. The only difference in 
this version of the PR was a fix to make the test stable on Windows, so I 
thought it would be ok to merge by the approval of the original PR. Apologies 
if I was mistaken on this.

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


[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #136121)

2025-04-24 Thread via lldb-commits

dyung wrote:

> The original PR (#115331) was approved and merged, but later reverted due an 
> unstable test. The only difference in this version of the PR was a fix to 
> make the test stable on Windows, so I thought it would be ok to merge by the 
> approval of the original PR. Apologies if I was mistaken on this.

Who approved the original PR? Was the approval done offline? I do not see an 
approval in the original PR, just some feedback.

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


[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #136121)

2025-04-24 Thread via lldb-commits

anjenner wrote:

Hmm... perhaps I have misunderstood the LLVM contribution process here. I had 
assumed that once all the review feedback had been addressed, some time had 
passed to allow reviewers to comment on the modifications resulting from review 
feedback, and the "merge" button was available, then that was all that was 
needed. This was my takeaway from reading the documentation at 
https://www.llvm.org/docs/Contributing.html . But it sounds like you're saying 
that a separate approval step is necessary? How is that approval obtained? 
Where is that process documented?

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


[Lldb-commits] [lldb] [lldb/Host] Enable inheriting "non-inheritable" FDs (PR #126935)

2025-04-24 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- 
lldb/source/Host/posix/ProcessLauncherPosixFork.cpp 
lldb/unittests/Host/HostTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/unittests/Host/HostTest.cpp b/lldb/unittests/Host/HostTest.cpp
index 154d584c0..53ec5cacf 100644
--- a/lldb/unittests/Host/HostTest.cpp
+++ b/lldb/unittests/Host/HostTest.cpp
@@ -12,9 +12,9 @@
 #include "lldb/Host/Pipe.h"
 #include "lldb/Host/ProcessLaunchInfo.h"
 #include "lldb/Utility/ProcessInfo.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/ADT/Twine.h"
 #include "llvm/Testing/Support/Error.h"
 #include "gtest/gtest.h"
 #include 

``




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


[Lldb-commits] [lldb] [llvm] [lldb] Implement CLI support for reverse-continue (PR #132783)

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

DavidSpickett wrote:

Sod's law that the supposedly simple test would be the problem.

I'll figure this out, I've disabled it on Windows for now.

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


[Lldb-commits] [lldb] [llvm] [lldb] Prefer `DW_AT_bit_size` over `DW_AT_byte_size` in `GetDIEBitSizeAndSign` (PR #137123)

2025-04-24 Thread Yingwei Zheng via lldb-commits

dtcxzyw wrote:

> > `DW_AT_bit_size` will be ignored by lldb if `DW_AT_byte_size` is available 
> > and non-zero. Unfortunately, gdb crashes when `DW_AT_byte_size` does not 
> > exist or is set to zero. So I decided to change lldb to match gdb's 
> > behavior :(
> 
> Can you file a gdb bug report with an executable showing this behavior? Or 
> even just email it to me?

Reproducer:
test.c:
```
int a, b, c;
int d(int e) { return e; }
int main() {
  int l_4516;
  c = d(1);
  l_4516 = 1 && c;
  b = l_4516 & a;
  return 0;
}
```
test.s: https://gist.github.com/dtcxzyw/a3fa3d33dbbea9717dfe7a1579df0d01

```
> gcc test.s # or use `clang test.s`
> gdb ./a.out
(gdb) b 7
(gdb) r
(gdb) p l_4516
/build/gdb-1WjiBe/gdb-15.0.50.20240403/gdb/gmp-utils.c:84: internal-error: 
export_bits: Assertion `buf.size () > 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
- Backtrace -
0x5d2df1cddbc6 ???
0x5d2df20f9dd4 ???
0x5d2df20fa0d0 ???
0x5d2df228df74 ???
0x5d2df1e41744 ???
0x5d2df21140ad ???
0x5d2df2105e96 ???
0x5d2df1d91242 ???
0x5d2df1d91ae7 ???
0x5d2df1d921c3 ???
0x5d2df1dacbcd ???
0x5d2df1dacfc6 ???
0x5d2df1dad599 ???
0x5d2df1e1d270 ???
0x5d2df2100eb8 ???
0x5d2df1dfaf46 ???
0x5d2df1dfa398 ???
0x5d2df1f3bcc3 ???
0x5d2df1f3c32f ???
0x5d2df1d16464 ???
0x5d2df2080727 ???
0x5d2df1e01967 ???
0x5d2df1e03143 ???
0x5d2df1e02332 ???
0x7c7e1b1ca9e4 ???
0x5d2df1e02495 ???
0x5d2df1e02663 ???
0x5d2df20c3a5c ???
0x5d2df228e975 ???
0x5d2df228f4f7 ???
0x5d2df1eddea9 ???
0x5d2df1ee0f04 ???
0x5d2df1c27dab ???
0x7c7e19e2a1c9 __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58
0x7c7e19e2a28a __libc_start_main_impl
../csu/libc-start.c:360
0x5d2df1c361f4 ???
0x ???
-
/build/gdb-1WjiBe/gdb-15.0.50.20240403/gdb/gmp-utils.c:84: internal-error: 
export_bits: Assertion `buf.size () > 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
```
gcc version: gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
gdb version: GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git


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


[Lldb-commits] [lldb] [lldb][AArch64] Fix Apple M4 on Linux (PR #135563)

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

DavidSpickett wrote:

I have got Arm's Foundation Model to boot with SME only, and the cpuinfo is:
```
Features: fp asimd evtstrm crc32 atomics fphp asimdhp cpuid asimdrdm 
jscvt fcma lrcpc dcpop asimddp asimdfhm dit uscat ilrcpc flagm sb paca pacg gcs 
dcpodp flagm2 frint i8mm bf16 dgh rng bti ecv afp sme smei16i64 smef64f64 
smei8i32 smef16f32 smeb16f32 smef32f32 wfxt ebf16 cssc mops hbc poe
```
It reports `sme` but no `sve` features, which makes sense because I built the 
kernel from the latest commit. I thought I was missing something else to get 
`sve2` as was seen in the linked docker issue.

Also, SME is disabled in kernel config for unrelated reasons, so I had to 
re-enable that:
```
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index a182295e6..27437f131 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -2285,7 +2285,6 @@ config ARM64_SME
bool "ARM Scalable Matrix Extension support"
default y
depends on ARM64_SVE
-   depends on BROKEN
help
  The Scalable Matrix Extension (SME) is an extension to the AArch64
  execution state which utilises a substantial subset of the SVE
```

I will find out what QEMU can do / plans to do.

Assuming I reproduce the failures this PR aims to fix, I'll write up an issue 
with how to reproduce it without an actual M4 and we can mark this as the fix 
for it.

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


[Lldb-commits] [lldb] [lldb][AArch64] Fix Apple M4 on Linux (PR #135563)

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

DavidSpickett wrote:

> Therefore, this situation should only be an issue with older kernels, so 
> perhaps it not something that regular user mode applications should need to 
> worry about (unless specifically wanting to run with older kernels).

I will test this PR with an older kernel as well. Would be nice if it works 
there too.

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


[Lldb-commits] [lldb] [lldb] Fix crash after second run when set a previous watchpoint. (PR #136682)

2025-04-24 Thread via lldb-commits

https://github.com/hapee updated 
https://github.com/llvm/llvm-project/pull/136682

>From 563cbddfe9b7da394c818a03e05924c0f7d39d5f Mon Sep 17 00:00:00 2001
From: hapee <623151...@qq.com>
Date: Tue, 22 Apr 2025 11:34:38 +0800
Subject: [PATCH 1/2] [lldb] Fix crash after second run when set a previous
 watchpoint.

---
 lldb/source/Breakpoint/Watchpoint.cpp | 9 +
 1 file changed, 9 insertions(+)

diff --git a/lldb/source/Breakpoint/Watchpoint.cpp 
b/lldb/source/Breakpoint/Watchpoint.cpp
index 2df848aaa0576..0fcc9b90c0ab5 100644
--- a/lldb/source/Breakpoint/Watchpoint.cpp
+++ b/lldb/source/Breakpoint/Watchpoint.cpp
@@ -409,6 +409,15 @@ bool Watchpoint::IsDisabledDuringEphemeralMode() {
 }
 
 void Watchpoint::SetEnabled(bool enabled, bool notify) {
+  // Whenever setting the enabled state of a watchpoint, we need to ensure
+  // that `m_new_value_sp` exists to avoid crash when reading old_data later.
+  // See https://github.com/llvm/llvm-project/issues/135590.
+  if (!m_new_value_sp) {
+ExecutionContext exe_ctx;
+m_target.GetProcessSP()->CalculateExecutionContext(exe_ctx);
+CaptureWatchedValue(exe_ctx);
+  }
+
   if (!enabled) {
 if (m_is_ephemeral)
   ++m_disabled_count;

>From 980c9bc97011fa4fbce4f67688c3539f3d518a42 Mon Sep 17 00:00:00 2001
From: hapee <623151...@qq.com>
Date: Wed, 23 Apr 2025 21:33:32 +0800
Subject: [PATCH 2/2] add testcase

---
 .../Makefile  |  3 +
 .../TestReuseWatchpointAfterReExecProcess.py  | 71 +++
 .../main.c|  5 ++
 3 files changed, 79 insertions(+)
 create mode 100644 
lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/Makefile
 create mode 100644 
lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/TestReuseWatchpointAfterReExecProcess.py
 create mode 100644 
lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/main.c

diff --git 
a/lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/Makefile
 
b/lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/Makefile
new file mode 100644
index 0..10495940055b6
--- /dev/null
+++ 
b/lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/TestReuseWatchpointAfterReExecProcess.py
 
b/lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/TestReuseWatchpointAfterReExecProcess.py
new file mode 100644
index 0..d4b4afd538cde
--- /dev/null
+++ 
b/lldb/test/API/functionalities/watchpoint/reuse-watchpoint-after-re-exec-process/TestReuseWatchpointAfterReExecProcess.py
@@ -0,0 +1,71 @@
+"""
+Set a watchpoint on a variable, then kill the process and restart it with the 
same watchpoint. 
+Check whether LLDB crashes due to a dangling pointer.
+"""
+
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestReuseWatchpointAfterReExecProcess(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def continue_and_report_stop_reason(self, process, iter_str):
+process.Continue()
+self.assertIn(
+process.GetState(), [lldb.eStateStopped, lldb.eStateExited], 
iter_str
+)
+thread = process.GetSelectedThread()
+return thread.GetStopReason()
+
+# debugserver only gained the ability to watch larger regions
+# with this patch.
+def test_reuse_watchpoint_after_re_exec_process(self):
+"""Test watchpoint that covers a large region of memory."""
+self.build()
+self.main_source_file = lldb.SBFileSpec("main.c")
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "break here", self.main_source_file
+)
+
+frame = thread.GetFrameAtIndex(0)
+var_wp = (
+frame.locals["var"][0]
+.Watch(True, False, True)
+)
+self.assertTrue(var_wp.IsValid())
+
+# Kill the process and restart it with the same watchpoint.
+process.Kill()
+process = target.LaunchSimple(None, None, os.getcwd())
+bkpt = target.BreakpointCreateBySourceRegex(
+"break here", self.main_source_file, None
+)
+
+threads = lldbutil.get_threads_stopped_at_breakpoint(process, bkpt)
+thread = threads[0]
+frame = thread.GetFrameAtIndex(0)
+
+var_reused_wp = (
+frame.locals["var"][0]
+.Watch(True, False, True)
+)
+
+self.assertTrue(var_reused_wp.IsValid())
+process.Continue()
+reason = self.continue_and_report_stop_reason(process, "continue to 
reused var wp")
+self.assertEqual(reason, lldb.eStopReasonW

[Lldb-commits] [lldb] [lldb][CPlusPlus] Always use CPlusPlusNameParser for parsing C++ function names (PR #137072)

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


@@ -174,6 +175,9 @@ int main(int argc, char **argv) {
   //% self.expect("expr (new struct C[1]); side_effect", endstr=" = 4\n")
   //% self.expect("expr delete c2; side_effect", endstr=" = 1\n")
   //% self.expect("expr delete[] c3; side_effect", endstr=" = 2\n")
+  //% self.expect("image lookup -n operator()", substrs=["C::operator()(int)"])

Michael137 wrote:

Yea it was deducing that `operator` is the basename because it just does a 
simple search for `()` and then checks whether the rest of the name looks like 
a valid function identifier.

>  Could you also add this to the unit tests in 
> unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
Yup!

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


[Lldb-commits] [lldb] [lldb][CPlusPlus] Always use CPlusPlusNameParser for parsing C++ function names (PR #137072)

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

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


[Lldb-commits] [lldb] [lldb][CPlusPlus] Always use CPlusPlusNameParser for parsing C++ function names (PR #137072)

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

Michael137 wrote:

> Yeah, getting some numbers would be nice. Maybe just repeating the benchmark 
> in that diff. It might be a good idea to do it with and without the 
> accelerator tables, just to rule out any effect from those.

Will do

On Darwin (without accelerator tables and statically linked Clang) I don't see 
this codepath being hit at all when setting a named breakpoint. If the function 
name doesn't exist we don't seem to call `CxxMethodName` at all. If the name 
does exist we hit it a couple of times (~10). I'll try on Linux too 

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

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


@@ -339,6 +342,48 @@ TEST_F(SocketTest, DomainGetConnectURI) {
 }
 #endif
 
+#if LLDB_ENABLE_POSIX
+TEST_F(SocketTest, DomainSocketFromBoundNativeSocket) {
+  // Generate a name for the domain socket.
+  llvm::SmallString<64> name;
+  std::error_code EC = llvm::sys::fs::createUniqueDirectory(
+  "DomainSocketFromBoundNativeSocket", name);
+  ASSERT_FALSE(EC);
+  llvm::sys::path::append(name, "test");
+
+  DomainSocket socket(true);
+  Status error = socket.Listen(name, /*backlog=*/10);
+  ASSERT_FALSE(error.ToError());
+  NativeSocket native_socket = socket.GetNativeSocket();
+
+  llvm::Expected> sock =
+  DomainSocket::FromBoundNativeSocket(native_socket, 
/*should_close=*/true);
+  ASSERT_THAT_EXPECTED(sock, llvm::Succeeded());
+  ASSERT_EQ(Socket::ProtocolUnixDomain, sock->get()->GetSocketProtocol());
+}
+#endif
+
+#if __linux__
+TEST_F(SocketTest, AbstractSocketFromBoundNativeSocket) {
+  // Generate a name for the abstract socket.
+  llvm::SmallString<64> name;
+  std::error_code EC = llvm::sys::fs::createUniqueDirectory(
+  "AbstractSocketFromBoundNativeSocket", name);

labath wrote:

This shouldn't be necessary as the abstract sockets are not tied to the file 
system. You can use eg. `createUniquePath` to create the socket name directly.

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

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


@@ -455,37 +455,33 @@ int main_platform(int argc, char *argv[]) {
   lldb_private::Args inferior_arguments;
   inferior_arguments.SetArguments(argc, const_cast(argv));
 
-  Socket::SocketProtocol protocol = Socket::ProtocolUnixDomain;
-
+  Log *log = GetLog(LLDBLog::Platform);
   if (fd != SharedSocket::kInvalidFD) {
 // Child process will handle the connection and exit.
-if (gdbserver_port)
-  protocol = Socket::ProtocolTcp;
-
-Log *log = GetLog(LLDBLog::Platform);
-
 NativeSocket sockfd;
 error = SharedSocket::GetNativeSocket(fd, sockfd);
 if (error.Fail()) {
   LLDB_LOGF(log, "lldb-platform child: %s", error.AsCString());
   return socket_error;
 }
 
-GDBRemoteCommunicationServerPlatform platform(protocol, gdbserver_port);
-Socket *socket;
-if (protocol == Socket::ProtocolTcp)
-  socket = new TCPSocket(sockfd, /*should_close=*/true);
-else {
-#if LLDB_ENABLE_POSIX
-  socket = new DomainSocket(sockfd, /*should_close=*/true);
-#else
-  WithColor::error() << "lldb-platform child: Unix domain sockets are not "
-"supported on this platform.";
-  return socket_error;
-#endif
+std::unique_ptr socket;
+if (gdbserver_port) {
+  socket = std::make_unique(sockfd, /*should_close=*/true);
+} else {
+  llvm::Expected> domain_socket =
+  DomainSocket::FromBoundNativeSocket(sockfd, /*should_close=*/true);
+  if (!domain_socket) {
+LLDB_LOGF(log, "Failed to create socket: %s\n", error.AsCString());

labath wrote:

```suggestion
LLDB_LOG_ERROR(log, domain_socket.takeError(), "Failed to create 
socket: {0}");
```

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

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


@@ -339,6 +342,48 @@ TEST_F(SocketTest, DomainGetConnectURI) {
 }
 #endif
 
+#if LLDB_ENABLE_POSIX
+TEST_F(SocketTest, DomainSocketFromBoundNativeSocket) {
+  // Generate a name for the domain socket.
+  llvm::SmallString<64> name;
+  std::error_code EC = llvm::sys::fs::createUniqueDirectory(
+  "DomainSocketFromBoundNativeSocket", name);
+  ASSERT_FALSE(EC);
+  llvm::sys::path::append(name, "test");
+
+  DomainSocket socket(true);
+  Status error = socket.Listen(name, /*backlog=*/10);
+  ASSERT_FALSE(error.ToError());
+  NativeSocket native_socket = socket.GetNativeSocket();
+
+  llvm::Expected> sock =
+  DomainSocket::FromBoundNativeSocket(native_socket, 
/*should_close=*/true);
+  ASSERT_THAT_EXPECTED(sock, llvm::Succeeded());
+  ASSERT_EQ(Socket::ProtocolUnixDomain, sock->get()->GetSocketProtocol());
+}
+#endif
+
+#if __linux__
+TEST_F(SocketTest, AbstractSocketFromBoundNativeSocket) {
+  // Generate a name for the abstract socket.
+  llvm::SmallString<64> name;
+  std::error_code EC = llvm::sys::fs::createUniqueDirectory(
+  "AbstractSocketFromBoundNativeSocket", name);
+  ASSERT_FALSE(EC);
+  llvm::sys::path::append(name, "test");
+
+  AbstractSocket socket;
+  Status error = socket.Listen(name, /*backlog=*/10);
+  ASSERT_FALSE(error.ToError());
+  NativeSocket native_socket = socket.GetNativeSocket();
+
+  llvm::Expected> sock =
+  DomainSocket::FromBoundNativeSocket(native_socket, 
/*should_close=*/true);

labath wrote:

```suggestion
  DomainSocket::FromBoundNativeSocket(native_socket, 
/*should_close=*/false);
```

since the fd is still owned by the other socket (same in the other test)

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

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


@@ -339,6 +342,48 @@ TEST_F(SocketTest, DomainGetConnectURI) {
 }
 #endif
 
+#if LLDB_ENABLE_POSIX
+TEST_F(SocketTest, DomainSocketFromBoundNativeSocket) {
+  // Generate a name for the domain socket.
+  llvm::SmallString<64> name;
+  std::error_code EC = llvm::sys::fs::createUniqueDirectory(
+  "DomainSocketFromBoundNativeSocket", name);
+  ASSERT_FALSE(EC);
+  llvm::sys::path::append(name, "test");
+
+  DomainSocket socket(true);
+  Status error = socket.Listen(name, /*backlog=*/10);
+  ASSERT_FALSE(error.ToError());

labath wrote:

```suggestion
  ASSERT_THAT_ERROR(error.takeError(), llvm::Succeeded());
```

-> better error messages

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

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


@@ -182,3 +191,20 @@ std::vector 
DomainSocket::GetListeningConnectionURI() const {
 
   return {llvm::formatv("unix-connect://{0}", addr.sun_path)};
 }
+
+llvm::Expected>
+DomainSocket::FromBoundNativeSocket(NativeSocket sockfd, bool should_close) {
+#ifdef __linux__
+  // Check if fd represents domain socket or abstract socket.
+  struct sockaddr_un addr;
+  socklen_t addr_len = sizeof(addr);
+  if (getsockname(sockfd, (struct sockaddr *)&addr, &addr_len) == -1)
+return llvm::createStringError("not a socket or error occurred");
+  if (addr.sun_family != AF_UNIX)
+return llvm::createStringError("Bad socket type");

labath wrote:

Moving the ifdef around to get a bit more consistent experience when passing an 
invalid (or unbound?) socket to this function

```suggestion
  // Check if fd represents domain socket or abstract socket.
  struct sockaddr_un addr;
  socklen_t addr_len = sizeof(addr);
  if (getsockname(sockfd, (struct sockaddr *)&addr, &addr_len) == -1)
return llvm::createStringError("not a socket or error occurred");
  if (addr.sun_family != AF_UNIX)
return llvm::createStringError("Bad socket type");
#ifdef __linux__
```

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

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


@@ -339,6 +342,48 @@ TEST_F(SocketTest, DomainGetConnectURI) {
 }
 #endif
 
+#if LLDB_ENABLE_POSIX

labath wrote:

```suggestion
```

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

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

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


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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ebuka Ezike via lldb-commits


@@ -0,0 +1,195 @@
+"""
+Test lldb-dap stack trace when some of the source paths are missing
+"""
+
+from lldbsuite.test.decorators import skipIfWindows
+from lldbsuite.test.lldbtest import line_number
+import lldbdap_testcase
+from contextlib import contextmanager
+import os
+
+
+OTHER_C_SOURCE_CODE = """
+int fibonacci(int n) {
+if (n < 0) return -1;
+if (n == 0) return 0;
+if (n == 1) return 1;
+int a = 0, b = 1, c;
+for (int i = 2; i <= n; ++i) {
+c = a + b;
+a = b;
+b = c;
+}
+
+return b; // Break here
+}
+"""
+
+
+@contextmanager
+def delete_file_on_exit(path):
+try:
+yield path
+finally:
+if os.path.exists(path):
+os.remove(path)
+
+
+class TestDAP_stackTraceMissingSourcePath(lldbdap_testcase.DAPTestCaseBase):
+def build_and_run_until_breakpoint(self, stop_disassembly_display: str):
+"""
+Build the program and run until the breakpoint is hit, and return the 
stack frames.
+"""
+other_source_file = "other.c"
+with delete_file_on_exit(other_source_file):
+with open(other_source_file, "w") as f:
+f.write(OTHER_C_SOURCE_CODE)
+
+breakpoint_line = line_number(other_source_file, "// Break here")
+
+program = self.getBuildArtifact("a.out")
+init_commands = [
+f"settings set stop-disassembly-display 
{stop_disassembly_display}"
+]
+self.build_and_launch(program, initCommands=init_commands)
+
+breakpoint_ids = self.set_source_breakpoints(
+other_source_file, [breakpoint_line]
+)
+self.assertEqual(
+len(breakpoint_ids), 1, "expect correct number of breakpoints"
+)
+
+self.continue_to_breakpoints(breakpoint_ids)
+
+frames = self.get_stackFrames()
+self.assertLessEqual(2, len(frames), "expect at least 2 frames")
+
+self.assertIn(
+"path",
+frames[0]["source"],
+"Expect source path to always be in frame (other.c)",
+)
+self.assertIn(
+"path",
+frames[1]["source"],
+"Expect source path in always be in frame (main.c)",
+)
+
+return frames
+
+@skipIfWindows
+def test_stopDisassemblyDispay_noSource(self):
+"""
+Test that with with stop-disassembly-display = no-source - frames 
without source available give assembly code.
+"""
+frames = self.build_and_run_until_breakpoint("no-source")
+
+self.assertNotIn(
+"other.c",
+frames[0]["source"]["path"],
+"Expect original source path to not be in unavailable source frame 
(other.c)",
+)
+self.assertIn(
+"sourceReference",
+frames[0]["source"],
+"Expect sourceReference source path in to be in unavailable source 
frame (other.c)",
+)
+
+self.assertIn(
+"main.c",
+frames[1]["source"]["path"],
+"Expect original source path to be in source code frame (main.c)",
+)
+self.assertNotIn(
+"sourceReference",
+frames[1]["source"],
+"Expect no sourceReference in source code frame (main.c)",
+)
+
+@skipIfWindows

da-viper wrote:

I am not sure why the tests are skipped on windows. I assume it should work 
fine on the platform 

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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ebuka Ezike via lldb-commits


@@ -0,0 +1,195 @@
+"""
+Test lldb-dap stack trace when some of the source paths are missing
+"""
+
+from lldbsuite.test.decorators import skipIfWindows
+from lldbsuite.test.lldbtest import line_number
+import lldbdap_testcase
+from contextlib import contextmanager
+import os
+
+
+OTHER_C_SOURCE_CODE = """
+int fibonacci(int n) {
+if (n < 0) return -1;
+if (n == 0) return 0;
+if (n == 1) return 1;
+int a = 0, b = 1, c;
+for (int i = 2; i <= n; ++i) {
+c = a + b;
+a = b;
+b = c;
+}
+
+return b; // Break here
+}
+"""
+
+
+@contextmanager
+def delete_file_on_exit(path):
+try:
+yield path
+finally:
+if os.path.exists(path):
+os.remove(path)
+
+
+class TestDAP_stackTraceMissingSourcePath(lldbdap_testcase.DAPTestCaseBase):
+def build_and_run_until_breakpoint(self, stop_disassembly_display: str):
+"""
+Build the program and run until the breakpoint is hit, and return the 
stack frames.
+"""
+other_source_file = "other.c"
+with delete_file_on_exit(other_source_file):
+with open(other_source_file, "w") as f:
+f.write(OTHER_C_SOURCE_CODE)
+
+breakpoint_line = line_number(other_source_file, "// Break here")
+
+program = self.getBuildArtifact("a.out")
+init_commands = [
+f"settings set stop-disassembly-display 
{stop_disassembly_display}"
+]
+self.build_and_launch(program, initCommands=init_commands)
+
+breakpoint_ids = self.set_source_breakpoints(
+other_source_file, [breakpoint_line]
+)
+self.assertEqual(
+len(breakpoint_ids), 1, "expect correct number of breakpoints"
+)
+
+self.continue_to_breakpoints(breakpoint_ids)
+
+frames = self.get_stackFrames()
+self.assertLessEqual(2, len(frames), "expect at least 2 frames")
+
+self.assertIn(
+"path",
+frames[0]["source"],
+"Expect source path to always be in frame (other.c)",
+)
+self.assertIn(
+"path",
+frames[1]["source"],
+"Expect source path in always be in frame (main.c)",
+)
+
+return frames
+
+@skipIfWindows
+def test_stopDisassemblyDispay_noSource(self):
+"""
+Test that with with stop-disassembly-display = no-source - frames 
without source available give assembly code.
+"""
+frames = self.build_and_run_until_breakpoint("no-source")
+
+self.assertNotIn(
+"other.c",
+frames[0]["source"]["path"],
+"Expect original source path to not be in unavailable source frame 
(other.c)",
+)
+self.assertIn(
+"sourceReference",
+frames[0]["source"],
+"Expect sourceReference source path in to be in unavailable source 
frame (other.c)",
+)
+
+self.assertIn(
+"main.c",
+frames[1]["source"]["path"],
+"Expect original source path to be in source code frame (main.c)",
+)
+self.assertNotIn(
+"sourceReference",
+frames[1]["source"],
+"Expect no sourceReference in source code frame (main.c)",
+)
+
+@skipIfWindows
+def test_stopDisassemblyDispay_noDebuginfo(self):
+"""
+Test that with with stop-disassembly-display = no-debuginfo - all 
frames give source code even when source not available.
+"""
+frames = self.build_and_run_until_breakpoint("no-debuginfo")
+
+self.assertIn(
+"other.c",
+frames[0]["source"]["path"],
+"Expect original source path to be in unavailable source frame 
(other.c)",
+)
+self.assertNotIn(
+"sourceReference",
+frames[0]["source"],
+"Expect sourceReference source path in to be in unavailable source 
frame (other.c)",
+)
+
+self.assertIn(
+"main.c",
+frames[1]["source"]["path"],
+"Expect original source path to be in source code frame (main.c)",
+)
+self.assertNotIn(
+"sourceReference",
+frames[1]["source"],
+"Expect no sourceReference in source code frame (main.c)",
+)
+
+@skipIfWindows
+def test_stopDisassemblyDispay_never(self):
+"""
+Test that with with stop-disassembly-display = never - all frames 
don't give assembly code.
+"""
+frames = self.build_and_run_until_breakpoint("never")
+
+self.assertIn(
+"other.c",
+frames[0]["source"]["path"],
+"Expect original source path to be in unavailable source frame 
(other.c)",
+)
+self.assertNotIn(
+"sourceReference",
+frames[0]["source"],
+

[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ebuka Ezike via lldb-commits


@@ -0,0 +1,195 @@
+"""
+Test lldb-dap stack trace when some of the source paths are missing
+"""
+
+from lldbsuite.test.decorators import skipIfWindows
+from lldbsuite.test.lldbtest import line_number
+import lldbdap_testcase
+from contextlib import contextmanager
+import os
+
+
+OTHER_C_SOURCE_CODE = """
+int fibonacci(int n) {
+if (n < 0) return -1;
+if (n == 0) return 0;
+if (n == 1) return 1;
+int a = 0, b = 1, c;
+for (int i = 2; i <= n; ++i) {
+c = a + b;
+a = b;
+b = c;
+}
+
+return b; // Break here
+}
+"""
+
+
+@contextmanager
+def delete_file_on_exit(path):
+try:
+yield path
+finally:
+if os.path.exists(path):
+os.remove(path)
+
+
+class TestDAP_stackTraceMissingSourcePath(lldbdap_testcase.DAPTestCaseBase):
+def build_and_run_until_breakpoint(self, stop_disassembly_display: str):
+"""
+Build the program and run until the breakpoint is hit, and return the 
stack frames.
+"""
+other_source_file = "other.c"
+with delete_file_on_exit(other_source_file):
+with open(other_source_file, "w") as f:
+f.write(OTHER_C_SOURCE_CODE)
+
+breakpoint_line = line_number(other_source_file, "// Break here")
+
+program = self.getBuildArtifact("a.out")
+init_commands = [
+f"settings set stop-disassembly-display 
{stop_disassembly_display}"
+]
+self.build_and_launch(program, initCommands=init_commands)
+
+breakpoint_ids = self.set_source_breakpoints(
+other_source_file, [breakpoint_line]
+)
+self.assertEqual(
+len(breakpoint_ids), 1, "expect correct number of breakpoints"
+)
+
+self.continue_to_breakpoints(breakpoint_ids)
+
+frames = self.get_stackFrames()
+self.assertLessEqual(2, len(frames), "expect at least 2 frames")
+
+self.assertIn(
+"path",
+frames[0]["source"],
+"Expect source path to always be in frame (other.c)",
+)
+self.assertIn(
+"path",
+frames[1]["source"],
+"Expect source path in always be in frame (main.c)",
+)
+
+return frames
+
+@skipIfWindows
+def test_stopDisassemblyDispay_noSource(self):

da-viper wrote:

```suggestion
def test_stopDisassemblyDisplay_noSource(self):
```

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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ebuka Ezike via lldb-commits


@@ -0,0 +1,195 @@
+"""
+Test lldb-dap stack trace when some of the source paths are missing
+"""
+
+from lldbsuite.test.decorators import skipIfWindows
+from lldbsuite.test.lldbtest import line_number
+import lldbdap_testcase
+from contextlib import contextmanager
+import os
+
+
+OTHER_C_SOURCE_CODE = """
+int fibonacci(int n) {
+if (n < 0) return -1;
+if (n == 0) return 0;
+if (n == 1) return 1;
+int a = 0, b = 1, c;
+for (int i = 2; i <= n; ++i) {
+c = a + b;
+a = b;
+b = c;
+}
+
+return b; // Break here
+}
+"""
+
+
+@contextmanager
+def delete_file_on_exit(path):
+try:
+yield path
+finally:
+if os.path.exists(path):
+os.remove(path)
+
+
+class TestDAP_stackTraceMissingSourcePath(lldbdap_testcase.DAPTestCaseBase):
+def build_and_run_until_breakpoint(self, stop_disassembly_display: str):
+"""
+Build the program and run until the breakpoint is hit, and return the 
stack frames.
+"""
+other_source_file = "other.c"
+with delete_file_on_exit(other_source_file):
+with open(other_source_file, "w") as f:
+f.write(OTHER_C_SOURCE_CODE)
+
+breakpoint_line = line_number(other_source_file, "// Break here")
+
+program = self.getBuildArtifact("a.out")
+init_commands = [
+f"settings set stop-disassembly-display 
{stop_disassembly_display}"
+]
+self.build_and_launch(program, initCommands=init_commands)
+
+breakpoint_ids = self.set_source_breakpoints(
+other_source_file, [breakpoint_line]
+)
+self.assertEqual(
+len(breakpoint_ids), 1, "expect correct number of breakpoints"
+)
+
+self.continue_to_breakpoints(breakpoint_ids)
+
+frames = self.get_stackFrames()
+self.assertLessEqual(2, len(frames), "expect at least 2 frames")
+
+self.assertIn(
+"path",
+frames[0]["source"],
+"Expect source path to always be in frame (other.c)",
+)
+self.assertIn(
+"path",
+frames[1]["source"],
+"Expect source path in always be in frame (main.c)",
+)
+
+return frames
+
+@skipIfWindows
+def test_stopDisassemblyDispay_noSource(self):

da-viper wrote:

the typo is in other functions

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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ebuka Ezike via lldb-commits


@@ -0,0 +1,10 @@
+#include 
+#include 

da-viper wrote:

we could remove the includes as it is not really used in tests. as adding them 
increases the test times. 

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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ely Ronnen via lldb-commits


@@ -1383,6 +1383,14 @@ enum CommandReturnObjectCallbackResult {
   eCommandReturnObjectPrintCallbackHandled = 1,
 };
 
+// Used to determine when to show disassembly

eronnen wrote:

:100: 

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


[Lldb-commits] [lldb] [lldb] Support riscv32 corefiles (PR #115408)

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


@@ -0,0 +1,76 @@
+//===-- RegisterInfoPOSIX_riscv32.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_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOPOSIX_RISCV32_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOPOSIX_RISCV32_H
+
+#include "RegisterInfoAndSetInterface.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Utility/Flags.h"
+#include "lldb/lldb-private.h"
+
+#include 
+
+class RegisterInfoPOSIX_riscv32
+: public lldb_private::RegisterInfoAndSetInterface {
+public:
+  static const lldb_private::RegisterInfo *
+  GetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch);
+  static uint32_t
+  GetRegisterInfoCount(const lldb_private::ArchSpec &target_arch);
+
+public:
+  // RISC-V32 register set mask value
+  enum {
+eRegsetMaskDefault = 0,
+eRegsetMaskFP = 1,
+eRegsetMaskAll = -1,
+  };
+
+  struct GPR {
+// note: gpr[0] is pc, not x0
+uint32_t gpr[32];
+  };
+
+  struct FPR {
+uint32_t fpr[32];
+uint32_t fcsr;
+  };
+
+  struct VPR {

DavidSpickett wrote:

ISTR the 64-bit has some mentions of the vector registers but we don't actually 
support them yet.

But I agree, leave them out until they are supposed to be useable.

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


[Lldb-commits] [lldb] [lldb] Support riscv32 corefiles (PR #115408)

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


@@ -0,0 +1,76 @@
+//===-- RegisterInfoPOSIX_riscv32.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_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOPOSIX_RISCV32_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOPOSIX_RISCV32_H
+
+#include "RegisterInfoAndSetInterface.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Utility/Flags.h"
+#include "lldb/lldb-private.h"
+
+#include 
+
+class RegisterInfoPOSIX_riscv32
+: public lldb_private::RegisterInfoAndSetInterface {
+public:
+  static const lldb_private::RegisterInfo *
+  GetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch);
+  static uint32_t
+  GetRegisterInfoCount(const lldb_private::ArchSpec &target_arch);
+
+public:
+  // RISC-V32 register set mask value
+  enum {
+eRegsetMaskDefault = 0,
+eRegsetMaskFP = 1,
+eRegsetMaskAll = -1,
+  };
+
+  struct GPR {
+// note: gpr[0] is pc, not x0

DavidSpickett wrote:

x0 is always tied to zero, right? Just for clarity:
```
// note: gpr[0] is pc, not x0, which is the zero register
```

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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen updated 
https://github.com/llvm/llvm-project/pull/136494

>From 05d605e3add0461b12ddfbb24349e20be4259060 Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 20 Apr 2025 17:07:09 +0200
Subject: [PATCH 1/6] fallback to assembly when source code is not available

---
 lldb/tools/lldb-dap/JSONUtils.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index 33f10c93d2ada..1a44df7740639 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -750,9 +750,10 @@ llvm::json::Value CreateStackFrame(lldb::SBFrame &frame,
   EmplaceSafeString(object, "name", frame_name);
 
   auto line_entry = frame.GetLineEntry();
+  auto file_spec = line_entry.GetFileSpec();
   // A line entry of 0 indicates the line is compiler generated i.e. no source
   // file is associated with the frame.
-  if (line_entry.GetFileSpec().IsValid() &&
+  if (file_spec.IsValid() && file_spec.Exists() &&
   (line_entry.GetLine() != 0 ||
line_entry.GetLine() != LLDB_INVALID_LINE_NUMBER)) {
 object.try_emplace("source", CreateSource(line_entry));

>From 589c70284a97092d76d626cb1ed68c36e8191ee0 Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 20 Apr 2025 21:03:02 +0200
Subject: [PATCH 2/6] fix TestDAP_coreFile.py with source maps

---
 .../API/tools/lldb-dap/coreFile/TestDAP_coreFile.py| 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py 
b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
index 1896acea15a99..ce54133a61f3e 100644
--- a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
+++ b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
@@ -19,7 +19,9 @@ def test_core_file(self):
 core_file = os.path.join(current_dir, "linux-x86_64.core")
 
 self.create_debug_adapter()
-self.attach(exe_file, coreFile=core_file)
+
+source_map = [["/home/labath/test", current_dir]]
+self.attach(exe_file, coreFile=core_file, sourceMap=source_map)
 
 expected_frames = [
 {
@@ -27,7 +29,7 @@ def test_core_file(self):
 "id": 524288,
 "line": 4,
 "name": "bar",
-"source": {"name": "main.c", "path": 
"/home/labath/test/main.c"},
+"source": {"name": "main.c", "path": os.path.join(current_dir, 
"main.c")},
 "instructionPointerReference": "0x40011C",
 },
 {
@@ -35,7 +37,7 @@ def test_core_file(self):
 "id": 524289,
 "line": 10,
 "name": "foo",
-"source": {"name": "main.c", "path": 
"/home/labath/test/main.c"},
+"source": {"name": "main.c", "path": os.path.join(current_dir, 
"main.c")},
 "instructionPointerReference": "0x400142",
 },
 {
@@ -43,7 +45,7 @@ def test_core_file(self):
 "id": 524290,
 "line": 16,
 "name": "_start",
-"source": {"name": "main.c", "path": 
"/home/labath/test/main.c"},
+"source": {"name": "main.c", "path": os.path.join(current_dir, 
"main.c")},
 "instructionPointerReference": "0x40015F",
 },
 ]

>From 51167c8a5f2bc61105934bff66f353ce36aa6710 Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 20 Apr 2025 21:04:46 +0200
Subject: [PATCH 3/6] use stop-disassembly-display setting to determine when to
 show disassembly

---
 .../lldb-dap/coreFile/TestDAP_coreFile.py |  10 +-
 .../stackTraceDisassemblyDisplay/Makefile |   3 +
 .../TestDAP_stackTraceDisassemblyDisplay.py   | 195 ++
 .../stackTraceDisassemblyDisplay/main.c   |  10 +
 lldb/tools/lldb-dap/DAP.h |   4 +
 .../lldb-dap/Handler/AttachRequestHandler.cpp |   1 +
 .../lldb-dap/Handler/LaunchRequestHandler.cpp |   1 +
 .../tools/lldb-dap/Handler/RequestHandler.cpp |   4 +
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |   3 +
 .../Handler/StackTraceRequestHandler.cpp  |   3 +-
 lldb/tools/lldb-dap/JSONUtils.cpp |  34 ++-
 lldb/tools/lldb-dap/JSONUtils.h   |  21 +-
 lldb/tools/lldb-dap/LLDBUtils.cpp |  19 ++
 lldb/tools/lldb-dap/LLDBUtils.h   |   9 +
 14 files changed, 300 insertions(+), 17 deletions(-)
 create mode 100644 
lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py
 create mode 100644 
lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/main.c

diff --git a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py 
b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
index ce54133a61f3e..1896acea15a99 100644
--- a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP

[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [mlir] [openmp] [polly] [Documentation] Always use SVG for dot-generated doxygen images. (PR #136843)

2025-04-24 Thread via lldb-commits


@@ -48,14 +48,6 @@ if (LLVM_ENABLE_DOXYGEN)
 set(bolt_doxygen_qhp_cust_filter_attrs "")
   endif()
 
-  option(LLVM_DOXYGEN_SVG

cor3ntin wrote:

The couple of projects I found on Github (which sets it to "on" might get

```
CMake Warning:
  Manually-specified variables were not used by the project:
LLVM_DOXYGEN_SVG
```

But it won't break anyone's build

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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ely Ronnen via lldb-commits

eronnen wrote:

@JDevlieghere  Fixed comments and conflicts with `main`, from my part it's 
ready to merge

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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ebuka Ezike via lldb-commits


@@ -0,0 +1,195 @@
+"""
+Test lldb-dap stack trace when some of the source paths are missing
+"""
+
+from lldbsuite.test.decorators import skipIfWindows
+from lldbsuite.test.lldbtest import line_number
+import lldbdap_testcase
+from contextlib import contextmanager
+import os
+
+
+OTHER_C_SOURCE_CODE = """
+int fibonacci(int n) {
+if (n < 0) return -1;
+if (n == 0) return 0;
+if (n == 1) return 1;
+int a = 0, b = 1, c;
+for (int i = 2; i <= n; ++i) {
+c = a + b;
+a = b;
+b = c;
+}
+
+return b; // Break here
+}
+"""
+
+
+@contextmanager
+def delete_file_on_exit(path):
+try:
+yield path
+finally:
+if os.path.exists(path):
+os.remove(path)
+
+
+class TestDAP_stackTraceMissingSourcePath(lldbdap_testcase.DAPTestCaseBase):
+def build_and_run_until_breakpoint(self, stop_disassembly_display: str):
+"""
+Build the program and run until the breakpoint is hit, and return the 
stack frames.
+"""
+other_source_file = "other.c"
+with delete_file_on_exit(other_source_file):
+with open(other_source_file, "w") as f:
+f.write(OTHER_C_SOURCE_CODE)
+
+breakpoint_line = line_number(other_source_file, "// Break here")
+
+program = self.getBuildArtifact("a.out")
+init_commands = [
+f"settings set stop-disassembly-display 
{stop_disassembly_display}"
+]
+self.build_and_launch(program, initCommands=init_commands)
+
+breakpoint_ids = self.set_source_breakpoints(
+other_source_file, [breakpoint_line]
+)
+self.assertEqual(
+len(breakpoint_ids), 1, "expect correct number of breakpoints"
+)
+
+self.continue_to_breakpoints(breakpoint_ids)
+
+frames = self.get_stackFrames()
+self.assertLessEqual(2, len(frames), "expect at least 2 frames")
+
+self.assertIn(
+"path",
+frames[0]["source"],
+"Expect source path to always be in frame (other.c)",
+)
+self.assertIn(
+"path",
+frames[1]["source"],
+"Expect source path in always be in frame (main.c)",
+)
+
+return frames
+
+@skipIfWindows
+def test_stopDisassemblyDispay_noSource(self):
+"""
+Test that with with stop-disassembly-display = no-source - frames 
without source available give assembly code.
+"""
+frames = self.build_and_run_until_breakpoint("no-source")
+
+self.assertNotIn(
+"other.c",
+frames[0]["source"]["path"],
+"Expect original source path to not be in unavailable source frame 
(other.c)",
+)
+self.assertIn(
+"sourceReference",
+frames[0]["source"],
+"Expect sourceReference source path in to be in unavailable source 
frame (other.c)",
+)
+
+self.assertIn(
+"main.c",
+frames[1]["source"]["path"],
+"Expect original source path to be in source code frame (main.c)",
+)
+self.assertNotIn(
+"sourceReference",
+frames[1]["source"],
+"Expect no sourceReference in source code frame (main.c)",
+)
+
+@skipIfWindows

da-viper wrote:

Some of the dap test skip windows if it has platform specific code or the 
feature is not implemented yet. For example run in the terminal.

In this case it is not needed and should work fine


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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ebuka Ezike via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ely Ronnen via lldb-commits


@@ -0,0 +1,195 @@
+"""
+Test lldb-dap stack trace when some of the source paths are missing
+"""
+
+from lldbsuite.test.decorators import skipIfWindows
+from lldbsuite.test.lldbtest import line_number
+import lldbdap_testcase
+from contextlib import contextmanager
+import os
+
+
+OTHER_C_SOURCE_CODE = """
+int fibonacci(int n) {
+if (n < 0) return -1;
+if (n == 0) return 0;
+if (n == 1) return 1;
+int a = 0, b = 1, c;
+for (int i = 2; i <= n; ++i) {
+c = a + b;
+a = b;
+b = c;
+}
+
+return b; // Break here
+}
+"""
+
+
+@contextmanager
+def delete_file_on_exit(path):
+try:
+yield path
+finally:
+if os.path.exists(path):
+os.remove(path)
+
+
+class TestDAP_stackTraceMissingSourcePath(lldbdap_testcase.DAPTestCaseBase):
+def build_and_run_until_breakpoint(self, stop_disassembly_display: str):
+"""
+Build the program and run until the breakpoint is hit, and return the 
stack frames.
+"""
+other_source_file = "other.c"
+with delete_file_on_exit(other_source_file):
+with open(other_source_file, "w") as f:
+f.write(OTHER_C_SOURCE_CODE)
+
+breakpoint_line = line_number(other_source_file, "// Break here")
+
+program = self.getBuildArtifact("a.out")
+init_commands = [
+f"settings set stop-disassembly-display 
{stop_disassembly_display}"
+]
+self.build_and_launch(program, initCommands=init_commands)
+
+breakpoint_ids = self.set_source_breakpoints(
+other_source_file, [breakpoint_line]
+)
+self.assertEqual(
+len(breakpoint_ids), 1, "expect correct number of breakpoints"
+)
+
+self.continue_to_breakpoints(breakpoint_ids)
+
+frames = self.get_stackFrames()
+self.assertLessEqual(2, len(frames), "expect at least 2 frames")
+
+self.assertIn(
+"path",
+frames[0]["source"],
+"Expect source path to always be in frame (other.c)",
+)
+self.assertIn(
+"path",
+frames[1]["source"],
+"Expect source path in always be in frame (main.c)",
+)
+
+return frames
+
+@skipIfWindows
+def test_stopDisassemblyDispay_noSource(self):
+"""
+Test that with with stop-disassembly-display = no-source - frames 
without source available give assembly code.
+"""
+frames = self.build_and_run_until_breakpoint("no-source")
+
+self.assertNotIn(
+"other.c",
+frames[0]["source"]["path"],
+"Expect original source path to not be in unavailable source frame 
(other.c)",
+)
+self.assertIn(
+"sourceReference",
+frames[0]["source"],
+"Expect sourceReference source path in to be in unavailable source 
frame (other.c)",
+)
+
+self.assertIn(
+"main.c",
+frames[1]["source"]["path"],
+"Expect original source path to be in source code frame (main.c)",
+)
+self.assertNotIn(
+"sourceReference",
+frames[1]["source"],
+"Expect no sourceReference in source code frame (main.c)",
+)
+
+@skipIfWindows

eronnen wrote:

Not sure too but I've seen it in a lot of other tests in lldb-dap, maybe 
building the executables from `make` doesn't work on the windows tester?

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


[Lldb-commits] [lldb] [lldb/Host] Enable inheriting "non-inheritable" FDs (PR #126935)

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

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

>From ac748d0911fb1ccf7bb70955da2d70d7f9d9117e Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Sun, 20 Oct 2024 02:55:02 +0200
Subject: [PATCH] [lldb/Host] Enable inheriting "non-inheritable" FDs

Currently we're creating inheritable (`~FD_CLOEXEC`) file descriptors in
the (few) cases where we need to pass an FD to a subprocess. The problem
with these is that, in a multithreaded application such as lldb, there's
essentially no way to prevent them from being leaked into processes
other than the intended one.

A safer (though still not completely safe) approach is to mark the
descriptors as FD_CLOEXEC and only clear this flag in the subprocess. We
currently have something that almost does that, which is the ability to
add a `DuplicateFileAction` to our `ProcessLaunchInfo` struct (the
duplicated file descriptor will be created with the flag cleared). The
problem with *that* is that this approach is completely incompatible
with Windows.

Windows equivalents of file descriptors are `HANDLE`s, but these do not
have user controlled values -- applications are expected to work with
whatever HANDLE values are assigned by the OS. In unix terms, there is
no equivalent to the `dup2` syscall (only `dup`).

To find a way out of this conundrum, and create a miniscule API surface
that works uniformly across platforms, this PR proposes to extend the
`DuplicateFileAction` API to support duplicating a file descriptor onto
itself. Currently, this operation does nothing (it leaves the FD_CLOEXEC
flag set), because that's how `dup2(fd, fd)` behaves, but I think it's
not completely unreasonable to say that this operation should clear the
FD_CLOEXEC flag, just like it would do if one was using different fd
values. This would enable us to pass a windows HANDLE as itself through
the ProcessLaunchInfo API.

This PR implements the unix portion of this idea. Macos and non-macos
launchers are updated to clear FD_CLOEXEC flag when duplicating a file
descriptor onto itself, and I've created a test which enables passing a
FD_CLOEXEC file descritor to the subprocess. For the windows portion,
please see the follow-up PR.
---
 lldb/source/Host/macosx/objcxx/Host.mm| 11 -
 .../Host/posix/ProcessLauncherPosixFork.cpp   | 11 -
 lldb/unittests/Host/HostTest.cpp  | 45 +--
 3 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index bb270f6a44e43..e187bf98188ae 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -1100,7 +1100,7 @@ static bool AddPosixSpawnFileAction(void *_file_actions, 
const FileAction *info,
 else if (info->GetActionArgument() == -1)
   error = Status::FromErrorString(
   "invalid duplicate fd for posix_spawn_file_actions_adddup2(...)");
-else {
+else if (info->GetFD() != info->GetActionArgument()) {
   error =
   Status(::posix_spawn_file_actions_adddup2(file_actions, 
info->GetFD(),
 info->GetActionArgument()),
@@ -1110,6 +1110,15 @@ static bool AddPosixSpawnFileAction(void *_file_actions, 
const FileAction *info,
  "error: {0}, posix_spawn_file_actions_adddup2 "
  "(action={1}, fd={2}, dup_fd={3})",
  error, file_actions, info->GetFD(), 
info->GetActionArgument());
+} else {
+  error =
+  Status(::posix_spawn_file_actions_addinherit_np(file_actions, 
info->GetFD()),
+ eErrorTypePOSIX);
+  if (error.Fail())
+LLDB_LOG(log,
+ "error: {0}, posix_spawn_file_actions_addinherit_np "
+ "(action={1}, fd={2})",
+ error, file_actions, info->GetFD());
 }
 break;
 
diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp 
b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
index 8c6d503fc7fe2..698524349e16a 100644
--- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
+++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
@@ -17,6 +17,7 @@
 #include "llvm/Support/Errno.h"
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -122,8 +123,14 @@ struct ForkLaunchInfo {
 ExitWithError(error_fd, "close");
   break;
 case FileAction::eFileActionDuplicate:
-  if (dup2(action.fd, action.arg) == -1)
-ExitWithError(error_fd, "dup2");
+  if (action.fd != action.arg) {
+if (dup2(action.fd, action.arg) == -1)
+  ExitWithError(error_fd, "dup2");
+  } else {
+if (fcntl(action.fd, F_SETFD,
+  fcntl(action.fd, F_GETFD) & ~FD_CLOEXEC) == -1)
+  ExitWithError(error_fd, "fcntl");
+  }
   break;
 case FileAction::eFileActionOpen:
   DupDescriptor(error_fd, action.path.c_str(), action.fd, action.arg);
diff --git a/lldb/unittests/Host/HostTest

[Lldb-commits] [lldb] [lldb-dap] Support StackFrameFormat (PR #137113)

2025-04-24 Thread John Harrison via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Support StackFrameFormat (PR #137113)

2025-04-24 Thread John Harrison via lldb-commits


@@ -180,44 +184,53 @@ void StackTraceRequestHandler::operator()(
   llvm::json::Object body;
 
   lldb::SBFormat frame_format = dap.frame_format;
+  bool include_all = false;

ashgti wrote:

Should this default to `dap.configuration.displayExtendedBacktrace` and then it 
simplifies line 75-77.

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


[Lldb-commits] [lldb] [lldb] Expose language plugin commands based based on language of current frame (PR #136766)

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

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/136766

>From daf394bf76b5fd627f77aee6e451e7d706d26916 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Tue, 22 Apr 2025 13:58:25 -0700
Subject: [PATCH 1/5] [lldb] Expose language plugin commands based based on
 language of current frame

---
 .../lldb/Interpreter/CommandInterpreter.h |  6 ++
 .../source/Interpreter/CommandInterpreter.cpp | 55 ++-
 2 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 724d88d65f6ac..26e0767951e7f 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -730,6 +730,12 @@ class CommandInterpreter : public Broadcaster,
   bool EchoCommandNonInteractive(llvm::StringRef line,
  const Flags &io_handler_flags) const;
 
+  /// Return the language specific command object for the current frame.
+  ///
+  /// For example, when stopped on a C++ frame, this returns the command object
+  /// for "language cplusplus" (`CommandObjectMultiwordItaniumABI`).
+  lldb::CommandObjectSP GetFrameLanguageCommand() const;
+
   // A very simple state machine which models the command handling transitions
   enum class CommandHandlingState {
 eIdle,
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index eb4741feb0aa5..2ff02ae5086b4 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1018,6 +1018,26 @@ CommandInterpreter::VerifyUserMultiwordCmdPath(Args 
&path, bool leaf_is_command,
   return cur_as_multi;
 }
 
+CommandObjectSP CommandInterpreter::GetFrameLanguageCommand() const {
+  if (auto frame_sp = GetExecutionContext().GetFrameSP()) {
+auto frame_language = Language::GetPrimaryLanguage(
+frame_sp->GuessLanguage().AsLanguageType());
+
+auto it = m_command_dict.find("language");
+if (it != m_command_dict.end()) {
+  // The root "language" command.
+  CommandObjectSP language_cmd_sp = it->second;
+
+  if (auto *plugin = Language::FindPlugin(frame_language)) {
+// "cplusplus", "objc", etc.
+auto lang_name = plugin->GetPluginName();
+return language_cmd_sp->GetSubcommandSPExact(lang_name);
+  }
+}
+  }
+  return {};
+}
+
 CommandObjectSP
 CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, bool include_aliases,
  bool exact, StringList *matches,
@@ -1050,11 +1070,20 @@ CommandInterpreter::GetCommandSP(llvm::StringRef 
cmd_str, bool include_aliases,
   command_sp = pos->second;
   }
 
+  // The `language` subcommand ("language objc", "language cplusplus", etc).
+  CommandObjectMultiword *lang_subcmd = nullptr;
+  if (!command_sp) {
+if (auto subcmd_sp = GetFrameLanguageCommand()) {
+  lang_subcmd = subcmd_sp->GetAsMultiwordCommand();
+  command_sp = subcmd_sp->GetSubcommandSPExact(cmd_str);
+}
+  }
+
   if (!exact && !command_sp) {
 // We will only get into here if we didn't find any exact matches.
 
 CommandObjectSP user_match_sp, user_mw_match_sp, alias_match_sp,
-real_match_sp;
+real_match_sp, lang_match_sp;
 
 StringList local_matches;
 if (matches == nullptr)
@@ -1064,6 +1093,7 @@ CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, 
bool include_aliases,
 unsigned int num_alias_matches = 0;
 unsigned int num_user_matches = 0;
 unsigned int num_user_mw_matches = 0;
+unsigned int num_lang_matches = 0;
 
 // Look through the command dictionaries one by one, and if we get only one
 // match from any of them in toto, then return that, otherwise return an
@@ -1121,11 +1151,28 @@ CommandInterpreter::GetCommandSP(llvm::StringRef 
cmd_str, bool include_aliases,
 user_mw_match_sp = pos->second;
 }
 
+if (lang_subcmd) {
+  num_lang_matches =
+  AddNamesMatchingPartialString(lang_subcmd->GetSubcommandDictionary(),
+cmd_str, *matches, descriptions);
+}
+
+if (num_lang_matches == 1) {
+  cmd.assign(matches->GetStringAtIndex(num_cmd_matches + num_alias_matches 
+
+   num_user_matches +
+   num_user_mw_matches));
+
+  auto &lang_dict = lang_subcmd->GetSubcommandDictionary();
+  auto pos = lang_dict.find(cmd);
+  if (pos != lang_dict.end())
+lang_match_sp = pos->second;
+}
+
 // If we got exactly one match, return that, otherwise return the match
 // list.
 
 if (num_user_matches + num_user_mw_matches + num_cmd_matches +
-num_alias_matches ==
+num_alias_matches + num_lang_matches ==
 1) {
   if (num_cmd_matches)
 return real_match_sp;
@@ -1133,8 +1180,10 @

[Lldb-commits] [lldb] [lldb] Support riscv32 corefiles (PR #115408)

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

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

>From fc24e6cfed5f93f700a92618459365f2e320f2b1 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 7 Nov 2024 17:18:50 -0800
Subject: [PATCH] [lldb] Support riscv32 corefiles

---
 .../Plugins/Process/Utility/CMakeLists.txt|   2 +
 .../Utility/RegisterContextPOSIX_riscv32.cpp  |  81 
 .../Utility/RegisterContextPOSIX_riscv32.h|  63 ++
 .../Utility/RegisterInfoPOSIX_riscv32.cpp | 142 ++
 .../Utility/RegisterInfoPOSIX_riscv32.h   |  71 +++
 .../Utility/RegisterInfoPOSIX_riscv64.cpp |   9 +-
 .../Process/Utility/RegisterInfos_riscv32.h   | 185 ++
 .../Plugins/Process/elf-core/CMakeLists.txt   |   1 +
 .../RegisterContextPOSIXCore_riscv32.cpp  |  81 
 .../RegisterContextPOSIXCore_riscv32.h|  56 ++
 10 files changed, 686 insertions(+), 5 deletions(-)
 create mode 100644 
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv32.cpp
 create mode 100644 
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv32.h
 create mode 100644 
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv32.cpp
 create mode 100644 
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv32.h
 create mode 100644 lldb/source/Plugins/Process/Utility/RegisterInfos_riscv32.h
 create mode 100644 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv32.cpp
 create mode 100644 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv32.h

diff --git a/lldb/source/Plugins/Process/Utility/CMakeLists.txt 
b/lldb/source/Plugins/Process/Utility/CMakeLists.txt
index f269f5d7d4d74..8f0b98204d724 100644
--- a/lldb/source/Plugins/Process/Utility/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/Utility/CMakeLists.txt
@@ -42,6 +42,7 @@ add_lldb_library(lldbPluginProcessUtility
   RegisterContextPOSIX_arm64.cpp
   RegisterContextPOSIX_loongarch64.cpp
   RegisterContextPOSIX_mips64.cpp
+  RegisterContextPOSIX_riscv32.cpp
   RegisterContextPOSIX_powerpc.cpp
   RegisterContextPOSIX_ppc64le.cpp
   RegisterContextPOSIX_riscv64.cpp
@@ -56,6 +57,7 @@ add_lldb_library(lldbPluginProcessUtility
   RegisterInfoPOSIX_arm64.cpp
   RegisterInfoPOSIX_loongarch64.cpp
   RegisterInfoPOSIX_ppc64le.cpp
+  RegisterInfoPOSIX_riscv32.cpp
   RegisterInfoPOSIX_riscv64.cpp
   StopInfoMachException.cpp
   ThreadMemory.cpp
diff --git 
a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv32.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv32.cpp
new file mode 100644
index 0..64064f86cea04
--- /dev/null
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv32.cpp
@@ -0,0 +1,81 @@
+//===-- RegisterContextPOSIX_riscv32.cpp *- 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
+//
+//===--===//
+
+#include "RegisterContextPOSIX_riscv32.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/RegisterValue.h"
+#include "lldb/Utility/Scalar.h"
+#include "llvm/Support/Compiler.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+RegisterContextPOSIX_riscv32::RegisterContextPOSIX_riscv32(
+lldb_private::Thread &thread,
+std::unique_ptr register_info)
+: lldb_private::RegisterContext(thread, 0),
+  m_register_info_up(std::move(register_info)) {}
+
+RegisterContextPOSIX_riscv32::~RegisterContextPOSIX_riscv32() = default;
+
+void RegisterContextPOSIX_riscv32::invalidate() {}
+
+void RegisterContextPOSIX_riscv32::InvalidateAllRegisters() {}
+
+size_t RegisterContextPOSIX_riscv32::GetRegisterCount() {
+  return m_register_info_up->GetRegisterCount();
+}
+
+size_t RegisterContextPOSIX_riscv32::GetGPRSize() {
+  return m_register_info_up->GetGPRSize();
+}
+
+unsigned RegisterContextPOSIX_riscv32::GetRegisterSize(unsigned int reg) {
+  return m_register_info_up->GetRegisterInfo()[reg].byte_size;
+}
+
+unsigned RegisterContextPOSIX_riscv32::GetRegisterOffset(unsigned int reg) {
+  return m_register_info_up->GetRegisterInfo()[reg].byte_offset;
+}
+
+const lldb_private::RegisterInfo *
+RegisterContextPOSIX_riscv32::GetRegisterInfoAtIndex(size_t reg) {
+  if (reg < GetRegisterCount())
+return &GetRegisterInfo()[reg];
+
+  return nullptr;
+}
+
+size_t RegisterContextPOSIX_riscv32::GetRegisterSetCount() {
+  return m_register_info_up->GetRegisterCount();
+}
+
+const lldb_private::RegisterSet *
+RegisterContextPOSIX_riscv32::GetRegisterSet(size_t set) {
+  return m_register_info_up->GetRegisterSet(set);
+}
+
+const lldb_private::RegisterInfo 

[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow arrays to be dereferenced in C/C++. (PR #135843)

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

https://github.com/kuilpd updated 
https://github.com/llvm/llvm-project/pull/135843

>From 08834d47602b0df46e43678c08b3902d45145871 Mon Sep 17 00:00:00 2001
From: Ilia Kuklin 
Date: Wed, 16 Apr 2025 00:30:51 +0500
Subject: [PATCH 1/3] [lldb][TypeSystemClang] Add a function
 `IsValidDereferenceType` to TypeSystem to allow arrays to be dereferenced in
 C/C++.

---
 lldb/include/lldb/Symbol/CompilerType.h  | 2 ++
 lldb/include/lldb/Symbol/TypeSystem.h| 2 ++
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 9 +
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h   | 2 ++
 lldb/source/Symbol/CompilerType.cpp  | 7 +++
 lldb/source/ValueObject/ValueObject.cpp  | 7 ---
 6 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index 671b5314c24a2..6e37f9a64cbf4 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -186,6 +186,8 @@ class CompilerType {
   bool IsReferenceType(CompilerType *pointee_type = nullptr,
bool *is_rvalue = nullptr) const;
 
+  bool IsValidDereferenceType() const;
+
   bool ShouldTreatScalarValueAsAddress() const;
 
   bool IsScalarType() const;
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 9e9edc09a0846..7a568098ac4a3 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -486,6 +486,8 @@ class TypeSystem : public PluginInterface,
   virtual bool IsReferenceType(lldb::opaque_compiler_type_t type,
CompilerType *pointee_type, bool *is_rvalue) = 
0;
 
+  virtual bool IsValidDereferenceType(lldb::opaque_compiler_type_t type) = 0;
+
   virtual bool
   ShouldTreatScalarValueAsAddress(lldb::opaque_compiler_type_t type) {
 return IsPointerOrReferenceType(type, nullptr);
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 59292f4b24af3..0859614691c69 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3443,6 +3443,13 @@ bool 
TypeSystemClang::IsReferenceType(lldb::opaque_compiler_type_t type,
   return false;
 }
 
+bool TypeSystemClang::IsValidDereferenceType(
+lldb::opaque_compiler_type_t type) {
+  CompilerType compiler_type = 
GetType(clang::QualType::getFromOpaquePtr(type));
+  return compiler_type.IsPointerOrReferenceType() ||
+ compiler_type.IsArrayType();
+}
+
 bool TypeSystemClang::IsFloatingPointType(lldb::opaque_compiler_type_t type,
   uint32_t &count, bool &is_complex) {
   if (type) {
@@ -6565,6 +6572,8 @@ llvm::Expected 
TypeSystemClang::GetChildCompilerTypeAtIndex(
 return size_or_err.takeError();
   child_byte_size = *size_or_err;
   child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
+  if (idx == 0)
+child_is_deref_of_parent = true;
   return element_type;
 }
   }
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 442f88a5b79ae..5026e26041afd 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -716,6 +716,8 @@ class TypeSystemClang : public TypeSystem {
   bool IsReferenceType(lldb::opaque_compiler_type_t type,
CompilerType *pointee_type, bool *is_rvalue) override;
 
+  bool IsValidDereferenceType(lldb::opaque_compiler_type_t type) override;
+
   bool IsScalarType(lldb::opaque_compiler_type_t type) override;
 
   bool IsTypedefType(lldb::opaque_compiler_type_t type) override;
diff --git a/lldb/source/Symbol/CompilerType.cpp 
b/lldb/source/Symbol/CompilerType.cpp
index 8e89d006d08d3..789ff7ae262f0 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -233,6 +233,13 @@ bool CompilerType::IsReferenceType(CompilerType 
*pointee_type,
   return false;
 }
 
+bool CompilerType::IsValidDereferenceType() const {
+  if (IsValid())
+if (auto type_system_sp = GetTypeSystem())
+  return type_system_sp->IsValidDereferenceType(m_type);
+  return false;
+}
+
 bool CompilerType::ShouldTreatScalarValueAsAddress() const {
   if (IsValid())
 if (auto type_system_sp = GetTypeSystem())
diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index 8741cb7343166..f999812f3b7be 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -2850,8 +2850,9 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
   if (m_deref_valobj)
 return m_deref_valobj->GetSP();
 
-  const bool is_pointer_or_reference_type 

[Lldb-commits] [lldb] [lldb-dap] Support StackFrameFormat (PR #137113)

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

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

>From 21681616560eceb9b46ef4c370817099fe149701 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 23 Apr 2025 20:05:19 -0700
Subject: [PATCH 1/3] [lldb-dap] Support StackFrameFormat

The debug adapter protocol supports an option to provide formatting
information for a stack frames as part of the StackTrace request.
lldb-dap incorrectly advertises it supports this, but until this PR that
support wasn't actually implemented.

Fixes #137057
---
 .../test/tools/lldb-dap/dap_server.py |  4 +-
 .../test/tools/lldb-dap/lldbdap_testcase.py   | 18 ++--
 .../lldb-dap/stackTrace/TestDAP_stackTrace.py | 30 +
 .../Handler/StackTraceRequestHandler.cpp  | 42 ---
 4 files changed, 84 insertions(+), 10 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 a9915ba2f6de6..dadf6b1f8774c 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
@@ -1046,7 +1046,7 @@ def request_modules(self):
 return self.send_recv({"command": "modules", "type": "request"})
 
 def request_stackTrace(
-self, threadId=None, startFrame=None, levels=None, dump=False
+self, threadId=None, startFrame=None, levels=None, format=None, 
dump=False
 ):
 if threadId is None:
 threadId = self.get_thread_id()
@@ -1055,6 +1055,8 @@ def request_stackTrace(
 args_dict["startFrame"] = startFrame
 if levels is not None:
 args_dict["levels"] = levels
+if format is not None:
+args_dict["format"] = format
 command_dict = {
 "command": "stackTrace",
 "type": "request",
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 70b04b051e0ec..b5b55b336d535 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -161,10 +161,14 @@ def get_dict_value(self, d, key_path):
 return value
 
 def get_stackFrames_and_totalFramesCount(
-self, threadId=None, startFrame=None, levels=None, dump=False
+self, threadId=None, startFrame=None, levels=None, format=None, 
dump=False
 ):
 response = self.dap_server.request_stackTrace(
-threadId=threadId, startFrame=startFrame, levels=levels, dump=dump
+threadId=threadId,
+startFrame=startFrame,
+levels=levels,
+format=format,
+dump=dump,
 )
 if response:
 stackFrames = self.get_dict_value(response, ["body", 
"stackFrames"])
@@ -177,9 +181,15 @@ def get_stackFrames_and_totalFramesCount(
 return (stackFrames, totalFrames)
 return (None, 0)
 
-def get_stackFrames(self, threadId=None, startFrame=None, levels=None, 
dump=False):
+def get_stackFrames(
+self, threadId=None, startFrame=None, levels=None, format=None, 
dump=False
+):
 (stackFrames, totalFrames) = self.get_stackFrames_and_totalFramesCount(
-threadId=threadId, startFrame=startFrame, levels=levels, dump=dump
+threadId=threadId,
+startFrame=startFrame,
+levels=levels,
+format=format,
+dump=dump,
 )
 return stackFrames
 
diff --git a/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py 
b/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
index 56ed1ebdf7ab4..713b5d841cfcd 100644
--- a/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
+++ b/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
@@ -217,3 +217,33 @@ def test_functionNameWithArgs(self):
 self.continue_to_next_stop()
 frame = self.get_stackFrames()[0]
 self.assertEqual(frame["name"], "recurse(x=1)")
+
+@skipIfWindows
+def test_StackFrameFormat(self):
+"""
+Test the StackFrameFormat.
+"""
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+source = "main.c"
+
+self.set_source_breakpoints(source, [line_number(source, "recurse 
end")])
+
+self.continue_to_next_stop()
+frame = self.get_stackFrames(format={"includeAll": True})[0]
+self.assertEqual(frame["name"], "a.out main.c:6:5 recurse(x=1)")
+
+frame = self.get_stackFrames(format={"parameters": True})[0]
+self.assertEqual(frame["name"], "recurse(x=1)")
+
+frame = self.get_stackFrames(format={"parameterNames": True})[0]
+self.assertEqual(frame["name"], "recurse(x=1)")
+
+frame = self.get_stackFrames(format={

[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow arrays to be dereferenced in C/C++. (PR #135843)

2025-04-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ilia Kuklin (kuilpd)


Changes

Add a function `IsValidDereferenceType` to TypeSystem.
TypeSystemClang now allows arrays to be dereferenced.

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


7 Files Affected:

- (modified) lldb/include/lldb/Symbol/CompilerType.h (+8) 
- (modified) lldb/include/lldb/Symbol/TypeSystem.h (+7) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+17) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h (+7) 
- (modified) lldb/source/Symbol/CompilerType.cpp (+15) 
- (modified) lldb/source/ValueObject/ValueObject.cpp (+31-33) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py
 (+1-1) 


``diff
diff --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index 671b5314c24a2..f02a415afd12c 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -433,6 +433,14 @@ class CompilerType {
 
   CompilerDecl GetStaticFieldWithName(llvm::StringRef name) const;
 
+  llvm::Expected
+  GetDereferencedType(ExecutionContext *exe_ctx, std::string &child_name,
+  uint32_t &child_byte_size, int32_t &child_byte_offset,
+  uint32_t &child_bitfield_bit_size,
+  uint32_t &child_bitfield_bit_offset,
+  bool &child_is_base_class, ValueObject *valobj,
+  uint64_t &language_flags, bool &type_valid) const;
+
   llvm::Expected GetChildCompilerTypeAtIndex(
   ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers,
   bool omit_empty_base_classes, bool ignore_array_bounds,
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 9e9edc09a0846..7c58805342993 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -364,6 +364,13 @@ class TypeSystem : public PluginInterface,
 return CompilerDecl();
   }
 
+  virtual llvm::Expected GetDereferencedType(
+  lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+  std::string &child_name, uint32_t &child_byte_size,
+  int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
+  uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
+  ValueObject *valobj, uint64_t &language_flags, bool &type_valid) = 0;
+
   virtual llvm::Expected GetChildCompilerTypeAtIndex(
   lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
   bool transparent_pointers, bool omit_empty_base_classes,
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 59292f4b24af3..5c1b98509892e 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -6201,6 +6201,23 @@ uint32_t 
TypeSystemClang::GetNumPointeeChildren(clang::QualType type) {
   return 0;
 }
 
+llvm::Expected TypeSystemClang::GetDereferencedType(
+lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+std::string &child_name, uint32_t &child_byte_size,
+int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
+uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
+ValueObject *valobj, uint64_t &language_flags, bool &type_valid) {
+  type_valid = IsPointerOrReferenceType(type, nullptr) ||
+   IsArrayType(type, nullptr, nullptr, nullptr);
+  if (!type_valid)
+return llvm::createStringError("not a pointer, reference or array type");
+  bool child_is_deref_of_parent;
+  return GetChildCompilerTypeAtIndex(
+  type, exe_ctx, 0, false, true, false, child_name, child_byte_size,
+  child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
+  child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
+}
+
 llvm::Expected TypeSystemClang::GetChildCompilerTypeAtIndex(
 lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
 bool transparent_pointers, bool omit_empty_base_classes,
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 442f88a5b79ae..ab74027cc75c4 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -889,6 +889,13 @@ class TypeSystemClang : public TypeSystem {
 
   static uint32_t GetNumPointeeChildren(clang::QualType type);
 
+  llvm::Expected GetDereferencedType(
+  lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+  std::string &child_name, uint32_t &child_byte_size,
+  int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
+  uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
+  ValueObject *valobj, 

[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow arrays to be dereferenced in C/C++. (PR #135843)

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

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


[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

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


@@ -172,8 +175,16 @@ bool lldb_private::formatters::BlockPointerSummaryProvider(
 
   static const ConstString s_FuncPtr_name("__FuncPtr");
 
-  lldb::ValueObjectSP child_sp = synthetic_children->GetChildAtIndex(
-  synthetic_children->GetIndexOfChildWithName(s_FuncPtr_name));
+  auto index_or_err =
+  synthetic_children->GetIndexOfChildWithName(s_FuncPtr_name);
+
+  if (!index_or_err) {
+LLDB_LOG_ERROR(GetLog(LLDBLog::Types), index_or_err.takeError(), "{0}");

Michael137 wrote:

```suggestion
LLDB_LOG_ERROR(GetLog(LLDBLog::DataFormatters), index_or_err.takeError(), 
"{0}");
```

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


[Lldb-commits] [lldb] [lldb-dap] Fix TestDap_attach.py flakiness (PR #137278)

2025-04-24 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Emit diagnostics as "important" output (PR #137280)

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

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

>From c2eab3f2f09fd771cbd8c18f141de1fa7664af49 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 24 Apr 2025 17:59:29 -0700
Subject: [PATCH 1/2] [lldb] Emit diagnostics as "important" output

Handle diagnostics events from the debugger (i.e. asynchronous errors
and warnings) in the lldb-dap event handler and emit them as "important"
output.
---
 .../test/tools/lldb-dap/lldbdap_testcase.py   | 13 --
 .../tools/lldb-dap/console/TestDAP_console.py | 17 +
 .../API/tools/lldb-dap/console/minidump.yaml  | 24 +++
 lldb/tools/lldb-dap/DAP.cpp   |  3 +++
 lldb/tools/lldb-dap/DAP.h |  2 +-
 .../Handler/InitializeRequestHandler.cpp  | 13 ++
 lldb/tools/lldb-dap/LLDBUtils.cpp | 14 +++
 lldb/tools/lldb-dap/LLDBUtils.h   |  3 +++
 8 files changed, 86 insertions(+), 3 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/console/minidump.yaml

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index b5b55b336d535..5f90830a34059 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -217,16 +217,25 @@ def get_stdout(self, timeout=0.0):
 def get_console(self, timeout=0.0):
 return self.dap_server.get_output("console", timeout=timeout)
 
+def get_important(self, timeout=0.0):
+return self.dap_server.get_output("important", timeout=timeout)
+
+def collect_stdout(self, timeout_secs, pattern=None):
+return self.dap_server.collect_output(
+"stdout", timeout_secs=timeout_secs, pattern=pattern
+)
+
 def collect_console(self, timeout_secs, pattern=None):
 return self.dap_server.collect_output(
 "console", timeout_secs=timeout_secs, pattern=pattern
 )
 
-def collect_stdout(self, timeout_secs, pattern=None):
+def collect_important(self, timeout_secs, pattern=None):
 return self.dap_server.collect_output(
-"stdout", timeout_secs=timeout_secs, pattern=pattern
+"important", timeout_secs=timeout_secs, pattern=pattern
 )
 
+
 def get_local_as_int(self, name, threadId=None):
 value = self.dap_server.get_local_variable_value(name, 
threadId=threadId)
 # 'value' may have the variable value and summary.
diff --git a/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py 
b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
index 8bbab8d0991de..b07c4f871d73b 100644
--- a/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
+++ b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
@@ -164,3 +164,20 @@ def test_exit_status_message_ok(self):
 console_output,
 "Exit status does not contain message 'exited with status'",
 )
+
+def test_diagnositcs(self):
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+
+core = self.getBuildArtifact("minidump.core")
+self.yaml2obj("minidump.yaml", core)
+self.dap_server.request_evaluate(
+f"target create --core  {core}", context="repl"
+)
+
+output = self.get_important()
+self.assertIn(
+"warning: unable to retrieve process ID from minidump file",
+output,
+"diagnostic found in important output",
+)
diff --git a/lldb/test/API/tools/lldb-dap/console/minidump.yaml 
b/lldb/test/API/tools/lldb-dap/console/minidump.yaml
new file mode 100644
index 0..42f0a23702950
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/console/minidump.yaml
@@ -0,0 +1,24 @@
+--- !minidump
+Streams:
+  - Type:ThreadList
+Threads:
+  - Thread Id:   0x3E81
+Context: 
0B001000330006020100100010A234EBFC7F10A234EBFC7FF09C34EBFC7FC0A91ABCE97FA0163FBCE97F4602921C400030A434EBFC7FC61D40007F03801F0000FF002525252525252525252525252525252500F

[Lldb-commits] [lldb] [lldb-dap] Fix TestDap_attach.py flakiness (PR #137278)

2025-04-24 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Fix TestDap_attach.py flakiness (PR #137278)

2025-04-24 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Fix TestDap_attach.py flakiness (PR #137278)

2025-04-24 Thread via lldb-commits


@@ -612,7 +612,16 @@ def request_attach(
 if gdbRemoteHostname is not None:
 args_dict["gdb-remote-hostname"] = gdbRemoteHostname
 command_dict = {"command": "attach", "type": "request", "arguments": 
args_dict}
-return self.send_recv(command_dict)
+response = self.send_recv(command_dict)
+
+if response["success"]:
+# Wait for a 'process' and 'initialized' event in any order
+first_event = self.wait_for_event(filter=["process", 
"initialized"])
+second_event = (
+"initialized" if first_event["event"] == "process" else 
"process"
+)
+self.wait_for_event(filter=[second_event])

jeffreytan81 wrote:

Can you make this into a helper method to avoid duplication code? 

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


[Lldb-commits] [lldb] [lldb] Add InstructionARM64 to lldb-server (PR #137267)

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

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

After reading 
https://github.com/llvm/llvm-project/issues/129543#issuecomment-2828385373 I 
get the feeling this is just speculative. So yea, there is a reason to not add 
InstructionARM64 -- it's not needed/used.

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


[Lldb-commits] [lldb] [lldb-dap] Fix TestDap_attach.py flakiness (PR #137278)

2025-04-24 Thread via lldb-commits

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

>From b5e0b6e31a6bd2145fce2f87200d1220627df9a6 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Thu, 24 Apr 2025 13:30:26 -0700
Subject: [PATCH 1/3] [lldb-dap] Fix TestDap_attach.py flakiness

Looks like these 2 test cases should be re-enabled in 
https://github.com/llvm/llvm-project/commit/0b8dfb5762fdc350c5071c9eeffd4f7e4d495e98
But only the comments got removed. The skip statement survived the change.
---
 .../Python/lldbsuite/test/tools/lldb-dap/dap_server.py| 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

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 dadf6b1f8774c..20f5286da3203 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
@@ -612,7 +612,13 @@ def request_attach(
 if gdbRemoteHostname is not None:
 args_dict["gdb-remote-hostname"] = gdbRemoteHostname
 command_dict = {"command": "attach", "type": "request", "arguments": 
args_dict}
-return self.send_recv(command_dict)
+response = self.send_recv(command_dict)
+
+if response["success"]:
+# Wait for a 'process' and 'initialized' event in any order
+self.wait_for_event(filter=["process", "initialized"])
+self.wait_for_event(filter=["process", "initialized"])
+return response
 
 def request_breakpointLocations(
 self, file_path, line, end_line=None, column=None, end_column=None

>From 2c5ff68fb979e9030dd4dd5b530179fe0ca9f00e Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Thu, 24 Apr 2025 18:43:18 -0700
Subject: [PATCH 2/3] [lldb-dap] Re-enable test cases on Darwin

Summary:
Looks like some test cases should be re-enabled in 
https://github.com/llvm/llvm-project/commit/0b8dfb5762fdc350c5071c9eeffd4f7e4d495e98
But only comments was removed. The skip statements survived the change.

Test Plan:
./bin/llvm-lit -va 
/Users/wanyi/llvm-upstream/llvm-project/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
All tests passed locally on my mac
---
 lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py 
b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
index b9fbf2c8d14f9..dcdfada2ff4c2 100644
--- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
+++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
@@ -93,7 +93,6 @@ def cleanup():
 self.set_and_hit_breakpoint(continueToExit=True)
 
 @skipUnlessDarwin
-@skipIfDarwin
 @skipIfNetBSD  # Hangs on NetBSD as well
 def test_by_name_waitFor(self):
 """
@@ -114,7 +113,6 @@ def test_by_name_waitFor(self):
 self.attach(program=program, waitFor=True)
 self.set_and_hit_breakpoint(continueToExit=True)
 
-@skipIfDarwin
 @skipIfNetBSD  # Hangs on NetBSD as well
 def test_commands(self):
 """
@@ -201,7 +199,6 @@ def test_commands(self):
 self.verify_commands("exitCommands", output, exitCommands)
 self.verify_commands("terminateCommands", output, terminateCommands)
 
-@skipIfDarwin
 @skipIfNetBSD  # Hangs on NetBSD as well
 @skipIf(
 archs=["arm", "aarch64"]

>From b87f1fe90fe2719797a9d0cbf57b21f547705cb4 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Thu, 24 Apr 2025 19:28:17 -0700
Subject: [PATCH 3/3] [lldb-dap] Improve the process & initialized event check

---
 .../lldbsuite/test/tools/lldb-dap/dap_server.py| 14 ++
 1 file changed, 10 insertions(+), 4 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 20f5286da3203..65069bd9df643 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
@@ -616,8 +616,11 @@ def request_attach(
 
 if response["success"]:
 # Wait for a 'process' and 'initialized' event in any order
-self.wait_for_event(filter=["process", "initialized"])
-self.wait_for_event(filter=["process", "initialized"])
+first_event = self.wait_for_event(filter=["process", 
"initialized"])
+second_event = (
+"initialized" if first_event["event"] == "process" else 
"process"
+)
+self.wait_for_event(filter=[second_event])
 return response
 
 def request_breakpointLocations(
@@ -872,8 +875,11 @@ def request_launch(
 
 if response["success"]:
 # Wait for a 'process' and 'initialized' event in any order
-self.wait_for_event(filter=["process", "initialized"])
-self.wait_for_event(filter=["process", "initialized"])
+

[Lldb-commits] [lldb] [lldb] Expose language plugin commands based based on language of current frame (PR #136766)

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

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/136766

>From daf394bf76b5fd627f77aee6e451e7d706d26916 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Tue, 22 Apr 2025 13:58:25 -0700
Subject: [PATCH 1/6] [lldb] Expose language plugin commands based based on
 language of current frame

---
 .../lldb/Interpreter/CommandInterpreter.h |  6 ++
 .../source/Interpreter/CommandInterpreter.cpp | 55 ++-
 2 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 724d88d65f6ac..26e0767951e7f 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -730,6 +730,12 @@ class CommandInterpreter : public Broadcaster,
   bool EchoCommandNonInteractive(llvm::StringRef line,
  const Flags &io_handler_flags) const;
 
+  /// Return the language specific command object for the current frame.
+  ///
+  /// For example, when stopped on a C++ frame, this returns the command object
+  /// for "language cplusplus" (`CommandObjectMultiwordItaniumABI`).
+  lldb::CommandObjectSP GetFrameLanguageCommand() const;
+
   // A very simple state machine which models the command handling transitions
   enum class CommandHandlingState {
 eIdle,
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index eb4741feb0aa5..2ff02ae5086b4 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1018,6 +1018,26 @@ CommandInterpreter::VerifyUserMultiwordCmdPath(Args 
&path, bool leaf_is_command,
   return cur_as_multi;
 }
 
+CommandObjectSP CommandInterpreter::GetFrameLanguageCommand() const {
+  if (auto frame_sp = GetExecutionContext().GetFrameSP()) {
+auto frame_language = Language::GetPrimaryLanguage(
+frame_sp->GuessLanguage().AsLanguageType());
+
+auto it = m_command_dict.find("language");
+if (it != m_command_dict.end()) {
+  // The root "language" command.
+  CommandObjectSP language_cmd_sp = it->second;
+
+  if (auto *plugin = Language::FindPlugin(frame_language)) {
+// "cplusplus", "objc", etc.
+auto lang_name = plugin->GetPluginName();
+return language_cmd_sp->GetSubcommandSPExact(lang_name);
+  }
+}
+  }
+  return {};
+}
+
 CommandObjectSP
 CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, bool include_aliases,
  bool exact, StringList *matches,
@@ -1050,11 +1070,20 @@ CommandInterpreter::GetCommandSP(llvm::StringRef 
cmd_str, bool include_aliases,
   command_sp = pos->second;
   }
 
+  // The `language` subcommand ("language objc", "language cplusplus", etc).
+  CommandObjectMultiword *lang_subcmd = nullptr;
+  if (!command_sp) {
+if (auto subcmd_sp = GetFrameLanguageCommand()) {
+  lang_subcmd = subcmd_sp->GetAsMultiwordCommand();
+  command_sp = subcmd_sp->GetSubcommandSPExact(cmd_str);
+}
+  }
+
   if (!exact && !command_sp) {
 // We will only get into here if we didn't find any exact matches.
 
 CommandObjectSP user_match_sp, user_mw_match_sp, alias_match_sp,
-real_match_sp;
+real_match_sp, lang_match_sp;
 
 StringList local_matches;
 if (matches == nullptr)
@@ -1064,6 +1093,7 @@ CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, 
bool include_aliases,
 unsigned int num_alias_matches = 0;
 unsigned int num_user_matches = 0;
 unsigned int num_user_mw_matches = 0;
+unsigned int num_lang_matches = 0;
 
 // Look through the command dictionaries one by one, and if we get only one
 // match from any of them in toto, then return that, otherwise return an
@@ -1121,11 +1151,28 @@ CommandInterpreter::GetCommandSP(llvm::StringRef 
cmd_str, bool include_aliases,
 user_mw_match_sp = pos->second;
 }
 
+if (lang_subcmd) {
+  num_lang_matches =
+  AddNamesMatchingPartialString(lang_subcmd->GetSubcommandDictionary(),
+cmd_str, *matches, descriptions);
+}
+
+if (num_lang_matches == 1) {
+  cmd.assign(matches->GetStringAtIndex(num_cmd_matches + num_alias_matches 
+
+   num_user_matches +
+   num_user_mw_matches));
+
+  auto &lang_dict = lang_subcmd->GetSubcommandDictionary();
+  auto pos = lang_dict.find(cmd);
+  if (pos != lang_dict.end())
+lang_match_sp = pos->second;
+}
+
 // If we got exactly one match, return that, otherwise return the match
 // list.
 
 if (num_user_matches + num_user_mw_matches + num_cmd_matches +
-num_alias_matches ==
+num_alias_matches + num_lang_matches ==
 1) {
   if (num_cmd_matches)
 return real_match_sp;
@@ -1133,8 +1180,10 @

[Lldb-commits] [lldb] [lldb] Support riscv32 corefiles (PR #115408)

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


@@ -0,0 +1,76 @@
+//===-- RegisterInfoPOSIX_riscv32.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_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOPOSIX_RISCV32_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOPOSIX_RISCV32_H
+
+#include "RegisterInfoAndSetInterface.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Utility/Flags.h"
+#include "lldb/lldb-private.h"
+
+#include 
+
+class RegisterInfoPOSIX_riscv32
+: public lldb_private::RegisterInfoAndSetInterface {
+public:
+  static const lldb_private::RegisterInfo *
+  GetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch);
+  static uint32_t
+  GetRegisterInfoCount(const lldb_private::ArchSpec &target_arch);
+
+public:
+  // RISC-V32 register set mask value
+  enum {
+eRegsetMaskDefault = 0,
+eRegsetMaskFP = 1,
+eRegsetMaskAll = -1,
+  };
+
+  struct GPR {
+// note: gpr[0] is pc, not x0

jasonmolenda wrote:

Yes, x0 aka zero is constant value 0, so they're using that slot of the GPR 
register file to store the PC internally.

The ReadRegister (and WriteRegister if it was implemented) method needs to 
special case accesses to x0 to return a UInt32(0) because it's not stored in 
the GPRs.  I don't see that part handled by this class (or by 
`RegisterInfoPOSIX_riscv64` / `RegisterInfos_riscv64.h` which it's inspired by).

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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ebuka Ezike via lldb-commits


@@ -0,0 +1,8 @@
+#include 

da-viper wrote:

don't need the header
```suggestion
```

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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ebuka Ezike via lldb-commits

da-viper wrote:

LGTM 

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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ebuka Ezike via lldb-commits

https://github.com/da-viper approved this pull request.


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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen updated 
https://github.com/llvm/llvm-project/pull/136494

>From 05d605e3add0461b12ddfbb24349e20be4259060 Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 20 Apr 2025 17:07:09 +0200
Subject: [PATCH 1/8] fallback to assembly when source code is not available

---
 lldb/tools/lldb-dap/JSONUtils.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index 33f10c93d2ada..1a44df7740639 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -750,9 +750,10 @@ llvm::json::Value CreateStackFrame(lldb::SBFrame &frame,
   EmplaceSafeString(object, "name", frame_name);
 
   auto line_entry = frame.GetLineEntry();
+  auto file_spec = line_entry.GetFileSpec();
   // A line entry of 0 indicates the line is compiler generated i.e. no source
   // file is associated with the frame.
-  if (line_entry.GetFileSpec().IsValid() &&
+  if (file_spec.IsValid() && file_spec.Exists() &&
   (line_entry.GetLine() != 0 ||
line_entry.GetLine() != LLDB_INVALID_LINE_NUMBER)) {
 object.try_emplace("source", CreateSource(line_entry));

>From 589c70284a97092d76d626cb1ed68c36e8191ee0 Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 20 Apr 2025 21:03:02 +0200
Subject: [PATCH 2/8] fix TestDAP_coreFile.py with source maps

---
 .../API/tools/lldb-dap/coreFile/TestDAP_coreFile.py| 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py 
b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
index 1896acea15a99..ce54133a61f3e 100644
--- a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
+++ b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
@@ -19,7 +19,9 @@ def test_core_file(self):
 core_file = os.path.join(current_dir, "linux-x86_64.core")
 
 self.create_debug_adapter()
-self.attach(exe_file, coreFile=core_file)
+
+source_map = [["/home/labath/test", current_dir]]
+self.attach(exe_file, coreFile=core_file, sourceMap=source_map)
 
 expected_frames = [
 {
@@ -27,7 +29,7 @@ def test_core_file(self):
 "id": 524288,
 "line": 4,
 "name": "bar",
-"source": {"name": "main.c", "path": 
"/home/labath/test/main.c"},
+"source": {"name": "main.c", "path": os.path.join(current_dir, 
"main.c")},
 "instructionPointerReference": "0x40011C",
 },
 {
@@ -35,7 +37,7 @@ def test_core_file(self):
 "id": 524289,
 "line": 10,
 "name": "foo",
-"source": {"name": "main.c", "path": 
"/home/labath/test/main.c"},
+"source": {"name": "main.c", "path": os.path.join(current_dir, 
"main.c")},
 "instructionPointerReference": "0x400142",
 },
 {
@@ -43,7 +45,7 @@ def test_core_file(self):
 "id": 524290,
 "line": 16,
 "name": "_start",
-"source": {"name": "main.c", "path": 
"/home/labath/test/main.c"},
+"source": {"name": "main.c", "path": os.path.join(current_dir, 
"main.c")},
 "instructionPointerReference": "0x40015F",
 },
 ]

>From 51167c8a5f2bc61105934bff66f353ce36aa6710 Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 20 Apr 2025 21:04:46 +0200
Subject: [PATCH 3/8] use stop-disassembly-display setting to determine when to
 show disassembly

---
 .../lldb-dap/coreFile/TestDAP_coreFile.py |  10 +-
 .../stackTraceDisassemblyDisplay/Makefile |   3 +
 .../TestDAP_stackTraceDisassemblyDisplay.py   | 195 ++
 .../stackTraceDisassemblyDisplay/main.c   |  10 +
 lldb/tools/lldb-dap/DAP.h |   4 +
 .../lldb-dap/Handler/AttachRequestHandler.cpp |   1 +
 .../lldb-dap/Handler/LaunchRequestHandler.cpp |   1 +
 .../tools/lldb-dap/Handler/RequestHandler.cpp |   4 +
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |   3 +
 .../Handler/StackTraceRequestHandler.cpp  |   3 +-
 lldb/tools/lldb-dap/JSONUtils.cpp |  34 ++-
 lldb/tools/lldb-dap/JSONUtils.h   |  21 +-
 lldb/tools/lldb-dap/LLDBUtils.cpp |  19 ++
 lldb/tools/lldb-dap/LLDBUtils.h   |   9 +
 14 files changed, 300 insertions(+), 17 deletions(-)
 create mode 100644 
lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py
 create mode 100644 
lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/main.c

diff --git a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py 
b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
index ce54133a61f3e..1896acea15a99 100644
--- a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP

[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-24 Thread Ebuka Ezike via lldb-commits

https://github.com/da-viper approved this pull request.


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


[Lldb-commits] [lldb] [lldb][cmake] Add clang resource dir to LLDB shell tests config (PR #136761)

2025-04-24 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Ptrace seize dead process (PR #137041)

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

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/137041

>From 94248d8526064859c2f3eda0ac82d61f299100b2 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Tue, 22 Apr 2025 16:35:00 -0700
Subject: [PATCH 1/2] Create proc status reader

---
 .../Plugins/Process/Utility/CMakeLists.txt|  1 +
 .../Process/Utility/LinuxProcStatus.cpp   | 42 +++
 .../Plugins/Process/Utility/LinuxProcStatus.h | 22 ++
 3 files changed, 65 insertions(+)
 create mode 100644 lldb/source/Plugins/Process/Utility/LinuxProcStatus.cpp
 create mode 100644 lldb/source/Plugins/Process/Utility/LinuxProcStatus.h

diff --git a/lldb/source/Plugins/Process/Utility/CMakeLists.txt 
b/lldb/source/Plugins/Process/Utility/CMakeLists.txt
index d29605fddd5cb..8db3a6879b618 100644
--- a/lldb/source/Plugins/Process/Utility/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/Utility/CMakeLists.txt
@@ -6,6 +6,7 @@ add_lldb_library(lldbPluginProcessUtility
   HistoryUnwind.cpp
   InferiorCallPOSIX.cpp
   LinuxProcMaps.cpp
+  LinuxProcStatus.cpp
   LinuxSignals.cpp
   MemoryTagManagerAArch64MTE.cpp
   NativeProcessSoftwareSingleStep.cpp
diff --git a/lldb/source/Plugins/Process/Utility/LinuxProcStatus.cpp 
b/lldb/source/Plugins/Process/Utility/LinuxProcStatus.cpp
new file mode 100644
index 0..75575d62210f0
--- /dev/null
+++ b/lldb/source/Plugins/Process/Utility/LinuxProcStatus.cpp
@@ -0,0 +1,42 @@
+//===-- LinuxProcMaps.cpp ---*- 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
+//
+//===--===//
+
+#include "LinuxProcStatus.h"
+#include 
+#include 
+#include 
+
+static std::vector SplitLines(llvm::StringRef proc_status) {
+  std::istringstream inputstream(proc_status.str());
+  std::vector lines;
+  std::string line;
+  while (std::getline(inputstream, line)) {
+lines.push_back(line);
+  }
+  return lines;
+}
+
+lldb_private::StructuredData::Dictionary
+ParseProcStatus(llvm::StringRef proc_status) {
+  std::vector lines = SplitLines(proc_status);
+  lldb_private::StructuredData::Dictionary proc_status_data;
+  for (auto &str : lines) {
+// proc/pid/status is a delineated by a colon, so we split all the lines
+// and then return a structureddata of each name : value. We keep these
+// all as text, and let the caller sort the type they want them as.
+size_t colonPos = str.find(':');
+if (colonPos == std::string::npos) {
+  continue;
+}
+std::string name = str.substr(0, colonPos);
+std::string value = str.substr(colonPos + 1);
+proc_status_data.AddStringItem(name, value);
+  }
+
+  return proc_status_data;
+}
diff --git a/lldb/source/Plugins/Process/Utility/LinuxProcStatus.h 
b/lldb/source/Plugins/Process/Utility/LinuxProcStatus.h
new file mode 100644
index 0..28e01ac9ff74e
--- /dev/null
+++ b/lldb/source/Plugins/Process/Utility/LinuxProcStatus.h
@@ -0,0 +1,22 @@
+//===-- LinuxProcStatus.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_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPROCSTATUS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPROCSTATUS_H
+
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+StructuredData::Dictionary ParseProcStatus(llvm::StringRef proc_status);
+
+} // namespace lldb_private
+
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPROCSTATUS_H

>From 3b10fcdbbaf80bc1d21e9e6757f7cf5056ad54a0 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Wed, 23 Apr 2025 11:31:01 -0700
Subject: [PATCH 2/2] Fix tabs, newlines, and spaces getting in the structured
 data

---
 .../Process/Linux/NativeProcessLinux.cpp  | 80 ---
 .../Process/Utility/LinuxProcStatus.cpp   | 12 ++-
 2 files changed, 78 insertions(+), 14 deletions(-)

diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp 
b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index 7f2aba0e4eb2c..f052931e1d377 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -23,6 +23,7 @@
 #include "NativeThreadLinux.h"
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
 #include "Plugins/Process/Utility/LinuxProcMaps.h"
+#include "Plugins/Process/Utility/LinuxProcStatus.h"
 #include "Procfs.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Host/Host.h"
@@ -443,10 +444,29 @@ Native

[Lldb-commits] [lldb] [lldb-dap] Fix TestDap_attach.py flakiness (PR #137278)

2025-04-24 Thread via lldb-commits

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

>From b5e0b6e31a6bd2145fce2f87200d1220627df9a6 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Thu, 24 Apr 2025 13:30:26 -0700
Subject: [PATCH 1/2] [lldb-dap] Fix TestDap_attach.py flakiness

Looks like these 2 test cases should be re-enabled in 
https://github.com/llvm/llvm-project/commit/0b8dfb5762fdc350c5071c9eeffd4f7e4d495e98
But only the comments got removed. The skip statement survived the change.
---
 .../Python/lldbsuite/test/tools/lldb-dap/dap_server.py| 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

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 dadf6b1f8774c..20f5286da3203 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
@@ -612,7 +612,13 @@ def request_attach(
 if gdbRemoteHostname is not None:
 args_dict["gdb-remote-hostname"] = gdbRemoteHostname
 command_dict = {"command": "attach", "type": "request", "arguments": 
args_dict}
-return self.send_recv(command_dict)
+response = self.send_recv(command_dict)
+
+if response["success"]:
+# Wait for a 'process' and 'initialized' event in any order
+self.wait_for_event(filter=["process", "initialized"])
+self.wait_for_event(filter=["process", "initialized"])
+return response
 
 def request_breakpointLocations(
 self, file_path, line, end_line=None, column=None, end_column=None

>From 2c5ff68fb979e9030dd4dd5b530179fe0ca9f00e Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Thu, 24 Apr 2025 18:43:18 -0700
Subject: [PATCH 2/2] [lldb-dap] Re-enable test cases on Darwin

Summary:
Looks like some test cases should be re-enabled in 
https://github.com/llvm/llvm-project/commit/0b8dfb5762fdc350c5071c9eeffd4f7e4d495e98
But only comments was removed. The skip statements survived the change.

Test Plan:
./bin/llvm-lit -va 
/Users/wanyi/llvm-upstream/llvm-project/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
All tests passed locally on my mac
---
 lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py 
b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
index b9fbf2c8d14f9..dcdfada2ff4c2 100644
--- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
+++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
@@ -93,7 +93,6 @@ def cleanup():
 self.set_and_hit_breakpoint(continueToExit=True)
 
 @skipUnlessDarwin
-@skipIfDarwin
 @skipIfNetBSD  # Hangs on NetBSD as well
 def test_by_name_waitFor(self):
 """
@@ -114,7 +113,6 @@ def test_by_name_waitFor(self):
 self.attach(program=program, waitFor=True)
 self.set_and_hit_breakpoint(continueToExit=True)
 
-@skipIfDarwin
 @skipIfNetBSD  # Hangs on NetBSD as well
 def test_commands(self):
 """
@@ -201,7 +199,6 @@ def test_commands(self):
 self.verify_commands("exitCommands", output, exitCommands)
 self.verify_commands("terminateCommands", output, terminateCommands)
 
-@skipIfDarwin
 @skipIfNetBSD  # Hangs on NetBSD as well
 @skipIf(
 archs=["arm", "aarch64"]

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


[Lldb-commits] [lldb] [lldb-dap] Fix TestDap_attach.py flakiness (PR #137278)

2025-04-24 Thread via lldb-commits


@@ -612,7 +612,16 @@ def request_attach(
 if gdbRemoteHostname is not None:
 args_dict["gdb-remote-hostname"] = gdbRemoteHostname
 command_dict = {"command": "attach", "type": "request", "arguments": 
args_dict}
-return self.send_recv(command_dict)
+response = self.send_recv(command_dict)
+
+if response["success"]:
+# Wait for a 'process' and 'initialized' event in any order
+first_event = self.wait_for_event(filter=["process", 
"initialized"])
+second_event = (
+"initialized" if first_event["event"] == "process" else 
"process"
+)
+self.wait_for_event(filter=[second_event])

kusmour wrote:

Yes! Updated

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


[Lldb-commits] [lldb] [lldb-dap] Fix TestDap_attach.py flakiness (PR #137278)

2025-04-24 Thread via lldb-commits

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

>From b5e0b6e31a6bd2145fce2f87200d1220627df9a6 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Thu, 24 Apr 2025 13:30:26 -0700
Subject: [PATCH 1/3] [lldb-dap] Fix TestDap_attach.py flakiness

Looks like these 2 test cases should be re-enabled in 
https://github.com/llvm/llvm-project/commit/0b8dfb5762fdc350c5071c9eeffd4f7e4d495e98
But only the comments got removed. The skip statement survived the change.
---
 .../Python/lldbsuite/test/tools/lldb-dap/dap_server.py| 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

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 dadf6b1f8774c..20f5286da3203 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
@@ -612,7 +612,13 @@ def request_attach(
 if gdbRemoteHostname is not None:
 args_dict["gdb-remote-hostname"] = gdbRemoteHostname
 command_dict = {"command": "attach", "type": "request", "arguments": 
args_dict}
-return self.send_recv(command_dict)
+response = self.send_recv(command_dict)
+
+if response["success"]:
+# Wait for a 'process' and 'initialized' event in any order
+self.wait_for_event(filter=["process", "initialized"])
+self.wait_for_event(filter=["process", "initialized"])
+return response
 
 def request_breakpointLocations(
 self, file_path, line, end_line=None, column=None, end_column=None

>From 2c5ff68fb979e9030dd4dd5b530179fe0ca9f00e Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Thu, 24 Apr 2025 18:43:18 -0700
Subject: [PATCH 2/3] [lldb-dap] Re-enable test cases on Darwin

Summary:
Looks like some test cases should be re-enabled in 
https://github.com/llvm/llvm-project/commit/0b8dfb5762fdc350c5071c9eeffd4f7e4d495e98
But only comments was removed. The skip statements survived the change.

Test Plan:
./bin/llvm-lit -va 
/Users/wanyi/llvm-upstream/llvm-project/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
All tests passed locally on my mac
---
 lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py 
b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
index b9fbf2c8d14f9..dcdfada2ff4c2 100644
--- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
+++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
@@ -93,7 +93,6 @@ def cleanup():
 self.set_and_hit_breakpoint(continueToExit=True)
 
 @skipUnlessDarwin
-@skipIfDarwin
 @skipIfNetBSD  # Hangs on NetBSD as well
 def test_by_name_waitFor(self):
 """
@@ -114,7 +113,6 @@ def test_by_name_waitFor(self):
 self.attach(program=program, waitFor=True)
 self.set_and_hit_breakpoint(continueToExit=True)
 
-@skipIfDarwin
 @skipIfNetBSD  # Hangs on NetBSD as well
 def test_commands(self):
 """
@@ -201,7 +199,6 @@ def test_commands(self):
 self.verify_commands("exitCommands", output, exitCommands)
 self.verify_commands("terminateCommands", output, terminateCommands)
 
-@skipIfDarwin
 @skipIfNetBSD  # Hangs on NetBSD as well
 @skipIf(
 archs=["arm", "aarch64"]

>From 0e6d4192962211d472cdbaff9e4f3b87c181f455 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Thu, 24 Apr 2025 19:28:17 -0700
Subject: [PATCH 3/3] [lldb-dap] Improve the process & initialized event check

---
 .../lldbsuite/test/tools/lldb-dap/dap_server.py| 14 --
 1 file changed, 8 insertions(+), 6 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 20f5286da3203..017abd89c36da 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
@@ -374,6 +374,12 @@ def wait_for_event(self, filter=None, timeout=None):
 )
 return None
 
+def wait_for_process_and_initialized(self, timeout=None):
+# Wait for a 'process' and 'initialized' event in any order
+first_event = self.wait_for_event(filter=["process", "initialized"])
+second_event = "initialized" if first_event["event"] == "process" else 
"process"
+self.wait_for_event(filter=[second_event])
+
 def wait_for_stopped(self, timeout=None):
 stopped_events = []
 stopped_event = self.wait_for_event(
@@ -615,9 +621,7 @@ def request_attach(
 response = self.send_recv(command_dict)
 
 if response["success"]:
-# Wait for a 'process' and 'initialized' event in any order
-self.wait_for_event(filter=["process", "initialized"])
-self.wait_for_event(filter=["process",

[Lldb-commits] [lldb] [lldb] Fix crash after second run when set a previous watchpoint. (PR #136682)

2025-04-24 Thread via lldb-commits

hapee wrote:

> This patch may be all that's necessary, I haven't reproduced the failure 
> myself. We'd really like to have a test for this to ensure it doesn't 
> regress, I recently added a watchpoint API test to the testsuite as 
> `lldb/test/API/functionalities/watchpoint/consecutive-watchpoints`, the only 
> difference is that after you've set the watchpoint once, you'd want to 
> `process.Kill()` and then `process = target.LaunchSimple(None, None, 
> os.getcwd())` or something, to execute back to the breakpoint.

Hi @jasonmolenda , I have added a test for the patch in 
`llvm-project/lldb/test/Shell/Watchpoint/ReuseWatchpointAfterReExecProcess.test`,
 and I have tested it in `ARM/AArch64` native environments. Please review my 
code again.

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


[Lldb-commits] [lldb] 5717c5f - [lldb] Re-enable TestDAP_stackTrace on Windows

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

Author: Jonas Devlieghere
Date: 2025-04-24T21:45:52-07:00
New Revision: 5717c5f385d3b8f5b395c3013aaba9929a618aa3

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

LOG: [lldb] Re-enable TestDAP_stackTrace on Windows

It's unclear why this test has been disabled on Windows. Remove the
unistd.h header and try re-enabling it.

Added: 


Modified: 
lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
lldb/test/API/tools/lldb-dap/stackTrace/main.c

Removed: 




diff  --git a/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py 
b/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
index 3a11df7505994..4e2a76cf76980 100644
--- a/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
+++ b/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
@@ -56,7 +56,6 @@ def verify_stackFrame(self, frame_idx, stackFrame):
 "frame #%i line %i == %i" % (frame_idx, frame_line, expected_line),
 )
 
-@skipIfWindows
 def test_stackTrace(self):
 """
 Tests the 'stackTrace' packet and all its variants.
@@ -202,7 +201,6 @@ def test_stackTrace(self):
 0, len(stackFrames), "verify zero frames with startFrame out of 
bounds"
 )
 
-@skipIfWindows
 def test_functionNameWithArgs(self):
 """
 Test that the stack frame without a function name is given its pc in 
the response.
@@ -217,7 +215,6 @@ def test_functionNameWithArgs(self):
 frame = self.get_stackFrames()[0]
 self.assertEqual(frame["name"], "recurse(x=1)")
 
-@skipIfWindows
 def test_StackFrameFormat(self):
 """
 Test the StackFrameFormat.
@@ -239,7 +236,7 @@ def test_StackFrameFormat(self):
 self.assertEqual(frame["name"], "recurse(x=1)")
 
 frame = self.get_stackFrames(format={"parameters": False, "line": 
True})[0]
-self.assertEqual(frame["name"], "main.c:6:5 recurse")
+self.assertEqual(frame["name"], "main.c:5:5 recurse")
 
 frame = self.get_stackFrames(format={"parameters": False, "module": 
True})[0]
 self.assertEqual(frame["name"], "a.out recurse")

diff  --git a/lldb/test/API/tools/lldb-dap/stackTrace/main.c 
b/lldb/test/API/tools/lldb-dap/stackTrace/main.c
index 25d81be08e778..1b3d6bb865564 100644
--- a/lldb/test/API/tools/lldb-dap/stackTrace/main.c
+++ b/lldb/test/API/tools/lldb-dap/stackTrace/main.c
@@ -1,5 +1,4 @@
 #include 
-#include 
 
 int recurse(int x) {
   if (x <= 1)



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


  1   2   >