[Lldb-commits] [lldb] [lldb] Tweak check for CommandLineTools in ParseXcodeSDK (PR #154574)

2025-08-21 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Improve error message in ResolveSDKPathFromDebugInfo (NFC) (PR #154607)

2025-08-21 Thread Dave Lee via lldb-commits


@@ -1039,7 +1039,12 @@ ResolveSDKPathFromDebugInfo(lldb_private::Target 
*target) {
 
   SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
   if (!sym_file)
-return llvm::createStringError("Failed to get symbol file from module");
+return llvm::createStringError("Failed to get symbol file from 
executable");

kastiglione wrote:

I don't see an existing place to test this `ResolveSDKPathFromDebugInfo`. It's 
a function used specifically by `AddClangModuleCompilationOptions`, which 
doesn't have any existing tests.

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


[Lldb-commits] [lldb] [lldb] Remove unused XcodeSDK::SupportsSwift (NFC) (PR #154572)

2025-08-21 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Improve error message in ResolveSDKPathFromDebugInfo (NFC) (PR #154607)

2025-08-21 Thread Dave Lee via lldb-commits

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

>From 1e70adad6b2d62bcb568ad603298a1a91121a87b Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 20 Aug 2025 13:27:51 -0700
Subject: [PATCH 1/2] [lldb] Improve error message in
 ResolveSDKPathFromDebugInfo (NFC)

While debugging, I saw a log line of:

>  Failed to resolve SDK path: Error while searching for SDK (XcodeSDK ''): 
> Unrecognized SDK type:

Looking into how this might happen, it seems `ResolveSDKPathFromDebugInfo` 
appears to
(implicitly) assume there's at least one compile unit. This change adds a 
precondition
to return a meaningful error when there are no compile units.
---
 lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 1db7bc78013d7..dc8b9437a64e4 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1039,7 +1039,12 @@ ResolveSDKPathFromDebugInfo(lldb_private::Target 
*target) {
 
   SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
   if (!sym_file)
-return llvm::createStringError("Failed to get symbol file from module");
+return llvm::createStringError("Failed to get symbol file from 
executable");
+
+  if (sym_file->GetNumCompileUnits() == 0)
+return llvm::createStringError(
+"Failed to resolve SDK for target: executable's symbol file has no "
+"compile units");
 
   XcodeSDK merged_sdk;
   for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i) {

>From 61e3ec601407ba39f507e4609935b981454a044e Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Thu, 21 Aug 2025 09:25:30 -0700
Subject: [PATCH 2/2] add matching check to
 PlatformDarwin::GetSDKPathFromDebugInfo

---
 lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index dc8b9437a64e4..cd72454fe0287 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1402,6 +1402,12 @@ PlatformDarwin::GetSDKPathFromDebugInfo(Module &module) {
 llvm::formatv("No symbol file available for module '{0}'",
   module.GetFileSpec().GetFilename().AsCString("")));
 
+  if (sym_file->GetNumCompileUnits() == 0)
+return llvm::createStringError(
+llvm::formatv("Could not resolve SDK for module '{0}'. Symbol file has 
"
+  "no compile units.",
+  module.GetFileSpec()));
+
   bool found_public_sdk = false;
   bool found_internal_sdk = false;
   XcodeSDK merged_sdk;

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


[Lldb-commits] [lldb] [lldb] Improve error message in ResolveSDKPathFromDebugInfo (NFC) (PR #154607)

2025-08-21 Thread Dave Lee via lldb-commits


@@ -1039,7 +1039,12 @@ ResolveSDKPathFromDebugInfo(lldb_private::Target 
*target) {
 
   SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
   if (!sym_file)
-return llvm::createStringError("Failed to get symbol file from module");
+return llvm::createStringError("Failed to get symbol file from 
executable");

kastiglione wrote:

the other place Charles mentioned does have tests: `GetSDKPathFromDebugInfo`

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


[Lldb-commits] [lldb] [lldb/API] Add setters to SBStructuredData (PR #154445)

2025-08-21 Thread via lldb-commits


@@ -109,6 +109,35 @@ class SBStructuredData {
   /// Return the generic pointer if this data structure is a generic type.
   lldb::SBScriptObject GetGenericValue() const;
 
+  /// Set the value corresponding to a key. If this data structure
+  /// is not a dictionary type, reset the type to be dictionary and overwrite
+  /// previous data.

jimingham wrote:

"the previous data"

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


[Lldb-commits] [lldb] [lldb/API] Add setters to SBStructuredData (PR #154445)

2025-08-21 Thread via lldb-commits


@@ -81,6 +81,39 @@ class StructuredDataImpl {
 
   void SetObjectSP(const StructuredData::ObjectSP &obj) { m_data_sp = obj; }
 
+  void SetValueForKey(llvm::StringRef key,
+  const StructuredData::ObjectSP &value) {
+if (m_data_sp) {
+  if (StructuredData::Dictionary *dict = m_data_sp->GetAsDictionary())
+return dict->AddItem(key, value);

jimingham wrote:

It looks confusing to seem to return a value here.  In the end, it works 
because AddItem is also a void return.  But it looks really weird.

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


[Lldb-commits] [lldb] [lldb/API] Add setters to SBStructuredData (PR #154445)

2025-08-21 Thread via lldb-commits


@@ -232,3 +232,46 @@ lldb::SBScriptObject SBStructuredData::GetGenericValue() 
const {
 
   return {m_impl_up->GetGenericValue(), eScriptLanguageDefault};
 }
+
+void SBStructuredData::SetValueForKey(const char *key,
+  SBStructuredData &value) {
+  LLDB_INSTRUMENT_VA(this, key, value);
+
+  m_impl_up->SetValueForKey(key, value.m_impl_up->GetObjectSP());

jimingham wrote:

A default constructed SBStructuredData always has a valid m_impl_up, so that 
part is okay.  But a default constructed StructuredDataImpl can have an empty 
m_data_sp.  Do we want to add an empty value, or should that be an error?

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


[Lldb-commits] [lldb] [lldb/API] Add setters to SBStructuredData (PR #154445)

2025-08-21 Thread via lldb-commits


@@ -232,3 +232,46 @@ lldb::SBScriptObject SBStructuredData::GetGenericValue() 
const {
 
   return {m_impl_up->GetGenericValue(), eScriptLanguageDefault};
 }
+
+void SBStructuredData::SetValueForKey(const char *key,
+  SBStructuredData &value) {
+  LLDB_INSTRUMENT_VA(this, key, value);
+
+  m_impl_up->SetValueForKey(key, value.m_impl_up->GetObjectSP());

jimingham wrote:

If we do think that's okay, then we should test that explicitly to make sure it 
isn't causing trouble.

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


[Lldb-commits] [lldb] 86c9a7b - [lldb] Remove unused XcodeSDK::SupportsSwift (NFC) (#154572)

2025-08-21 Thread via lldb-commits

Author: Dave Lee
Date: 2025-08-21T08:55:50-07:00
New Revision: 86c9a7b0c1a99e9bed49edf4621e3a79847c6c35

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

LOG: [lldb] Remove unused XcodeSDK::SupportsSwift (NFC) (#154572)

Added: 


Modified: 
lldb/include/lldb/Utility/XcodeSDK.h
lldb/source/Utility/XcodeSDK.cpp
lldb/unittests/Utility/XcodeSDKTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/XcodeSDK.h 
b/lldb/include/lldb/Utility/XcodeSDK.h
index a1a0ec415b90e..5b345a4965cf9 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -86,8 +86,6 @@ class XcodeSDK {
   Type GetType() const;
   llvm::StringRef GetString() const;
   const FileSpec &GetSysroot() const;
-  /// Whether this Xcode SDK supports Swift.
-  bool SupportsSwift() const;
 
   /// Whether LLDB feels confident importing Clang modules from this SDK.
   static bool SDKSupportsModules(Type type, llvm::VersionTuple version);

diff  --git a/lldb/source/Utility/XcodeSDK.cpp 
b/lldb/source/Utility/XcodeSDK.cpp
index eb2047e67c326..2040791882fd0 100644
--- a/lldb/source/Utility/XcodeSDK.cpp
+++ b/lldb/source/Utility/XcodeSDK.cpp
@@ -243,29 +243,6 @@ bool XcodeSDK::SDKSupportsModules(XcodeSDK::Type sdk_type,
   return false;
 }
 
-bool XcodeSDK::SupportsSwift() const {
-  XcodeSDK::Info info = Parse();
-  switch (info.type) {
-  case Type::MacOSX:
-return info.version.empty() || info.version >= llvm::VersionTuple(10, 10);
-  case Type::iPhoneOS:
-  case Type::iPhoneSimulator:
-return info.version.empty() || info.version >= llvm::VersionTuple(8);
-  case Type::AppleTVSimulator:
-  case Type::AppleTVOS:
-return info.version.empty() || info.version >= llvm::VersionTuple(9);
-  case Type::WatchSimulator:
-  case Type::watchOS:
-return info.version.empty() || info.version >= llvm::VersionTuple(2);
-  case Type::XROS:
-  case Type::XRSimulator:
-  case Type::Linux:
-return true;
-  default:
-return false;
-  }
-}
-
 bool XcodeSDK::SDKSupportsModules(XcodeSDK::Type desired_type,
   const FileSpec &sdk_path) {
   ConstString last_path_component = sdk_path.GetFilename();

diff  --git a/lldb/unittests/Utility/XcodeSDKTest.cpp 
b/lldb/unittests/Utility/XcodeSDKTest.cpp
index 4db6a50fcf860..de9f91a04d53e 100644
--- a/lldb/unittests/Utility/XcodeSDKTest.cpp
+++ b/lldb/unittests/Utility/XcodeSDKTest.cpp
@@ -102,17 +102,6 @@ TEST(XcodeSDKTest, SDKSupportsModules) {
 }
 #endif
 
-TEST(XcodeSDKTest, SDKSupportsSwift) {
-  EXPECT_TRUE(XcodeSDK("iPhoneSimulator12.0.sdk").SupportsSwift());
-  EXPECT_TRUE(XcodeSDK("iPhoneSimulator12.0.Internal.sdk").SupportsSwift());
-  EXPECT_FALSE(XcodeSDK("iPhoneSimulator7.2.sdk").SupportsSwift());
-  EXPECT_TRUE(XcodeSDK("MacOSX10.10.sdk").SupportsSwift());
-  EXPECT_FALSE(XcodeSDK("MacOSX10.9.sdk").SupportsSwift());
-  EXPECT_TRUE(XcodeSDK("Linux.sdk").SupportsSwift());
-  EXPECT_TRUE(XcodeSDK("MacOSX.sdk").SupportsSwift());
-  EXPECT_FALSE(XcodeSDK("EverythingElse.sdk").SupportsSwift());
-}
-
 TEST(XcodeSDKTest, GetCanonicalNameAndConstruct) {
   XcodeSDK::Info info;
   info.type = XcodeSDK::Type::MacOSX;



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


[Lldb-commits] [lldb] dacabc1 - [lldb] Tweak check for CommandLineTools in ParseXcodeSDK (#154574)

2025-08-21 Thread via lldb-commits

Author: Dave Lee
Date: 2025-08-21T08:56:17-07:00
New Revision: dacabc1fee69d3cdced779d9a72916ddf2ca57e6

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

LOG: [lldb] Tweak check for CommandLineTools in ParseXcodeSDK (#154574)

Follow up to https://github.com/llvm/llvm-project/pull/128712

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 9958af26379b9..b15e0c15fedb8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -8,6 +8,7 @@
 
 #include "SymbolFileDWARF.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
 #include "llvm/Support/Casting.h"
@@ -998,12 +999,12 @@ XcodeSDK SymbolFileDWARF::ParseXcodeSDK(CompileUnit 
&comp_unit) {
   const char *sdk = cu_die.GetAttributeValueAsString(DW_AT_APPLE_sdk, nullptr);
   if (!sdk)
 return {};
-  std::string sysroot =
+  llvm::StringRef sysroot =
   cu_die.GetAttributeValueAsString(DW_AT_LLVM_sysroot, "");
 
   // RegisterXcodeSDK calls into xcrun which is not aware of CLT, which is
   // expensive.
-  if (sysroot.find("/Library/Developer/CommandLineTools/SDKs") != 0) {
+  if (!sysroot.starts_with("/Library/Developer/CommandLineTools/SDKs")) {
 // Register the sysroot path remapping with the module belonging to
 // the CU as well as the one belonging to the symbol file. The two
 // would be 
diff erent if this is an OSO object and module is the
@@ -1017,7 +1018,7 @@ XcodeSDK SymbolFileDWARF::ParseXcodeSDK(CompileUnit 
&comp_unit) {
   local_module_sp->RegisterXcodeSDK(sdk, sysroot);
   }
 
-  return {sdk, FileSpec{std::move(sysroot)}};
+  return {sdk, FileSpec(sysroot)};
 }
 
 size_t SymbolFileDWARF::ParseFunctions(CompileUnit &comp_unit) {



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


[Lldb-commits] [clang] [lldb] [llvm] [lldb][Expression] Add structor variant to LLDB's function call labels (PR #149827)

2025-08-21 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] 13eca52 - [lldb-dap] Re-land refactor of DebugCommunication. (#147787)

2025-08-21 Thread via lldb-commits

Author: John Harrison
Date: 2025-08-21T10:20:01-07:00
New Revision: 13eca5248c7bf625af9c7af898d48e8c0a441496

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

LOG: [lldb-dap] Re-land refactor of DebugCommunication. (#147787)

Originally commited in 362b9d78b4ee9107da2b5e90b3764b0f0fa610fe and then
reverted in cb63b75e32a415c9bfc298ed7fdcd67e8d9de54c.

This re-lands a subset of the changes to
dap_server.py/DebugCommunication and addresses the python3.10
compatibility issue.

This includes less type annotations since those were the reason for the
failures on that specific version of python.

I've done additional testing on python3.8, python3.10 and python3.13 to
further validate these changes.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py

lldb/test/API/tools/lldb-dap/breakpoint-assembly/TestDAP_breakpointAssembly.py
lldb/test/API/tools/lldb-dap/breakpoint-events/TestDAP_breakpointEvents.py
lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py
lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py
lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py
lldb/test/API/tools/lldb-dap/console/TestDAP_console.py

lldb/test/API/tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py
lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
lldb/test/API/tools/lldb-dap/module-event/TestDAP_module_event.py
lldb/test/API/tools/lldb-dap/module/TestDAP_module.py
lldb/test/API/tools/lldb-dap/output/TestDAP_output.py
lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 7acb9c89b8b7d..7a2c2876f0b15 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
@@ -12,15 +12,91 @@
 import sys
 import threading
 import time
-from typing import Any, Optional, Union, BinaryIO, TextIO
+from typing import (
+Any,
+Optional,
+Dict,
+cast,
+List,
+Callable,
+IO,
+Union,
+BinaryIO,
+TextIO,
+TypedDict,
+Literal,
+)
 
 ## DAP type references
-Event = dict[str, Any]
-Request = dict[str, Any]
-Response = dict[str, Any]
+
+
+class Event(TypedDict):
+type: Literal["event"]
+seq: int
+event: str
+body: Any
+
+
+class Request(TypedDict, total=False):
+type: Literal["request"]
+seq: int
+command: str
+arguments: Any
+
+
+class Response(TypedDict):
+type: Literal["response"]
+seq: int
+request_seq: int
+success: bool
+command: str
+message: Optional[str]
+body: Any
+
+
 ProtocolMessage = Union[Event, Request, Response]
 
 
+class Source(TypedDict, total=False):
+name: str
+path: str
+sourceReference: int
+
+@staticmethod
+def build(
+*,
+name: Optional[str] = None,
+path: Optional[str] = None,
+source_reference: Optional[int] = None,
+) -> "Source":
+"""Builds a source from the given name, path or source_reference."""
+if not name and not path and not source_reference:
+raise ValueError(
+"Source.build requires either name, path, or source_reference"
+)
+
+s = Source()
+if name:
+s["name"] = name
+if path:
+if not name:
+s["name"] = os.path.basename(path)
+s["path"] = path
+if source_reference is not None:
+s["sourceReference"] = source_reference
+return s
+
+
+class Breakpoint(TypedDict, total=False):
+id: int
+verified: bool
+source: Source
+
+@staticmethod
+def is_verified(src: "Breakpoint") -> bool:
+return src.get("verified", False)
+
+
 def dump_memory(base_addr, data, num_per_line, outfile):
 data_len = len(data)
 hex_string = binascii.hexlify(data)
@@ -58,7 +134,9 @@ def dump_memory(base_addr, data, num_per_line, outfile):
 outfile.write("\n")
 
 
-def read_packet(f, verbose=False, trace_file=None):
+def read_packet(
+f: IO[bytes], trace_file: Optional[IO[str]] = None
+) -> Optional[ProtocolMessage]:
 """Decode a JSON packet that starts with the content length and is
 followed by the JSON bytes from a file 'f'. Returns None on EOF.
 """
@@ -70,19 +148,13 @@ def read_packet(f, verbose=False, trace_file=None):
 prefix = "Content-Length: "
 if line.startswith(prefix):
 # Decode length of JSON bytes
-if verbose

[Lldb-commits] [lldb] [lldb-dap] Re-land refactor of DebugCommunication. (PR #147787)

2025-08-21 Thread John Harrison via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Migrating 'completions' to structured types. (PR #153317)

2025-08-21 Thread Ebuka Ezike via lldb-commits


@@ -198,27 +85,25 @@ void CompletionsRequestHandler::operator()(
   std::string match = matches.GetStringAtIndex(i);
   std::string description = descriptions.GetStringAtIndex(i);
 
-  llvm::json::Object item;
-  llvm::StringRef match_ref = match;
-  for (llvm::StringRef commit_point : {".", "->"}) {
+  CompletionItem item;
+  StringRef match_ref = match;
+  for (StringRef commit_point : {".", "->"}) {
 if (match_ref.contains(commit_point)) {
   match_ref = match_ref.rsplit(commit_point).second;
 }
   }
-  EmplaceSafeString(item, "text", match_ref);
+  item.text = match_ref;
 
   if (description.empty())
-EmplaceSafeString(item, "label", match);
+item.label = match;
   else
-EmplaceSafeString(item, "label", match + " -- " + description);
+item.label = match + " -- " + description;
 
   targets.emplace_back(std::move(item));
 }
   }
 
-  body.try_emplace("targets", std::move(targets));
-  response.try_emplace("body", std::move(body));
-  dap.SendJSON(llvm::json::Value(std::move(response)));
+  return CompletionsResponseBody{targets};

da-viper wrote:

```suggestion
  return CompletionsResponseBody{std::move(targets)};
```

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


[Lldb-commits] [lldb] [lldb-dap] Migrating 'completions' to structured types. (PR #153317)

2025-08-21 Thread Ebuka Ezike via lldb-commits


@@ -8,167 +8,54 @@
 
 #include "DAP.h"
 #include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
+#include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBStringList.h"
 
-namespace lldb_dap {
+using namespace llvm;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
 
-// "CompletionsRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Returns a list of possible completions for a given caret
-// position and text.\nThe CompletionsRequest may only be called if the
-// 'supportsCompletionsRequest' capability exists and is true.",
-// "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "completions" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/CompletionsArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "CompletionsArguments": {
-//   "type": "object",
-//   "description": "Arguments for 'completions' request.",
-//   "properties": {
-// "frameId": {
-//   "type": "integer",
-//   "description": "Returns completions in the scope of this stack frame.
-//   If not specified, the completions are returned for the global scope."
-// },
-// "text": {
-//   "type": "string",
-//   "description": "One or more source lines. Typically this is the text a
-//   user has typed into the debug console before he asked for completion."
-// },
-// "column": {
-//   "type": "integer",
-//   "description": "The character position for which to determine the
-//   completion proposals."
-// },
-// "line": {
-//   "type": "integer",
-//   "description": "An optional line for which to determine the completion
-//   proposals. If missing the first line of the text is assumed."
-// }
-//   },
-//   "required": [ "text", "column" ]
-// },
-// "CompletionsResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to 'completions' request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "targets": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/CompletionItem"
-// },
-// "description": "The possible completions for ."
-//   }
-// },
-// "required": [ "targets" ]
-//   }
-// },
-// "required": [ "body" ]
-//   }]
-// },
-// "CompletionItem": {
-//   "type": "object",
-//   "description": "CompletionItems are the suggestions returned from the
-//   CompletionsRequest.", "properties": {
-// "label": {
-//   "type": "string",
-//   "description": "The label of this completion item. By default this is
-//   also the text that is inserted when selecting this completion."
-// },
-// "text": {
-//   "type": "string",
-//   "description": "If text is not falsy then it is inserted instead of 
the
-//   label."
-// },
-// "sortText": {
-//   "type": "string",
-//   "description": "A string that should be used when comparing this item
-//   with other items. When `falsy` the label is used."
-// },
-// "type": {
-//   "$ref": "#/definitions/CompletionItemType",
-//   "description": "The item's type. Typically the client uses this
-//   information to render the item in the UI with an icon."
-// },
-// "start": {
-//   "type": "integer",
-//   "description": "This value determines the location (in the
-//   CompletionsRequest's 'text' attribute) where the completion text is
-//   added.\nIf missing the text is added at the location specified by the
-//   CompletionsRequest's 'column' attribute."
-// },
-// "length": {
-//   "type": "integer",
-//   "description": "This value determines how many characters are
-//   overwritten by the completion text.\nIf missing the value 0 is assumed
-//   which results in the completion text being inserted."
-// }
-//   },
-//   "required": [ "label" ]
-// },
-// "CompletionItemType": {
-//   "type": "string",
-//   "description": "Some predefined types for the CompletionItem. Please note
-//   that not all clients have specific icons for all of them.", "enum": [
-//   "method", "function", "constructor", "field", "variable", "class",
-//   "interface", "module", "property", "unit", "value", "enum", "keyword",
-//   "snippet", "text", "color", "file", "reference", "customcolor" ]
-// }
-void CompletionsRequestHandler::operator()(
-const llvm::json::Object &request) const {
-  llvm::json::Object response;
-  FillResponse(request, response);
-  llvm::json::Object body;
-  const auto *arguments = request.getObject("arguments");
+namespace lldb_dap {
 
+/// Returns a list of possible completions fo

[Lldb-commits] [clang] [lldb] [llvm] [lldb][Expression] Add structor variant to LLDB's function call labels (PR #149827)

2025-08-21 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Re-land refactor of DebugCommunication. (PR #147787)

2025-08-21 Thread Ebuka Ezike via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb/API] Add setters to SBStructuredData (PR #154445)

2025-08-21 Thread Alex Langford via lldb-commits


@@ -81,6 +81,40 @@ class StructuredDataImpl {
 
   void SetObjectSP(const StructuredData::ObjectSP &obj) { m_data_sp = obj; }
 
+  void SetValueForKey(llvm::StringRef key,
+  const StructuredData::ObjectSP &value) {
+if (m_data_sp) {
+  if (StructuredData::Dictionary *dict = m_data_sp->GetAsDictionary())
+dict->AddItem(key, value);
+  return;

bulbazord wrote:

I'm not sure this does what it's supposed to. If you have a data type that's 
not a dictionary, this setter does nothing. But all of the other setters always 
override. I think you probably wanted to put the return in the same block as 
`dict->AddItem`, but I suggest we sidestep the explicit return entirely.

Suggestion:
```
if (!m_data_sp) {
  m_data_sp = StructuredData::FromKeyValue(key, value);
} else if (StructuredData::Dictionary *dict = m_data_sp->GetAsDictionary()) {
  dict->AddItem(key, value);
}
```

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


[Lldb-commits] [lldb] [lldb/API] Add setters to SBStructuredData (PR #154445)

2025-08-21 Thread Alex Langford via lldb-commits


@@ -81,6 +81,40 @@ class StructuredDataImpl {
 
   void SetObjectSP(const StructuredData::ObjectSP &obj) { m_data_sp = obj; }
 
+  void SetValueForKey(llvm::StringRef key,
+  const StructuredData::ObjectSP &value) {
+if (m_data_sp) {
+  if (StructuredData::Dictionary *dict = m_data_sp->GetAsDictionary())
+dict->AddItem(key, value);
+  return;
+}
+m_data_sp = StructuredData::FromKeyValue(key, value);
+  }
+
+  void SetUnsignedIntegerValue(uint64_t value) {
+m_data_sp = StructuredData::FromInteger(value);
+  }
+
+  void SetSignedIntegerValue(int64_t value) {
+m_data_sp = StructuredData::FromInteger(value);
+  }
+
+  void SetFloatValue(double value) {
+m_data_sp = StructuredData::FromFloat(value);
+  }
+
+  void SetBooleanValue(bool value) {
+m_data_sp = StructuredData::FromBoolean(value);
+  }
+
+  void SetStringValue(std::string value) {
+m_data_sp = StructuredData::FromString(value);

bulbazord wrote:

Suggestion: Move here to avoid an unnecessary copy

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


[Lldb-commits] [lldb] [lldb/API] Add setters to SBStructuredData (PR #154445)

2025-08-21 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb/API] Add setters to SBStructuredData (PR #154445)

2025-08-21 Thread Alex Langford via lldb-commits


@@ -130,6 +130,38 @@ class MyRandomClass:
 self.assertSuccess(example.SetFromJSON("null"))
 self.assertEqual(example.GetType(), lldb.eStructuredDataTypeNull)
 
+example = lldb.SBStructuredData()
+example.SetUnsignedIntegerValue(1)
+self.assertEqual(example.GetType(), lldb.eStructuredDataTypeInteger)
+self.assertEqual(example.GetIntegerValue(), 1)
+
+example.SetSignedIntegerValue(-42)
+self.assertEqual(example.GetType(), 
lldb.eStructuredDataTypeSignedInteger)
+self.assertEqual(example.GetSignedIntegerValue(), -42)
+
+example.SetFloatValue(4.19)
+self.assertEqual(example.GetType(), lldb.eStructuredDataTypeFloat)
+self.assertEqual(example.GetFloatValue(), 4.19)
+
+example.SetStringValue("Bonjour, 123!")
+self.assertEqual(example.GetType(), lldb.eStructuredDataTypeString)
+self.assertEqual(example.GetStringValue(42), "Bonjour, 123!")
+

bulbazord wrote:

Can you add a test for dictionary, both adding to an existing one and 
clobbering a structured data of different type?

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


[Lldb-commits] [lldb] Fix non-deterministic failure in ```TestDAP_attach.py``` and improve error message handling in ```lldbdap_testcase.py``` (PR #154632)

2025-08-21 Thread Walter Erquinigo via lldb-commits


@@ -227,3 +228,46 @@ def test_terminate_commands(self):
 pattern=terminateCommands[0],
 )
 self.verify_commands("terminateCommands", output, terminateCommands)
+
+def test_session_id_update(self):
+program = self.build_and_create_debug_adapter_for_attach()
+self.process = subprocess.Popen(
+[program],
+stdin=subprocess.PIPE,
+stdout=subprocess.PIPE,
+stderr=subprocess.PIPE,
+)
+
+postRunCommands = [

walter-erquinigo wrote:

for the sake of readability, can you add a comment here about the env var 
VSCODE_DEBUG_SESSION_ID and how you are using it here?

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


[Lldb-commits] [lldb] a447fc6 - [lldb] Improve error message in ResolveSDKPathFromDebugInfo (NFC) (#154607)

2025-08-21 Thread via lldb-commits

Author: Dave Lee
Date: 2025-08-21T13:23:38-07:00
New Revision: a447fc63f9b7add22eaa693e9ea8925402af04b7

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

LOG: [lldb] Improve error message in ResolveSDKPathFromDebugInfo (NFC) (#154607)

While debugging, I saw a log line of:

> Failed to resolve SDK path: Error while searching for SDK (XcodeSDK ''): 
> Unrecognized SDK type:

Looking into how this might happen, it seems `ResolveSDKPathFromDebugInfo` 
appears to
(implicitly) assume there's at least one compile unit. This change adds a 
precondition
to return a meaningful error when there are no compile units.

Original: https://github.com/llvm/llvm-project/pull/146062

Added: 


Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 1db7bc78013d7..cd72454fe0287 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1039,7 +1039,12 @@ ResolveSDKPathFromDebugInfo(lldb_private::Target 
*target) {
 
   SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
   if (!sym_file)
-return llvm::createStringError("Failed to get symbol file from module");
+return llvm::createStringError("Failed to get symbol file from 
executable");
+
+  if (sym_file->GetNumCompileUnits() == 0)
+return llvm::createStringError(
+"Failed to resolve SDK for target: executable's symbol file has no "
+"compile units");
 
   XcodeSDK merged_sdk;
   for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i) {
@@ -1397,6 +1402,12 @@ PlatformDarwin::GetSDKPathFromDebugInfo(Module &module) {
 llvm::formatv("No symbol file available for module '{0}'",
   module.GetFileSpec().GetFilename().AsCString("")));
 
+  if (sym_file->GetNumCompileUnits() == 0)
+return llvm::createStringError(
+llvm::formatv("Could not resolve SDK for module '{0}'. Symbol file has 
"
+  "no compile units.",
+  module.GetFileSpec()));
+
   bool found_public_sdk = false;
   bool found_internal_sdk = false;
   XcodeSDK merged_sdk;



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


[Lldb-commits] [lldb] [lldb-dap] Re-land refactor of DebugCommunication. (PR #147787)

2025-08-21 Thread Ebuka Ezike via lldb-commits

da-viper wrote:

```
AttributeError: 'DebugAdapterServer' object has no attribute 'send_recv'. Did 
you mean: '_send_recv'?
```
missed update location. 

`lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py` line 1319 

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


[Lldb-commits] [lldb] Omit loading local symbols in LLDB symbol table (PR #154809)

2025-08-21 Thread via lldb-commits

https://github.com/barsolo2000 updated 
https://github.com/llvm/llvm-project/pull/154809

>From f378e6a09487eca27d4741bc527c578b8fb8d161 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik 
Date: Wed, 20 Aug 2025 14:54:52 -0700
Subject: [PATCH 1/4] added helper function

---
 .../source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 13 +
 1 file changed, 13 insertions(+)

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index f69358de6a288..37983cfef0a2e 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2037,6 +2037,19 @@ static char FindArmAarch64MappingSymbol(const char 
*symbol_name) {
   return '\0';
 }
 
+static char FindRISCVMappingSymbol(const char *symbol_name) {
+  if (!symbol_name)
+return '\0';
+
+  if (symbol_name.size() == 2 && symbol_name[0] == '$'){
+char c = symbol_name[1];
+if (c == 'd' || c == 'x'){
+  return c;
+}
+  return '\0';
+  }
+}
+
 #define STO_MIPS_ISA (3 << 6)
 #define STO_MICROMIPS (2 << 6)
 #define IS_MICROMIPS(ST_OTHER) (((ST_OTHER)&STO_MIPS_ISA) == STO_MICROMIPS)

>From b88812ae8e4a7647258360985721fa6b1ada0614 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik 
Date: Thu, 21 Aug 2025 10:51:17 -0700
Subject: [PATCH 2/4] fixed format

---
 .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp  | 44 ++-
 1 file changed, 33 insertions(+), 11 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 37983cfef0a2e..99744b25ea66f 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2041,13 +2041,12 @@ static char FindRISCVMappingSymbol(const char 
*symbol_name) {
   if (!symbol_name)
 return '\0';
 
-  if (symbol_name.size() == 2 && symbol_name[0] == '$'){
-char c = symbol_name[1];
-if (c == 'd' || c == 'x'){
-  return c;
-}
-  return '\0';
+  if (symbol_name[0] == '$' &&
+  (symbol_name[1] == 'd' || symbol_name[1] == 'x') &&
+  symbol_name[2] == '\0') {
+return symbol_name[1];
   }
+  return '\0';
 }
 
 #define STO_MIPS_ISA (3 << 6)
@@ -2115,11 +2114,13 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
 if (!symbol_name)
   symbol_name = "";
 
+if (symbol_name[0] == '.' && symbol_name[1] == 'L')
+  continue;
 // No need to add non-section symbols that have no names
 if (symbol.getType() != STT_SECTION &&
 (symbol_name == nullptr || symbol_name[0] == '\0'))
   continue;
-
+
 // Skipping oatdata and oatexec sections if it is requested. See details
 // above the definition of skip_oatdata_oatexec for the reasons.
 if (skip_oatdata_oatexec && (::strcmp(symbol_name, "oatdata") == 0 ||
@@ -2203,9 +2204,9 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
 
 int64_t symbol_value_offset = 0;
 uint32_t additional_flags = 0;
-
+llvm::Triple::ArchType arch_machine = arch.GetMachine();
 if (arch.IsValid()) {
-  if (arch.GetMachine() == llvm::Triple::arm) {
+  if (arch_machine == llvm::Triple::arm) {
 if (symbol.getBinding() == STB_LOCAL) {
   char mapping_symbol = FindArmAarch64MappingSymbol(symbol_name);
   if (symbol_type == eSymbolTypeCode) {
@@ -2230,7 +2231,7 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
   if (mapping_symbol)
 continue;
 }
-  } else if (arch.GetMachine() == llvm::Triple::aarch64) {
+  } else if (arch_machine == llvm::Triple::aarch64) {
 if (symbol.getBinding() == STB_LOCAL) {
   char mapping_symbol = FindArmAarch64MappingSymbol(symbol_name);
   if (symbol_type == eSymbolTypeCode) {
@@ -2248,9 +2249,30 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
   if (mapping_symbol)
 continue;
 }
+  } else if (arch_machine == llvm::Triple::riscv32 ||
+ arch_machine == llvm::Triple::riscv64 ||
+ arch_machine == llvm::Triple::riscv32be ||
+ arch_machine == llvm::Triple::riscv64be) {
+if (symbol.getBinding() == STB_LOCAL) {
+  char mapping_symbol = FindRISCVMappingSymbol(symbol_name);
+  if (symbol_type == eSymbolTypeCode) {
+switch (mapping_symbol) {
+case 'x':
+  // $x - marks a RISCV instruction sequence
+  address_class_map[symbol.st_value] = AddressClass::eCode;
+  break;
+case 'd':
+  // $d - marks a RISCV data item sequence
+  address_class_map[symbol.st_value] = AddressClass::eData;
+  break;
+}
+  }
+  if (mapping_symbol)
+continue;
+}
   }
 
-  if (arch.GetMachine() == llvm::Triple::arm) {
+  if (arch_machine =

[Lldb-commits] [lldb] Reapply "[lldb-dap] Re-land refactor of DebugCommunication. (#147787)" (PR #154832)

2025-08-21 Thread John Harrison via lldb-commits

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

This reverts commit 0f33b90b6117bcfa6ca3779c641c1ee8d03590fd and includes a fix 
for the added test that was submitted between my last update and pull.

>From ff17fd28c43d1109c8cb6057c628ad6f4b541242 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Thu, 21 Aug 2025 12:19:29 -0700
Subject: [PATCH 1/2] Reapply "[lldb-dap] Re-land refactor of
 DebugCommunication. (#147787)"

This reverts commit 0f33b90b6117bcfa6ca3779c641c1ee8d03590fd.
---
 .../test/tools/lldb-dap/dap_server.py | 802 ++
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  87 +-
 .../tools/lldb-dap/attach/TestDAP_attach.py   |   8 +-
 .../TestDAP_breakpointAssembly.py |   9 +-
 .../TestDAP_breakpointEvents.py   |   4 +-
 .../breakpoint/TestDAP_setBreakpoints.py  |  33 +-
 .../tools/lldb-dap/cancel/TestDAP_cancel.py   |  21 +-
 .../lldb-dap/commands/TestDAP_commands.py |  15 +-
 .../tools/lldb-dap/console/TestDAP_console.py |  12 +-
 .../TestDAP_instruction_breakpoint.py |   2 +-
 .../tools/lldb-dap/launch/TestDAP_launch.py   |  25 +-
 .../module-event/TestDAP_module_event.py  |  10 +-
 .../tools/lldb-dap/module/TestDAP_module.py   |  10 +-
 .../tools/lldb-dap/output/TestDAP_output.py   |   6 +-
 .../lldb-dap/progress/TestDAP_Progress.py |   2 +-
 15 files changed, 579 insertions(+), 467 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 7acb9c89b8b7d..7a2c2876f0b15 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
@@ -12,15 +12,91 @@
 import sys
 import threading
 import time
-from typing import Any, Optional, Union, BinaryIO, TextIO
+from typing import (
+Any,
+Optional,
+Dict,
+cast,
+List,
+Callable,
+IO,
+Union,
+BinaryIO,
+TextIO,
+TypedDict,
+Literal,
+)
 
 ## DAP type references
-Event = dict[str, Any]
-Request = dict[str, Any]
-Response = dict[str, Any]
+
+
+class Event(TypedDict):
+type: Literal["event"]
+seq: int
+event: str
+body: Any
+
+
+class Request(TypedDict, total=False):
+type: Literal["request"]
+seq: int
+command: str
+arguments: Any
+
+
+class Response(TypedDict):
+type: Literal["response"]
+seq: int
+request_seq: int
+success: bool
+command: str
+message: Optional[str]
+body: Any
+
+
 ProtocolMessage = Union[Event, Request, Response]
 
 
+class Source(TypedDict, total=False):
+name: str
+path: str
+sourceReference: int
+
+@staticmethod
+def build(
+*,
+name: Optional[str] = None,
+path: Optional[str] = None,
+source_reference: Optional[int] = None,
+) -> "Source":
+"""Builds a source from the given name, path or source_reference."""
+if not name and not path and not source_reference:
+raise ValueError(
+"Source.build requires either name, path, or source_reference"
+)
+
+s = Source()
+if name:
+s["name"] = name
+if path:
+if not name:
+s["name"] = os.path.basename(path)
+s["path"] = path
+if source_reference is not None:
+s["sourceReference"] = source_reference
+return s
+
+
+class Breakpoint(TypedDict, total=False):
+id: int
+verified: bool
+source: Source
+
+@staticmethod
+def is_verified(src: "Breakpoint") -> bool:
+return src.get("verified", False)
+
+
 def dump_memory(base_addr, data, num_per_line, outfile):
 data_len = len(data)
 hex_string = binascii.hexlify(data)
@@ -58,7 +134,9 @@ def dump_memory(base_addr, data, num_per_line, outfile):
 outfile.write("\n")
 
 
-def read_packet(f, verbose=False, trace_file=None):
+def read_packet(
+f: IO[bytes], trace_file: Optional[IO[str]] = None
+) -> Optional[ProtocolMessage]:
 """Decode a JSON packet that starts with the content length and is
 followed by the JSON bytes from a file 'f'. Returns None on EOF.
 """
@@ -70,19 +148,13 @@ def read_packet(f, verbose=False, trace_file=None):
 prefix = "Content-Length: "
 if line.startswith(prefix):
 # Decode length of JSON bytes
-if verbose:
-print('content: "%s"' % (line))
 length = int(line[len(prefix) :])
-if verbose:
-print('length: "%u"' % (length))
 # Skip empty line
-line = f.readline()
-if verbose:
-print('empty: "%s"' % (line))
+separator = f.readline().decode()
+if separator != "":
+Exception("malformed DAP content header, unexpected line: " + 
separator)
 # Read JSON bytes
-json_str = f.read(length)
-if verbose:
-print(

[Lldb-commits] [lldb] Reapply "[lldb-dap] Re-land refactor of DebugCommunication. (#147787)" (PR #154832)

2025-08-21 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

This reverts commit 0f33b90b6117bcfa6ca3779c641c1ee8d03590fd and includes a fix 
for the added test that was submitted between my last update and pull.

---

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


15 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
(+459-347) 
- (modified) 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py (+51-36) 
- (modified) lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py (+4-4) 
- (modified) 
lldb/test/API/tools/lldb-dap/breakpoint-assembly/TestDAP_breakpointAssembly.py 
(+4-5) 
- (modified) 
lldb/test/API/tools/lldb-dap/breakpoint-events/TestDAP_breakpointEvents.py 
(+2-2) 
- (modified) lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py 
(+22-11) 
- (modified) lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py (+8-13) 
- (modified) lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py (+6-9) 
- (modified) lldb/test/API/tools/lldb-dap/console/TestDAP_console.py (+3-9) 
- (modified) 
lldb/test/API/tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py
 (+1-1) 
- (modified) lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py (+8-17) 
- (modified) lldb/test/API/tools/lldb-dap/module-event/TestDAP_module_event.py 
(+5-5) 
- (modified) lldb/test/API/tools/lldb-dap/module/TestDAP_module.py (+4-6) 
- (modified) lldb/test/API/tools/lldb-dap/output/TestDAP_output.py (+3-3) 
- (modified) lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py (+1-1) 


``diff
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 7acb9c89b8b7d..0608ac3fd83be 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
@@ -12,15 +12,91 @@
 import sys
 import threading
 import time
-from typing import Any, Optional, Union, BinaryIO, TextIO
+from typing import (
+Any,
+Optional,
+Dict,
+cast,
+List,
+Callable,
+IO,
+Union,
+BinaryIO,
+TextIO,
+TypedDict,
+Literal,
+)
 
 ## DAP type references
-Event = dict[str, Any]
-Request = dict[str, Any]
-Response = dict[str, Any]
+
+
+class Event(TypedDict):
+type: Literal["event"]
+seq: int
+event: str
+body: Any
+
+
+class Request(TypedDict, total=False):
+type: Literal["request"]
+seq: int
+command: str
+arguments: Any
+
+
+class Response(TypedDict):
+type: Literal["response"]
+seq: int
+request_seq: int
+success: bool
+command: str
+message: Optional[str]
+body: Any
+
+
 ProtocolMessage = Union[Event, Request, Response]
 
 
+class Source(TypedDict, total=False):
+name: str
+path: str
+sourceReference: int
+
+@staticmethod
+def build(
+*,
+name: Optional[str] = None,
+path: Optional[str] = None,
+source_reference: Optional[int] = None,
+) -> "Source":
+"""Builds a source from the given name, path or source_reference."""
+if not name and not path and not source_reference:
+raise ValueError(
+"Source.build requires either name, path, or source_reference"
+)
+
+s = Source()
+if name:
+s["name"] = name
+if path:
+if not name:
+s["name"] = os.path.basename(path)
+s["path"] = path
+if source_reference is not None:
+s["sourceReference"] = source_reference
+return s
+
+
+class Breakpoint(TypedDict, total=False):
+id: int
+verified: bool
+source: Source
+
+@staticmethod
+def is_verified(src: "Breakpoint") -> bool:
+return src.get("verified", False)
+
+
 def dump_memory(base_addr, data, num_per_line, outfile):
 data_len = len(data)
 hex_string = binascii.hexlify(data)
@@ -58,7 +134,9 @@ def dump_memory(base_addr, data, num_per_line, outfile):
 outfile.write("\n")
 
 
-def read_packet(f, verbose=False, trace_file=None):
+def read_packet(
+f: IO[bytes], trace_file: Optional[IO[str]] = None
+) -> Optional[ProtocolMessage]:
 """Decode a JSON packet that starts with the content length and is
 followed by the JSON bytes from a file 'f'. Returns None on EOF.
 """
@@ -70,19 +148,13 @@ def read_packet(f, verbose=False, trace_file=None):
 prefix = "Content-Length: "
 if line.startswith(prefix):
 # Decode length of JSON bytes
-if verbose:
-print('content: "%s"' % (line))
 length = int(line[len(prefix) :])
-if verbose:
-print('length: "%u"' % (length))
 # Skip empty line
-line = f.readline()
-if verbose:
-print('empty: "%s"' % (line))
+sepa

[Lldb-commits] [lldb] [lldb-dap] Migrating 'completions' to structured types. (PR #153317)

2025-08-21 Thread John Harrison via lldb-commits

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

>From 3db3a7184eb7d729c37f7dc02f826c77df8c65e9 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Tue, 12 Aug 2025 16:23:18 -0700
Subject: [PATCH 1/6] [lldb-dap] Migrating 'completions' to structured types.

This migrates the CompletionHandler to structured types and adds a new 
CompletionItem and CompletionItemType to the general types.
---
 .../lldb-dap/Handler/CompletionsHandler.cpp   | 175 --
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |   9 +-
 .../lldb-dap/Protocol/ProtocolRequests.cpp|  11 ++
 .../lldb-dap/Protocol/ProtocolRequests.h  |  29 +++
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp | 117 
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  78 
 6 files changed, 272 insertions(+), 147 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp 
b/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp
index c72fc5686cd5b..7507aa17f5421 100644
--- a/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp
@@ -8,156 +8,46 @@
 
 #include "DAP.h"
 #include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
+#include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBStringList.h"
 
-namespace lldb_dap {
+using namespace llvm;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
 
-// "CompletionsRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Returns a list of possible completions for a given caret
-// position and text.\nThe CompletionsRequest may only be called if the
-// 'supportsCompletionsRequest' capability exists and is true.",
-// "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "completions" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/CompletionsArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "CompletionsArguments": {
-//   "type": "object",
-//   "description": "Arguments for 'completions' request.",
-//   "properties": {
-// "frameId": {
-//   "type": "integer",
-//   "description": "Returns completions in the scope of this stack frame.
-//   If not specified, the completions are returned for the global scope."
-// },
-// "text": {
-//   "type": "string",
-//   "description": "One or more source lines. Typically this is the text a
-//   user has typed into the debug console before he asked for completion."
-// },
-// "column": {
-//   "type": "integer",
-//   "description": "The character position for which to determine the
-//   completion proposals."
-// },
-// "line": {
-//   "type": "integer",
-//   "description": "An optional line for which to determine the completion
-//   proposals. If missing the first line of the text is assumed."
-// }
-//   },
-//   "required": [ "text", "column" ]
-// },
-// "CompletionsResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to 'completions' request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "targets": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/CompletionItem"
-// },
-// "description": "The possible completions for ."
-//   }
-// },
-// "required": [ "targets" ]
-//   }
-// },
-// "required": [ "body" ]
-//   }]
-// },
-// "CompletionItem": {
-//   "type": "object",
-//   "description": "CompletionItems are the suggestions returned from the
-//   CompletionsRequest.", "properties": {
-// "label": {
-//   "type": "string",
-//   "description": "The label of this completion item. By default this is
-//   also the text that is inserted when selecting this completion."
-// },
-// "text": {
-//   "type": "string",
-//   "description": "If text is not falsy then it is inserted instead of 
the
-//   label."
-// },
-// "sortText": {
-//   "type": "string",
-//   "description": "A string that should be used when comparing this item
-//   with other items. When `falsy` the label is used."
-// },
-// "type": {
-//   "$ref": "#/definitions/CompletionItemType",
-//   "description": "The item's type. Typically the client uses this
-//   information to render the item in the UI with an icon."
-// },
-// "start": {
-//   "type": "integer",
-//   "description": "This value determines the location (in the
-//   CompletionsRequest's 'text' attribute) where the completion text is
-//   added.\nIf missing the text is added at the location specified by the
-//   CompletionsReques

[Lldb-commits] [lldb] [lldb] Corretly parse Wasm segments (PR #154727)

2025-08-21 Thread Jonas Devlieghere via lldb-commits

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

>From defb8e0fe69009362537b3e2c9c05c4eac544505 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 21 Aug 2025 03:25:19 -0700
Subject: [PATCH] [lldb] Corretly parse Wasm segments

My original implementation for parsing Wasm segments was wrong in two
related ways. I had a bug in calculating the file vm address and I
didn't fully understand the difference between active and passive
segments and how that impacted their file vm address.

With this PR, we now support parsing init expressions for active
segments, rather than just skipping over them. This is necessary to
determine where they get loaded.

Similar to llvm-objdump, we currently only support simple opcodes (i.e.
constants). We also currently do not support active segments that use a
non-zero memory index. However this covers all segments for a
non-trivial Swift binary compiled to Wasm.
---
 .../ObjectFile/wasm/ObjectFileWasm.cpp| 329 +++---
 .../Plugins/ObjectFile/wasm/ObjectFileWasm.h  |  13 +-
 lldb/test/Shell/Symtab/symtab-wasm.test   |  25 +-
 3 files changed, 227 insertions(+), 140 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp 
b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
index 777b20e9bb0f6..492b441867205 100644
--- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
+++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
@@ -71,6 +71,47 @@ GetWasmString(llvm::DataExtractor &data, 
llvm::DataExtractor::Cursor &c) {
   return std::string(toStringRef(llvm::ArrayRef(str_storage)));
 }
 
+/// An "init expr" refers to a constant expression used to determine the 
initial
+/// value of certain elements within a module during instantiation. These
+/// expressions are restricted to operations that can be evaluated at module
+/// instantiation time. Currently we only support simple constant opcodes.
+static lldb::offset_t GetWasmOffsetFromInitExpr(DataExtractor &data,
+lldb::offset_t &offset) {
+  lldb::offset_t init_expr_offset = LLDB_INVALID_OFFSET;
+
+  uint8_t opcode = data.GetU8(&offset);
+  switch (opcode) {
+  case llvm::wasm::WASM_OPCODE_I32_CONST:
+  case llvm::wasm::WASM_OPCODE_I64_CONST:
+init_expr_offset = data.GetSLEB128(&offset);
+break;
+  case llvm::wasm::WASM_OPCODE_GLOBAL_GET:
+init_expr_offset = data.GetULEB128(&offset);
+break;
+  case llvm::wasm::WASM_OPCODE_F32_CONST:
+  case llvm::wasm::WASM_OPCODE_F64_CONST:
+// Not a meaningful offset.
+data.GetFloat(&offset);
+break;
+  case llvm::wasm::WASM_OPCODE_REF_NULL:
+// Not a meaningful offset.
+data.GetULEB128(&offset);
+break;
+  }
+
+  // Make sure the opcodes we read aren't part of an extended init expr.
+  opcode = data.GetU8(&offset);
+  if (opcode == llvm::wasm::WASM_OPCODE_END)
+return init_expr_offset;
+
+  // Extended init expressions are not supported, but we still have to parse
+  // them to skip over them and read the next segment.
+  do {
+opcode = data.GetU8(&offset);
+  } while (opcode != llvm::wasm::WASM_OPCODE_END);
+  return LLDB_INVALID_OFFSET;
+}
+
 /// Checks whether the data buffer starts with a valid Wasm module header.
 static bool ValidateModuleHeader(const DataBufferSP &data_sp) {
   if (!data_sp || data_sp->GetByteSize() < kWasmHeaderSize)
@@ -261,17 +302,20 @@ bool ObjectFileWasm::ParseHeader() {
   return true;
 }
 
-static llvm::Expected>
-ParseFunctions(SectionSP code_section_sp) {
-  DataExtractor data;
-  code_section_sp->GetSectionData(data);
+struct WasmFunction {
+  lldb::offset_t section_offset = LLDB_INVALID_OFFSET;
+  uint32_t size = 0;
+};
+
+static llvm::Expected>
+ParseFunctions(DataExtractor &data) {
   lldb::offset_t offset = 0;
 
   llvm::Expected function_count = GetULEB32(data, offset);
   if (!function_count)
 return function_count.takeError();
 
-  std::vector functions;
+  std::vector functions;
   functions.reserve(*function_count);
 
   for (uint32_t i = 0; i < *function_count; ++i) {
@@ -281,7 +325,7 @@ ParseFunctions(SectionSP code_section_sp) {
 // llvm-objdump considers the ULEB with the function size to be part of the
 // function. We can't do that here because that would break symbolic
 // breakpoints, as that address is never executed.
-functions.emplace_back(code_section_sp, offset, *function_size);
+functions.push_back({offset, *function_size});
 
 std::optional next_offset =
 llvm::checkedAddUnsigned(offset, *function_size);
@@ -294,17 +338,22 @@ ParseFunctions(SectionSP code_section_sp) {
 }
 
 struct WasmSegment {
-  WasmSegment(SectionSP section_sp, lldb::offset_t offset, uint32_t size)
-  : address_range(section_sp, offset, size) {};
+  enum SegmentType {
+Active,
+Passive,
+  };
+
   std::string name;
-  AddressRange address_range;
-};
+  SegmentType type = Passive;
+  lldb::offset_t section_offset 

[Lldb-commits] [lldb] [lldb-dap] Migrating 'completions' to structured types. (PR #153317)

2025-08-21 Thread John Harrison via lldb-commits

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

>From 3db3a7184eb7d729c37f7dc02f826c77df8c65e9 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Tue, 12 Aug 2025 16:23:18 -0700
Subject: [PATCH 1/5] [lldb-dap] Migrating 'completions' to structured types.

This migrates the CompletionHandler to structured types and adds a new 
CompletionItem and CompletionItemType to the general types.
---
 .../lldb-dap/Handler/CompletionsHandler.cpp   | 175 --
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |   9 +-
 .../lldb-dap/Protocol/ProtocolRequests.cpp|  11 ++
 .../lldb-dap/Protocol/ProtocolRequests.h  |  29 +++
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp | 117 
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  78 
 6 files changed, 272 insertions(+), 147 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp 
b/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp
index c72fc5686cd5b..7507aa17f5421 100644
--- a/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp
@@ -8,156 +8,46 @@
 
 #include "DAP.h"
 #include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
+#include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBStringList.h"
 
-namespace lldb_dap {
+using namespace llvm;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
 
-// "CompletionsRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Returns a list of possible completions for a given caret
-// position and text.\nThe CompletionsRequest may only be called if the
-// 'supportsCompletionsRequest' capability exists and is true.",
-// "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "completions" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/CompletionsArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "CompletionsArguments": {
-//   "type": "object",
-//   "description": "Arguments for 'completions' request.",
-//   "properties": {
-// "frameId": {
-//   "type": "integer",
-//   "description": "Returns completions in the scope of this stack frame.
-//   If not specified, the completions are returned for the global scope."
-// },
-// "text": {
-//   "type": "string",
-//   "description": "One or more source lines. Typically this is the text a
-//   user has typed into the debug console before he asked for completion."
-// },
-// "column": {
-//   "type": "integer",
-//   "description": "The character position for which to determine the
-//   completion proposals."
-// },
-// "line": {
-//   "type": "integer",
-//   "description": "An optional line for which to determine the completion
-//   proposals. If missing the first line of the text is assumed."
-// }
-//   },
-//   "required": [ "text", "column" ]
-// },
-// "CompletionsResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to 'completions' request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "targets": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/CompletionItem"
-// },
-// "description": "The possible completions for ."
-//   }
-// },
-// "required": [ "targets" ]
-//   }
-// },
-// "required": [ "body" ]
-//   }]
-// },
-// "CompletionItem": {
-//   "type": "object",
-//   "description": "CompletionItems are the suggestions returned from the
-//   CompletionsRequest.", "properties": {
-// "label": {
-//   "type": "string",
-//   "description": "The label of this completion item. By default this is
-//   also the text that is inserted when selecting this completion."
-// },
-// "text": {
-//   "type": "string",
-//   "description": "If text is not falsy then it is inserted instead of 
the
-//   label."
-// },
-// "sortText": {
-//   "type": "string",
-//   "description": "A string that should be used when comparing this item
-//   with other items. When `falsy` the label is used."
-// },
-// "type": {
-//   "$ref": "#/definitions/CompletionItemType",
-//   "description": "The item's type. Typically the client uses this
-//   information to render the item in the UI with an icon."
-// },
-// "start": {
-//   "type": "integer",
-//   "description": "This value determines the location (in the
-//   CompletionsRequest's 'text' attribute) where the completion text is
-//   added.\nIf missing the text is added at the location specified by the
-//   CompletionsReques

[Lldb-commits] [lldb] Omit loading local symbols in LLDB symbol table (PR #154809)

2025-08-21 Thread via lldb-commits

https://github.com/barsolo2000 created 
https://github.com/llvm/llvm-project/pull/154809

https://discourse.llvm.org/t/rfc-should-we-omit-local-symbols-in-eekciihgtfvflvnbieicunjlrtnufhuelf-files-from-the-lldb-symbol-table/87384

Improving symbolication by excluding local symbols that are typically not 
useful for debugging or symbol lookups. This aligns with the discussion that 
local symbols, especially those with STB_LOCAL binding and STT_NOTYPE type 
(including .L-prefixed symbols), often interfere with symbol resolution and can 
be safely omitted.

>From f378e6a09487eca27d4741bc527c578b8fb8d161 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik 
Date: Wed, 20 Aug 2025 14:54:52 -0700
Subject: [PATCH 1/2] added helper function

---
 .../source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 13 +
 1 file changed, 13 insertions(+)

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index f69358de6a288..37983cfef0a2e 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2037,6 +2037,19 @@ static char FindArmAarch64MappingSymbol(const char 
*symbol_name) {
   return '\0';
 }
 
+static char FindRISCVMappingSymbol(const char *symbol_name) {
+  if (!symbol_name)
+return '\0';
+
+  if (symbol_name.size() == 2 && symbol_name[0] == '$'){
+char c = symbol_name[1];
+if (c == 'd' || c == 'x'){
+  return c;
+}
+  return '\0';
+  }
+}
+
 #define STO_MIPS_ISA (3 << 6)
 #define STO_MICROMIPS (2 << 6)
 #define IS_MICROMIPS(ST_OTHER) (((ST_OTHER)&STO_MIPS_ISA) == STO_MICROMIPS)

>From b88812ae8e4a7647258360985721fa6b1ada0614 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik 
Date: Thu, 21 Aug 2025 10:51:17 -0700
Subject: [PATCH 2/2] fixed format

---
 .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp  | 44 ++-
 1 file changed, 33 insertions(+), 11 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 37983cfef0a2e..99744b25ea66f 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2041,13 +2041,12 @@ static char FindRISCVMappingSymbol(const char 
*symbol_name) {
   if (!symbol_name)
 return '\0';
 
-  if (symbol_name.size() == 2 && symbol_name[0] == '$'){
-char c = symbol_name[1];
-if (c == 'd' || c == 'x'){
-  return c;
-}
-  return '\0';
+  if (symbol_name[0] == '$' &&
+  (symbol_name[1] == 'd' || symbol_name[1] == 'x') &&
+  symbol_name[2] == '\0') {
+return symbol_name[1];
   }
+  return '\0';
 }
 
 #define STO_MIPS_ISA (3 << 6)
@@ -2115,11 +2114,13 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
 if (!symbol_name)
   symbol_name = "";
 
+if (symbol_name[0] == '.' && symbol_name[1] == 'L')
+  continue;
 // No need to add non-section symbols that have no names
 if (symbol.getType() != STT_SECTION &&
 (symbol_name == nullptr || symbol_name[0] == '\0'))
   continue;
-
+
 // Skipping oatdata and oatexec sections if it is requested. See details
 // above the definition of skip_oatdata_oatexec for the reasons.
 if (skip_oatdata_oatexec && (::strcmp(symbol_name, "oatdata") == 0 ||
@@ -2203,9 +2204,9 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
 
 int64_t symbol_value_offset = 0;
 uint32_t additional_flags = 0;
-
+llvm::Triple::ArchType arch_machine = arch.GetMachine();
 if (arch.IsValid()) {
-  if (arch.GetMachine() == llvm::Triple::arm) {
+  if (arch_machine == llvm::Triple::arm) {
 if (symbol.getBinding() == STB_LOCAL) {
   char mapping_symbol = FindArmAarch64MappingSymbol(symbol_name);
   if (symbol_type == eSymbolTypeCode) {
@@ -2230,7 +2231,7 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
   if (mapping_symbol)
 continue;
 }
-  } else if (arch.GetMachine() == llvm::Triple::aarch64) {
+  } else if (arch_machine == llvm::Triple::aarch64) {
 if (symbol.getBinding() == STB_LOCAL) {
   char mapping_symbol = FindArmAarch64MappingSymbol(symbol_name);
   if (symbol_type == eSymbolTypeCode) {
@@ -2248,9 +2249,30 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
   if (mapping_symbol)
 continue;
 }
+  } else if (arch_machine == llvm::Triple::riscv32 ||
+ arch_machine == llvm::Triple::riscv64 ||
+ arch_machine == llvm::Triple::riscv32be ||
+ arch_machine == llvm::Triple::riscv64be) {
+if (symbol.getBinding() == STB_LOCAL) {
+  char mapping_symbol = FindRISCVMappingSymbol(symbol_name);
+  if (symbol_type == eSymbolTypeCode) {
+switch (mapping_symbol) {
+case 'x':
+  // $x - marks a RISCV in

[Lldb-commits] [clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-21 Thread Dan Liew via lldb-commits


@@ -30,6 +30,7 @@ def CLASS_REMARK: DiagClass;
 def CLASS_WARNING   : DiagClass;
 def CLASS_EXTENSION : DiagClass;
 def CLASS_ERROR : DiagClass;
+def CLASS_TRAP  : DiagClass;

delcypher wrote:

My initial prototype didn't add a new class but after thinking about it I 
really didn't think any of the existing classes made much sense other than 
`error`. And as you say adding a class means we can enforce that we don't 
actually emit a trap diagnostic as a regular diagnostic.

I'll add the assert as you suggest.

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


[Lldb-commits] [lldb] Omit loading local symbols in LLDB symbol table (PR #154809)

2025-08-21 Thread via lldb-commits

https://github.com/barsolo2000 updated 
https://github.com/llvm/llvm-project/pull/154809

>From f378e6a09487eca27d4741bc527c578b8fb8d161 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik 
Date: Wed, 20 Aug 2025 14:54:52 -0700
Subject: [PATCH 1/3] added helper function

---
 .../source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 13 +
 1 file changed, 13 insertions(+)

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index f69358de6a288..37983cfef0a2e 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2037,6 +2037,19 @@ static char FindArmAarch64MappingSymbol(const char 
*symbol_name) {
   return '\0';
 }
 
+static char FindRISCVMappingSymbol(const char *symbol_name) {
+  if (!symbol_name)
+return '\0';
+
+  if (symbol_name.size() == 2 && symbol_name[0] == '$'){
+char c = symbol_name[1];
+if (c == 'd' || c == 'x'){
+  return c;
+}
+  return '\0';
+  }
+}
+
 #define STO_MIPS_ISA (3 << 6)
 #define STO_MICROMIPS (2 << 6)
 #define IS_MICROMIPS(ST_OTHER) (((ST_OTHER)&STO_MIPS_ISA) == STO_MICROMIPS)

>From b88812ae8e4a7647258360985721fa6b1ada0614 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik 
Date: Thu, 21 Aug 2025 10:51:17 -0700
Subject: [PATCH 2/3] fixed format

---
 .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp  | 44 ++-
 1 file changed, 33 insertions(+), 11 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 37983cfef0a2e..99744b25ea66f 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2041,13 +2041,12 @@ static char FindRISCVMappingSymbol(const char 
*symbol_name) {
   if (!symbol_name)
 return '\0';
 
-  if (symbol_name.size() == 2 && symbol_name[0] == '$'){
-char c = symbol_name[1];
-if (c == 'd' || c == 'x'){
-  return c;
-}
-  return '\0';
+  if (symbol_name[0] == '$' &&
+  (symbol_name[1] == 'd' || symbol_name[1] == 'x') &&
+  symbol_name[2] == '\0') {
+return symbol_name[1];
   }
+  return '\0';
 }
 
 #define STO_MIPS_ISA (3 << 6)
@@ -2115,11 +2114,13 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
 if (!symbol_name)
   symbol_name = "";
 
+if (symbol_name[0] == '.' && symbol_name[1] == 'L')
+  continue;
 // No need to add non-section symbols that have no names
 if (symbol.getType() != STT_SECTION &&
 (symbol_name == nullptr || symbol_name[0] == '\0'))
   continue;
-
+
 // Skipping oatdata and oatexec sections if it is requested. See details
 // above the definition of skip_oatdata_oatexec for the reasons.
 if (skip_oatdata_oatexec && (::strcmp(symbol_name, "oatdata") == 0 ||
@@ -2203,9 +2204,9 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
 
 int64_t symbol_value_offset = 0;
 uint32_t additional_flags = 0;
-
+llvm::Triple::ArchType arch_machine = arch.GetMachine();
 if (arch.IsValid()) {
-  if (arch.GetMachine() == llvm::Triple::arm) {
+  if (arch_machine == llvm::Triple::arm) {
 if (symbol.getBinding() == STB_LOCAL) {
   char mapping_symbol = FindArmAarch64MappingSymbol(symbol_name);
   if (symbol_type == eSymbolTypeCode) {
@@ -2230,7 +2231,7 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
   if (mapping_symbol)
 continue;
 }
-  } else if (arch.GetMachine() == llvm::Triple::aarch64) {
+  } else if (arch_machine == llvm::Triple::aarch64) {
 if (symbol.getBinding() == STB_LOCAL) {
   char mapping_symbol = FindArmAarch64MappingSymbol(symbol_name);
   if (symbol_type == eSymbolTypeCode) {
@@ -2248,9 +2249,30 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
   if (mapping_symbol)
 continue;
 }
+  } else if (arch_machine == llvm::Triple::riscv32 ||
+ arch_machine == llvm::Triple::riscv64 ||
+ arch_machine == llvm::Triple::riscv32be ||
+ arch_machine == llvm::Triple::riscv64be) {
+if (symbol.getBinding() == STB_LOCAL) {
+  char mapping_symbol = FindRISCVMappingSymbol(symbol_name);
+  if (symbol_type == eSymbolTypeCode) {
+switch (mapping_symbol) {
+case 'x':
+  // $x - marks a RISCV instruction sequence
+  address_class_map[symbol.st_value] = AddressClass::eCode;
+  break;
+case 'd':
+  // $d - marks a RISCV data item sequence
+  address_class_map[symbol.st_value] = AddressClass::eData;
+  break;
+}
+  }
+  if (mapping_symbol)
+continue;
+}
   }
 
-  if (arch.GetMachine() == llvm::Triple::arm) {
+  if (arch_machine =

[Lldb-commits] [lldb] [lldb] Underline short option letters as mnemonics (PR #153695)

2025-08-21 Thread via lldb-commits

jimingham wrote:

> Regarding capitalization, I pretty strongly prefer **not** to change it and 
> focus on highlighting the mnemonic. Here's why:
> 
> * I don't think that matching the capitalization was ever the goal, but 
> rather capitalization was used to highlight the letter, regardless of whether 
> the short option was actually capitalized. Now the same thing is achieved 
> through an underline.
> * I think the capitalization of the short option is much less important than 
> the mnemonic aspect. If the option is `-W` and I see an underlined `w`, it 
> doesn't take much mental overhead to piece the two together. Similar to the 
> above, I don't think the goal was to be able to read the help text and figure 
> out the exact option without having to look at the line above with the short 
> and long option.
> * If we do change the capitalization, we're back to the original problem when 
> someone runs lldb without color (or if we end up detangling the two, without 
> escape codes) where this looks like a typo. Even with the underline, users 
> might still think it's a typo.
> 
> @DavidSpickett @kastiglione let me know if you folks feel differently or have 
> an alternative suggestion.

I'm fine with this option.  The purpose was to help make the letter we're 
choosing for the short option stick in people's minds a bit when they look at 
the help output.  underlining the letter does that all the way for lower case 
and gets close enough for upper case short options to be useful without making 
the output look weird.

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


[Lldb-commits] [lldb] [lldb-dap] Migrating 'completions' to structured types. (PR #153317)

2025-08-21 Thread John Harrison via lldb-commits

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

>From 3db3a7184eb7d729c37f7dc02f826c77df8c65e9 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Tue, 12 Aug 2025 16:23:18 -0700
Subject: [PATCH 1/6] [lldb-dap] Migrating 'completions' to structured types.

This migrates the CompletionHandler to structured types and adds a new 
CompletionItem and CompletionItemType to the general types.
---
 .../lldb-dap/Handler/CompletionsHandler.cpp   | 175 --
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |   9 +-
 .../lldb-dap/Protocol/ProtocolRequests.cpp|  11 ++
 .../lldb-dap/Protocol/ProtocolRequests.h  |  29 +++
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp | 117 
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  78 
 6 files changed, 272 insertions(+), 147 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp 
b/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp
index c72fc5686cd5b..7507aa17f5421 100644
--- a/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp
@@ -8,156 +8,46 @@
 
 #include "DAP.h"
 #include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
+#include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBStringList.h"
 
-namespace lldb_dap {
+using namespace llvm;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
 
-// "CompletionsRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Returns a list of possible completions for a given caret
-// position and text.\nThe CompletionsRequest may only be called if the
-// 'supportsCompletionsRequest' capability exists and is true.",
-// "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "completions" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/CompletionsArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "CompletionsArguments": {
-//   "type": "object",
-//   "description": "Arguments for 'completions' request.",
-//   "properties": {
-// "frameId": {
-//   "type": "integer",
-//   "description": "Returns completions in the scope of this stack frame.
-//   If not specified, the completions are returned for the global scope."
-// },
-// "text": {
-//   "type": "string",
-//   "description": "One or more source lines. Typically this is the text a
-//   user has typed into the debug console before he asked for completion."
-// },
-// "column": {
-//   "type": "integer",
-//   "description": "The character position for which to determine the
-//   completion proposals."
-// },
-// "line": {
-//   "type": "integer",
-//   "description": "An optional line for which to determine the completion
-//   proposals. If missing the first line of the text is assumed."
-// }
-//   },
-//   "required": [ "text", "column" ]
-// },
-// "CompletionsResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to 'completions' request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "targets": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/CompletionItem"
-// },
-// "description": "The possible completions for ."
-//   }
-// },
-// "required": [ "targets" ]
-//   }
-// },
-// "required": [ "body" ]
-//   }]
-// },
-// "CompletionItem": {
-//   "type": "object",
-//   "description": "CompletionItems are the suggestions returned from the
-//   CompletionsRequest.", "properties": {
-// "label": {
-//   "type": "string",
-//   "description": "The label of this completion item. By default this is
-//   also the text that is inserted when selecting this completion."
-// },
-// "text": {
-//   "type": "string",
-//   "description": "If text is not falsy then it is inserted instead of 
the
-//   label."
-// },
-// "sortText": {
-//   "type": "string",
-//   "description": "A string that should be used when comparing this item
-//   with other items. When `falsy` the label is used."
-// },
-// "type": {
-//   "$ref": "#/definitions/CompletionItemType",
-//   "description": "The item's type. Typically the client uses this
-//   information to render the item in the UI with an icon."
-// },
-// "start": {
-//   "type": "integer",
-//   "description": "This value determines the location (in the
-//   CompletionsRequest's 'text' attribute) where the completion text is
-//   added.\nIf missing the text is added at the location specified by the
-//   CompletionsReques

[Lldb-commits] [lldb] [lldb] Improve error message in ResolveSDKPathFromDebugInfo (NFC) (PR #154607)

2025-08-21 Thread Dave Lee via lldb-commits


@@ -1039,7 +1039,12 @@ ResolveSDKPathFromDebugInfo(lldb_private::Target 
*target) {
 
   SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
   if (!sym_file)
-return llvm::createStringError("Failed to get symbol file from module");
+return llvm::createStringError("Failed to get symbol file from 
executable");

kastiglione wrote:

@Michael137 I tried to update XcodeSDKModuleTests.cpp but can't figure out how 
to construct a yaml that represents zero compile units. If you know how to do 
that, I'll make a follow up test.

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


[Lldb-commits] [lldb] [lldb] Improve error message in ResolveSDKPathFromDebugInfo (NFC) (PR #154607)

2025-08-21 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-21 Thread Dan Liew via lldb-commits


@@ -30,4 +30,5 @@
 #include "clang/Basic/DiagnosticAnalysisKinds.inc"
 #include "clang/Basic/DiagnosticRefactoringKinds.inc"
 #include "clang/Basic/DiagnosticInstallAPIKinds.inc"
+#include "clang/Basic/DiagnosticCodeGenKinds.inc"

delcypher wrote:

So the reason I picked the name `CodeGen` is because it seemed like the 
Diagnostics subsystem named the component after the library it was used in 
(e.g. `Analysis`, `InstallAPI`, `Sema`, etc...). An outlier to that I suppose 
would be the `Common` component. If you are ok with breaking (what looks like) 
convention then I'm happy with `DiagnosticTrapKinds` because it's a much better 
name.

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


[Lldb-commits] [lldb] Fix non-deterministic failure in ```TestDAP_attach.py``` and improve error message handling in ```lldbdap_testcase.py``` (PR #154632)

2025-08-21 Thread Piyush Jaiswal via lldb-commits

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


[Lldb-commits] [lldb] [lldb][debugserver] update --help to list all the options (PR #154853)

2025-08-21 Thread via lldb-commits

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

LGMT

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


[Lldb-commits] [lldb] [lldb][debugserver] update --help to list all the options (PR #154853)

2025-08-21 Thread Jonas Devlieghere via lldb-commits

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

Nice 📚

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


[Lldb-commits] [lldb] [lldb/API] Add setters to SBStructuredData (PR #154445)

2025-08-21 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] Reapply "[lldb-dap] Re-land refactor of DebugCommunication. (#147787)" (PR #154832)

2025-08-21 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb/API] Add setters to SBStructuredData (PR #154445)

2025-08-21 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Re-land refactor of DebugCommunication. (PR #147787)

2025-08-21 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

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

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


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: 
functionalities/thread/create_after_attach/TestCreateAfterAttach.py (336 of 
3150)
PASS: lldb-api :: 
functionalities/breakpoint/serialize/TestBreakpointSerialization.py (337 of 
3150)
PASS: lldb-api :: 
tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py
 (338 of 3150)
PASS: lldb-api :: functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py 
(339 of 3150)
PASS: lldb-api :: 
functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py (340 of 3150)
PASS: lldb-api :: types/TestRecursiveTypes.py (341 of 3150)
PASS: lldb-api :: 
functionalities/data-formatter/custom-printf-summary/TestCustomSummaryLLVMFormat.py
 (342 of 3150)
PASS: lldb-api :: 
functionalities/thread/state_after_expression/TestStateAfterExpression.py (343 
of 3150)
PASS: lldb-api :: python_api/type/TestTypeList.py (344 of 3150)
UNRESOLVED: lldb-api :: tools/lldb-dap/moduleSymbols/TestDAP_moduleSymbols.py 
(345 of 3150)
 TEST 'lldb-api :: 
tools/lldb-dap/moduleSymbols/TestDAP_moduleSymbols.py' FAILED 

Script:
--
/usr/bin/python3 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/dotest.py -u 
CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --env 
LLVM_INCLUDE_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/include --env 
LLVM_TOOLS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --arch x86_64 
--build-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/lldb --compiler 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin/clang --dsymutil 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin/dsymutil --make 
/usr/bin/gmake --llvm-tools-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --lldb-obj-root 
/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb --lldb-libs-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --cmake-build-type Release -t 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/moduleSymbols
 -p TestDAP_moduleSymbols.py
--
Exit Code: 1

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

--
Command Output (stderr):
--
Change dir to: 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/moduleSymbols
runCmd: settings clear --all

output: 

runCmd: settings set symbols.enable-external-lookup false

output: 

runCmd: settings set target.inherit-tcc true

output: 

runCmd: settings set target.disable-aslr false

output: 

runCmd: settings set target.detach-on-error false

output: 

runCmd: settings set target.auto-apply-fixits false

```



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


[Lldb-commits] [lldb] Omit loading local symbols in LLDB symbol table (PR #154809)

2025-08-21 Thread via lldb-commits

https://github.com/barsolo2000 updated 
https://github.com/llvm/llvm-project/pull/154809

>From f378e6a09487eca27d4741bc527c578b8fb8d161 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik 
Date: Wed, 20 Aug 2025 14:54:52 -0700
Subject: [PATCH 1/5] added helper function

---
 .../source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 13 +
 1 file changed, 13 insertions(+)

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index f69358de6a288..37983cfef0a2e 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2037,6 +2037,19 @@ static char FindArmAarch64MappingSymbol(const char 
*symbol_name) {
   return '\0';
 }
 
+static char FindRISCVMappingSymbol(const char *symbol_name) {
+  if (!symbol_name)
+return '\0';
+
+  if (symbol_name.size() == 2 && symbol_name[0] == '$'){
+char c = symbol_name[1];
+if (c == 'd' || c == 'x'){
+  return c;
+}
+  return '\0';
+  }
+}
+
 #define STO_MIPS_ISA (3 << 6)
 #define STO_MICROMIPS (2 << 6)
 #define IS_MICROMIPS(ST_OTHER) (((ST_OTHER)&STO_MIPS_ISA) == STO_MICROMIPS)

>From b88812ae8e4a7647258360985721fa6b1ada0614 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik 
Date: Thu, 21 Aug 2025 10:51:17 -0700
Subject: [PATCH 2/5] fixed format

---
 .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp  | 44 ++-
 1 file changed, 33 insertions(+), 11 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 37983cfef0a2e..99744b25ea66f 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2041,13 +2041,12 @@ static char FindRISCVMappingSymbol(const char 
*symbol_name) {
   if (!symbol_name)
 return '\0';
 
-  if (symbol_name.size() == 2 && symbol_name[0] == '$'){
-char c = symbol_name[1];
-if (c == 'd' || c == 'x'){
-  return c;
-}
-  return '\0';
+  if (symbol_name[0] == '$' &&
+  (symbol_name[1] == 'd' || symbol_name[1] == 'x') &&
+  symbol_name[2] == '\0') {
+return symbol_name[1];
   }
+  return '\0';
 }
 
 #define STO_MIPS_ISA (3 << 6)
@@ -2115,11 +2114,13 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
 if (!symbol_name)
   symbol_name = "";
 
+if (symbol_name[0] == '.' && symbol_name[1] == 'L')
+  continue;
 // No need to add non-section symbols that have no names
 if (symbol.getType() != STT_SECTION &&
 (symbol_name == nullptr || symbol_name[0] == '\0'))
   continue;
-
+
 // Skipping oatdata and oatexec sections if it is requested. See details
 // above the definition of skip_oatdata_oatexec for the reasons.
 if (skip_oatdata_oatexec && (::strcmp(symbol_name, "oatdata") == 0 ||
@@ -2203,9 +2204,9 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
 
 int64_t symbol_value_offset = 0;
 uint32_t additional_flags = 0;
-
+llvm::Triple::ArchType arch_machine = arch.GetMachine();
 if (arch.IsValid()) {
-  if (arch.GetMachine() == llvm::Triple::arm) {
+  if (arch_machine == llvm::Triple::arm) {
 if (symbol.getBinding() == STB_LOCAL) {
   char mapping_symbol = FindArmAarch64MappingSymbol(symbol_name);
   if (symbol_type == eSymbolTypeCode) {
@@ -2230,7 +2231,7 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
   if (mapping_symbol)
 continue;
 }
-  } else if (arch.GetMachine() == llvm::Triple::aarch64) {
+  } else if (arch_machine == llvm::Triple::aarch64) {
 if (symbol.getBinding() == STB_LOCAL) {
   char mapping_symbol = FindArmAarch64MappingSymbol(symbol_name);
   if (symbol_type == eSymbolTypeCode) {
@@ -2248,9 +2249,30 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
   if (mapping_symbol)
 continue;
 }
+  } else if (arch_machine == llvm::Triple::riscv32 ||
+ arch_machine == llvm::Triple::riscv64 ||
+ arch_machine == llvm::Triple::riscv32be ||
+ arch_machine == llvm::Triple::riscv64be) {
+if (symbol.getBinding() == STB_LOCAL) {
+  char mapping_symbol = FindRISCVMappingSymbol(symbol_name);
+  if (symbol_type == eSymbolTypeCode) {
+switch (mapping_symbol) {
+case 'x':
+  // $x - marks a RISCV instruction sequence
+  address_class_map[symbol.st_value] = AddressClass::eCode;
+  break;
+case 'd':
+  // $d - marks a RISCV data item sequence
+  address_class_map[symbol.st_value] = AddressClass::eData;
+  break;
+}
+  }
+  if (mapping_symbol)
+continue;
+}
   }
 
-  if (arch.GetMachine() == llvm::Triple::arm) {
+  if (arch_machine =

[Lldb-commits] [lldb] Omit loading local symbols in LLDB symbol table (PR #154809)

2025-08-21 Thread via lldb-commits

https://github.com/barsolo2000 updated 
https://github.com/llvm/llvm-project/pull/154809

>From f378e6a09487eca27d4741bc527c578b8fb8d161 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik 
Date: Wed, 20 Aug 2025 14:54:52 -0700
Subject: [PATCH 1/6] added helper function

---
 .../source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 13 +
 1 file changed, 13 insertions(+)

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index f69358de6a288..37983cfef0a2e 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2037,6 +2037,19 @@ static char FindArmAarch64MappingSymbol(const char 
*symbol_name) {
   return '\0';
 }
 
+static char FindRISCVMappingSymbol(const char *symbol_name) {
+  if (!symbol_name)
+return '\0';
+
+  if (symbol_name.size() == 2 && symbol_name[0] == '$'){
+char c = symbol_name[1];
+if (c == 'd' || c == 'x'){
+  return c;
+}
+  return '\0';
+  }
+}
+
 #define STO_MIPS_ISA (3 << 6)
 #define STO_MICROMIPS (2 << 6)
 #define IS_MICROMIPS(ST_OTHER) (((ST_OTHER)&STO_MIPS_ISA) == STO_MICROMIPS)

>From b88812ae8e4a7647258360985721fa6b1ada0614 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik 
Date: Thu, 21 Aug 2025 10:51:17 -0700
Subject: [PATCH 2/6] fixed format

---
 .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp  | 44 ++-
 1 file changed, 33 insertions(+), 11 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 37983cfef0a2e..99744b25ea66f 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2041,13 +2041,12 @@ static char FindRISCVMappingSymbol(const char 
*symbol_name) {
   if (!symbol_name)
 return '\0';
 
-  if (symbol_name.size() == 2 && symbol_name[0] == '$'){
-char c = symbol_name[1];
-if (c == 'd' || c == 'x'){
-  return c;
-}
-  return '\0';
+  if (symbol_name[0] == '$' &&
+  (symbol_name[1] == 'd' || symbol_name[1] == 'x') &&
+  symbol_name[2] == '\0') {
+return symbol_name[1];
   }
+  return '\0';
 }
 
 #define STO_MIPS_ISA (3 << 6)
@@ -2115,11 +2114,13 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
 if (!symbol_name)
   symbol_name = "";
 
+if (symbol_name[0] == '.' && symbol_name[1] == 'L')
+  continue;
 // No need to add non-section symbols that have no names
 if (symbol.getType() != STT_SECTION &&
 (symbol_name == nullptr || symbol_name[0] == '\0'))
   continue;
-
+
 // Skipping oatdata and oatexec sections if it is requested. See details
 // above the definition of skip_oatdata_oatexec for the reasons.
 if (skip_oatdata_oatexec && (::strcmp(symbol_name, "oatdata") == 0 ||
@@ -2203,9 +2204,9 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
 
 int64_t symbol_value_offset = 0;
 uint32_t additional_flags = 0;
-
+llvm::Triple::ArchType arch_machine = arch.GetMachine();
 if (arch.IsValid()) {
-  if (arch.GetMachine() == llvm::Triple::arm) {
+  if (arch_machine == llvm::Triple::arm) {
 if (symbol.getBinding() == STB_LOCAL) {
   char mapping_symbol = FindArmAarch64MappingSymbol(symbol_name);
   if (symbol_type == eSymbolTypeCode) {
@@ -2230,7 +2231,7 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
   if (mapping_symbol)
 continue;
 }
-  } else if (arch.GetMachine() == llvm::Triple::aarch64) {
+  } else if (arch_machine == llvm::Triple::aarch64) {
 if (symbol.getBinding() == STB_LOCAL) {
   char mapping_symbol = FindArmAarch64MappingSymbol(symbol_name);
   if (symbol_type == eSymbolTypeCode) {
@@ -2248,9 +2249,30 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
   if (mapping_symbol)
 continue;
 }
+  } else if (arch_machine == llvm::Triple::riscv32 ||
+ arch_machine == llvm::Triple::riscv64 ||
+ arch_machine == llvm::Triple::riscv32be ||
+ arch_machine == llvm::Triple::riscv64be) {
+if (symbol.getBinding() == STB_LOCAL) {
+  char mapping_symbol = FindRISCVMappingSymbol(symbol_name);
+  if (symbol_type == eSymbolTypeCode) {
+switch (mapping_symbol) {
+case 'x':
+  // $x - marks a RISCV instruction sequence
+  address_class_map[symbol.st_value] = AddressClass::eCode;
+  break;
+case 'd':
+  // $d - marks a RISCV data item sequence
+  address_class_map[symbol.st_value] = AddressClass::eData;
+  break;
+}
+  }
+  if (mapping_symbol)
+continue;
+}
   }
 
-  if (arch.GetMachine() == llvm::Triple::arm) {
+  if (arch_machine =

[Lldb-commits] [clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-21 Thread Dan Liew via lldb-commits

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


[Lldb-commits] [lldb] [lldb/crashlog] Avoid StopAtEntry when launch crashlog in interactive mode (PR #154651)

2025-08-21 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)


Changes

In 88f409194, we changed the way the crashlog scripted process was
launched since the previous approach required to parse the file twice,
by stopping at entry, setting the crashlog object in the middle of the
scripted process launch and resuming it.

Since then, we've introduced SBScriptObject which allows to pass any
arbitrary python object accross the SBAPI boundary to another scripted
affordance.

This patch make sure of that to include the parse crashlog object into
the scripted process launch info dictionary, which eliviates the need to
stop at entry.

Signed-off-by: Med Ismail Bennani 

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


2 Files Affected:

- (modified) lldb/examples/python/crashlog.py (+7-4) 
- (modified) lldb/examples/python/crashlog_scripted_process.py (+8-3) 


``diff
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index bb20f3a25c1c1..b466be6a62428 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1540,13 +1540,19 @@ def load_crashlog_in_scripted_process(debugger, 
crashlog_path, options, result):
 }
 )
 )
+
+crashlog_sd = lldb.SBStructuredData()
+crashlog_sd.SetGenericValue(
+lldb.SBScriptObject(crashlog, lldb.eScriptLanguagePython)
+)
+structured_data.SetValueForKey("crashlog", crashlog_sd)
+
 launch_info = lldb.SBLaunchInfo(None)
 launch_info.SetProcessPluginName("ScriptedProcess")
 launch_info.SetScriptedProcessClassName(
 "crashlog_scripted_process.CrashLogScriptedProcess"
 )
 launch_info.SetScriptedProcessDictionary(structured_data)
-launch_info.SetLaunchFlags(lldb.eLaunchFlagStopAtEntry)
 
 error = lldb.SBError()
 process = target.Launch(launch_info, error)
@@ -1554,9 +1560,6 @@ def load_crashlog_in_scripted_process(debugger, 
crashlog_path, options, result):
 if not process or error.Fail():
 raise InteractiveCrashLogException("couldn't launch Scripted Process", 
error)
 
-process.GetScriptedImplementation().set_crashlog(crashlog)
-process.Continue()
-
 if not options.skip_status:
 
 @contextlib.contextmanager
diff --git a/lldb/examples/python/crashlog_scripted_process.py 
b/lldb/examples/python/crashlog_scripted_process.py
index f54a8df0479e7..f8a727a1e393a 100644
--- a/lldb/examples/python/crashlog_scripted_process.py
+++ b/lldb/examples/python/crashlog_scripted_process.py
@@ -10,8 +10,7 @@
 
 
 class CrashLogScriptedProcess(ScriptedProcess):
-def set_crashlog(self, crashlog):
-self.crashlog = crashlog
+def parse_crashlog(self):
 if self.crashlog.process_id:
 if type(self.crashlog.process_id) is int:
 self.pid = self.crashlog.process_id
@@ -29,7 +28,7 @@ def set_crashlog(self, crashlog):
 if hasattr(self.crashlog, "asb"):
 self.extended_thread_info = self.crashlog.asb
 
-crashlog.load_images(self.options, self.loaded_images)
+self.crashlog.load_images(self.options, self.loaded_images)
 
 for thread in self.crashlog.threads:
 if (
@@ -92,10 +91,16 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args: 
lldb.SBStructuredData
 no_parallel_image_loading.GetBooleanValue()
 )
 
+crashlog = args.GetValueForKey("crashlog")
+if crashlog and crashlog.IsValid():
+if crashlog.GetType() == lldb.eStructuredDataTypeGeneric:
+self.crashlog = crashlog.GetGenericValue()
+
 self.pid = super().get_process_id()
 self.crashed_thread_idx = 0
 self.exception = None
 self.extended_thread_info = None
+self.parse_crashlog()
 
 def read_memory_at_address(
 self, addr: int, size: int, error: lldb.SBError

``




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


[Lldb-commits] [lldb] [lldb/crashlog] Avoid StopAtEntry when launch crashlog in interactive mode (PR #154651)

2025-08-21 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/154651

>From 5bd75225a9a934be76ce7b337c1defb1e25e9153 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Wed, 20 Aug 2025 17:07:33 -0700
Subject: [PATCH] [lldb/crashlog] Avoid StopAtEntry when launch crashlog in
 interactive mode

In 88f409194, we changed the way the crashlog scripted process was
launched since the previous approach required to parse the file twice,
by stopping at entry, setting the crashlog object in the middle of the
scripted process launch and resuming it.

Since then, we've introduced SBScriptObject which allows to pass any
arbitrary python object accross the SBAPI boundary to another scripted
affordance.

This patch make sure of that to include the parse crashlog object into
the scripted process launch info dictionary, which eliviates the need to
stop at entry.

Signed-off-by: Med Ismail Bennani 
---
 lldb/examples/python/crashlog.py  | 11 +++
 lldb/examples/python/crashlog_scripted_process.py | 11 ---
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index bb20f3a25c1c1..b466be6a62428 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1540,13 +1540,19 @@ def load_crashlog_in_scripted_process(debugger, 
crashlog_path, options, result):
 }
 )
 )
+
+crashlog_sd = lldb.SBStructuredData()
+crashlog_sd.SetGenericValue(
+lldb.SBScriptObject(crashlog, lldb.eScriptLanguagePython)
+)
+structured_data.SetValueForKey("crashlog", crashlog_sd)
+
 launch_info = lldb.SBLaunchInfo(None)
 launch_info.SetProcessPluginName("ScriptedProcess")
 launch_info.SetScriptedProcessClassName(
 "crashlog_scripted_process.CrashLogScriptedProcess"
 )
 launch_info.SetScriptedProcessDictionary(structured_data)
-launch_info.SetLaunchFlags(lldb.eLaunchFlagStopAtEntry)
 
 error = lldb.SBError()
 process = target.Launch(launch_info, error)
@@ -1554,9 +1560,6 @@ def load_crashlog_in_scripted_process(debugger, 
crashlog_path, options, result):
 if not process or error.Fail():
 raise InteractiveCrashLogException("couldn't launch Scripted Process", 
error)
 
-process.GetScriptedImplementation().set_crashlog(crashlog)
-process.Continue()
-
 if not options.skip_status:
 
 @contextlib.contextmanager
diff --git a/lldb/examples/python/crashlog_scripted_process.py 
b/lldb/examples/python/crashlog_scripted_process.py
index f54a8df0479e7..f8a727a1e393a 100644
--- a/lldb/examples/python/crashlog_scripted_process.py
+++ b/lldb/examples/python/crashlog_scripted_process.py
@@ -10,8 +10,7 @@
 
 
 class CrashLogScriptedProcess(ScriptedProcess):
-def set_crashlog(self, crashlog):
-self.crashlog = crashlog
+def parse_crashlog(self):
 if self.crashlog.process_id:
 if type(self.crashlog.process_id) is int:
 self.pid = self.crashlog.process_id
@@ -29,7 +28,7 @@ def set_crashlog(self, crashlog):
 if hasattr(self.crashlog, "asb"):
 self.extended_thread_info = self.crashlog.asb
 
-crashlog.load_images(self.options, self.loaded_images)
+self.crashlog.load_images(self.options, self.loaded_images)
 
 for thread in self.crashlog.threads:
 if (
@@ -92,10 +91,16 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args: 
lldb.SBStructuredData
 no_parallel_image_loading.GetBooleanValue()
 )
 
+crashlog = args.GetValueForKey("crashlog")
+if crashlog and crashlog.IsValid():
+if crashlog.GetType() == lldb.eStructuredDataTypeGeneric:
+self.crashlog = crashlog.GetGenericValue()
+
 self.pid = super().get_process_id()
 self.crashed_thread_idx = 0
 self.exception = None
 self.extended_thread_info = None
+self.parse_crashlog()
 
 def read_memory_at_address(
 self, addr: int, size: int, error: lldb.SBError

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


[Lldb-commits] [lldb] [lldb/crashlog] Avoid StopAtEntry when launch crashlog in interactive mode (PR #154651)

2025-08-21 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] [lldb][Expression] Add structor variant to LLDB's function call labels (PR #149827)

2025-08-21 Thread Michael Buch via lldb-commits

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

>From d55e41fa03d09b2ddfc9484c4a70a7d21ed9a994 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 18 Aug 2025 15:12:45 +0100
Subject: [PATCH 01/11] [llvm][DebugInfo] Support DW_AT_linkage_names that are
 different between declaration and definition

(cherry picked from commit 62641a7cc6b439c747be0a9ae91b9b266d67816e)
---
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp |  7 +-
 .../structor-declaration-linkage-names.ll | 68 +++
 2 files changed, 70 insertions(+), 5 deletions(-)
 create mode 100644 
llvm/test/DebugInfo/Generic/structor-declaration-linkage-names.ll

diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index b03fac2d22a52..4904ad03199c7 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1403,11 +1403,8 @@ bool 
DwarfUnit::applySubprogramDefinitionAttributes(const DISubprogram *SP,
 
   // Add the linkage name if we have one and it isn't in the Decl.
   StringRef LinkageName = SP->getLinkageName();
-  assert(((LinkageName.empty() || DeclLinkageName.empty()) ||
-  LinkageName == DeclLinkageName) &&
- "decl has a linkage name and it is different");
-  if (DeclLinkageName.empty() &&
-  // Always emit it for abstract subprograms.
+  // Always emit linkage name for abstract subprograms.
+  if (DeclLinkageName != LinkageName &&
   (DD->useAllLinkageNames() || DU->getAbstractScopeDIEs().lookup(SP)))
 addLinkageName(SPDie, LinkageName);
 
diff --git a/llvm/test/DebugInfo/Generic/structor-declaration-linkage-names.ll 
b/llvm/test/DebugInfo/Generic/structor-declaration-linkage-names.ll
new file mode 100644
index 0..9b1f2a5b2a186
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/structor-declaration-linkage-names.ll
@@ -0,0 +1,68 @@
+; RUN: %llc_dwarf < %s -filetype=obj | llvm-dwarfdump -debug-info - | 
FileCheck %s
+
+; Make sure we attach DW_AT_linkage_name on function declarations but only
+; attach it on definitions if the value is different than on the declaration.
+
+target triple = "arm64-apple-macosx"
+
+define void @_Z11SameLinkagev() !dbg !4 {
+entry:
+  ret void
+}
+
+; CHECK: DW_AT_linkage_name ("_Z11SameLinkagev")
+; CHECK: DW_AT_declaration (true)
+; CHECK-NOT: DW_AT_linkage_name ("_Z11SameLinkagev")
+
+define void @_Z11DiffLinkagev() !dbg !8 {
+entry:
+  ret void
+}
+
+; CHECK: DW_AT_linkage_name ("SomeName")
+; CHECK: DW_AT_declaration (true)
+; CHECK: DW_AT_linkage_name ("_Z11DiffLinkagev")
+
+define void @_Z15EmptyDefLinkagev() !dbg !10 {
+entry:
+  ret void
+}
+
+; CHECK: DW_AT_linkage_name ("_Z15EmptyDefLinkagev")
+; CHECK: DW_AT_declaration (true)
+; CHECK-NOT: DW_AT_linkage_name
+
+define void @_Z16EmptyDeclLinkagev() !dbg !12 {
+entry:
+  ret void
+}
+
+; CHECK: DW_AT_declaration (true)
+; CHECK: DW_AT_linkage_name ("_Z16EmptyDeclLinkagev")
+
+define void @_Z13EmptyLinkagesv() !dbg !14 {
+entry:
+  ret void
+}
+
+; CHECK-NOT: DW_AT_linkage_name
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, 
producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: 
FullDebug, splitDebugInlining: false, nameTableKind: Apple, sysroot: "/")
+!1 = !DIFile(filename: "foo.cpp", directory: "/tmp")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = distinct !DISubprogram(name: "SameLinkage", linkageName: 
"_Z11SameLinkagev", scope: !1, file: !1, line: 3, type: !5, scopeLine: 3, 
flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !7)
+!5 = !DISubroutineType(types: !6)
+!6 = !{null}
+!7 = !DISubprogram(name: "SameLinkage", linkageName: "_Z11SameLinkagev", 
scope: !1, file: !1, line: 3, type: !5, scopeLine: 3, flags: DIFlagPrototyped, 
spFlags: 0)
+!8 = distinct !DISubprogram(name: "DiffLinkage", linkageName: 
"_Z11DiffLinkagev", scope: !1, file: !1, line: 5, type: !5, scopeLine: 5, 
flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !9)
+!9 = !DISubprogram(name: "DiffLinkage", linkageName: "SomeName", scope: !1, 
file: !1, line: 3, type: !5, scopeLine: 3, flags: DIFlagPrototyped, spFlags: 0)
+!10 = distinct !DISubprogram(name: "EmptyDefLinkage", linkageName: "", scope: 
!1, file: !1, line: 5, type: !5, scopeLine: 5, flags: DIFlagPrototyped, 
spFlags: DISPFlagDefinition, unit: !0, declaration: !11)
+!11 = !DISubprogram(name: "EmptyDefLinkage", linkageName: 
"_Z15EmptyDefLinkagev", scope: !1, file: !1, line: 3, type: !5, scopeLine: 3, 
flags: DIFlagPrototyped, spFlags: 0)
+!12 = distinct !DISubprogram(name: "EmptyDeclLinkage", linkageName: 
"_Z16EmptyDeclLinkagev", scope: !1, file: !1, line: 5, type: !5, scopeLine: 5, 
flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: 
!13)
+!13 = !DISubprogram(name: "EmptyDeclLinkage", linkageNam

[Lldb-commits] [clang] [lldb] [llvm] [lldb][Expression] Add structor variant to LLDB's function call labels (PR #149827)

2025-08-21 Thread Michael Buch via lldb-commits

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

>From d55e41fa03d09b2ddfc9484c4a70a7d21ed9a994 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 18 Aug 2025 15:12:45 +0100
Subject: [PATCH 01/10] [llvm][DebugInfo] Support DW_AT_linkage_names that are
 different between declaration and definition

(cherry picked from commit 62641a7cc6b439c747be0a9ae91b9b266d67816e)
---
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp |  7 +-
 .../structor-declaration-linkage-names.ll | 68 +++
 2 files changed, 70 insertions(+), 5 deletions(-)
 create mode 100644 
llvm/test/DebugInfo/Generic/structor-declaration-linkage-names.ll

diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index b03fac2d22a52..4904ad03199c7 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1403,11 +1403,8 @@ bool 
DwarfUnit::applySubprogramDefinitionAttributes(const DISubprogram *SP,
 
   // Add the linkage name if we have one and it isn't in the Decl.
   StringRef LinkageName = SP->getLinkageName();
-  assert(((LinkageName.empty() || DeclLinkageName.empty()) ||
-  LinkageName == DeclLinkageName) &&
- "decl has a linkage name and it is different");
-  if (DeclLinkageName.empty() &&
-  // Always emit it for abstract subprograms.
+  // Always emit linkage name for abstract subprograms.
+  if (DeclLinkageName != LinkageName &&
   (DD->useAllLinkageNames() || DU->getAbstractScopeDIEs().lookup(SP)))
 addLinkageName(SPDie, LinkageName);
 
diff --git a/llvm/test/DebugInfo/Generic/structor-declaration-linkage-names.ll 
b/llvm/test/DebugInfo/Generic/structor-declaration-linkage-names.ll
new file mode 100644
index 0..9b1f2a5b2a186
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/structor-declaration-linkage-names.ll
@@ -0,0 +1,68 @@
+; RUN: %llc_dwarf < %s -filetype=obj | llvm-dwarfdump -debug-info - | 
FileCheck %s
+
+; Make sure we attach DW_AT_linkage_name on function declarations but only
+; attach it on definitions if the value is different than on the declaration.
+
+target triple = "arm64-apple-macosx"
+
+define void @_Z11SameLinkagev() !dbg !4 {
+entry:
+  ret void
+}
+
+; CHECK: DW_AT_linkage_name ("_Z11SameLinkagev")
+; CHECK: DW_AT_declaration (true)
+; CHECK-NOT: DW_AT_linkage_name ("_Z11SameLinkagev")
+
+define void @_Z11DiffLinkagev() !dbg !8 {
+entry:
+  ret void
+}
+
+; CHECK: DW_AT_linkage_name ("SomeName")
+; CHECK: DW_AT_declaration (true)
+; CHECK: DW_AT_linkage_name ("_Z11DiffLinkagev")
+
+define void @_Z15EmptyDefLinkagev() !dbg !10 {
+entry:
+  ret void
+}
+
+; CHECK: DW_AT_linkage_name ("_Z15EmptyDefLinkagev")
+; CHECK: DW_AT_declaration (true)
+; CHECK-NOT: DW_AT_linkage_name
+
+define void @_Z16EmptyDeclLinkagev() !dbg !12 {
+entry:
+  ret void
+}
+
+; CHECK: DW_AT_declaration (true)
+; CHECK: DW_AT_linkage_name ("_Z16EmptyDeclLinkagev")
+
+define void @_Z13EmptyLinkagesv() !dbg !14 {
+entry:
+  ret void
+}
+
+; CHECK-NOT: DW_AT_linkage_name
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, 
producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: 
FullDebug, splitDebugInlining: false, nameTableKind: Apple, sysroot: "/")
+!1 = !DIFile(filename: "foo.cpp", directory: "/tmp")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = distinct !DISubprogram(name: "SameLinkage", linkageName: 
"_Z11SameLinkagev", scope: !1, file: !1, line: 3, type: !5, scopeLine: 3, 
flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !7)
+!5 = !DISubroutineType(types: !6)
+!6 = !{null}
+!7 = !DISubprogram(name: "SameLinkage", linkageName: "_Z11SameLinkagev", 
scope: !1, file: !1, line: 3, type: !5, scopeLine: 3, flags: DIFlagPrototyped, 
spFlags: 0)
+!8 = distinct !DISubprogram(name: "DiffLinkage", linkageName: 
"_Z11DiffLinkagev", scope: !1, file: !1, line: 5, type: !5, scopeLine: 5, 
flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !9)
+!9 = !DISubprogram(name: "DiffLinkage", linkageName: "SomeName", scope: !1, 
file: !1, line: 3, type: !5, scopeLine: 3, flags: DIFlagPrototyped, spFlags: 0)
+!10 = distinct !DISubprogram(name: "EmptyDefLinkage", linkageName: "", scope: 
!1, file: !1, line: 5, type: !5, scopeLine: 5, flags: DIFlagPrototyped, 
spFlags: DISPFlagDefinition, unit: !0, declaration: !11)
+!11 = !DISubprogram(name: "EmptyDefLinkage", linkageName: 
"_Z15EmptyDefLinkagev", scope: !1, file: !1, line: 3, type: !5, scopeLine: 3, 
flags: DIFlagPrototyped, spFlags: 0)
+!12 = distinct !DISubprogram(name: "EmptyDeclLinkage", linkageName: 
"_Z16EmptyDeclLinkagev", scope: !1, file: !1, line: 5, type: !5, scopeLine: 5, 
flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: 
!13)
+!13 = !DISubprogram(name: "EmptyDeclLinkage", linkageNam

[Lldb-commits] [lldb] [lldb] Improve error message in ResolveSDKPathFromDebugInfo (NFC) (PR #154607)

2025-08-21 Thread Charles Zablit via lldb-commits

charles-zablit wrote:

Should this check also be added to the implementations of 
GetSDKPathFromDebugInfo? They also loop over the compile units and some callers 
[assume the resolved sdk won't be 
empty](https://github.com/swiftlang/llvm-project/blob/f55dc0824ebcf546b1d34a5102021c15101e4d3b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp#L1420).

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


[Lldb-commits] [clang] [lldb] [llvm] [lldb][Expression] Add structor variant to LLDB's function call labels (PR #149827)

2025-08-21 Thread Michael Buch via lldb-commits

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

>From d55e41fa03d09b2ddfc9484c4a70a7d21ed9a994 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 18 Aug 2025 15:12:45 +0100
Subject: [PATCH 01/11] [llvm][DebugInfo] Support DW_AT_linkage_names that are
 different between declaration and definition

(cherry picked from commit 62641a7cc6b439c747be0a9ae91b9b266d67816e)
---
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp |  7 +-
 .../structor-declaration-linkage-names.ll | 68 +++
 2 files changed, 70 insertions(+), 5 deletions(-)
 create mode 100644 
llvm/test/DebugInfo/Generic/structor-declaration-linkage-names.ll

diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index b03fac2d22a52..4904ad03199c7 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1403,11 +1403,8 @@ bool 
DwarfUnit::applySubprogramDefinitionAttributes(const DISubprogram *SP,
 
   // Add the linkage name if we have one and it isn't in the Decl.
   StringRef LinkageName = SP->getLinkageName();
-  assert(((LinkageName.empty() || DeclLinkageName.empty()) ||
-  LinkageName == DeclLinkageName) &&
- "decl has a linkage name and it is different");
-  if (DeclLinkageName.empty() &&
-  // Always emit it for abstract subprograms.
+  // Always emit linkage name for abstract subprograms.
+  if (DeclLinkageName != LinkageName &&
   (DD->useAllLinkageNames() || DU->getAbstractScopeDIEs().lookup(SP)))
 addLinkageName(SPDie, LinkageName);
 
diff --git a/llvm/test/DebugInfo/Generic/structor-declaration-linkage-names.ll 
b/llvm/test/DebugInfo/Generic/structor-declaration-linkage-names.ll
new file mode 100644
index 0..9b1f2a5b2a186
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/structor-declaration-linkage-names.ll
@@ -0,0 +1,68 @@
+; RUN: %llc_dwarf < %s -filetype=obj | llvm-dwarfdump -debug-info - | 
FileCheck %s
+
+; Make sure we attach DW_AT_linkage_name on function declarations but only
+; attach it on definitions if the value is different than on the declaration.
+
+target triple = "arm64-apple-macosx"
+
+define void @_Z11SameLinkagev() !dbg !4 {
+entry:
+  ret void
+}
+
+; CHECK: DW_AT_linkage_name ("_Z11SameLinkagev")
+; CHECK: DW_AT_declaration (true)
+; CHECK-NOT: DW_AT_linkage_name ("_Z11SameLinkagev")
+
+define void @_Z11DiffLinkagev() !dbg !8 {
+entry:
+  ret void
+}
+
+; CHECK: DW_AT_linkage_name ("SomeName")
+; CHECK: DW_AT_declaration (true)
+; CHECK: DW_AT_linkage_name ("_Z11DiffLinkagev")
+
+define void @_Z15EmptyDefLinkagev() !dbg !10 {
+entry:
+  ret void
+}
+
+; CHECK: DW_AT_linkage_name ("_Z15EmptyDefLinkagev")
+; CHECK: DW_AT_declaration (true)
+; CHECK-NOT: DW_AT_linkage_name
+
+define void @_Z16EmptyDeclLinkagev() !dbg !12 {
+entry:
+  ret void
+}
+
+; CHECK: DW_AT_declaration (true)
+; CHECK: DW_AT_linkage_name ("_Z16EmptyDeclLinkagev")
+
+define void @_Z13EmptyLinkagesv() !dbg !14 {
+entry:
+  ret void
+}
+
+; CHECK-NOT: DW_AT_linkage_name
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, 
producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: 
FullDebug, splitDebugInlining: false, nameTableKind: Apple, sysroot: "/")
+!1 = !DIFile(filename: "foo.cpp", directory: "/tmp")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = distinct !DISubprogram(name: "SameLinkage", linkageName: 
"_Z11SameLinkagev", scope: !1, file: !1, line: 3, type: !5, scopeLine: 3, 
flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !7)
+!5 = !DISubroutineType(types: !6)
+!6 = !{null}
+!7 = !DISubprogram(name: "SameLinkage", linkageName: "_Z11SameLinkagev", 
scope: !1, file: !1, line: 3, type: !5, scopeLine: 3, flags: DIFlagPrototyped, 
spFlags: 0)
+!8 = distinct !DISubprogram(name: "DiffLinkage", linkageName: 
"_Z11DiffLinkagev", scope: !1, file: !1, line: 5, type: !5, scopeLine: 5, 
flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !9)
+!9 = !DISubprogram(name: "DiffLinkage", linkageName: "SomeName", scope: !1, 
file: !1, line: 3, type: !5, scopeLine: 3, flags: DIFlagPrototyped, spFlags: 0)
+!10 = distinct !DISubprogram(name: "EmptyDefLinkage", linkageName: "", scope: 
!1, file: !1, line: 5, type: !5, scopeLine: 5, flags: DIFlagPrototyped, 
spFlags: DISPFlagDefinition, unit: !0, declaration: !11)
+!11 = !DISubprogram(name: "EmptyDefLinkage", linkageName: 
"_Z15EmptyDefLinkagev", scope: !1, file: !1, line: 3, type: !5, scopeLine: 3, 
flags: DIFlagPrototyped, spFlags: 0)
+!12 = distinct !DISubprogram(name: "EmptyDeclLinkage", linkageName: 
"_Z16EmptyDeclLinkagev", scope: !1, file: !1, line: 5, type: !5, scopeLine: 5, 
flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: 
!13)
+!13 = !DISubprogram(name: "EmptyDeclLinkage", linkageNam

[Lldb-commits] [lldb] [lldb/crashlog] Avoid StopAtEntry when launch crashlog in interactive mode (PR #154651)

2025-08-21 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/154651

>From 04db318bbd6b3c4e9245a11a711960cd016dcb19 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Thu, 21 Aug 2025 22:55:59 -0700
Subject: [PATCH] [lldb/crashlog] Avoid StopAtEntry when launch crashlog in
 interactive mode

In 88f409194, we changed the way the crashlog scripted process was
launched since the previous approach required to parse the file twice,
by stopping at entry, setting the crashlog object in the middle of the
scripted process launch and resuming it.

Since then, we've introduced SBScriptObject which allows to pass any
arbitrary python object accross the SBAPI boundary to another scripted
affordance.

This patch make sure of that to include the parse crashlog object into
the scripted process launch info dictionary, which eliviates the need to
stop at entry.

Signed-off-by: Med Ismail Bennani 
---
 lldb/examples/python/crashlog.py  | 11 ++
 .../python/crashlog_scripted_process.py   | 20 +--
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index bb20f3a25c1c1..b466be6a62428 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1540,13 +1540,19 @@ def load_crashlog_in_scripted_process(debugger, 
crashlog_path, options, result):
 }
 )
 )
+
+crashlog_sd = lldb.SBStructuredData()
+crashlog_sd.SetGenericValue(
+lldb.SBScriptObject(crashlog, lldb.eScriptLanguagePython)
+)
+structured_data.SetValueForKey("crashlog", crashlog_sd)
+
 launch_info = lldb.SBLaunchInfo(None)
 launch_info.SetProcessPluginName("ScriptedProcess")
 launch_info.SetScriptedProcessClassName(
 "crashlog_scripted_process.CrashLogScriptedProcess"
 )
 launch_info.SetScriptedProcessDictionary(structured_data)
-launch_info.SetLaunchFlags(lldb.eLaunchFlagStopAtEntry)
 
 error = lldb.SBError()
 process = target.Launch(launch_info, error)
@@ -1554,9 +1560,6 @@ def load_crashlog_in_scripted_process(debugger, 
crashlog_path, options, result):
 if not process or error.Fail():
 raise InteractiveCrashLogException("couldn't launch Scripted Process", 
error)
 
-process.GetScriptedImplementation().set_crashlog(crashlog)
-process.Continue()
-
 if not options.skip_status:
 
 @contextlib.contextmanager
diff --git a/lldb/examples/python/crashlog_scripted_process.py 
b/lldb/examples/python/crashlog_scripted_process.py
index f54a8df0479e7..6c6eec8d12b96 100644
--- a/lldb/examples/python/crashlog_scripted_process.py
+++ b/lldb/examples/python/crashlog_scripted_process.py
@@ -10,8 +10,7 @@
 
 
 class CrashLogScriptedProcess(ScriptedProcess):
-def set_crashlog(self, crashlog):
-self.crashlog = crashlog
+def parse_crashlog(self):
 if self.crashlog.process_id:
 if type(self.crashlog.process_id) is int:
 self.pid = self.crashlog.process_id
@@ -29,8 +28,6 @@ def set_crashlog(self, crashlog):
 if hasattr(self.crashlog, "asb"):
 self.extended_thread_info = self.crashlog.asb
 
-crashlog.load_images(self.options, self.loaded_images)
-
 for thread in self.crashlog.threads:
 if (
 hasattr(thread, "app_specific_backtrace")
@@ -92,10 +89,21 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args: 
lldb.SBStructuredData
 no_parallel_image_loading.GetBooleanValue()
 )
 
+self.crashlog = None
+crashlog = args.GetValueForKey("crashlog")
+if crashlog and crashlog.IsValid():
+if crashlog.GetType() == lldb.eStructuredDataTypeGeneric:
+self.crashlog = crashlog.GetGenericValue()
+
+if not self.crashlog:
+# Return error
+return
+
 self.pid = super().get_process_id()
 self.crashed_thread_idx = 0
 self.exception = None
 self.extended_thread_info = None
+self.parse_crashlog()
 
 def read_memory_at_address(
 self, addr: int, size: int, error: lldb.SBError
@@ -104,8 +112,8 @@ def read_memory_at_address(
 return lldb.SBData()
 
 def get_loaded_images(self):
-# TODO: Iterate over corefile_target modules and build a data structure
-# from it.
+if len(self.loaded_images) == 0:
+self.crashlog.load_images(self.options, self.loaded_images)
 return self.loaded_images
 
 def should_stop(self) -> bool:

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