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

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

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

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

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

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

[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang][modules] Lazily load by name lookups in module maps (PR #132853)

2025-04-15 Thread Michael Spencer via lldb-commits

https://github.com/Bigcheese updated 
https://github.com/llvm/llvm-project/pull/132853

>From 93fa13d9efabf72032966306473689dfac221857 Mon Sep 17 00:00:00 2001
From: Michael Spencer 
Date: Wed, 29 Jan 2025 12:49:29 -0800
Subject: [PATCH] [clang][modules] Lazily load by name lookups in module maps

Instead of eagerly populating the `clang::ModuleMap` when looking up
a module by name, this patch changes `HeaderSearch` to only load the
modules that are actually used.

This introduces `ModuleMap::findOrLoadModule` which will load modules
from parsed but not loaded module maps. This cannot be used anywhere
that the module loading code calls into as it can create infinite
recursion.

This currently just reparses module maps when looking up a module by
header. This is fine as redeclarations are allowed from the same file,
but future patches will also make looking up a module by header lazy.

This patch changes the shadow.m test to use explicitly built modules
and `#import`. This test and the shadow feature are very brittle and
do not work in general. The test relied on pcm files being left behind
by prior failing clang invocations that were then reused by the last
invocation. If you clean the cache then the last invocation will
always fail. This is because the input module map and the
`-fmodule-map-file=` module map are parsed in the same module scope,
and `-fmodule-map-file=` is forwarded to implicit module builds. That
means you are guaranteed to hit a module redeclaration error if the TU
actually imports the module it is trying to shadow.

This patch changes when we load A2's module map to after the `A`
module has been loaded, which sets the `IsFromModuleFile` bit on `A`.
This means that A2's `A` is skipped entirely instead of creating a
shadow module, and we get textual inclusion. It is possible to
construct a case where this would happen before this patch too.

An upcoming patch in this series will rework shadowing to work in the
general case, but that's only possible once header -> module lookup is
lazy too.
---
 .../modularize/ModularizeUtilities.cpp|   2 +-
 clang/include/clang/Basic/DiagnosticGroups.td |   1 +
 .../include/clang/Basic/DiagnosticLexKinds.td |   6 +
 clang/include/clang/Lex/HeaderSearch.h|  70 --
 clang/include/clang/Lex/ModuleMap.h   |  29 ++-
 clang/include/clang/Lex/ModuleMapFile.h   |   9 +
 clang/lib/Frontend/CompilerInstance.cpp   |   4 +-
 clang/lib/Frontend/FrontendAction.cpp |   8 +-
 clang/lib/Lex/HeaderSearch.cpp| 234 --
 clang/lib/Lex/ModuleMap.cpp   | 162 ++--
 clang/lib/Lex/ModuleMapFile.cpp   |   3 +
 clang/lib/Sema/SemaModule.cpp |   2 +-
 clang/test/Modules/Inputs/shadow/A1/A1.h  |   0
 .../Modules/Inputs/shadow/A1/module.modulemap |   4 +-
 clang/test/Modules/Inputs/shadow/A2/A2.h  |   0
 .../Modules/Inputs/shadow/A2/module.modulemap |   4 +-
 clang/test/Modules/lazy-by-name-lookup.c  |  31 +++
 clang/test/Modules/shadow.m   |  11 +-
 .../Clang/ClangModulesDeclVendor.cpp  |   2 +-
 19 files changed, 446 insertions(+), 136 deletions(-)
 create mode 100644 clang/test/Modules/Inputs/shadow/A1/A1.h
 create mode 100644 clang/test/Modules/Inputs/shadow/A2/A2.h
 create mode 100644 clang/test/Modules/lazy-by-name-lookup.c

diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp 
b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index f45190f8aebec..24c1a9d98a310 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -290,7 +290,7 @@ std::error_code ModularizeUtilities::loadModuleMap(
 Target.get(), *HeaderInfo));
 
   // Parse module.modulemap file into module map.
-  if (ModMap->loadModuleMapFile(ModuleMapEntry, false, Dir)) {
+  if (ModMap->parseAndLoadModuleMapFile(ModuleMapEntry, false, Dir)) {
 return std::error_code(1, std::generic_category());
   }
 
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index b9f08d96151c9..1abb63ba3aea6 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -576,6 +576,7 @@ def ModuleImport : DiagGroup<"module-import">;
 def ModuleConflict : DiagGroup<"module-conflict">;
 def ModuleFileExtension : DiagGroup<"module-file-extension">;
 def ModuleIncludeDirectiveTranslation : 
DiagGroup<"module-include-translation">;
+def ModuleMap : DiagGroup<"module-map">;
 def RoundTripCC1Args : DiagGroup<"round-trip-cc1-args">;
 def NewlineEOF : DiagGroup<"newline-eof">;
 def Nullability : DiagGroup<"nullability">;
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 912b8bd46e194..a6866ef868dcd 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -836,6 +836,

[Lldb-commits] [lldb] [llvm] [Support] [lldb] Fix thread jump #45326 (PR #135778)

2025-04-15 Thread David Blaikie via lldb-commits

dwblaikie wrote:

Looks like this could/should be 2-3 comits. The ADT change is one, the 
llvm-symbolizer could be another (with or without the lldb test coverage), then 
possibly the lldb test coverage as a separate third step. (the contents of the 
patch I don't have much opinion on, I haven't even thought about whether the 
ADT change is good/bad, etc)

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


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

2025-04-15 Thread via lldb-commits

Author: Wanyi
Date: 2025-04-15T13:46:15-04:00
New Revision: 7a41761407c485d18b7d48232b308556b3b43934

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

LOG: [lldb] Make SBProcess thread related actions listen to StopLocker (#134339)

# Summary

This PR updates `SBProcess::GetNumThreads()` and
`SBProcess::GetThreadAtIndex()` to listen to the stop locker.
`SBProcess::GetNumThreads()` will return 0 if the process is running.

## Problem Description

Recently upon debugging a program with thousands of threads in VS Code,
lldb-dap would hang at a `threads` request sent right after receiving
the `configurationDone` response. Soon after it will end the debug
session with the following error
```
Process  exited with status = -1 (0x) lost connection
```

This is because LLDB is still in the middle of resuming all the threads.
And requesting threads will end up interrupt the process on Linux. From
the gdb-remote log it ended up getting `lldb::StateType::eStateInvalid`
and just exit with status -1.

I don't think it's reasonable to allow getting threads from a running
process. There are a few approaches to fix this:
1) Send the stopped event to IDE after `configurationDone`. This aligns
with the CLI behavior.
2) However, the above approach will break the existing user facing
behavior. The alternative will be reject the `threads` request if the
process is not stopped.
3) Improve the run lock. This is a synchronize issue where process was
in the middle of resuming while lldb-dap attempts to interrupt it.

**This PR implements the option 3**

## HOWEVER

This fixed the "lost connection" issue below but new issue has surfaced.
>From testing, and also from checking the [VSCode source
code](https://github.com/microsoft/vscode/blob/174af221c9ea2ccdb64abe4aab8e1a805e77beae/src/vs/workbench/contrib/debug/browser/debugSession.ts#L791),
it expects having threadID to perform `pause`. So after attaching,
without any threads reported to the client, the user will not be able to
pause the attached process. `setBreakpoint` will still work and once we
make a stop at the bp (or any stop that will report threads, client can
perform pause again.

## NEXT
1) Made an attempt to return initial thread list so that VSCode can
pause (second commit in the PR)
2) Investigate why threads will trigger unwinding the second frame of a
thread, which leads to sending the interrupt
3) Decided if we want to support `stopOnEntry` for attaching, given
  i. This is not an official specification
ii. If enable stopOnEntry, we need to fix attaching on Linux, to send
only one stopped event. Currently, all threads upon attaching will have
stop reason `SIGSTOP` and lldb-dap will send `stopped` event for each
one of them. Every `stopped` will trigger the client request for
threads.
iii. Alternatively, we can support auto continue correspond to `(lldb)
process attach --continue`. This require the ii above.


### Additionally

lldb-dap will not send a `continued` event after `configurationDone`
because it checks `dap.focus_tid == LLDB_INVALID_THREAD_ID` (so that we
don't send it for `launch` request). Notice `dap.focus_tid` will only
get assigned when handling stop or stepping.

According to DAP

> Please note: a debug adapter is not expected to send this event in
response to a request that implies that execution continues, e.g. launch
or continue.
It is only necessary to send a continued event if there was no previous
request that implied this.

So I guess we are not violating DAP if we don't send `continued` event.
But I'd like to get some sense about this.


## Test Plan
Used following program for testing:
https://gist.github.com/kusmour/1729d2e07b7b1063897db77de194e47d
**NOTE: Utilize stdin to get pid and attach AFTER hitting enter. Attach
should happen when all the threads start running.**

DAP messages before the change
https://github.com/user-attachments/assets/a9ad85fb-81ce-419c-95e5-612639905c66";
/>

DAP message after the change - report zero threads after attaching
https://github.com/user-attachments/assets/a1179e18-6844-437a-938c-0383702294cd";
/>

-

Co-authored-by: Jonas Devlieghere 

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
lldb/source/API/SBProcess.cpp
lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
lldb/tools/lldb-dap/DAP.h
lldb/tools/lldb-dap/Handler/ConfigurationDoneRequestHandler.cpp
lldb/tools/lldb-dap/Handler/ThreadsRequestHandler.cpp
lldb/tools/lldb-dap/JSONUtils.cpp
lldb/tools/lldb-dap/JSONUtils.h

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 45403e9df8525..61d7fa94479b8 100644
--- a/lldb/packages/Pyt

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

2025-04-15 Thread via lldb-commits

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


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

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

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


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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap 'launch' request to use typed RequestHandler<>. (PR #133624)

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

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/133624

>From 3240fe49515e5f59c5b9ff9c02423b77504d8a43 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Fri, 28 Mar 2025 14:02:53 -0700
Subject: [PATCH 1/6] [lldb-dap] Refactoring lldb-dap 'launch' request to use
 typed RequestHandler<>.

This converts a number of json::Value's into well defined types that are used 
throughout lldb-dap and updates the 'launch' command to use the new well 
defined types.
---
 .../test/tools/lldb-dap/dap_server.py |   3 +-
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   2 +-
 .../tools/lldb-dap/launch/TestDAP_launch.py   |   6 +-
 .../restart/TestDAP_restart_runInTerminal.py  |   4 +-
 .../runInTerminal/TestDAP_runInTerminal.py|  16 +-
 lldb/tools/lldb-dap/DAP.cpp   |  82 +---
 lldb/tools/lldb-dap/DAP.h |  44 +++--
 .../lldb-dap/Handler/AttachRequestHandler.cpp |  33 ++--
 .../lldb-dap/Handler/CompletionsHandler.cpp   |   7 +-
 .../Handler/EvaluateRequestHandler.cpp|   3 +-
 .../lldb-dap/Handler/LaunchRequestHandler.cpp | 118 +++-
 .../tools/lldb-dap/Handler/RequestHandler.cpp |  96 +-
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  19 +-
 .../Handler/RestartRequestHandler.cpp |  54 --
 .../Handler/SetVariableRequestHandler.cpp |   3 +-
 .../Handler/StackTraceRequestHandler.cpp  |   2 +-
 .../Handler/VariablesRequestHandler.cpp   |  20 +-
 lldb/tools/lldb-dap/JSONUtils.cpp |  48 ++---
 lldb/tools/lldb-dap/JSONUtils.h   |  11 +-
 .../lldb-dap/Protocol/ProtocolRequests.cpp| 175 +-
 .../lldb-dap/Protocol/ProtocolRequests.h  | 150 +++
 lldb/tools/lldb-dap/SourceBreakpoint.cpp  |   6 +-
 22 files changed, 616 insertions(+), 286 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 01ef4b68f2653..6e13fcddcc933 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
@@ -862,7 +862,8 @@ def request_launch(
 args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
 args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
 args_dict["displayExtendedBacktrace"] = displayExtendedBacktrace
-args_dict["commandEscapePrefix"] = commandEscapePrefix
+if commandEscapePrefix:
+args_dict["commandEscapePrefix"] = commandEscapePrefix
 command_dict = {"command": "launch", "type": "request", "arguments": 
args_dict}
 response = self.send_recv(command_dict)
 
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..9ab8a905a79dd 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
@@ -443,7 +443,7 @@ def cleanup():
 
 if not (response and response["success"]):
 self.assertTrue(
-response["success"], "launch failed (%s)" % 
(response["message"])
+response["success"], "launch failed (%s)" % 
(response["body"]["error"]["format"])
 )
 return response
 
diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py 
b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
index 64c99019a1c9b..c6a3e9cc879a4 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
@@ -41,7 +41,9 @@ def test_termination(self):
 self.dap_server.request_disconnect()
 
 # Wait until the underlying lldb-dap process dies.
-
self.dap_server.process.wait(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval)
+self.dap_server.process.wait(
+timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval
+)
 
 # Check the return code
 self.assertEqual(self.dap_server.process.poll(), 0)
@@ -459,7 +461,7 @@ def test_failing_launch_commands(self):
 
 self.assertFalse(response["success"])
 self.assertRegex(
-response["message"],
+response["body"]["error"]["format"],
 r"Failed to run launch commands\. See the Debug Console for more 
details",
 )
 
diff --git 
a/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py 
b/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py
index 5a9938c25c2c8..a94c9860c1508 100644
--- a/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py
@@ -21,7 +21,7 @@ def isTestSupported(self):
 return False
 
 @skipIfWindows
-@skipIf(archs=["arm"])  #

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

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

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

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

>From 889900ece6cccfb7cd2d8d16706bc2d5db18c381 Mon Sep 17 00:00:00 2001
From: Ilia Kuklin 
Date: Wed, 16 Apr 2025 00:30:51 +0500
Subject: [PATCH] [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 41a1676dabd76..de222a6c5ce8e 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 59fb066e087d3..d881136b22699 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -494,6 +494,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 ed6297cc6f3e0..ed56ad92e23f2 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 22fdd24fc7cd5..c73046f137470 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 eac24353de90b..caa859376c698 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -2844,8 +2844,9 @@ ValueObjectSP ValueObject::Dereference(Status &error) {

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

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

kuilpd wrote:

@labath @jimingham 
This is just one way to allow C/C++ to dereference arrays and let other 
languages decide on which types they allow to dereference.
I tried making a `GetDereferencedType` function in TypeSystem, but it doesn't 
really need to do anything right now, everything is handled in 
`GetChildCompilerTypeAtIndex` anyway.
Also, you raised a problem that if a user has defined a synthetic child 
provider for the array type, then after converting array to a pointer that 
provider will not be used. Allowing the array to be dereferenced will do the 
same because of where the check for a synthetic child is in 
`ValueObject::Dereference`. I'm really not sure how to avoid that.

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-dap] Improve error reporting dap command arguments. (PR #135684)

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

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


[Lldb-commits] [lldb] [lldb-dap] Improve error reporting for dap command arguments. (PR #135684)

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

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


[Lldb-commits] [lldb] 14cb656 - [lldb-dap] Improve error reporting for dap command arguments. (#135684)

2025-04-15 Thread via lldb-commits

Author: John Harrison
Date: 2025-04-15T13:30:33-07:00
New Revision: 14cb6566d6701feaef2ffd686af5de4ff9e3eb29

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

LOG: [lldb-dap] Improve error reporting for dap command arguments. (#135684)

Previously the error only contained the failed to parse JSON message,
which has no additional context.

This improves the error messages and improves the consistency of
handling properties in protocol structures. Updating the fields to use
'ObjectMapper.map' instead of 'ObjectMapper.mapOptional' caught that
adapterID was misspelled as well.

For example, previously:

```
$ echo 'Content-Length: 
81\r\n\r\n{"type":"request","command":"initialize","seq":1,"arguments":{"adapterID":12345}}
 | lldb-dap
```

Worked without an error but now it reports:

```
invalid arguments for request 'initialize': expected string at 
arguments.adapterID
{
  "adapterID": /* error: expected string */ 12345
}
```

Added: 


Modified: 
lldb/tools/lldb-dap/Handler/RequestHandler.h
lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp

Removed: 




diff  --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h 
b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index 50795f8252de3..7e56c258ad78a 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -120,11 +120,13 @@ class RequestHandler : public BaseRequestHandler {
 }
 
 Args arguments;
-llvm::json::Path::Root root;
-if (request.arguments && !fromJSON(request.arguments, arguments, root)) {
+llvm::json::Path::Root root("arguments");
+if (request.arguments && !fromJSON(*request.arguments, arguments, root)) {
   std::string parse_failure;
   llvm::raw_string_ostream OS(parse_failure);
-  root.printErrorContext(request.arguments, OS);
+  OS << "invalid arguments for request '" << request.command
+ << "': " << llvm::toString(root.getError()) << "\n";
+  root.printErrorContext(*request.arguments, OS);
 
   protocol::ErrorMessage error_message;
   error_message.format = parse_failure;

diff  --git a/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
index af63cc803e545..bfd68448fb483 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
@@ -178,7 +178,7 @@ bool fromJSON(json::Value const &Params, Response &R, 
json::Path P) {
 return false;
   }
 
-  return O.map("success", R.success) && O.mapOptional("message", R.message) &&
+  return O.map("success", R.success) && O.map("message", R.message) &&
  mapRaw(Params, "body", R.body, P);
 }
 

diff  --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
index 7163399899f7e..3523f8ac87ec9 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
@@ -20,16 +20,16 @@ namespace lldb_dap::protocol {
 bool fromJSON(const llvm::json::Value &Params, CancelArguments &CA,
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
-  return O && O.mapOptional("requestId", CA.requestId) &&
- O.mapOptional("progressId", CA.progressId);
+  return O && O.map("requestId", CA.requestId) &&
+ O.map("progressId", CA.progressId);
 }
 
 bool fromJSON(const json::Value &Params, DisconnectArguments &DA,
   json::Path P) {
   json::ObjectMapper O(Params, P);
-  return O && O.mapOptional("restart", DA.restart) &&
- O.mapOptional("terminateDebuggee", DA.terminateDebuggee) &&
- O.mapOptional("suspendDebuggee", DA.suspendDebuggee);
+  return O && O.map("restart", DA.restart) &&
+ O.map("terminateDebuggee", DA.terminateDebuggee) &&
+ O.map("suspendDebuggee", DA.suspendDebuggee);
 }
 
 bool fromJSON(const llvm::json::Value &Params, PathFormat &PF,
@@ -75,23 +75,33 @@ bool fromJSON(const llvm::json::Value &Params, 
InitializeRequestArguments &IRA,
 
   const json::Object *O = Params.getAsObject();
 
-  for (auto &kv : ClientFeatureByKey)
-if (std::optional v = O->getBoolean(kv.first()); v && *v)
+  for (auto &kv : ClientFeatureByKey) {
+const json::Value *value_ref = O->get(kv.first());
+if (!value_ref)
+  continue;
+
+const std::optional value = value_ref->getAsBoolean();
+if (!value) {
+  P.field(kv.first()).report("expected bool");
+  return false;
+}
+
+if (*value)
   IRA.supportedFeatures.insert(kv.second);
+  }
 
-  return OM.mapOptional("adatperID", IRA.adatperID) &&
- OM.mapOptional("client

[Lldb-commits] [lldb] [lldb-dap] Improve error reporting for dap command arguments. (PR #135684)

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

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap 'launch' request to use typed RequestHandler<>. (PR #133624)

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

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/133624

>From 3240fe49515e5f59c5b9ff9c02423b77504d8a43 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Fri, 28 Mar 2025 14:02:53 -0700
Subject: [PATCH 1/8] [lldb-dap] Refactoring lldb-dap 'launch' request to use
 typed RequestHandler<>.

This converts a number of json::Value's into well defined types that are used 
throughout lldb-dap and updates the 'launch' command to use the new well 
defined types.
---
 .../test/tools/lldb-dap/dap_server.py |   3 +-
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   2 +-
 .../tools/lldb-dap/launch/TestDAP_launch.py   |   6 +-
 .../restart/TestDAP_restart_runInTerminal.py  |   4 +-
 .../runInTerminal/TestDAP_runInTerminal.py|  16 +-
 lldb/tools/lldb-dap/DAP.cpp   |  82 +---
 lldb/tools/lldb-dap/DAP.h |  44 +++--
 .../lldb-dap/Handler/AttachRequestHandler.cpp |  33 ++--
 .../lldb-dap/Handler/CompletionsHandler.cpp   |   7 +-
 .../Handler/EvaluateRequestHandler.cpp|   3 +-
 .../lldb-dap/Handler/LaunchRequestHandler.cpp | 118 +++-
 .../tools/lldb-dap/Handler/RequestHandler.cpp |  96 +-
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  19 +-
 .../Handler/RestartRequestHandler.cpp |  54 --
 .../Handler/SetVariableRequestHandler.cpp |   3 +-
 .../Handler/StackTraceRequestHandler.cpp  |   2 +-
 .../Handler/VariablesRequestHandler.cpp   |  20 +-
 lldb/tools/lldb-dap/JSONUtils.cpp |  48 ++---
 lldb/tools/lldb-dap/JSONUtils.h   |  11 +-
 .../lldb-dap/Protocol/ProtocolRequests.cpp| 175 +-
 .../lldb-dap/Protocol/ProtocolRequests.h  | 150 +++
 lldb/tools/lldb-dap/SourceBreakpoint.cpp  |   6 +-
 22 files changed, 616 insertions(+), 286 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 01ef4b68f2653..6e13fcddcc933 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
@@ -862,7 +862,8 @@ def request_launch(
 args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
 args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
 args_dict["displayExtendedBacktrace"] = displayExtendedBacktrace
-args_dict["commandEscapePrefix"] = commandEscapePrefix
+if commandEscapePrefix:
+args_dict["commandEscapePrefix"] = commandEscapePrefix
 command_dict = {"command": "launch", "type": "request", "arguments": 
args_dict}
 response = self.send_recv(command_dict)
 
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..9ab8a905a79dd 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
@@ -443,7 +443,7 @@ def cleanup():
 
 if not (response and response["success"]):
 self.assertTrue(
-response["success"], "launch failed (%s)" % 
(response["message"])
+response["success"], "launch failed (%s)" % 
(response["body"]["error"]["format"])
 )
 return response
 
diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py 
b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
index 64c99019a1c9b..c6a3e9cc879a4 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
@@ -41,7 +41,9 @@ def test_termination(self):
 self.dap_server.request_disconnect()
 
 # Wait until the underlying lldb-dap process dies.
-
self.dap_server.process.wait(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval)
+self.dap_server.process.wait(
+timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval
+)
 
 # Check the return code
 self.assertEqual(self.dap_server.process.poll(), 0)
@@ -459,7 +461,7 @@ def test_failing_launch_commands(self):
 
 self.assertFalse(response["success"])
 self.assertRegex(
-response["message"],
+response["body"]["error"]["format"],
 r"Failed to run launch commands\. See the Debug Console for more 
details",
 )
 
diff --git 
a/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py 
b/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py
index 5a9938c25c2c8..a94c9860c1508 100644
--- a/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py
@@ -21,7 +21,7 @@ def isTestSupported(self):
 return False
 
 @skipIfWindows
-@skipIf(archs=["arm"])  #

[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang][modules] Lazily load by name lookups in module maps (PR #132853)

2025-04-15 Thread Jan Svoboda via lldb-commits

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

LGTM, thank you!

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


[Lldb-commits] [lldb] [lldb][Language] Change GetFunctionDisplayName to take SymbolContext by reference (PR #135536)

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

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


[Lldb-commits] [lldb] af7a7ba - [lldb][Format][NFC] Factor FunctionNameWithArgs case out into helper function

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

Author: Michael Buch
Date: 2025-04-14T00:12:30+01:00
New Revision: af7a7ba4aadea3600e78a5f522b72e5413c8e595

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

LOG: [lldb][Format][NFC] Factor FunctionNameWithArgs case out into helper 
function

Added: 


Modified: 
lldb/source/Core/FormatEntity.cpp

Removed: 




diff  --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 2392edb78d2ce..23e5999bd80cb 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -1184,6 +1184,40 @@ static bool PrintFunctionNameWithArgs(Stream &s,
   return true;
 }
 
+static bool HandleFunctionNameWithArgs(Stream &s,const ExecutionContext 
*exe_ctx,
+   const SymbolContext &sc) {
+  Language *language_plugin = nullptr;
+  bool language_plugin_handled = false;
+  StreamString ss;
+  if (sc.function)
+language_plugin = Language::FindPlugin(sc.function->GetLanguage());
+  else if (sc.symbol)
+language_plugin = Language::FindPlugin(sc.symbol->GetLanguage());
+
+  if (language_plugin)
+language_plugin_handled = language_plugin->GetFunctionDisplayName(
+sc, exe_ctx, Language::FunctionNameRepresentation::eNameWithArgs, ss);
+
+  if (language_plugin_handled) {
+s << ss.GetString();
+return true;
+  }
+
+  if (sc.function)
+return PrintFunctionNameWithArgs(s, exe_ctx, sc);
+
+  if (!sc.symbol)
+return false;
+
+  const char *cstr = sc.symbol->GetName().AsCString(nullptr);
+  if (!cstr)
+return false;
+
+  s.PutCString(cstr);
+
+  return true;
+}
+
 bool FormatEntity::FormatStringRef(const llvm::StringRef &format_str, Stream 
&s,
const SymbolContext *sc,
const ExecutionContext *exe_ctx,
@@ -1738,36 +1772,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
 if (!sc)
   return false;
 
-Language *language_plugin = nullptr;
-bool language_plugin_handled = false;
-StreamString ss;
-if (sc->function)
-  language_plugin = Language::FindPlugin(sc->function->GetLanguage());
-else if (sc->symbol)
-  language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());
-
-if (language_plugin)
-  language_plugin_handled = language_plugin->GetFunctionDisplayName(
-  *sc, exe_ctx, Language::FunctionNameRepresentation::eNameWithArgs,
-  ss);
-
-if (language_plugin_handled) {
-  s << ss.GetString();
-  return true;
-}
-
-if (sc->function)
-  return PrintFunctionNameWithArgs(s, exe_ctx, *sc);
-
-if (!sc->symbol)
-  return false;
-
-const char *cstr = sc->symbol->GetName().AsCString(nullptr);
-if (!cstr)
-  return false;
-
-s.PutCString(cstr);
-return true;
+return HandleFunctionNameWithArgs(s, exe_ctx, *sc);
   }
 
   case Entry::Type::FunctionMangledName: {



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


[Lldb-commits] [lldb] [lldb-dap] Imporve error reporting if a command's arguments fail to parse correctly. (PR #135684)

2025-04-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

Previously the error only contained the failed to parse JSON message, which has 
no additional context.

This improves the error messages and improves the consistency of handling 
properties in protocol structures. Updating the fields to use 
'ObjectMapper.map' instead of 'ObjectMapper.mapOptional' caught that adapterID 
was misspelled as well.

For example, previously:

```
$ echo 'Content-Length: 
81\r\n\r\n{"type":"request","command":"initialize","seq":1,"arguments":{"adapterID":12345}}
 | lldb-dap
```

Worked without an error but now it reports:

```
invalid arguments for request 'initialize': {
  "adapterID": /* error: expected string */ 12345
}
```


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


5 Files Affected:

- (modified) lldb/tools/lldb-dap/Handler/RequestHandler.h (+1) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp (+1-1) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp (+26-16) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolRequests.h (+2-2) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp (+3-3) 


``diff
diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h 
b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index 50795f8252de3..488628b224f53 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -124,6 +124,7 @@ class RequestHandler : public BaseRequestHandler {
 if (request.arguments && !fromJSON(request.arguments, arguments, root)) {
   std::string parse_failure;
   llvm::raw_string_ostream OS(parse_failure);
+  OS << "invalid arguments for request '" << request.command << "': ";
   root.printErrorContext(request.arguments, OS);
 
   protocol::ErrorMessage error_message;
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
index af63cc803e545..bfd68448fb483 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
@@ -178,7 +178,7 @@ bool fromJSON(json::Value const &Params, Response &R, 
json::Path P) {
 return false;
   }
 
-  return O.map("success", R.success) && O.mapOptional("message", R.message) &&
+  return O.map("success", R.success) && O.map("message", R.message) &&
  mapRaw(Params, "body", R.body, P);
 }
 
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
index 7163399899f7e..3523f8ac87ec9 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
@@ -20,16 +20,16 @@ namespace lldb_dap::protocol {
 bool fromJSON(const llvm::json::Value &Params, CancelArguments &CA,
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
-  return O && O.mapOptional("requestId", CA.requestId) &&
- O.mapOptional("progressId", CA.progressId);
+  return O && O.map("requestId", CA.requestId) &&
+ O.map("progressId", CA.progressId);
 }
 
 bool fromJSON(const json::Value &Params, DisconnectArguments &DA,
   json::Path P) {
   json::ObjectMapper O(Params, P);
-  return O && O.mapOptional("restart", DA.restart) &&
- O.mapOptional("terminateDebuggee", DA.terminateDebuggee) &&
- O.mapOptional("suspendDebuggee", DA.suspendDebuggee);
+  return O && O.map("restart", DA.restart) &&
+ O.map("terminateDebuggee", DA.terminateDebuggee) &&
+ O.map("suspendDebuggee", DA.suspendDebuggee);
 }
 
 bool fromJSON(const llvm::json::Value &Params, PathFormat &PF,
@@ -75,23 +75,33 @@ bool fromJSON(const llvm::json::Value &Params, 
InitializeRequestArguments &IRA,
 
   const json::Object *O = Params.getAsObject();
 
-  for (auto &kv : ClientFeatureByKey)
-if (std::optional v = O->getBoolean(kv.first()); v && *v)
+  for (auto &kv : ClientFeatureByKey) {
+const json::Value *value_ref = O->get(kv.first());
+if (!value_ref)
+  continue;
+
+const std::optional value = value_ref->getAsBoolean();
+if (!value) {
+  P.field(kv.first()).report("expected bool");
+  return false;
+}
+
+if (*value)
   IRA.supportedFeatures.insert(kv.second);
+  }
 
-  return OM.mapOptional("adatperID", IRA.adatperID) &&
- OM.mapOptional("clientID", IRA.clientID) &&
- OM.mapOptional("clientName", IRA.clientName) &&
- OM.mapOptional("locale", IRA.locale) &&
- OM.mapOptional("linesStartAt1", IRA.linesStartAt1) &&
- OM.mapOptional("columnsStartAt1", IRA.columnsStartAt1) &&
- OM.mapOptional("pathFormat", IRA.pathFormat) &&
- OM.mapOptional("$__lldb_sourceInitFile", IRA.lldbExtSourceInitFile);
+  return OM.map("adapterID", IRA.adapterID) &&
+ OM.map("clientID", IRA.clientID) &&
+ OM.map("clientName", IRA.clientName) && OM.map("locale", IRA.locale) 
&&
+ OM.map("linesStartAt1

[Lldb-commits] [lldb] Draft: test (PR #135630)

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

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/135630

>From f9afd2f06762c30dd22218d8eacd2cb6599ffb59 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 14 Apr 2025 11:56:01 -0300
Subject: [PATCH] Draft: test

With change:
1) 4m46s - 
https://buildkite.com/llvm-project/github-pull-requests/builds/168411#_
2) 4m36s - 
https://buildkite.com/llvm-project/github-pull-requests/builds/168431#01963503-57a4-4934-9de8-f298abe3c432
3) 4m05s - 
https://buildkite.com/llvm-project/github-pull-requests/builds/168455#01963544-0108-4474-bcfe-781e6facc804

Without change:
1) 3m41s - 
https://buildkite.com/llvm-project/github-pull-requests/builds/168504#019635ca-f0cc-4ab7-8723-c761a640a701
---
 lldb/DELETE.ME | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 lldb/DELETE.ME

diff --git a/lldb/DELETE.ME b/lldb/DELETE.ME
new file mode 100644
index 0..e69de29bb2d1d

___
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 win32 build. (PR #135638)

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

ashgti wrote:

> @ashgti Did you test #130169 on Windows? This patch will fix the building, 
> but I'm not sure that it will work on Windows considering this:

SelectHelper has a Windows implementation: 
https://github.com/llvm/llvm-project/blob/a43ff0ec8a684b2f8e93bb9f6df3b513c577091b/lldb/source/Utility/SelectHelper.cpp#L93
 it only works with Socket types on Windows.

https://github.com/llvm/llvm-project/pull/135638
___
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-15 Thread Marcel Laverdet via lldb-commits

laverdet wrote:

Closing this since Docker on macOS simply disabled SME, SVE, etc. I believe 
this is still an issue in theory for users with Linux installed directly on M4 
hardware but if such a user exists I haven't heard of them.

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-dap] Imporve error reporting if a command's arguments fail to parse correctly. (PR #135684)

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

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


[Lldb-commits] [lldb] [llvm] [Support] [lldb] Fix thread jump #45326 (PR #135778)

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

da-viper wrote:

having a `+` before the address is also valid in `gnu addr2line` 

```sh
$ projects/test_lldb → addr2line --exe=/home/test/Inputs/symbols.so 0x1138  
   
/tmp/dbginfo/symbols.part1.cpp:12

$ projects/test_lldb → addr2line --exe=/home/test/Inputs/symbols.so +0x1138
/tmp/dbginfo/symbols.part1.cpp:12

$ projects/test_lldb → addr2line --exe=/home/test/Inputs/symbols.so -a +0x1138  
   
0x1138
/tmp/dbginfo/symbols.part1.cpp:12 
```

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


[Lldb-commits] [lldb] Draft: test (PR #135630)

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

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


[Lldb-commits] [lldb] [llvm] [CI] monolithic-linux improvements (PR #135499)

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

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


[Lldb-commits] [lldb] [lldb-dap] Imporve error reporting if a command's arguments fail to parse correctly. (PR #135684)

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

https://github.com/ashgti created 
https://github.com/llvm/llvm-project/pull/135684

Previously the error only contained the failed to parse JSON message, which has 
no additional context.

This improves the error messages and improves the consistency of handling 
properties in protocol structures. Updating the fields to use 
'ObjectMapper.map' instead of 'ObjectMapper.mapOptional' caught that adapterID 
was misspelled as well.

For example, previously:

```
$ echo 'Content-Length: 
81\r\n\r\n{"type":"request","command":"initialize","seq":1,"arguments":{"adapterID":12345}}
 | lldb-dap
```

Worked without an error but now it reports:

```
invalid arguments for request 'initialize': {
  "adapterID": /* error: expected string */ 12345
}
```


>From cab7671780bde4d4e2e137f10ced6b5fe504 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 14 Apr 2025 13:22:31 -0700
Subject: [PATCH] [lldb-dap] Imporve error reporting if a command's arguments
 fail to parse correctly.

Previously the error only contained the failed to parse JSON message, which has 
no additional context.

This improves the error messages and improves the consistency of handling 
properties in protocol structures. Updating the fields to use 
'ObjectMapper.map' instead of 'ObjectMapper.mapOptional' caught that adapterID 
was misspelled as well.
---
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  1 +
 lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp |  2 +-
 .../lldb-dap/Protocol/ProtocolRequests.cpp| 42 ---
 .../lldb-dap/Protocol/ProtocolRequests.h  |  4 +-
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  6 +--
 5 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h 
b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index 50795f8252de3..488628b224f53 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -124,6 +124,7 @@ class RequestHandler : public BaseRequestHandler {
 if (request.arguments && !fromJSON(request.arguments, arguments, root)) {
   std::string parse_failure;
   llvm::raw_string_ostream OS(parse_failure);
+  OS << "invalid arguments for request '" << request.command << "': ";
   root.printErrorContext(request.arguments, OS);
 
   protocol::ErrorMessage error_message;
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
index af63cc803e545..bfd68448fb483 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolBase.cpp
@@ -178,7 +178,7 @@ bool fromJSON(json::Value const &Params, Response &R, 
json::Path P) {
 return false;
   }
 
-  return O.map("success", R.success) && O.mapOptional("message", R.message) &&
+  return O.map("success", R.success) && O.map("message", R.message) &&
  mapRaw(Params, "body", R.body, P);
 }
 
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
index 7163399899f7e..3523f8ac87ec9 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
@@ -20,16 +20,16 @@ namespace lldb_dap::protocol {
 bool fromJSON(const llvm::json::Value &Params, CancelArguments &CA,
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
-  return O && O.mapOptional("requestId", CA.requestId) &&
- O.mapOptional("progressId", CA.progressId);
+  return O && O.map("requestId", CA.requestId) &&
+ O.map("progressId", CA.progressId);
 }
 
 bool fromJSON(const json::Value &Params, DisconnectArguments &DA,
   json::Path P) {
   json::ObjectMapper O(Params, P);
-  return O && O.mapOptional("restart", DA.restart) &&
- O.mapOptional("terminateDebuggee", DA.terminateDebuggee) &&
- O.mapOptional("suspendDebuggee", DA.suspendDebuggee);
+  return O && O.map("restart", DA.restart) &&
+ O.map("terminateDebuggee", DA.terminateDebuggee) &&
+ O.map("suspendDebuggee", DA.suspendDebuggee);
 }
 
 bool fromJSON(const llvm::json::Value &Params, PathFormat &PF,
@@ -75,23 +75,33 @@ bool fromJSON(const llvm::json::Value &Params, 
InitializeRequestArguments &IRA,
 
   const json::Object *O = Params.getAsObject();
 
-  for (auto &kv : ClientFeatureByKey)
-if (std::optional v = O->getBoolean(kv.first()); v && *v)
+  for (auto &kv : ClientFeatureByKey) {
+const json::Value *value_ref = O->get(kv.first());
+if (!value_ref)
+  continue;
+
+const std::optional value = value_ref->getAsBoolean();
+if (!value) {
+  P.field(kv.first()).report("expected bool");
+  return false;
+}
+
+if (*value)
   IRA.supportedFeatures.insert(kv.second);
+  }
 
-  return OM.mapOptional("adatperID", IRA.adatperID) &&
- OM.mapOptional("clientID", IRA.clientID) &&
- OM.mapOptional("clientName", IRA.clientName) &&
- OM.mapOptional("locale", IRA.locale) 

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

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

llvm-ci wrote:

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

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


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

```
Step 6 (test) failure: build (failure)
...
UNSUPPORTED: lldb-api :: tools/lldb-server/TestGdbRemoteFork.py (1199 of 2123)
PASS: lldb-api :: tools/lldb-server/TestGdbRemoteAttach.py (1200 of 2123)
PASS: lldb-api :: tools/lldb-server/TestGdbRemoteCompletion.py (1201 of 2123)
UNSUPPORTED: lldb-api :: tools/lldb-server/TestGdbRemoteForkNonStop.py (1202 of 
2123)
UNSUPPORTED: lldb-api :: tools/lldb-server/TestGdbRemoteForkResume.py (1203 of 
2123)
PASS: lldb-api :: tools/lldb-server/TestGdbRemoteExitCode.py (1204 of 2123)
PASS: lldb-api :: tools/lldb-server/TestGdbRemoteHostInfo.py (1205 of 2123)
PASS: lldb-api :: tools/lldb-server/TestGdbRemoteModuleInfo.py (1206 of 2123)
PASS: lldb-api :: tools/lldb-server/TestGdbRemoteAuxvSupport.py (1207 of 2123)
UNRESOLVED: lldb-api :: tools/lldb-dap/variables/TestDAP_variables.py (1208 of 
2123)
 TEST 'lldb-api :: 
tools/lldb-dap/variables/TestDAP_variables.py' FAILED 
Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
--env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--arch aarch64 --build-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil 
--make /usr/bin/gmake --llvm-tools-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/variables
 -p TestDAP_variables.py
--
Exit Code: 1

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

--
Command Output (stderr):
--
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_darwin_dwarf_missing_obj (TestDAP_variables.TestDAP_variables) (requires 
one of macosx, darwin, ios, tvos, watchos, bridgeos, iphonesimulator, 
watchsimulator, appletvsimulator) 
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_darwin_dwarf_missing_obj_with_symbol_ondemand_enabled 
(TestDAP_variables.TestDAP_variables) (requires one of macosx, darwin, ios, 
tvos, watchos, bridgeos, iphonesimulator, watchsimulator, appletvsimulator) 
= DEBUG ADAPTER PROTOCOL LOGS =
1744739844.540583611 --> (stdin/stdout) 
{"command":"initialize","type":"request","arguments":{"adapterID":"lldb-native","clientID":"vscode","columnsStartAt1":true,"linesStartAt1":true,"locale":"en-us","pathFormat":"path","supportsRunInTerminalRequest":true,"supportsVariablePaging":true,"supportsVariableType":true,"supportsStartDebuggingRequest":true,"supportsProgressReporting":true,"$__lldb_sourceInitFile":false},"seq":1}
1744739844.542667866 <-- (stdin/stdout) {"body":{"$__lldb_version":"lldb 
version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
7a41761407c485d18b7d48232b308556b3b43934)\n  clang revision 
7a41761407c485d18b7d48232b308556b3b43934\n  llvm revision 
7a41761407c485d18b7d48232b308556b3b43934","completionTriggerCharacters":["."," 
","\t"],"exceptionBreakpointFilters":[{"default":false,"filter":"cpp_catch","label":"C++
 Catch"},{"default":false,"filter":"cpp_throw","label":"C++ 
Throw"},{"default":false,"filter":"objc_catch","label":"Objective-C 
Catch"},{"default":false,"filter":"objc_throw","label":"Objective-C 
Throw"}],"supportTerminateDebuggee":true,"supportsBreakpointLocationsRequest":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBr

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

2025-04-15 Thread via lldb-commits

eaeltsin wrote:

No, the problem seems to be in serialization/deserialization, there must be 
some mismatch between `ASTStmtWriter::VisitSubstNonTypeTemplateParmExpr` and 
`ASTStmtReader::VisitSubstNonTypeTemplateParmExpr`.

More precisely, I'm seeing that 
`ASTStmtWriter::VisitSubstNonTypeTemplateParmExpr` outputs a record of 5 
elements, while `ASTStmtReader::VisitSubstNonTypeTemplateParmExpr` gets a 
record of 4 elements as input, and thus triggers assertion when reading the 
source location.


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


[Lldb-commits] [lldb] [lldb-dap] Imporve error reporting if a command's arguments fail to parse correctly. (PR #135684)

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

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


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


[Lldb-commits] [lldb] [NFC][lldb]Fix stack-use-after-free bugs in exit-callbacks. (PR #135763)

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

https://github.com/oontvoo created 
https://github.com/llvm/llvm-project/pull/135763

None

>From dd74c3abe3a69e6c3cc4b9c22a38ca09997848f7 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 15 Apr 2025 04:42:30 -0400
Subject: [PATCH] [NFC][lldb]Fix stack-use-after-free bugs in exit-callbacks.

---
 lldb/source/Target/Process.cpp | 9 +
 lldb/source/Target/Target.cpp  | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 633f7488dc76a..73557eb767c72 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1047,10 +1047,11 @@ bool Process::SetExitStatus(int status, llvm::StringRef 
exit_string) {
 info->exit_desc = {status, exit_string.str()};
   });
 
-  helper.DispatchOnExit([&](telemetry::ProcessExitInfo *info) {
-info->module_uuid = module_uuid;
-info->pid = m_pid;
-  });
+  helper.DispatchOnExit(
+  [module_uuid, pid = m_pid](telemetry::ProcessExitInfo *info) {
+info->module_uuid = module_uuid;
+info->pid = pid;
+  });
 
   m_exit_status = status;
   if (!exit_string.empty())
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 42b1561fb2993..b6186b76d6236 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1578,7 +1578,7 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
   info->is_start_entry = true;
 });
 
-helper.DispatchOnExit([&](telemetry::ExecutableModuleInfo *info) {
+helper.DispatchOnExit([&, pid](telemetry::ExecutableModuleInfo *info) {
   info->exec_mod = executable_sp;
   info->uuid = executable_sp->GetUUID();
   info->pid = pid;

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


[Lldb-commits] [lldb] [NFC][lldb]Fix stack-use-after-free bugs in exit-callbacks. (PR #135763)

2025-04-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vy Nguyen (oontvoo)


Changes



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


2 Files Affected:

- (modified) lldb/source/Target/Process.cpp (+5-4) 
- (modified) lldb/source/Target/Target.cpp (+1-1) 


``diff
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 633f7488dc76a..73557eb767c72 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1047,10 +1047,11 @@ bool Process::SetExitStatus(int status, llvm::StringRef 
exit_string) {
 info->exit_desc = {status, exit_string.str()};
   });
 
-  helper.DispatchOnExit([&](telemetry::ProcessExitInfo *info) {
-info->module_uuid = module_uuid;
-info->pid = m_pid;
-  });
+  helper.DispatchOnExit(
+  [module_uuid, pid = m_pid](telemetry::ProcessExitInfo *info) {
+info->module_uuid = module_uuid;
+info->pid = pid;
+  });
 
   m_exit_status = status;
   if (!exit_string.empty())
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 42b1561fb2993..b6186b76d6236 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1578,7 +1578,7 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
   info->is_start_entry = true;
 });
 
-helper.DispatchOnExit([&](telemetry::ExecutableModuleInfo *info) {
+helper.DispatchOnExit([&, pid](telemetry::ExecutableModuleInfo *info) {
   info->exec_mod = executable_sp;
   info->uuid = executable_sp->GetUUID();
   info->pid = pid;

``




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


[Lldb-commits] [lldb] [NFC][lldb]Fix stack-use-after-free bugs in exit-callbacks. (PR #135763)

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

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

>From dd74c3abe3a69e6c3cc4b9c22a38ca09997848f7 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 15 Apr 2025 04:42:30 -0400
Subject: [PATCH] [NFC][lldb]Fix stack-use-after-free bugs in exit-callbacks.

---
 lldb/source/Target/Process.cpp | 9 +
 lldb/source/Target/Target.cpp  | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 633f7488dc76a..73557eb767c72 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1047,10 +1047,11 @@ bool Process::SetExitStatus(int status, llvm::StringRef 
exit_string) {
 info->exit_desc = {status, exit_string.str()};
   });
 
-  helper.DispatchOnExit([&](telemetry::ProcessExitInfo *info) {
-info->module_uuid = module_uuid;
-info->pid = m_pid;
-  });
+  helper.DispatchOnExit(
+  [module_uuid, pid = m_pid](telemetry::ProcessExitInfo *info) {
+info->module_uuid = module_uuid;
+info->pid = pid;
+  });
 
   m_exit_status = status;
   if (!exit_string.empty())
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 42b1561fb2993..b6186b76d6236 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1578,7 +1578,7 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
   info->is_start_entry = true;
 });
 
-helper.DispatchOnExit([&](telemetry::ExecutableModuleInfo *info) {
+helper.DispatchOnExit([&, pid](telemetry::ExecutableModuleInfo *info) {
   info->exec_mod = executable_sp;
   info->uuid = executable_sp->GetUUID();
   info->pid = pid;

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


[Lldb-commits] [lldb] [NFC][lldb]Fix stack-use-after-free bugs in exit-callbacks. (PR #135763)

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

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


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


[Lldb-commits] [lldb] [NFC][lldb]Fix stack-use-after-free bugs in exit-callbacks. (PR #135763)

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

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


[Lldb-commits] [lldb] 81499ed - [NFC][lldb]Fix stack-use-after-free bugs in exit-callbacks. (#135763)

2025-04-15 Thread via lldb-commits

Author: Vy Nguyen
Date: 2025-04-15T11:40:07+02:00
New Revision: 81499edb30665d377a680990ef3c5129f9b54261

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

LOG: [NFC][lldb]Fix stack-use-after-free bugs in exit-callbacks. (#135763)

Added: 


Modified: 
lldb/source/Target/Process.cpp
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 633f7488dc76a..73557eb767c72 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1047,10 +1047,11 @@ bool Process::SetExitStatus(int status, llvm::StringRef 
exit_string) {
 info->exit_desc = {status, exit_string.str()};
   });
 
-  helper.DispatchOnExit([&](telemetry::ProcessExitInfo *info) {
-info->module_uuid = module_uuid;
-info->pid = m_pid;
-  });
+  helper.DispatchOnExit(
+  [module_uuid, pid = m_pid](telemetry::ProcessExitInfo *info) {
+info->module_uuid = module_uuid;
+info->pid = pid;
+  });
 
   m_exit_status = status;
   if (!exit_string.empty())

diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 42b1561fb2993..b6186b76d6236 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1578,7 +1578,7 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
   info->is_start_entry = true;
 });
 
-helper.DispatchOnExit([&](telemetry::ExecutableModuleInfo *info) {
+helper.DispatchOnExit([&, pid](telemetry::ExecutableModuleInfo *info) {
   info->exec_mod = executable_sp;
   info->uuid = executable_sp->GetUUID();
   info->pid = pid;



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


[Lldb-commits] [lldb] [llvm] [CI] monolithic-linux improvements (PR #135499)

2025-04-15 Thread Aiden Grossman via lldb-commits

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


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


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

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

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


[Lldb-commits] [lldb] [Support] [lldb] Fix thread jump #45326 (PR #135778)

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

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


[Lldb-commits] [lldb] [Support] [lldb] Fix thread jump #45326 (PR #135778)

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

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

>From a7e200ad48ea84deca9a10d90addece8d14c08ac Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 15 Apr 2025 12:25:41 +0100
Subject: [PATCH 1/2] [lldb] Add test for jumping by offset

Signed-off-by: Ebuka Ezike 
---
 .../thread/jump/TestThreadJump.py | 70 ++-
 1 file changed, 69 insertions(+), 1 deletion(-)

diff --git a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py 
b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
index 3c13a969bc3fd..d603580ac6f36 100644
--- a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
+++ b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
@@ -10,9 +10,12 @@
 
 
 class ThreadJumpTestCase(TestBase):
+def setUp(self):
+TestBase.setUp(self)
+self.build()
+
 def test(self):
 """Test thread jump handling."""
-self.build()
 exe = self.getBuildArtifact("a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
@@ -62,6 +65,71 @@ def test(self):
 substrs=["error"],
 )
 
+def test_jump_offset(self):
+"""Test Thread Jump by negative or positive offset"""
+exe = self.getBuildArtifact("a.out")
+file_name = "main.cpp"
+self.runCmd(f"target create {exe}", CURRENT_EXECUTABLE_SET)
+
+pos_jump = line_number(file_name, "// jump_offset 1")
+neg_jump = line_number(file_name, "// jump_offset 2")
+pos_breakpoint = line_number(file_name, "// breakpoint 1")
+neg_breakpoint = line_number(file_name, "// breakpoint 2")
+pos_jump_offset = pos_jump - pos_breakpoint
+neg_jump_offset = neg_jump - neg_breakpoint
+
+var_1, var_1_value = ("var_1", "10")
+var_2, var_2_value = ("var_2", "40")
+var_3, var_3_value = ("var_3", "10")
+
+# create pos_breakpoint and neg_breakpoint
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, pos_breakpoint, num_expected_locations=1
+)
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, neg_breakpoint, num_expected_locations=1
+)
+
+self.runCmd("run", RUN_SUCCEEDED)
+
+# test positive jump
+# The stop reason of the thread should be breakpoint 1.
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT + " 1",
+substrs=[
+"stopped",
+f"{file_name}:{pos_breakpoint}",
+"stop reason = breakpoint 1",
+],
+)
+
+self.runCmd(f"thread jump --by +{pos_jump_offset}")
+self.expect("process status", substrs=[f"at {file_name}:{pos_jump}"])
+self.expect(f"print {var_1}", substrs=[var_1_value])
+
+self.runCmd("thread step-over")
+self.expect(f"print {var_2}", substrs=[var_2_value])
+
+self.runCmd("continue")
+
+# test negative jump
+# The stop reason of the thread should be breakpoint 1.
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT + " 2",
+substrs=[
+"stopped",
+f"{file_name}:{neg_breakpoint}",
+"stop reason = breakpoint 2",
+],
+)
+
+self.runCmd(f"thread jump --by {neg_jump_offset}")
+self.expect("process status", substrs=[f"at {file_name}:{neg_jump}"])
+self.runCmd("thread step-over")
+self.expect(f"print {var_3}", substrs=[var_3_value])
+
 def do_min_test(self, start, jump, var, value):
 # jump to the start marker
 self.runCmd("j %i" % start)

>From 67047337eee83a766a9dc7c82d42f95994419fbb Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 15 Apr 2025 12:33:52 +0100
Subject: [PATCH 2/2] [lldb] Add test main.cpp file

Signed-off-by: Ebuka Ezike 
---
 .../API/functionalities/thread/jump/main.cpp| 17 +
 1 file changed, 17 insertions(+)

diff --git a/lldb/test/API/functionalities/thread/jump/main.cpp 
b/lldb/test/API/functionalities/thread/jump/main.cpp
index d3c0de2af4bf4..9c7f0bcb3b732 100644
--- a/lldb/test/API/functionalities/thread/jump/main.cpp
+++ b/lldb/test/API/functionalities/thread/jump/main.cpp
@@ -13,6 +13,21 @@ T min(T a, T b)
 }
 }
 
+int jump_positive_offset() {
+  int var_1 = 10;
+  var_1 = 20; // breakpoint 1
+
+  int var_2 = 40; // jump_offset 1
+  return var_2;
+}
+
+int jump_negative_offset() {
+  int var_3 = 10; // jump_offset 2
+  var_3 = 99;
+
+  return var_3; // breakpoint 2
+}
+
 int main ()
 {
 int i;
@@ -22,5 +37,7 @@ int main ()
 i = min(min_i_a, min_i_b); // 3rd marker
 j = min(min_j_a, min_j_b); // 4th marker
 
+jump_positive_offset();
+jump_negative_offset();
 return 0;
 }

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

[Lldb-commits] [lldb] [llvm] [Support] [lldb] Fix thread jump #45326 (PR #135778)

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

da-viper wrote:

I wasn't sure if I should split it as they are quite small on their own. 

Will create a two new PR for the `symbolizer` and `llvm::StringRef` and this PR 
will depend on the llvm::StringRef one. 

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


[Lldb-commits] [lldb] [lldb] returning command completions up to a maximum (PR #135565)

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

eronnen wrote:

@JDevlieghere Revoled comments and added the `test_expr_completion_max_results` 
test

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


[Lldb-commits] [lldb] [lldb][nfc] Add customization flags for ThreadPlanStepOut (PR #135866)

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

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

ThreadPlanStepOut always skips over Hidden/Artificial frames when computing its 
destination frame, without providing any customization of this behavior. This 
is problematic for some plans like StepThrough, which may need to step out of a 
frame _without_ stepping out of a Hidden/Artificial frame. Any first step 
towards fixing this requires the ability to customize ThreadPlanStepOut, which 
is what this NFC patch addresses.

Since the computation of which frames to skip is done by the constructor, this 
patch adds a Flags parameter to
`ThreadPlanStepOut::ThreadPlanStepOut`.

>From 166d0321ea59ac9797a9e97f21d42d1c91f145b4 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Tue, 15 Apr 2025 10:20:41 -0700
Subject: [PATCH] [lldb][nfc] Add customization flags for ThreadPlanStepOut

ThreadPlanStepOut always skips over Hidden/Artificial frames when
computing its destination frame, without providing any customization of
this behavior. This is problematic for some plans like StepThrough,
which may need to step out of a frame _without_ stepping out of a
Hidden/Artificial frame. Any first step towards fixing this requires the
ability to customize ThreadPlanStepOut, which is what this NFC patch
addresses.

Since the computation of which frames to skip is done by the
constructor, this patch adds a Flags parameter to
`ThreadPlanStepOut::ThreadPlanStepOut`.
---
 .../lldb/Target/ThreadPlanShouldStopHere.h|  4 +-
 lldb/include/lldb/Target/ThreadPlanStepOut.h  | 15 +++--
 lldb/source/Target/ThreadPlanStepOut.cpp  | 57 ---
 3 files changed, 48 insertions(+), 28 deletions(-)

diff --git a/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h 
b/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
index d0094c90b91a5..e712ee8d2d94f 100644
--- a/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
+++ b/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
@@ -60,7 +60,9 @@ class ThreadPlanShouldStopHere {
 eAvoidInlines = (1 << 0),
 eStepInAvoidNoDebug = (1 << 1),
 eStepOutAvoidNoDebug = (1 << 2),
-eStepOutPastThunks = (1 << 3)
+eStepOutPastThunks = (1 << 3),
+eStepOutPastHiddenFunctions = (1 << 4),
+eStepOutPastArtificialFunctions = (1 << 5),
   };
 
   // Constructors and Destructors
diff --git a/lldb/include/lldb/Target/ThreadPlanStepOut.h 
b/lldb/include/lldb/Target/ThreadPlanStepOut.h
index 013c675afc33d..c8eb334e4311c 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepOut.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepOut.h
@@ -17,12 +17,12 @@ namespace lldb_private {
 
 class ThreadPlanStepOut : public ThreadPlan, public ThreadPlanShouldStopHere {
 public:
-  ThreadPlanStepOut(Thread &thread, SymbolContext *addr_context,
-bool first_insn, bool stop_others, Vote report_stop_vote,
-Vote report_run_vote, uint32_t frame_idx,
-LazyBool step_out_avoids_code_without_debug_info,
-bool continue_to_next_branch = false,
-bool gather_return_value = true);
+  ThreadPlanStepOut(
+  Thread &thread, SymbolContext *addr_context, bool first_insn,
+  bool stop_others, Vote report_stop_vote, Vote report_run_vote,
+  uint32_t frame_idx, LazyBool step_out_avoids_code_without_debug_info,
+  bool continue_to_next_branch = false, bool gather_return_value = true,
+  lldb_private::Flags flags = ThreadPlanStepOut::s_default_flag_values);
 
   ~ThreadPlanStepOut() override;
 
@@ -87,6 +87,9 @@ class ThreadPlanStepOut : public ThreadPlan, public 
ThreadPlanShouldStopHere {
 
   void CalculateReturnValue();
 
+  lldb::StackFrameSP
+  ComputeReturnToFrame(Thread &thread, uint32_t start_frame_idx, Flags flags);
+
   ThreadPlanStepOut(const ThreadPlanStepOut &) = delete;
   const ThreadPlanStepOut &operator=(const ThreadPlanStepOut &) = delete;
 };
diff --git a/lldb/source/Target/ThreadPlanStepOut.cpp 
b/lldb/source/Target/ThreadPlanStepOut.cpp
index a05c46db6b8ca..ef060b376407d 100644
--- a/lldb/source/Target/ThreadPlanStepOut.cpp
+++ b/lldb/source/Target/ThreadPlanStepOut.cpp
@@ -29,14 +29,44 @@
 using namespace lldb;
 using namespace lldb_private;
 
-uint32_t ThreadPlanStepOut::s_default_flag_values = 0;
+uint32_t ThreadPlanStepOut::s_default_flag_values =
+eStepOutPastArtificialFunctions | eStepOutPastHiddenFunctions;
+
+StackFrameSP ThreadPlanStepOut::ComputeReturnToFrame(Thread &thread,
+ uint32_t start_frame_idx,
+ Flags flags) {
+  uint32_t frame_idx = start_frame_idx + 1;
+  StackFrameSP return_frame_sp = thread.GetStackFrameAtIndex(frame_idx);
+  if (!return_frame_sp)
+return nullptr;
+
+  // If asked to, step out past artificial/hidden frames.
+  while ((flags.Test(eStepOutPastArtificialFunctions) &&
+  return_frame_sp->IsArtificial()) ||
+ (fla

[Lldb-commits] [lldb] [lldb][nfc] Add customization flags for ThreadPlanStepOut (PR #135866)

2025-04-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)


Changes

ThreadPlanStepOut always skips over Hidden/Artificial frames when computing its 
destination frame, without providing any customization of this behavior. This 
is problematic for some plans like StepThrough, which may need to step out of a 
frame _without_ stepping out of a Hidden/Artificial frame. Any first step 
towards fixing this requires the ability to customize ThreadPlanStepOut, which 
is what this NFC patch addresses.

Since the computation of which frames to skip is done by the constructor, this 
patch adds a Flags parameter to
`ThreadPlanStepOut::ThreadPlanStepOut`.

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


3 Files Affected:

- (modified) lldb/include/lldb/Target/ThreadPlanShouldStopHere.h (+3-1) 
- (modified) lldb/include/lldb/Target/ThreadPlanStepOut.h (+9-6) 
- (modified) lldb/source/Target/ThreadPlanStepOut.cpp (+36-21) 


``diff
diff --git a/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h 
b/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
index d0094c90b91a5..e712ee8d2d94f 100644
--- a/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
+++ b/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
@@ -60,7 +60,9 @@ class ThreadPlanShouldStopHere {
 eAvoidInlines = (1 << 0),
 eStepInAvoidNoDebug = (1 << 1),
 eStepOutAvoidNoDebug = (1 << 2),
-eStepOutPastThunks = (1 << 3)
+eStepOutPastThunks = (1 << 3),
+eStepOutPastHiddenFunctions = (1 << 4),
+eStepOutPastArtificialFunctions = (1 << 5),
   };
 
   // Constructors and Destructors
diff --git a/lldb/include/lldb/Target/ThreadPlanStepOut.h 
b/lldb/include/lldb/Target/ThreadPlanStepOut.h
index 013c675afc33d..c8eb334e4311c 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepOut.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepOut.h
@@ -17,12 +17,12 @@ namespace lldb_private {
 
 class ThreadPlanStepOut : public ThreadPlan, public ThreadPlanShouldStopHere {
 public:
-  ThreadPlanStepOut(Thread &thread, SymbolContext *addr_context,
-bool first_insn, bool stop_others, Vote report_stop_vote,
-Vote report_run_vote, uint32_t frame_idx,
-LazyBool step_out_avoids_code_without_debug_info,
-bool continue_to_next_branch = false,
-bool gather_return_value = true);
+  ThreadPlanStepOut(
+  Thread &thread, SymbolContext *addr_context, bool first_insn,
+  bool stop_others, Vote report_stop_vote, Vote report_run_vote,
+  uint32_t frame_idx, LazyBool step_out_avoids_code_without_debug_info,
+  bool continue_to_next_branch = false, bool gather_return_value = true,
+  lldb_private::Flags flags = ThreadPlanStepOut::s_default_flag_values);
 
   ~ThreadPlanStepOut() override;
 
@@ -87,6 +87,9 @@ class ThreadPlanStepOut : public ThreadPlan, public 
ThreadPlanShouldStopHere {
 
   void CalculateReturnValue();
 
+  lldb::StackFrameSP
+  ComputeReturnToFrame(Thread &thread, uint32_t start_frame_idx, Flags flags);
+
   ThreadPlanStepOut(const ThreadPlanStepOut &) = delete;
   const ThreadPlanStepOut &operator=(const ThreadPlanStepOut &) = delete;
 };
diff --git a/lldb/source/Target/ThreadPlanStepOut.cpp 
b/lldb/source/Target/ThreadPlanStepOut.cpp
index a05c46db6b8ca..ef060b376407d 100644
--- a/lldb/source/Target/ThreadPlanStepOut.cpp
+++ b/lldb/source/Target/ThreadPlanStepOut.cpp
@@ -29,14 +29,44 @@
 using namespace lldb;
 using namespace lldb_private;
 
-uint32_t ThreadPlanStepOut::s_default_flag_values = 0;
+uint32_t ThreadPlanStepOut::s_default_flag_values =
+eStepOutPastArtificialFunctions | eStepOutPastHiddenFunctions;
+
+StackFrameSP ThreadPlanStepOut::ComputeReturnToFrame(Thread &thread,
+ uint32_t start_frame_idx,
+ Flags flags) {
+  uint32_t frame_idx = start_frame_idx + 1;
+  StackFrameSP return_frame_sp = thread.GetStackFrameAtIndex(frame_idx);
+  if (!return_frame_sp)
+return nullptr;
+
+  // If asked to, step out past artificial/hidden frames.
+  while ((flags.Test(eStepOutPastArtificialFunctions) &&
+  return_frame_sp->IsArtificial()) ||
+ (flags.Test(eStepOutPastHiddenFunctions) &&
+  return_frame_sp->IsHidden())) {
+m_stepped_past_frames.push_back(return_frame_sp);
+
+frame_idx++;
+return_frame_sp = thread.GetStackFrameAtIndex(frame_idx);
+
+// We never expect to see an artificial frame without a regular ancestor.
+// Defensively refuse to step out.
+if (!return_frame_sp) {
+  LLDB_LOG(GetLog(LLDBLog::Step),
+   "Can't step out of frame with artificial ancestors");
+  return nullptr;
+}
+  }
+  return return_frame_sp;
+}
 
 // ThreadPlanStepOut: Step out of the current frame
 ThreadPlanStepOut::ThreadPlanStepOut(
 Thread &thread, SymbolContext *context, bool first_insn, bool stop_ot

[Lldb-commits] [lldb] [lldb][nfc] Add customization flags for ThreadPlanStepOut (PR #135866)

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

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

>From 3804a622a92ed541e4ee1a40298442e78b687507 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Tue, 15 Apr 2025 10:20:41 -0700
Subject: [PATCH] [lldb][nfc] Add customization flags for ThreadPlanStepOut

ThreadPlanStepOut always skips over Hidden/Artificial frames when
computing its destination frame, without providing any customization of
this behavior. This is problematic for some plans like StepThrough,
which may need to step out of a frame _without_ stepping out of a
Hidden/Artificial frame. Any first step towards fixing this requires the
ability to customize ThreadPlanStepOut, which is what this NFC patch
addresses.

Since the computation of which frames to skip is done by the
constructor, this patch adds a Flags parameter to
`ThreadPlanStepOut::ThreadPlanStepOut`.
---
 .../lldb/Target/ThreadPlanShouldStopHere.h|  4 +-
 lldb/include/lldb/Target/ThreadPlanStepOut.h  | 16 --
 lldb/source/Target/ThreadPlanStepOut.cpp  | 56 ---
 3 files changed, 48 insertions(+), 28 deletions(-)

diff --git a/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h 
b/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
index d0094c90b91a5..e712ee8d2d94f 100644
--- a/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
+++ b/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
@@ -60,7 +60,9 @@ class ThreadPlanShouldStopHere {
 eAvoidInlines = (1 << 0),
 eStepInAvoidNoDebug = (1 << 1),
 eStepOutAvoidNoDebug = (1 << 2),
-eStepOutPastThunks = (1 << 3)
+eStepOutPastThunks = (1 << 3),
+eStepOutPastHiddenFunctions = (1 << 4),
+eStepOutPastArtificialFunctions = (1 << 5),
   };
 
   // Constructors and Destructors
diff --git a/lldb/include/lldb/Target/ThreadPlanStepOut.h 
b/lldb/include/lldb/Target/ThreadPlanStepOut.h
index 013c675afc33d..030e532fe4d57 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepOut.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepOut.h
@@ -17,12 +17,12 @@ namespace lldb_private {
 
 class ThreadPlanStepOut : public ThreadPlan, public ThreadPlanShouldStopHere {
 public:
-  ThreadPlanStepOut(Thread &thread, SymbolContext *addr_context,
-bool first_insn, bool stop_others, Vote report_stop_vote,
-Vote report_run_vote, uint32_t frame_idx,
-LazyBool step_out_avoids_code_without_debug_info,
-bool continue_to_next_branch = false,
-bool gather_return_value = true);
+  ThreadPlanStepOut(
+  Thread &thread, SymbolContext *addr_context, bool first_insn,
+  bool stop_others, Vote report_stop_vote, Vote report_run_vote,
+  uint32_t frame_idx, LazyBool step_out_avoids_code_without_debug_info,
+  bool continue_to_next_branch = false, bool gather_return_value = true,
+  lldb_private::Flags flags = ThreadPlanStepOut::s_default_flag_values);
 
   ~ThreadPlanStepOut() override;
 
@@ -87,6 +87,10 @@ class ThreadPlanStepOut : public ThreadPlan, public 
ThreadPlanShouldStopHere {
 
   void CalculateReturnValue();
 
+  /// Computes the target frame this plan should step out to.
+  lldb::StackFrameSP ComputeTargetFrame(Thread &thread,
+uint32_t start_frame_idx, Flags flags);
+
   ThreadPlanStepOut(const ThreadPlanStepOut &) = delete;
   const ThreadPlanStepOut &operator=(const ThreadPlanStepOut &) = delete;
 };
diff --git a/lldb/source/Target/ThreadPlanStepOut.cpp 
b/lldb/source/Target/ThreadPlanStepOut.cpp
index a05c46db6b8ca..340abd6731d0c 100644
--- a/lldb/source/Target/ThreadPlanStepOut.cpp
+++ b/lldb/source/Target/ThreadPlanStepOut.cpp
@@ -29,14 +29,44 @@
 using namespace lldb;
 using namespace lldb_private;
 
-uint32_t ThreadPlanStepOut::s_default_flag_values = 0;
+uint32_t ThreadPlanStepOut::s_default_flag_values =
+eStepOutPastArtificialFunctions | eStepOutPastHiddenFunctions;
+
+StackFrameSP ThreadPlanStepOut::ComputeTargetFrame(Thread &thread,
+   uint32_t start_frame_idx,
+   Flags flags) {
+  uint32_t frame_idx = start_frame_idx + 1;
+  StackFrameSP return_frame_sp = thread.GetStackFrameAtIndex(frame_idx);
+  if (!return_frame_sp)
+return nullptr;
+
+  // If asked to, step out past artificial/hidden frames.
+  while ((flags.Test(eStepOutPastArtificialFunctions) &&
+  return_frame_sp->IsArtificial()) ||
+ (flags.Test(eStepOutPastHiddenFunctions) &&
+  return_frame_sp->IsHidden())) {
+m_stepped_past_frames.push_back(return_frame_sp);
+
+frame_idx++;
+return_frame_sp = thread.GetStackFrameAtIndex(frame_idx);
+
+// We never expect to see an artificial frame without a regular ancestor.
+// Defensively refuse to step out.
+if (!return_frame_sp) {
+  LLDB_LOG(GetLog(LLDBLog::Step),
+   "Can't step out of frame with artificial ancestors");
+  re

[Lldb-commits] [lldb] [lldb][nfc] Remove redundant check in if statement (PR #135869)

2025-04-15 Thread via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb][nfc] Add customization flags for ThreadPlanStepOut (PR #135866)

2025-04-15 Thread via lldb-commits

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

My original notion was that instead of passing in flags to the setup of 
ThreadPlanStepOut and having it compute where it should go based on that, the 
plan that was deciding to step out would call 
ThreadPlanShouldStopHere::CheckShouldStopHereAndQueueStepOut, and that would 
figure out based on the flags of that plan what frame it should step out to, 
then it would queue up a ThreadPlanStepOut that would go to that frame.  

In that version ComputeTargetFrame would be logic in the 
StepOutFromHereCallback.  I was trying to keep all the strategy decisions about 
where to go in the ShouldStopHere callbacks so that they could be reused more 
easily.

In this version, the StepOutFromHere callback figures out which flags it wants 
to use, and then passes them to the ThreadPlanStepOut, which computes where to 
go.  I'm not sure that makes much difference; once we're deciding to go to 
older frames on the stack we're really only going to use a ThreadPlanStepOut, 
so it doesn't much matter where that logic is.

LGTM

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


[Lldb-commits] [lldb] [llvm] [Support] [lldb] Fix thread jump #45326 (PR #135778)

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

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

>From 73fc9565d973fd7e1ce92b005696f17c9a9acd5f Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 15 Apr 2025 12:21:59 +0100
Subject: [PATCH 1/4] [Support] Recognise the '+' char for positive integers

Fixes https://github.com/llvm/llvm-project/issues/45326

Signed-off-by: Ebuka Ezike 
---
 llvm/lib/Support/StringRef.cpp   |  3 +++
 llvm/unittests/ADT/StringRefTest.cpp | 28 +++-
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index 4f5fcb4857e80..bdf7a9aa5c7e0 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -409,6 +409,9 @@ static unsigned GetAutoSenseRadix(StringRef &Str) {
 
 bool llvm::consumeUnsignedInteger(StringRef &Str, unsigned Radix,
   unsigned long long &Result) {
+  // Consume the + value
+  Str.consume_front("+");
+
   // Autosense radix if not specified.
   if (Radix == 0)
 Radix = GetAutoSenseRadix(Str);
diff --git a/llvm/unittests/ADT/StringRefTest.cpp 
b/llvm/unittests/ADT/StringRefTest.cpp
index ec9cdc197597d..55d222a915ab5 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -622,19 +622,21 @@ TEST(StringRefTest, Hashing) {
 struct UnsignedPair {
   const char *Str;
   uint64_t Expected;
-} Unsigned[] =
-  { {"0", 0}
-  , {"255", 255}
-  , {"256", 256}
-  , {"65535", 65535}
-  , {"65536", 65536}
-  , {"4294967295", 4294967295ULL}
-  , {"4294967296", 4294967296ULL}
-  , {"18446744073709551615", 18446744073709551615ULL}
-  , {"042", 34}
-  , {"0x42", 66}
-  , {"0b101010", 42}
-  };
+} Unsigned[] = {{"0", 0},
+{"255", 255},
+{"256", 256},
+{"65535", 65535},
+{"65536", 65536},
+{"4294967295", 4294967295ULL},
+{"4294967296", 4294967296ULL},
+{"18446744073709551615", 18446744073709551615ULL},
+{"042", 34},
+{"0x42", 66},
+{"0b101010", 42},
+{"+42", 42},
+{"+042", 34},
+{"+0x42", 66},
+{"+0b101010", 42}};
 
 struct SignedPair {
   const char *Str;

>From 6ab61ef8ca7de96d3cdb6deb60c30fc1c8b6e9d2 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 15 Apr 2025 12:25:41 +0100
Subject: [PATCH 2/4] [lldb] Add test for jumping by offset

Signed-off-by: Ebuka Ezike 
---
 .../thread/jump/TestThreadJump.py | 70 ++-
 1 file changed, 69 insertions(+), 1 deletion(-)

diff --git a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py 
b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
index 3c13a969bc3fd..d603580ac6f36 100644
--- a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
+++ b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
@@ -10,9 +10,12 @@
 
 
 class ThreadJumpTestCase(TestBase):
+def setUp(self):
+TestBase.setUp(self)
+self.build()
+
 def test(self):
 """Test thread jump handling."""
-self.build()
 exe = self.getBuildArtifact("a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
@@ -62,6 +65,71 @@ def test(self):
 substrs=["error"],
 )
 
+def test_jump_offset(self):
+"""Test Thread Jump by negative or positive offset"""
+exe = self.getBuildArtifact("a.out")
+file_name = "main.cpp"
+self.runCmd(f"target create {exe}", CURRENT_EXECUTABLE_SET)
+
+pos_jump = line_number(file_name, "// jump_offset 1")
+neg_jump = line_number(file_name, "// jump_offset 2")
+pos_breakpoint = line_number(file_name, "// breakpoint 1")
+neg_breakpoint = line_number(file_name, "// breakpoint 2")
+pos_jump_offset = pos_jump - pos_breakpoint
+neg_jump_offset = neg_jump - neg_breakpoint
+
+var_1, var_1_value = ("var_1", "10")
+var_2, var_2_value = ("var_2", "40")
+var_3, var_3_value = ("var_3", "10")
+
+# create pos_breakpoint and neg_breakpoint
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, pos_breakpoint, num_expected_locations=1
+)
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, neg_breakpoint, num_expected_locations=1
+)
+
+self.runCmd("run", RUN_SUCCEEDED)
+
+# test positive jump
+# The stop reason of the thread should be breakpoint 1.
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT + " 1",
+substrs=[
+"stopped",
+f"{file_name}:{pos_breakpoint}",
+"stop reason = breakpoint 1",
+],
+)
+
+self.runCmd(f"thread jump --by +{pos_jump_offset}")
+self.expect("process status", substrs=[f"at {fil

[Lldb-commits] [lldb] [llvm] [Support] [lldb] Fix thread jump #45326 (PR #135778)

2025-04-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-support

Author: Ebuka Ezike (da-viper)


Changes

Fixes #45326 

When you thread jump by calling 
`j +2` or `thread jump --by +2`  the offset is not recognised. This commit 
fixes that. 

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


3 Files Affected:

- (modified) lldb/test/API/functionalities/thread/jump/TestThreadJump.py 
(+69-1) 
- (modified) llvm/lib/Support/StringRef.cpp (+3) 
- (modified) llvm/unittests/ADT/StringRefTest.cpp (+15-13) 


``diff
diff --git a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py 
b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
index 3c13a969bc3fd..d603580ac6f36 100644
--- a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
+++ b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
@@ -10,9 +10,12 @@
 
 
 class ThreadJumpTestCase(TestBase):
+def setUp(self):
+TestBase.setUp(self)
+self.build()
+
 def test(self):
 """Test thread jump handling."""
-self.build()
 exe = self.getBuildArtifact("a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
@@ -62,6 +65,71 @@ def test(self):
 substrs=["error"],
 )
 
+def test_jump_offset(self):
+"""Test Thread Jump by negative or positive offset"""
+exe = self.getBuildArtifact("a.out")
+file_name = "main.cpp"
+self.runCmd(f"target create {exe}", CURRENT_EXECUTABLE_SET)
+
+pos_jump = line_number(file_name, "// jump_offset 1")
+neg_jump = line_number(file_name, "// jump_offset 2")
+pos_breakpoint = line_number(file_name, "// breakpoint 1")
+neg_breakpoint = line_number(file_name, "// breakpoint 2")
+pos_jump_offset = pos_jump - pos_breakpoint
+neg_jump_offset = neg_jump - neg_breakpoint
+
+var_1, var_1_value = ("var_1", "10")
+var_2, var_2_value = ("var_2", "40")
+var_3, var_3_value = ("var_3", "10")
+
+# create pos_breakpoint and neg_breakpoint
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, pos_breakpoint, num_expected_locations=1
+)
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, neg_breakpoint, num_expected_locations=1
+)
+
+self.runCmd("run", RUN_SUCCEEDED)
+
+# test positive jump
+# The stop reason of the thread should be breakpoint 1.
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT + " 1",
+substrs=[
+"stopped",
+f"{file_name}:{pos_breakpoint}",
+"stop reason = breakpoint 1",
+],
+)
+
+self.runCmd(f"thread jump --by +{pos_jump_offset}")
+self.expect("process status", substrs=[f"at {file_name}:{pos_jump}"])
+self.expect(f"print {var_1}", substrs=[var_1_value])
+
+self.runCmd("thread step-over")
+self.expect(f"print {var_2}", substrs=[var_2_value])
+
+self.runCmd("continue")
+
+# test negative jump
+# The stop reason of the thread should be breakpoint 1.
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT + " 2",
+substrs=[
+"stopped",
+f"{file_name}:{neg_breakpoint}",
+"stop reason = breakpoint 2",
+],
+)
+
+self.runCmd(f"thread jump --by {neg_jump_offset}")
+self.expect("process status", substrs=[f"at {file_name}:{neg_jump}"])
+self.runCmd("thread step-over")
+self.expect(f"print {var_3}", substrs=[var_3_value])
+
 def do_min_test(self, start, jump, var, value):
 # jump to the start marker
 self.runCmd("j %i" % start)
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index 4f5fcb4857e80..bdf7a9aa5c7e0 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -409,6 +409,9 @@ static unsigned GetAutoSenseRadix(StringRef &Str) {
 
 bool llvm::consumeUnsignedInteger(StringRef &Str, unsigned Radix,
   unsigned long long &Result) {
+  // Consume the + value
+  Str.consume_front("+");
+
   // Autosense radix if not specified.
   if (Radix == 0)
 Radix = GetAutoSenseRadix(Str);
diff --git a/llvm/unittests/ADT/StringRefTest.cpp 
b/llvm/unittests/ADT/StringRefTest.cpp
index ec9cdc197597d..55d222a915ab5 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -622,19 +622,21 @@ TEST(StringRefTest, Hashing) {
 struct UnsignedPair {
   const char *Str;
   uint64_t Expected;
-} Unsigned[] =
-  { {"0", 0}
-  , {"255", 255}
-  , {"256", 256}
-  , {"65535", 65535}
-  , {"65536", 65536}
-  , {"4294967295", 4294967295ULL}
-  , {"4294967296", 4294967296ULL}
-  , {"18446744073709551615", 18446744073709551615ULL}
-  , {"042", 34}
-  , {"0x42", 66}
-  , {"0b101010", 4

[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap 'launch' request to use typed RequestHandler<>. (PR #133624)

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

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/133624

>From 3240fe49515e5f59c5b9ff9c02423b77504d8a43 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Fri, 28 Mar 2025 14:02:53 -0700
Subject: [PATCH 1/5] [lldb-dap] Refactoring lldb-dap 'launch' request to use
 typed RequestHandler<>.

This converts a number of json::Value's into well defined types that are used 
throughout lldb-dap and updates the 'launch' command to use the new well 
defined types.
---
 .../test/tools/lldb-dap/dap_server.py |   3 +-
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   2 +-
 .../tools/lldb-dap/launch/TestDAP_launch.py   |   6 +-
 .../restart/TestDAP_restart_runInTerminal.py  |   4 +-
 .../runInTerminal/TestDAP_runInTerminal.py|  16 +-
 lldb/tools/lldb-dap/DAP.cpp   |  82 +---
 lldb/tools/lldb-dap/DAP.h |  44 +++--
 .../lldb-dap/Handler/AttachRequestHandler.cpp |  33 ++--
 .../lldb-dap/Handler/CompletionsHandler.cpp   |   7 +-
 .../Handler/EvaluateRequestHandler.cpp|   3 +-
 .../lldb-dap/Handler/LaunchRequestHandler.cpp | 118 +++-
 .../tools/lldb-dap/Handler/RequestHandler.cpp |  96 +-
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  19 +-
 .../Handler/RestartRequestHandler.cpp |  54 --
 .../Handler/SetVariableRequestHandler.cpp |   3 +-
 .../Handler/StackTraceRequestHandler.cpp  |   2 +-
 .../Handler/VariablesRequestHandler.cpp   |  20 +-
 lldb/tools/lldb-dap/JSONUtils.cpp |  48 ++---
 lldb/tools/lldb-dap/JSONUtils.h   |  11 +-
 .../lldb-dap/Protocol/ProtocolRequests.cpp| 175 +-
 .../lldb-dap/Protocol/ProtocolRequests.h  | 150 +++
 lldb/tools/lldb-dap/SourceBreakpoint.cpp  |   6 +-
 22 files changed, 616 insertions(+), 286 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 01ef4b68f2653..6e13fcddcc933 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
@@ -862,7 +862,8 @@ def request_launch(
 args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
 args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
 args_dict["displayExtendedBacktrace"] = displayExtendedBacktrace
-args_dict["commandEscapePrefix"] = commandEscapePrefix
+if commandEscapePrefix:
+args_dict["commandEscapePrefix"] = commandEscapePrefix
 command_dict = {"command": "launch", "type": "request", "arguments": 
args_dict}
 response = self.send_recv(command_dict)
 
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..9ab8a905a79dd 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
@@ -443,7 +443,7 @@ def cleanup():
 
 if not (response and response["success"]):
 self.assertTrue(
-response["success"], "launch failed (%s)" % 
(response["message"])
+response["success"], "launch failed (%s)" % 
(response["body"]["error"]["format"])
 )
 return response
 
diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py 
b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
index 64c99019a1c9b..c6a3e9cc879a4 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
@@ -41,7 +41,9 @@ def test_termination(self):
 self.dap_server.request_disconnect()
 
 # Wait until the underlying lldb-dap process dies.
-
self.dap_server.process.wait(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval)
+self.dap_server.process.wait(
+timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval
+)
 
 # Check the return code
 self.assertEqual(self.dap_server.process.poll(), 0)
@@ -459,7 +461,7 @@ def test_failing_launch_commands(self):
 
 self.assertFalse(response["success"])
 self.assertRegex(
-response["message"],
+response["body"]["error"]["format"],
 r"Failed to run launch commands\. See the Debug Console for more 
details",
 )
 
diff --git 
a/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py 
b/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py
index 5a9938c25c2c8..a94c9860c1508 100644
--- a/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py
@@ -21,7 +21,7 @@ def isTestSupported(self):
 return False
 
 @skipIfWindows
-@skipIf(archs=["arm"])  #

[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap 'launch' request to use typed RequestHandler<>. (PR #133624)

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


@@ -33,15 +35,12 @@ MakeArgv(const llvm::ArrayRef &strs) {
   return argv;
 }
 
-static uint32_t SetLaunchFlag(uint32_t flags, const llvm::json::Object *obj,
-  llvm::StringRef key, lldb::LaunchFlags mask) {
-  if (const auto opt_value = GetBoolean(obj, key)) {
-if (*opt_value)
-  flags |= mask;
-else
-  flags &= ~mask;
-  }
-
+static uint32_t SetLaunchFlag(uint32_t flags, bool opt,
+  lldb::LaunchFlags mask) {
+  if (opt)
+flags |= mask;
+  else
+flags &= ~mask;
   return flags;
 }

ashgti wrote:

I'm not sure I understand this issue. For example, the `disableASLR`. If a user 
launched with:

```json
{
  "type": "lldb-dap",
  "request": "launch",
  "name": "Debug a.out",
  "program": "a.out"
}
```

This would default to `stopOnEntry == false`.

If the user launched with:

```json
{
  "type": "lldb-dap",
  "request": "launch",
  "name": "Debug a.out",
  "program": "a.out",
  "stopOnEntry": false
}
```

This would also set `stopOnEntry == false`.

If a user launched with:

```json
{
  "type": "lldb-dap",
  "request": "launch",
  "name": "Debug a.out",
  "program": "a.out",
  "stopOnEntry": true
}
```

This would result in `stopOnEntry == true`.

I guess the only complicated example is the `disableASLR` flag because that is 
enabled by default because of 
https://github.com/llvm/llvm-project/blob/af63e1b505453de3e6a281d1b72e62fa8d396b23/lldb/source/API/SBLaunchInfo.cpp#L47
 so its flag that is defaulted to `true` implicitly.


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


[Lldb-commits] [lldb] [lldb] returning command completions up to a maximum (PR #135565)

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

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

>From 79e1ae6ac953ab5d3e1eb3dae75745a01d7d7a56 Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 13 Apr 2025 20:46:56 +0200
Subject: [PATCH 1/2] [lldb] returning command completions up to a maximum

- Adding `max_return_elements` field to `CompletionRequest`.
- adding maximum checks to `SymbolCompleter` and `SourceFileCompleter`.
---
 lldb/include/lldb/Utility/CompletionRequest.h | 24 +++
 lldb/source/API/SBCommandInterpreter.cpp  |  2 ++
 lldb/source/Commands/CommandCompletions.cpp   | 14 ---
 3 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Utility/CompletionRequest.h 
b/lldb/include/lldb/Utility/CompletionRequest.h
index 865d6db576298..2d3f0a8a44a0a 100644
--- a/lldb/include/lldb/Utility/CompletionRequest.h
+++ b/lldb/include/lldb/Utility/CompletionRequest.h
@@ -115,6 +115,11 @@ class CompletionRequest {
   CompletionRequest(llvm::StringRef command_line, unsigned raw_cursor_pos,
 CompletionResult &result);
 
+  /// Sets the maximum number of completions that should be returned.
+  void SetMaxReturnElements(size_t max_return_elements) {
+m_max_return_elements = max_return_elements;
+  }
+
   /// Returns the raw user input used to create this CompletionRequest cut off
   /// at the cursor position. The cursor will be at the end of the raw line.
   llvm::StringRef GetRawLine() const {
@@ -157,6 +162,23 @@ class CompletionRequest {
 
   size_t GetCursorIndex() const { return m_cursor_index; }
 
+  size_t GetMaxReturnElements() const { return m_max_return_elements; }
+
+  /// Returns true if the maximum number of completions has been reached
+  /// already.
+  bool ShouldStopAddingResults() const {
+return m_result.GetNumberOfResults() >= m_max_return_elements;
+  }
+
+  /// Returns the maximum number of completions that need to be added
+  /// until reaching the maximum
+  size_t GetMaxNumberOfResultsToAdd() const {
+const size_t number_of_results = m_result.GetNumberOfResults();
+if (number_of_results >= m_max_return_elements)
+  return 0;
+return m_max_return_elements - number_of_results;
+  }
+
   /// Adds a possible completion string. If the completion was already
   /// suggested before, it will not be added to the list of results. A copy of
   /// the suggested completion is stored, so the given string can be free'd
@@ -231,6 +253,8 @@ class CompletionRequest {
   size_t m_cursor_index;
   /// The cursor position in the argument indexed by m_cursor_index.
   size_t m_cursor_char_position;
+  /// The maximum number of completions that should be returned.
+  size_t m_max_return_elements = SIZE_MAX;
 
   /// The result this request is supposed to fill out.
   /// We keep this object private to ensure that no backend can in any way
diff --git a/lldb/source/API/SBCommandInterpreter.cpp 
b/lldb/source/API/SBCommandInterpreter.cpp
index de22a9dd96bd8..ad3cc3c556fd4 100644
--- a/lldb/source/API/SBCommandInterpreter.cpp
+++ b/lldb/source/API/SBCommandInterpreter.cpp
@@ -266,6 +266,8 @@ int SBCommandInterpreter::HandleCompletionWithDescriptions(
   lldb_private::StringList lldb_matches, lldb_descriptions;
   CompletionResult result;
   CompletionRequest request(current_line, cursor - current_line, result);
+  if (max_return_elements >= 0)
+request.SetMaxReturnElements(max_return_elements);
   m_opaque_ptr->HandleCompletion(request);
   result.GetMatches(lldb_matches);
   result.GetDescriptions(lldb_descriptions);
diff --git a/lldb/source/Commands/CommandCompletions.cpp 
b/lldb/source/Commands/CommandCompletions.cpp
index 216aaf9abce6c..11cb94d4eda15 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -91,7 +91,7 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks(
nullptr} // This one has to be last in the list.
   };
 
-  for (int i = 0;; i++) {
+  for (int i = 0; !request.ShouldStopAddingResults(); i++) {
 if (common_completions[i].type == lldb::eTerminatorCompletion)
   break;
 else if ((common_completions[i].type & completion_mask) ==
@@ -167,7 +167,9 @@ class SourceFileCompleter : public Completer {
 m_matching_files.AppendIfUnique(context.comp_unit->GetPrimaryFile());
   }
 }
-return Searcher::eCallbackReturnContinue;
+return m_matching_files.GetSize() >= m_request.GetMaxNumberOfResultsToAdd()
+   ? Searcher::eCallbackReturnStop
+   : Searcher::eCallbackReturnContinue;
   }
 
   void DoCompletion(SearchFilter *filter) override {
@@ -230,6 +232,10 @@ class SymbolCompleter : public Completer {
 
   // Now add the functions & symbols to the list - only add if unique:
   for (const SymbolContext &sc : sc_list) {
+if (m_match_set.size() >= m_request.GetMaxNumberOfResultsToAdd()) {
+  break;
+}
+
 ConstString func_name = sc.GetFunctionName(Mang

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

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


@@ -1217,28 +1217,36 @@ 
PluginManager::GetSymbolLocatorCreateCallbackAtIndex(uint32_t idx) {
 }
 
 ModuleSpec
-PluginManager::LocateExecutableObjectFile(const ModuleSpec &module_spec) {
+PluginManager::LocateExecutableObjectFile(const ModuleSpec &module_spec,
+  std::string *locator_name) {
   auto instances = GetSymbolLocatorInstances().GetSnapshot();
   for (auto &instance : instances) {
 if (instance.locate_executable_object_file) {
   std::optional result =
   instance.locate_executable_object_file(module_spec);
-  if (result)
+  if (result) {

Jlalond wrote:

would it be cleaner/easier to do `if(!result) return {};` as a guard clause to 
have less nested ifs?

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


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

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

https://github.com/Jlalond commented:

Just a nit or to. LGTM, but I'll defer to Greg.

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


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

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


@@ -1217,28 +1217,36 @@ 
PluginManager::GetSymbolLocatorCreateCallbackAtIndex(uint32_t idx) {
 }
 
 ModuleSpec
-PluginManager::LocateExecutableObjectFile(const ModuleSpec &module_spec) {
+PluginManager::LocateExecutableObjectFile(const ModuleSpec &module_spec,
+  std::string *locator_name) {
   auto instances = GetSymbolLocatorInstances().GetSnapshot();
   for (auto &instance : instances) {
 if (instance.locate_executable_object_file) {
   std::optional result =
   instance.locate_executable_object_file(module_spec);
-  if (result)
+  if (result) {
+if (locator_name)
+  *locator_name = instance.name;
 return *result;
+  }
 }
   }
   return {};
 }
 
 FileSpec PluginManager::LocateExecutableSymbolFile(
-const ModuleSpec &module_spec, const FileSpecList &default_search_paths) {
+const ModuleSpec &module_spec, const FileSpecList &default_search_paths,
+std::string *locator_name) {
   auto instances = GetSymbolLocatorInstances().GetSnapshot();
   for (auto &instance : instances) {
 if (instance.locate_executable_symbol_file) {
   std::optional result = instance.locate_executable_symbol_file(
   module_spec, default_search_paths);
-  if (result)
+  if (result) {

Jlalond wrote:

same question about nesting.

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


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

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

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


[Lldb-commits] [lldb] [llvm] [Support] [lldb] Fix thread jump #45326 (PR #135778)

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

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

Fixes #45326 

When you thread jump by calling 
`j +2` or `thread jump --by +2`  the offset is not recognised. This commit 
fixes that. 

>From de43c70a26f5c6fb72f836804f2b3ed6851a0cc7 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 15 Apr 2025 12:21:59 +0100
Subject: [PATCH 1/2] [Support] Recognise the '+' char for positive integers

Fixes https://github.com/llvm/llvm-project/issues/45326

Signed-off-by: Ebuka Ezike 
---
 llvm/lib/Support/StringRef.cpp   |  3 +++
 llvm/unittests/ADT/StringRefTest.cpp | 28 +++-
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index 4f5fcb4857e80..bdf7a9aa5c7e0 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -409,6 +409,9 @@ static unsigned GetAutoSenseRadix(StringRef &Str) {
 
 bool llvm::consumeUnsignedInteger(StringRef &Str, unsigned Radix,
   unsigned long long &Result) {
+  // Consume the + value
+  Str.consume_front("+");
+
   // Autosense radix if not specified.
   if (Radix == 0)
 Radix = GetAutoSenseRadix(Str);
diff --git a/llvm/unittests/ADT/StringRefTest.cpp 
b/llvm/unittests/ADT/StringRefTest.cpp
index ec9cdc197597d..55d222a915ab5 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -622,19 +622,21 @@ TEST(StringRefTest, Hashing) {
 struct UnsignedPair {
   const char *Str;
   uint64_t Expected;
-} Unsigned[] =
-  { {"0", 0}
-  , {"255", 255}
-  , {"256", 256}
-  , {"65535", 65535}
-  , {"65536", 65536}
-  , {"4294967295", 4294967295ULL}
-  , {"4294967296", 4294967296ULL}
-  , {"18446744073709551615", 18446744073709551615ULL}
-  , {"042", 34}
-  , {"0x42", 66}
-  , {"0b101010", 42}
-  };
+} Unsigned[] = {{"0", 0},
+{"255", 255},
+{"256", 256},
+{"65535", 65535},
+{"65536", 65536},
+{"4294967295", 4294967295ULL},
+{"4294967296", 4294967296ULL},
+{"18446744073709551615", 18446744073709551615ULL},
+{"042", 34},
+{"0x42", 66},
+{"0b101010", 42},
+{"+42", 42},
+{"+042", 34},
+{"+0x42", 66},
+{"+0b101010", 42}};
 
 struct SignedPair {
   const char *Str;

>From c89501a8299e77c92554fa608968ba2cc670838e Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 15 Apr 2025 12:25:41 +0100
Subject: [PATCH 2/2] [lldb] Add test for jumping by offset

Signed-off-by: Ebuka Ezike 
---
 .../thread/jump/TestThreadJump.py | 70 ++-
 1 file changed, 69 insertions(+), 1 deletion(-)

diff --git a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py 
b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
index 3c13a969bc3fd..d603580ac6f36 100644
--- a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
+++ b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
@@ -10,9 +10,12 @@
 
 
 class ThreadJumpTestCase(TestBase):
+def setUp(self):
+TestBase.setUp(self)
+self.build()
+
 def test(self):
 """Test thread jump handling."""
-self.build()
 exe = self.getBuildArtifact("a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
@@ -62,6 +65,71 @@ def test(self):
 substrs=["error"],
 )
 
+def test_jump_offset(self):
+"""Test Thread Jump by negative or positive offset"""
+exe = self.getBuildArtifact("a.out")
+file_name = "main.cpp"
+self.runCmd(f"target create {exe}", CURRENT_EXECUTABLE_SET)
+
+pos_jump = line_number(file_name, "// jump_offset 1")
+neg_jump = line_number(file_name, "// jump_offset 2")
+pos_breakpoint = line_number(file_name, "// breakpoint 1")
+neg_breakpoint = line_number(file_name, "// breakpoint 2")
+pos_jump_offset = pos_jump - pos_breakpoint
+neg_jump_offset = neg_jump - neg_breakpoint
+
+var_1, var_1_value = ("var_1", "10")
+var_2, var_2_value = ("var_2", "40")
+var_3, var_3_value = ("var_3", "10")
+
+# create pos_breakpoint and neg_breakpoint
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, pos_breakpoint, num_expected_locations=1
+)
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, neg_breakpoint, num_expected_locations=1
+)
+
+self.runCmd("run", RUN_SUCCEEDED)
+
+# test positive jump
+# The stop reason of the thread should be breakpoint 1.
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT + " 1",
+substrs=[
+"stopped",
+f"{file_name}:{pos_breakpoint}",
+"stop reason = breakpoint 1",
+

[Lldb-commits] [lldb] [llvm] [Support] [lldb] Fix thread jump #45326 (PR #135778)

2025-04-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)


Changes

Fixes #45326 

When you thread jump by calling 
`j +2` or `thread jump --by +2`  the offset is not recognised. This commit 
fixes that. 

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


3 Files Affected:

- (modified) lldb/test/API/functionalities/thread/jump/TestThreadJump.py 
(+69-1) 
- (modified) llvm/lib/Support/StringRef.cpp (+3) 
- (modified) llvm/unittests/ADT/StringRefTest.cpp (+15-13) 


``diff
diff --git a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py 
b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
index 3c13a969bc3fd..d603580ac6f36 100644
--- a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
+++ b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
@@ -10,9 +10,12 @@
 
 
 class ThreadJumpTestCase(TestBase):
+def setUp(self):
+TestBase.setUp(self)
+self.build()
+
 def test(self):
 """Test thread jump handling."""
-self.build()
 exe = self.getBuildArtifact("a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
@@ -62,6 +65,71 @@ def test(self):
 substrs=["error"],
 )
 
+def test_jump_offset(self):
+"""Test Thread Jump by negative or positive offset"""
+exe = self.getBuildArtifact("a.out")
+file_name = "main.cpp"
+self.runCmd(f"target create {exe}", CURRENT_EXECUTABLE_SET)
+
+pos_jump = line_number(file_name, "// jump_offset 1")
+neg_jump = line_number(file_name, "// jump_offset 2")
+pos_breakpoint = line_number(file_name, "// breakpoint 1")
+neg_breakpoint = line_number(file_name, "// breakpoint 2")
+pos_jump_offset = pos_jump - pos_breakpoint
+neg_jump_offset = neg_jump - neg_breakpoint
+
+var_1, var_1_value = ("var_1", "10")
+var_2, var_2_value = ("var_2", "40")
+var_3, var_3_value = ("var_3", "10")
+
+# create pos_breakpoint and neg_breakpoint
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, pos_breakpoint, num_expected_locations=1
+)
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, neg_breakpoint, num_expected_locations=1
+)
+
+self.runCmd("run", RUN_SUCCEEDED)
+
+# test positive jump
+# The stop reason of the thread should be breakpoint 1.
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT + " 1",
+substrs=[
+"stopped",
+f"{file_name}:{pos_breakpoint}",
+"stop reason = breakpoint 1",
+],
+)
+
+self.runCmd(f"thread jump --by +{pos_jump_offset}")
+self.expect("process status", substrs=[f"at {file_name}:{pos_jump}"])
+self.expect(f"print {var_1}", substrs=[var_1_value])
+
+self.runCmd("thread step-over")
+self.expect(f"print {var_2}", substrs=[var_2_value])
+
+self.runCmd("continue")
+
+# test negative jump
+# The stop reason of the thread should be breakpoint 1.
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT + " 2",
+substrs=[
+"stopped",
+f"{file_name}:{neg_breakpoint}",
+"stop reason = breakpoint 2",
+],
+)
+
+self.runCmd(f"thread jump --by {neg_jump_offset}")
+self.expect("process status", substrs=[f"at {file_name}:{neg_jump}"])
+self.runCmd("thread step-over")
+self.expect(f"print {var_3}", substrs=[var_3_value])
+
 def do_min_test(self, start, jump, var, value):
 # jump to the start marker
 self.runCmd("j %i" % start)
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index 4f5fcb4857e80..bdf7a9aa5c7e0 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -409,6 +409,9 @@ static unsigned GetAutoSenseRadix(StringRef &Str) {
 
 bool llvm::consumeUnsignedInteger(StringRef &Str, unsigned Radix,
   unsigned long long &Result) {
+  // Consume the + value
+  Str.consume_front("+");
+
   // Autosense radix if not specified.
   if (Radix == 0)
 Radix = GetAutoSenseRadix(Str);
diff --git a/llvm/unittests/ADT/StringRefTest.cpp 
b/llvm/unittests/ADT/StringRefTest.cpp
index ec9cdc197597d..55d222a915ab5 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -622,19 +622,21 @@ TEST(StringRefTest, Hashing) {
 struct UnsignedPair {
   const char *Str;
   uint64_t Expected;
-} Unsigned[] =
-  { {"0", 0}
-  , {"255", 255}
-  , {"256", 256}
-  , {"65535", 65535}
-  , {"65536", 65536}
-  , {"4294967295", 4294967295ULL}
-  , {"4294967296", 4294967296ULL}
-  , {"18446744073709551615", 18446744073709551615ULL}
-  , {"042", 34}
-  , {"0x42", 66}
-  , {"0b101010", 42}
-  };

[Lldb-commits] [lldb] [llvm] [Support] [lldb] Fix thread jump #45326 (PR #135778)

2025-04-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-adt

Author: Ebuka Ezike (da-viper)


Changes

Fixes #45326 

When you thread jump by calling 
`j +2` or `thread jump --by +2`  the offset is not recognised. This commit 
fixes that. 

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


3 Files Affected:

- (modified) lldb/test/API/functionalities/thread/jump/TestThreadJump.py 
(+69-1) 
- (modified) llvm/lib/Support/StringRef.cpp (+3) 
- (modified) llvm/unittests/ADT/StringRefTest.cpp (+15-13) 


``diff
diff --git a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py 
b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
index 3c13a969bc3fd..d603580ac6f36 100644
--- a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
+++ b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
@@ -10,9 +10,12 @@
 
 
 class ThreadJumpTestCase(TestBase):
+def setUp(self):
+TestBase.setUp(self)
+self.build()
+
 def test(self):
 """Test thread jump handling."""
-self.build()
 exe = self.getBuildArtifact("a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
@@ -62,6 +65,71 @@ def test(self):
 substrs=["error"],
 )
 
+def test_jump_offset(self):
+"""Test Thread Jump by negative or positive offset"""
+exe = self.getBuildArtifact("a.out")
+file_name = "main.cpp"
+self.runCmd(f"target create {exe}", CURRENT_EXECUTABLE_SET)
+
+pos_jump = line_number(file_name, "// jump_offset 1")
+neg_jump = line_number(file_name, "// jump_offset 2")
+pos_breakpoint = line_number(file_name, "// breakpoint 1")
+neg_breakpoint = line_number(file_name, "// breakpoint 2")
+pos_jump_offset = pos_jump - pos_breakpoint
+neg_jump_offset = neg_jump - neg_breakpoint
+
+var_1, var_1_value = ("var_1", "10")
+var_2, var_2_value = ("var_2", "40")
+var_3, var_3_value = ("var_3", "10")
+
+# create pos_breakpoint and neg_breakpoint
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, pos_breakpoint, num_expected_locations=1
+)
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, neg_breakpoint, num_expected_locations=1
+)
+
+self.runCmd("run", RUN_SUCCEEDED)
+
+# test positive jump
+# The stop reason of the thread should be breakpoint 1.
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT + " 1",
+substrs=[
+"stopped",
+f"{file_name}:{pos_breakpoint}",
+"stop reason = breakpoint 1",
+],
+)
+
+self.runCmd(f"thread jump --by +{pos_jump_offset}")
+self.expect("process status", substrs=[f"at {file_name}:{pos_jump}"])
+self.expect(f"print {var_1}", substrs=[var_1_value])
+
+self.runCmd("thread step-over")
+self.expect(f"print {var_2}", substrs=[var_2_value])
+
+self.runCmd("continue")
+
+# test negative jump
+# The stop reason of the thread should be breakpoint 1.
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT + " 2",
+substrs=[
+"stopped",
+f"{file_name}:{neg_breakpoint}",
+"stop reason = breakpoint 2",
+],
+)
+
+self.runCmd(f"thread jump --by {neg_jump_offset}")
+self.expect("process status", substrs=[f"at {file_name}:{neg_jump}"])
+self.runCmd("thread step-over")
+self.expect(f"print {var_3}", substrs=[var_3_value])
+
 def do_min_test(self, start, jump, var, value):
 # jump to the start marker
 self.runCmd("j %i" % start)
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index 4f5fcb4857e80..bdf7a9aa5c7e0 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -409,6 +409,9 @@ static unsigned GetAutoSenseRadix(StringRef &Str) {
 
 bool llvm::consumeUnsignedInteger(StringRef &Str, unsigned Radix,
   unsigned long long &Result) {
+  // Consume the + value
+  Str.consume_front("+");
+
   // Autosense radix if not specified.
   if (Radix == 0)
 Radix = GetAutoSenseRadix(Str);
diff --git a/llvm/unittests/ADT/StringRefTest.cpp 
b/llvm/unittests/ADT/StringRefTest.cpp
index ec9cdc197597d..55d222a915ab5 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -622,19 +622,21 @@ TEST(StringRefTest, Hashing) {
 struct UnsignedPair {
   const char *Str;
   uint64_t Expected;
-} Unsigned[] =
-  { {"0", 0}
-  , {"255", 255}
-  , {"256", 256}
-  , {"65535", 65535}
-  , {"65536", 65536}
-  , {"4294967295", 4294967295ULL}
-  , {"4294967296", 4294967296ULL}
-  , {"18446744073709551615", 18446744073709551615ULL}
-  , {"042", 34}
-  , {"0x42", 66}
-  , {"0b101010", 42}
-

[Lldb-commits] [lldb] [llvm] [Support] [lldb] Fix thread jump #45326 (PR #135778)

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

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

>From de43c70a26f5c6fb72f836804f2b3ed6851a0cc7 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 15 Apr 2025 12:21:59 +0100
Subject: [PATCH 1/3] [Support] Recognise the '+' char for positive integers

Fixes https://github.com/llvm/llvm-project/issues/45326

Signed-off-by: Ebuka Ezike 
---
 llvm/lib/Support/StringRef.cpp   |  3 +++
 llvm/unittests/ADT/StringRefTest.cpp | 28 +++-
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index 4f5fcb4857e80..bdf7a9aa5c7e0 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -409,6 +409,9 @@ static unsigned GetAutoSenseRadix(StringRef &Str) {
 
 bool llvm::consumeUnsignedInteger(StringRef &Str, unsigned Radix,
   unsigned long long &Result) {
+  // Consume the + value
+  Str.consume_front("+");
+
   // Autosense radix if not specified.
   if (Radix == 0)
 Radix = GetAutoSenseRadix(Str);
diff --git a/llvm/unittests/ADT/StringRefTest.cpp 
b/llvm/unittests/ADT/StringRefTest.cpp
index ec9cdc197597d..55d222a915ab5 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -622,19 +622,21 @@ TEST(StringRefTest, Hashing) {
 struct UnsignedPair {
   const char *Str;
   uint64_t Expected;
-} Unsigned[] =
-  { {"0", 0}
-  , {"255", 255}
-  , {"256", 256}
-  , {"65535", 65535}
-  , {"65536", 65536}
-  , {"4294967295", 4294967295ULL}
-  , {"4294967296", 4294967296ULL}
-  , {"18446744073709551615", 18446744073709551615ULL}
-  , {"042", 34}
-  , {"0x42", 66}
-  , {"0b101010", 42}
-  };
+} Unsigned[] = {{"0", 0},
+{"255", 255},
+{"256", 256},
+{"65535", 65535},
+{"65536", 65536},
+{"4294967295", 4294967295ULL},
+{"4294967296", 4294967296ULL},
+{"18446744073709551615", 18446744073709551615ULL},
+{"042", 34},
+{"0x42", 66},
+{"0b101010", 42},
+{"+42", 42},
+{"+042", 34},
+{"+0x42", 66},
+{"+0b101010", 42}};
 
 struct SignedPair {
   const char *Str;

>From c89501a8299e77c92554fa608968ba2cc670838e Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 15 Apr 2025 12:25:41 +0100
Subject: [PATCH 2/3] [lldb] Add test for jumping by offset

Signed-off-by: Ebuka Ezike 
---
 .../thread/jump/TestThreadJump.py | 70 ++-
 1 file changed, 69 insertions(+), 1 deletion(-)

diff --git a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py 
b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
index 3c13a969bc3fd..d603580ac6f36 100644
--- a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
+++ b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
@@ -10,9 +10,12 @@
 
 
 class ThreadJumpTestCase(TestBase):
+def setUp(self):
+TestBase.setUp(self)
+self.build()
+
 def test(self):
 """Test thread jump handling."""
-self.build()
 exe = self.getBuildArtifact("a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
@@ -62,6 +65,71 @@ def test(self):
 substrs=["error"],
 )
 
+def test_jump_offset(self):
+"""Test Thread Jump by negative or positive offset"""
+exe = self.getBuildArtifact("a.out")
+file_name = "main.cpp"
+self.runCmd(f"target create {exe}", CURRENT_EXECUTABLE_SET)
+
+pos_jump = line_number(file_name, "// jump_offset 1")
+neg_jump = line_number(file_name, "// jump_offset 2")
+pos_breakpoint = line_number(file_name, "// breakpoint 1")
+neg_breakpoint = line_number(file_name, "// breakpoint 2")
+pos_jump_offset = pos_jump - pos_breakpoint
+neg_jump_offset = neg_jump - neg_breakpoint
+
+var_1, var_1_value = ("var_1", "10")
+var_2, var_2_value = ("var_2", "40")
+var_3, var_3_value = ("var_3", "10")
+
+# create pos_breakpoint and neg_breakpoint
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, pos_breakpoint, num_expected_locations=1
+)
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, neg_breakpoint, num_expected_locations=1
+)
+
+self.runCmd("run", RUN_SUCCEEDED)
+
+# test positive jump
+# The stop reason of the thread should be breakpoint 1.
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT + " 1",
+substrs=[
+"stopped",
+f"{file_name}:{pos_breakpoint}",
+"stop reason = breakpoint 1",
+],
+)
+
+self.runCmd(f"thread jump --by +{pos_jump_offset}")
+self.expect("process status", substrs=[f"at {fil

[Lldb-commits] [libcxxabi] [lldb] [llvm] [lldb] Add new per-language frame-format variables for formatting function names (PR #131836)

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

Michael137 wrote:

Also another open question is whether we should `${function.name-with-args}` 
for this or introduce a new format variable, e.g., 
`${function.name-formatted}`. @JDevlieghere was looking into implementing a 
"fallback" operator for `{}` scopes. With that we could make the default 
`frame-format`:
```
{ ${name-formatted} || ${function.name-with-args }
```
(depending on the "fallback" syntax)

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


[Lldb-commits] [lldb] [llvm] [Support] [lldb] Fix thread jump #45326 (PR #135778)

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

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

>From 73fc9565d973fd7e1ce92b005696f17c9a9acd5f Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 15 Apr 2025 12:21:59 +0100
Subject: [PATCH 1/3] [Support] Recognise the '+' char for positive integers

Fixes https://github.com/llvm/llvm-project/issues/45326

Signed-off-by: Ebuka Ezike 
---
 llvm/lib/Support/StringRef.cpp   |  3 +++
 llvm/unittests/ADT/StringRefTest.cpp | 28 +++-
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index 4f5fcb4857e80..bdf7a9aa5c7e0 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -409,6 +409,9 @@ static unsigned GetAutoSenseRadix(StringRef &Str) {
 
 bool llvm::consumeUnsignedInteger(StringRef &Str, unsigned Radix,
   unsigned long long &Result) {
+  // Consume the + value
+  Str.consume_front("+");
+
   // Autosense radix if not specified.
   if (Radix == 0)
 Radix = GetAutoSenseRadix(Str);
diff --git a/llvm/unittests/ADT/StringRefTest.cpp 
b/llvm/unittests/ADT/StringRefTest.cpp
index ec9cdc197597d..55d222a915ab5 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -622,19 +622,21 @@ TEST(StringRefTest, Hashing) {
 struct UnsignedPair {
   const char *Str;
   uint64_t Expected;
-} Unsigned[] =
-  { {"0", 0}
-  , {"255", 255}
-  , {"256", 256}
-  , {"65535", 65535}
-  , {"65536", 65536}
-  , {"4294967295", 4294967295ULL}
-  , {"4294967296", 4294967296ULL}
-  , {"18446744073709551615", 18446744073709551615ULL}
-  , {"042", 34}
-  , {"0x42", 66}
-  , {"0b101010", 42}
-  };
+} Unsigned[] = {{"0", 0},
+{"255", 255},
+{"256", 256},
+{"65535", 65535},
+{"65536", 65536},
+{"4294967295", 4294967295ULL},
+{"4294967296", 4294967296ULL},
+{"18446744073709551615", 18446744073709551615ULL},
+{"042", 34},
+{"0x42", 66},
+{"0b101010", 42},
+{"+42", 42},
+{"+042", 34},
+{"+0x42", 66},
+{"+0b101010", 42}};
 
 struct SignedPair {
   const char *Str;

>From 6ab61ef8ca7de96d3cdb6deb60c30fc1c8b6e9d2 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 15 Apr 2025 12:25:41 +0100
Subject: [PATCH 2/3] [lldb] Add test for jumping by offset

Signed-off-by: Ebuka Ezike 
---
 .../thread/jump/TestThreadJump.py | 70 ++-
 1 file changed, 69 insertions(+), 1 deletion(-)

diff --git a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py 
b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
index 3c13a969bc3fd..d603580ac6f36 100644
--- a/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
+++ b/lldb/test/API/functionalities/thread/jump/TestThreadJump.py
@@ -10,9 +10,12 @@
 
 
 class ThreadJumpTestCase(TestBase):
+def setUp(self):
+TestBase.setUp(self)
+self.build()
+
 def test(self):
 """Test thread jump handling."""
-self.build()
 exe = self.getBuildArtifact("a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
@@ -62,6 +65,71 @@ def test(self):
 substrs=["error"],
 )
 
+def test_jump_offset(self):
+"""Test Thread Jump by negative or positive offset"""
+exe = self.getBuildArtifact("a.out")
+file_name = "main.cpp"
+self.runCmd(f"target create {exe}", CURRENT_EXECUTABLE_SET)
+
+pos_jump = line_number(file_name, "// jump_offset 1")
+neg_jump = line_number(file_name, "// jump_offset 2")
+pos_breakpoint = line_number(file_name, "// breakpoint 1")
+neg_breakpoint = line_number(file_name, "// breakpoint 2")
+pos_jump_offset = pos_jump - pos_breakpoint
+neg_jump_offset = neg_jump - neg_breakpoint
+
+var_1, var_1_value = ("var_1", "10")
+var_2, var_2_value = ("var_2", "40")
+var_3, var_3_value = ("var_3", "10")
+
+# create pos_breakpoint and neg_breakpoint
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, pos_breakpoint, num_expected_locations=1
+)
+lldbutil.run_break_set_by_file_and_line(
+self, file_name, neg_breakpoint, num_expected_locations=1
+)
+
+self.runCmd("run", RUN_SUCCEEDED)
+
+# test positive jump
+# The stop reason of the thread should be breakpoint 1.
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT + " 1",
+substrs=[
+"stopped",
+f"{file_name}:{pos_breakpoint}",
+"stop reason = breakpoint 1",
+],
+)
+
+self.runCmd(f"thread jump --by +{pos_jump_offset}")
+self.expect("process status", substrs=[f"at {fil

[Lldb-commits] [lldb] [lldb][lldb-dap] fix repeating commands in repl mode (PR #135008)

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

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

>From 296019edb5edba4a21e040feb154b1ef83f1e64d Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Wed, 9 Apr 2025 14:35:09 +0100
Subject: [PATCH 1/3] [lldb][lldb-dap] fix repeating commands in repl mode

Fixes #131589
Add a new option to the RunCommands* functions to control the echoing of 
commands
---
 .../lldb-dap/evaluate/TestDAP_evaluate.py |  2 +-
 .../tools/lldb-dap/launch/TestDAP_launch.py   |  4 +--
 .../repl-mode/TestDAP_repl_mode_detection.py  | 11 +++---
 lldb/tools/lldb-dap/DAP.cpp   |  6 ++--
 lldb/tools/lldb-dap/DAP.h |  3 +-
 .../Handler/EvaluateRequestHandler.cpp|  3 +-
 lldb/tools/lldb-dap/LLDBUtils.cpp | 35 ++-
 lldb/tools/lldb-dap/LLDBUtils.h   | 19 +++---
 8 files changed, 54 insertions(+), 29 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py 
b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
index 251d77d79d080..e2f843bd337a6 100644
--- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
+++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
@@ -101,7 +101,7 @@ def run_test_evaluate_expressions(
 if context == "repl":
 # In the repl context expressions may be interpreted as lldb
 # commands since no variables have the same name as the command.
-self.assertEvaluate("list", r"\(lldb\) list\n.*")
+self.assertEvaluate("list", r".*")
 else:
 self.assertEvaluateFailure("list")  # local variable of a_function
 
diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py 
b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
index 64c99019a1c9b..eceba2f8a13cb 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
@@ -522,11 +522,9 @@ def test_version(self):
 )
 version_eval_output = version_eval_response["body"]["result"]
 
-# The first line is the prompt line like "(lldb) version", so we skip 
it.
-version_eval_output_without_prompt_line = 
version_eval_output.splitlines()[1:]
 version_string = 
self.dap_server.get_initialize_value("$__lldb_version")
 self.assertEqual(
-version_eval_output_without_prompt_line,
+version_eval_output.splitlines(),
 version_string.splitlines(),
 "version string does not match",
 )
diff --git 
a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py 
b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py
index 7c77fc8541b93..09ca725ee8883 100644
--- a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py
+++ b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py
@@ -28,15 +28,12 @@ def test_completions(self):
 
 self.set_source_breakpoints(source, [breakpoint1_line, 
breakpoint2_line])
 
-self.assertEvaluate(
-"`command regex user_command s/^$/platform/", r"\(lldb\) command 
regex"
-)
-self.assertEvaluate(
-"`command alias alias_command platform", r"\(lldb\) command alias"
-)
+# the result of the commands should return the empty string.
+self.assertEvaluate("`command regex user_command s/^$/platform/", 
r"^$")
+self.assertEvaluate("`command alias alias_command platform", r"^$")
 self.assertEvaluate(
 "`command alias alias_command_with_arg platform select --sysroot 
%1 remote-linux",
-r"\(lldb\) command alias",
+r"^$",
 )
 
 self.continue_to_next_stop()
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 9361ba968e9c2..03b9dc7135ef7 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -561,10 +561,12 @@ ReplMode DAP::DetectReplMode(lldb::SBFrame frame, 
std::string &expression,
 }
 
 bool DAP::RunLLDBCommands(llvm::StringRef prefix,
-  llvm::ArrayRef commands) {
+  llvm::ArrayRef commands,
+  bool echo_commands) {
   bool required_command_failed = false;
   std::string output =
-  ::RunLLDBCommands(debugger, prefix, commands, required_command_failed);
+  ::RunLLDBCommands(debugger, prefix, commands, required_command_failed,
+/*parse_command_directives*/ true, echo_commands);
   SendOutput(OutputType::Console, output);
   return !required_command_failed;
 }
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index fc43d988f3a09..cb3431cc87fd1 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -290,7 +290,8 @@ struct DAP {
   ///   \b false if a fatal error was found while executing these commands,
   ///   according to the rules of \a LLDBUtils::RunLLDBCommands.
   bool RunLL

[Lldb-commits] [lldb] [lldb][lldb-dap] fix repeating commands in repl mode (PR #135008)

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

da-viper wrote:

> With this patch, is there anything that turns on echoing of commands? 

Yeah, the launch options 

InitCommands, PreCommands and ***Commands.




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