[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits

tgs-sc wrote:

Does this patch look ok now?

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits


@@ -1873,6 +1873,19 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
+// If we got nullptr, then such specialization already exists.

tgs-sc wrote:

Addressed

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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


@@ -1873,6 +1873,19 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
+// If we got nullptr, then such specialization already exists.

Michael137 wrote:

```suggestion
```

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits


@@ -1676,6 +1676,14 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl(
   class_template_specialization_decl->setInstantiationOf(class_template_decl);
   class_template_specialization_decl->setTemplateArgs(
   TemplateArgumentList::CreateCopy(ast, args));
+  void *InsertPos = nullptr;
+  if (!class_template_decl->findSpecialization(args, InsertPos)) {
+// Add this specialization to the class template.
+class_template_decl->AddSpecialization(class_template_specialization_decl,
+   InsertPos);
+  } else
+// Specialization exists, so return nullptr.
+return nullptr;

tgs-sc wrote:

Addressed

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][elf-core][ARM] Add support for VFP registers (PR #155956)

2025-09-08 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> With all those neat sequential values across the GPR registers, it's clear 
> that the file was created artificially.

Yeah, so I was expecting to find some inline asm for that.

> The values in some of these registers would differ with each regeneration of 
> the core file, requiring an update to the test with the actual values, so I'd 
> prefer to keep the existing test as is.

Not if the asm is:
```
mov to fpu

mov to gpr

cause a fault
```
Sure the control register values might change but we can get consistent GPRs. 
I'm not saying we'd regenerate the file on every build, it's just about having 
the source code to be able to regenerate it if we want/need to.

But as I said, I am OK taking this as is.

https://github.com/llvm/llvm-project/pull/155956
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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


@@ -1873,6 +1873,17 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);

Michael137 wrote:

lets move the check before we call `CreateClassTemplateSpecializationType`

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits

https://github.com/tgs-sc deleted 
https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFC] Fix style issues with StackID.h (PR #157483)

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

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

LGTM

https://github.com/llvm/llvm-project/pull/157483
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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


@@ -1873,6 +1874,24 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
+// Try to find an existing specialization with these template arguments and
+// template parameter list.
+void *InsertPos = nullptr;
+llvm::ArrayRef args =
+template_param_infos.GetArgs();
+if (!args.empty() &&
+!class_template_decl->findSpecialization(args, InsertPos))
+  // Add this specialization to the class template.
+  class_template_decl->AddSpecialization(class_specialization_decl,
+ InsertPos);

Michael137 wrote:

Wouldn't returning a `nullptr` work?

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix assertion when opcodes are exactly the length of the buffer (PR #157196)

2025-09-08 Thread Daniel Sanders via lldb-commits

https://github.com/dsandersllvm closed 
https://github.com/llvm/llvm-project/pull/157196
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add new optional argument `time-to-live` when using `--connection` (PR #156803)

2025-09-08 Thread Roy Shi via lldb-commits

https://github.com/royitaqi edited 
https://github.com/llvm/llvm-project/pull/156803
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFC] Architecture plugins should report the vector element order (PR #157198)

2025-09-08 Thread Daniel Sanders via lldb-commits

https://github.com/dsandersllvm edited 
https://github.com/llvm/llvm-project/pull/157198
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-mcp] Auto connect to the first running lldb mcp instance. (PR #157503)

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

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

>From ec45d323014b15ce7a960fc519ef3782820a44d2 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 8 Sep 2025 09:05:15 -0700
Subject: [PATCH] [lldb-mcp] Auto connect to the first running lldb mcp
 instance.

This improves the flow by automatically connecting to an exisitng lldb 
instance, if one is found.

Future improvements include:

* Launching a binary if an instance isn't detected.
* Multiplexing if multiple instances are detected.
---
 lldb/include/lldb/Protocol/MCP/Server.h |   5 +
 lldb/source/Protocol/MCP/Server.cpp |  78 +--
 lldb/tools/lldb-mcp/CMakeLists.txt  |   1 +
 lldb/tools/lldb-mcp/lldb-mcp.cpp| 125 
 4 files changed, 184 insertions(+), 25 deletions(-)

diff --git a/lldb/include/lldb/Protocol/MCP/Server.h 
b/lldb/include/lldb/Protocol/MCP/Server.h
index 254b7d9680cd8..a65c310828daf 100644
--- a/lldb/include/lldb/Protocol/MCP/Server.h
+++ b/lldb/include/lldb/Protocol/MCP/Server.h
@@ -30,6 +30,11 @@ namespace lldb_protocol::mcp {
 struct ServerInfo {
   std::string connection_uri;
   lldb::pid_t pid;
+
+  /// Writes the server info into a unique file in `~/.lldb`.
+  static llvm::Error Write(const ServerInfo &);
+  /// Loads any server info saved in `~/.lldb`.
+  static llvm::Expected> Load();
 };
 llvm::json::Value toJSON(const ServerInfo &);
 bool fromJSON(const llvm::json::Value &, ServerInfo &, llvm::json::Path);
diff --git a/lldb/source/Protocol/MCP/Server.cpp 
b/lldb/source/Protocol/MCP/Server.cpp
index 0381b7f745e98..3c2c246218774 100644
--- a/lldb/source/Protocol/MCP/Server.cpp
+++ b/lldb/source/Protocol/MCP/Server.cpp
@@ -7,25 +7,89 @@
 
//===--===//
 
 #include "lldb/Protocol/MCP/Server.h"
+#include "lldb/Host/File.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Host/JSONTransport.h"
 #include "lldb/Protocol/MCP/MCPError.h"
 #include "lldb/Protocol/MCP/Protocol.h"
 #include "llvm/Support/JSON.h"
 
-using namespace lldb_protocol::mcp;
 using namespace llvm;
+using namespace lldb_private;
+using namespace lldb_protocol::mcp;
 
-llvm::json::Value lldb_protocol::mcp::toJSON(const ServerInfo &SM) {
-  return llvm::json::Object{{"connection_uri", SM.connection_uri},
-{"pid", SM.pid}};
+json::Value lldb_protocol::mcp::toJSON(const ServerInfo &SM) {
+  return json::Object{{"connection_uri", SM.connection_uri}, {"pid", SM.pid}};
 }
 
-bool lldb_protocol::mcp::fromJSON(const llvm::json::Value &V, ServerInfo &SM,
-  llvm::json::Path P) {
-  llvm::json::ObjectMapper O(V, P);
+bool lldb_protocol::mcp::fromJSON(const json::Value &V, ServerInfo &SM,
+  json::Path P) {
+  json::ObjectMapper O(V, P);
   return O && O.map("connection_uri", SM.connection_uri) &&
  O.map("pid", SM.pid);
 }
 
+llvm::Error ServerInfo::Write(const ServerInfo &info) {
+  std::string buf = formatv("{0}", toJSON(info)).str();
+  size_t num_bytes = buf.size();
+
+  FileSpec user_lldb_dir = HostInfo::GetUserLLDBDir();
+
+  Status error(llvm::sys::fs::create_directory(user_lldb_dir.GetPath()));
+  if (error.Fail())
+return error.takeError();
+
+  FileSpec mcp_registry_entry_path = 
user_lldb_dir.CopyByAppendingPathComponent(
+  formatv("lldb-mcp-{0}.json", getpid()).str());
+
+  const File::OpenOptions flags = File::eOpenOptionWriteOnly |
+  File::eOpenOptionCanCreate |
+  File::eOpenOptionTruncate;
+  llvm::Expected file = FileSystem::Instance().Open(
+  mcp_registry_entry_path, flags, lldb::eFilePermissionsFileDefault, 
false);
+  if (!file)
+return file.takeError();
+  if (llvm::Error error = (*file)->Write(buf.data(), num_bytes).takeError())
+return error;
+  return llvm::Error::success();
+}
+
+llvm::Expected> ServerInfo::Load() {
+  FileSpec user_lldb_dir = HostInfo::GetUserLLDBDir();
+  namespace path = llvm::sys::path;
+  FileSystem &fs = FileSystem::Instance();
+  std::error_code EC;
+  llvm::vfs::directory_iterator it = fs.DirBegin(user_lldb_dir, EC);
+  llvm::vfs::directory_iterator end;
+  std::vector infos;
+  for (; it != end && !EC; it.increment(EC)) {
+auto &entry = *it;
+auto name = path::filename(entry.path());
+if (!name.starts_with("lldb-mcp-") || !name.ends_with(".json")) {
+  continue;
+}
+
+llvm::Expected> file =
+fs.Open(FileSpec(entry.path()), File::eOpenOptionReadOnly);
+if (!file)
+  return file.takeError();
+
+char buf[1024] = {0};
+size_t bytes_read = sizeof(buf);
+if (llvm::Error error = (*file)->Read(buf, bytes_read).takeError())
+  return std::move(error);
+
+auto info = json::parse(StringRef(buf, bytes_read));
+if (!info)
+  return info.takeError();
+
+infos.emplace_back(std::move(*info));
+  }
+

[Lldb-commits] [lldb] [lldb][NFC] Architecture plugins should report the vector element order (PR #157198)

2025-09-08 Thread Daniel Sanders via lldb-commits

dsandersllvm wrote:

> > Some targets like PowerPC store their
> 
> Is there some text missing here?

Oops, fixed it.

> Do we know what vector extension s390x/SystemZ has and what order it uses?

I don't know but I've found 
https://github.com/bytecodealliance/wasmtime/issues/4566 so @uweigand might be 
able to confirm. The first section seems to be describing the ARM/MIPS 
behaviour where the element order in the ISA remains the same regardless of the 
endianness of the elements themselves . I don't see any of the required 
shuffling bitcasts in lib/Target/SystemZ for that behaviour though. That thread 
goes on to mention implementing all four combinations so it might be 
configurable

https://github.com/llvm/llvm-project/pull/157198
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [NFC][lldb] Cleanup the ArchDefinitionEntry definitons. (PR #152618)

2025-09-08 Thread Greg Clayton via lldb-commits

https://github.com/clayborg updated 
https://github.com/llvm/llvm-project/pull/152618

>From b1a41aa0b3f65b5c72190a19091de88965d4fd6a Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Thu, 7 Aug 2025 17:15:29 -0700
Subject: [PATCH] [NFC][lldb] Cleanup the ArchDefinitionEntry definitons.

This patch has default initialization values for the "sub", "cpu_mask" and 
"sub_mask" member variables of the ArchDefinitionEntry structure. This can 
simplify and cleanup the ArchDefinitionEntry arrays by allowing those that 
don't override the values to not have to initialize the values in the 
definitions if they match the default values.

This patchs also disables clang format to align the values in the columns for 
easier readability.
---
 lldb/source/Utility/ArchSpec.cpp | 163 ---
 1 file changed, 61 insertions(+), 102 deletions(-)

diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index 8f14cf6e39438..1b8dae39735df 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -260,9 +260,9 @@ static_assert(sizeof(g_core_definitions) / 
sizeof(CoreDefinition) ==
 struct ArchDefinitionEntry {
   ArchSpec::Core core;
   uint32_t cpu;
-  uint32_t sub;
-  uint32_t cpu_mask;
-  uint32_t sub_mask;
+  uint32_t sub = LLDB_INVALID_CPUTYPE;
+  uint32_t cpu_mask = UINT32_MAX;
+  uint32_t sub_mask = UINT32_MAX;
 };
 
 struct ArchDefinition {
@@ -357,7 +357,8 @@ static const ArchDefinitionEntry g_macho_arch_entries[] = {
 {ArchSpec::eCore_riscv32, llvm::MachO::CPU_TYPE_RISCV,  
CPU_ANY,UINT32_MAX, SUBTYPE_MASK},
 // Catch any unknown mach architectures so we can always use the object 
and symbol mach-o files
 {ArchSpec::eCore_uknownMach32,0,0, 
 0xFF00u, 0xu},
-{ArchSpec::eCore_uknownMach64,llvm::MachO::CPU_ARCH_ABI64,  0, 
 0xFF00u, 0xu}};
+{ArchSpec::eCore_uknownMach64,llvm::MachO::CPU_ARCH_ABI64,  0, 
 0xFF00u, 0xu}
+};
 // clang-format on
 
 static const ArchDefinition g_macho_arch_def = {eArchTypeMachO,
@@ -369,72 +370,41 @@ static const ArchDefinition g_macho_arch_def = 
{eArchTypeMachO,
 // convert cpu type and subtypes to architecture names, and to convert
 // architecture names to cpu types and subtypes. The ordering is important and
 // allows the precedence to be set when the table is built.
+// clang-format off
 static const ArchDefinitionEntry g_elf_arch_entries[] = {
-{ArchSpec::eCore_sparc_generic, llvm::ELF::EM_SPARC, LLDB_INVALID_CPUTYPE,
- 0xu, 0xu}, // Sparc
-{ArchSpec::eCore_x86_32_i386, llvm::ELF::EM_386, LLDB_INVALID_CPUTYPE,
- 0xu, 0xu}, // Intel 80386
-{ArchSpec::eCore_x86_32_i486, llvm::ELF::EM_IAMCU, LLDB_INVALID_CPUTYPE,
- 0xu, 0xu}, // Intel MCU // FIXME: is this correct?
-{ArchSpec::eCore_ppc_generic, llvm::ELF::EM_PPC, LLDB_INVALID_CPUTYPE,
- 0xu, 0xu}, // PowerPC
-{ArchSpec::eCore_ppc64le_generic, llvm::ELF::EM_PPC64,
- ArchSpec::eCore_ppc64le_generic, 0xu, 0xu}, // PowerPC64le
-{ArchSpec::eCore_ppc64_generic, llvm::ELF::EM_PPC64,
- ArchSpec::eCore_ppc64_generic, 0xu, 0xu}, // PowerPC64
-{ArchSpec::eCore_arm_generic, llvm::ELF::EM_ARM, LLDB_INVALID_CPUTYPE,
- 0xu, 0xu}, // ARM
-{ArchSpec::eCore_arm_aarch64, llvm::ELF::EM_AARCH64, LLDB_INVALID_CPUTYPE,
- 0xu, 0xu}, // ARM64
-{ArchSpec::eCore_s390x_generic, llvm::ELF::EM_S390, LLDB_INVALID_CPUTYPE,
- 0xu, 0xu}, // SystemZ
-{ArchSpec::eCore_sparc9_generic, llvm::ELF::EM_SPARCV9,
- LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // SPARC V9
-{ArchSpec::eCore_x86_64_x86_64, llvm::ELF::EM_X86_64, LLDB_INVALID_CPUTYPE,
- 0xu, 0xu}, // AMD64
-{ArchSpec::eCore_mips32, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips32,
- 0xu, 0xu}, // mips32
-{ArchSpec::eCore_mips32r2, llvm::ELF::EM_MIPS,
- ArchSpec::eMIPSSubType_mips32r2, 0xu, 0xu}, // mips32r2
-{ArchSpec::eCore_mips32r6, llvm::ELF::EM_MIPS,
- ArchSpec::eMIPSSubType_mips32r6, 0xu, 0xu}, // mips32r6
-{ArchSpec::eCore_mips32el, llvm::ELF::EM_MIPS,
- ArchSpec::eMIPSSubType_mips32el, 0xu, 0xu}, // mips32el
-{ArchSpec::eCore_mips32r2el, llvm::ELF::EM_MIPS,
- ArchSpec::eMIPSSubType_mips32r2el, 0xu, 0xu}, // 
mips32r2el
-{ArchSpec::eCore_mips32r6el, llvm::ELF::EM_MIPS,
- ArchSpec::eMIPSSubType_mips32r6el, 0xu, 0xu}, // 
mips32r6el
-{ArchSpec::eCore_mips64, llvm::ELF::EM_MIPS, ArchSpec::eMIPSSubType_mips64,
- 0xu, 0xu}, // mips64
-{ArchSpec::eCore_mips64r2, llvm

[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

2025-09-08 Thread via lldb-commits

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

LGTM

https://github.com/llvm/llvm-project/pull/133078
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-mcp] Auto connect to the first running lldb mcp instance. (PR #157503)

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

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

This improves the flow by automatically connecting to an exisitng lldb 
instance, if one is found.

Future improvements include:

* Launching a binary if an instance isn't detected.
* Multiplexing if multiple instances are detected.

>From 1ae89d1db62d4c32b83d7e2b7c1c9d4c00175e50 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 8 Sep 2025 09:05:15 -0700
Subject: [PATCH] [lldb-mcp] Auto connect to the first running lldb mcp
 instance.

This improves the flow by automatically connecting to an exisitng lldb 
instance, if one is found.

Future improvements include:

* Launching a binary if an instance isn't detected.
* Multiplexing if multiple instances are detected.
---
 lldb/include/lldb/Protocol/MCP/Server.h |   3 +
 lldb/source/Protocol/MCP/Server.cpp | 102 +++
 lldb/tools/lldb-mcp/CMakeLists.txt  |   1 +
 lldb/tools/lldb-mcp/lldb-mcp.cpp| 125 
 4 files changed, 171 insertions(+), 60 deletions(-)

diff --git a/lldb/include/lldb/Protocol/MCP/Server.h 
b/lldb/include/lldb/Protocol/MCP/Server.h
index 254b7d9680cd8..567af96530e89 100644
--- a/lldb/include/lldb/Protocol/MCP/Server.h
+++ b/lldb/include/lldb/Protocol/MCP/Server.h
@@ -30,6 +30,9 @@ namespace lldb_protocol::mcp {
 struct ServerInfo {
   std::string connection_uri;
   lldb::pid_t pid;
+
+  static llvm::Error Write(const ServerInfo &);
+  static llvm::Expected> Load();
 };
 llvm::json::Value toJSON(const ServerInfo &);
 bool fromJSON(const llvm::json::Value &, ServerInfo &, llvm::json::Path);
diff --git a/lldb/source/Protocol/MCP/Server.cpp 
b/lldb/source/Protocol/MCP/Server.cpp
index 0381b7f745e98..cb0e1034fe51f 100644
--- a/lldb/source/Protocol/MCP/Server.cpp
+++ b/lldb/source/Protocol/MCP/Server.cpp
@@ -11,62 +11,80 @@
 #include "lldb/Protocol/MCP/Protocol.h"
 #include "llvm/Support/JSON.h"
 
-using namespace lldb_protocol::mcp;
 using namespace llvm;
+using namespace lldb_private;
+using namespace lldb_protocol::mcp;
 
-llvm::json::Value lldb_protocol::mcp::toJSON(const ServerInfo &SM) {
-  return llvm::json::Object{{"connection_uri", SM.connection_uri},
-{"pid", SM.pid}};
+json::Value lldb_protocol::mcp::toJSON(const ServerInfo &SM) {
+  return json::Object{{"connection_uri", SM.connection_uri}, {"pid", SM.pid}};
 }
 
-bool lldb_protocol::mcp::fromJSON(const llvm::json::Value &V, ServerInfo &SM,
-  llvm::json::Path P) {
-  llvm::json::ObjectMapper O(V, P);
+bool lldb_protocol::mcp::fromJSON(const json::Value &V, ServerInfo &SM,
+  json::Path P) {
+  json::ObjectMapper O(V, P);
   return O && O.map("connection_uri", SM.connection_uri) &&
  O.map("pid", SM.pid);
 }
 
-Server::Server(std::string name, std::string version,
-   std::unique_ptr transport_up,
-   lldb_private::MainLoop &loop)
-: m_name(std::move(name)), m_version(std::move(version)),
-  m_transport_up(std::move(transport_up)), m_loop(loop) {
-  AddRequestHandlers();
-}
+llvm::Error ServerInfo::Write(const ServerInfo &info) {
+  std::string buf = formatv("{0}", toJSON(info)).str();
+  size_t num_bytes = buf.size();
 
-void Server::AddRequestHandlers() {
-  AddRequestHandler("initialize", std::bind(&Server::InitializeHandler, this,
-std::placeholders::_1));
-  AddRequestHandler("tools/list", std::bind(&Server::ToolsListHandler, this,
-std::placeholders::_1));
-  AddRequestHandler("tools/call", std::bind(&Server::ToolsCallHandler, this,
-std::placeholders::_1));
-  AddRequestHandler("resources/list", std::bind(&Server::ResourcesListHandler,
-this, std::placeholders::_1));
-  AddRequestHandler("resources/read", std::bind(&Server::ResourcesReadHandler,
-this, std::placeholders::_1));
-}
+  FileSpec user_lldb_dir = HostInfo::GetUserLLDBDir();
 
-llvm::Expected Server::Handle(const Request &request) {
-  auto it = m_request_handlers.find(request.method);
-  if (it != m_request_handlers.end()) {
-llvm::Expected response = it->second(request);
-if (!response)
-  return response;
-response->id = request.id;
-return *response;
-  }
+  Status error(llvm::sys::fs::create_directory(user_lldb_dir.GetPath()));
+  if (error.Fail())
+return error.takeError();
+
+  FileSpec mcp_registry_entry_path = 
user_lldb_dir.CopyByAppendingPathComponent(
+  formatv("lldb-mcp-{0}.json", getpid()).str());
 
-  return llvm::make_error(
-  llvm::formatv("no handler for request: {0}", request.method).str());
+  const File::OpenOptions flags = File::eOpenOptionWriteOnly |
+  File::eOpenOptionCanCreate |
+  File::eOpenOptionTru

[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

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

https://github.com/Michael137 closed 
https://github.com/llvm/llvm-project/pull/133078
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Track CFA pointer metadata in StackID (PR #157498)

2025-09-08 Thread Felipe de Azevedo Piovezan via lldb-commits

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

In this commit:

9c8e71644227 [lldb] Make StackID call Fix{Code,Data} pointers (#152796)

We made StackID keep track of the CFA without any pointer metadata in it. This 
is necessary when comparing two StackIDs to determine which one is "younger".

However, the CFA inside StackIDs is also used in other contexts through the 
method StackID::GetCallFrameAddress. One notable case is DWARFExpression: the 
computation of `DW_OP_call_frame_address` is done using StackID. This feeds 
into many other places, e.g. expression evaluation (which may require a signed 
pointer). As such, StackID must be able to provide both versions of the CFA.

In the spirit of allowing consumers of pointers to decide what to do with 
pointer metadata, this patch changes StackID to store both versions of the cfa 
pointer. Two getter methods are provided, and all call sites except 
DWARFExpression preserve their existing behavior (stripped pointer). Other 
alternatives were considered:

* Just store the raw pointer. This would require changing the comparisong 
operator `<` to also receive a Process, as the comparison requires stripped 
pointers. It wasn't clear if all call-sites had a non-null process, whereas we 
know we have a process when creating a StackID.

* Store a weak pointer to the process inside the class, and then strip metadata 
as needed. This would require a `weak_ptr::lock` in many operations of LLDB, 
and it felt wasteful. It also prevents stripping of the pointer if the process 
has gone away.

>From afed92d55eefce1ad681c4e2d9df3b754c01dc2a Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Mon, 8 Sep 2025 08:30:19 -0700
Subject: [PATCH] [lldb] Track CFA pointer metadata in StackID

In this commit:

9c8e71644227 [lldb] Make StackID call Fix{Code,Data} pointers (#152796)

We made StackID keep track of the CFA without any pointer metadata in
it. This is necessary when comparing two StackIDs to determine which one
is "younger".

However, the CFA inside StackIDs is also used in other contexts through
the method StackID::GetCallFrameAddress. One notable case is
DWARFExpression: the computation of `DW_OP_call_frame_address` is done
using StackID. This feeds into many other places, e.g. expression
evaluation (which may require a signed pointer). As such, StackID must
be able to provide both versions of the CFA.

In the spirit of allowing consumers of pointers to decide what to do
with pointer metadata, this patch changes StackID to store both versions
of the cfa pointer. Two getter methods are provided, and all call sites
except DWARFExpression preserve their existing behavior (stripped
pointer). Other alternatives were considered:

* Just store the raw pointer. This would require changing the
  comparisong operator `<` to also receive a Process, as the comparison
  requires stripped pointers. It wasn't clear if all call-sites had a
  non-null process, whereas we know we have a process when creating a
  StackID.

* Store a weak pointer to the process inside the class, and then strip
  metadata as needed. This would require a `weak_ptr::lock` in many
  operations of LLDB, and it felt wasteful. It also prevents stripping
  of the pointer if the process has gone away.
---
 lldb/include/lldb/Target/StackID.h | 11 +--
 lldb/source/API/SBFrame.cpp|  2 +-
 lldb/source/Expression/DWARFExpression.cpp |  2 +-
 lldb/source/Target/StackFrameList.cpp  |  2 +-
 lldb/source/Target/StackID.cpp | 11 +++
 5 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/lldb/include/lldb/Target/StackID.h 
b/lldb/include/lldb/Target/StackID.h
index c2a5d733dcd69..754f80d001647 100644
--- a/lldb/include/lldb/Target/StackID.h
+++ b/lldb/include/lldb/Target/StackID.h
@@ -26,7 +26,11 @@ class StackID {
 
   lldb::addr_t GetPC() const { return m_pc; }
 
-  lldb::addr_t GetCallFrameAddress() const { return m_cfa; }
+  lldb::addr_t GetCallFrameAddressWithMetadata() const {
+return m_cfa_with_metadata;
+  }
+
+  lldb::addr_t GetCallFrameAddressWithoutMetadata() const { return m_cfa; }
 
   SymbolContextScope *GetSymbolContextScope() const { return m_symbol_scope; }
 
@@ -59,9 +63,12 @@ class StackID {
 
   /// The call frame address (stack pointer) value at the beginning of the
   /// function that uniquely identifies this frame (along with m_symbol_scope
-  /// below)
+  /// below).
   lldb::addr_t m_cfa = LLDB_INVALID_ADDRESS;
 
+  /// The cfa with metadata (i.e. prior to Process::FixAddress).
+  lldb::addr_t m_cfa_with_metadata = LLDB_INVALID_ADDRESS;
+
   /// If nullptr, there is no block or symbol for this frame. If not nullptr,
   /// this will either be the scope for the lexical block for the frame, or the
   /// scope for the symbol. Symbol context scopes are always be unique pointers
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index b6724bb0c4119..42dbed

[Lldb-commits] [lldb] [LLDB][NativePDB] Mark blocks as parsed after parsing (PR #157493)

2025-09-08 Thread via lldb-commits

Nerixyz wrote:

> Why can't the native plugin use `PDB_DataKind::ObjectPtr`?

It's something DIA determines - in 
[`IDiaSymbol::get_dataKind`](https://learn.microsoft.com/en-us/visualstudio/debugger/debug-interface-access/idiasymbol-get-datakind?view=vs-2022).

The symbol information we have is the following:
```
1132 | S_GPROC32 [size = 52] `Class::Func`
   parent = 0, end = 1248, addr = 0001:0208, code size = 7
   type = `0x1010 (void Class::())`, debug start = 0, debug end = 0, 
flags = noinline | opt debuginfo
1184 | S_FRAMEPROC [size = 32]
   size = 8, padding size = 0, offset to padding = 0
   bytes of callee saved registers = 0, exception handler addr = 
:
   local fp reg = RSP, param fp reg = RSP
   flags = safe buffers
1216 | S_LOCAL [size = 16] `this`
   type=0x1013 (Class*), flags = param
1232 | S_DEFRANGE_FRAMEPOINTER_REL [size = 16]
   offset = 0, range = [0001:0213,+2)
   gaps = []
1248 | S_END [size = 4]
```
This is `Class::Func()` which takes no parameters (except `this`).

https://github.com/llvm/llvm-project/pull/157493
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test] Prevent TestqOffsets.py picking up host binaries (PR #157432)

2025-09-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

Due to a fallback in GDBRemoteCommunicationClient.cpp, on Linux we will assume 
a PID of 1 if the remote does not respond in some way that tells us the real 
PID.

So if PID 1 happened to be a process that the current user could read, we would 
try to debug that instead. On my current machine, PID 1 was sshd run by root so 
we would ignore it. If I changed the fallback to some process ID run by my 
user, the test would fail.

To prevent this, return something to LLDB that tells it there is no remote PID, 
preventing the host lookup.

Fixes #155895

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


1 Files Affected:

- (modified) lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py 
(+5) 


``diff
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
index a1adc20e864ba..e069f10b19e1e 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
@@ -10,6 +10,11 @@ class Responder(MockGDBServerResponder):
 def qOffsets(self):
 return "Text=47;Data=47"
 
+def qfThreadInfo(self):
+# Prevent LLDB defaulting to PID of 1 and looking up some other
+# process when on an AArch64 host.
+return "m-1"
+
 def test(self):
 self.server.responder = TestqOffsets.Responder()
 target = self.createTarget("qOffsets.yaml")

``




https://github.com/llvm/llvm-project/pull/157432
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [NFC][lldb] Cleanup the ArchDefinitionEntry definitons. (PR #152618)

2025-09-08 Thread Greg Clayton via lldb-commits

clayborg wrote:

> I think this makes sense.
> 
> Out of curiosity, what does clang-format do to the formatting?

It will complain or try to reformat. This allows lines to exceed the column 
limit and also won't reformat any spacing.

https://github.com/llvm/llvm-project/pull/152618
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits


@@ -1873,6 +1873,17 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);

tgs-sc wrote:

Addressed

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Expression] Reject languages not supported by TypeSystems for expression evaluation (PR #156648)

2025-09-08 Thread Pavel Labath via lldb-commits

labath wrote:

> I don't remember how that works in swift, but note, there are two separate 
> issues with the C family expression parser. One was making local declarations 
> override ivar references in name resolution in the context of the expression. 
> That is why we inject variables into the expression by hand (and is 
> controlled by the target.experimental.inject-local-vars setting). That's not 
> even necessary, IIRC it's to work around the side effect of the too much 
> optimizing of the DWARF. 

I don't believe that has anything to do with DWARF -- the debug info describes 
that situation perfectly. The problem is that when you have code like
```
struct Foo {
  int bar;
  void foo() { int bar; ...; }
};
```
if you stop in `foo` and go `expr bar`, per c++ rules, you'd expect to see the 
local variable, but clang will not even ask us what `bar` is because it will 
assume you're referring to the member variable. Injecting the local variable 
into the expression forces clang to ask us what `__lldb_local_vars::bar` is.

That said, C doesn't have methods, so maybe this isn't an issue there.

> But the more important C++ requirement is that we use it to make the 
> expression
> 
> local_or_global_variable = 100
> 
> work correctly without having to pass variable references into the expression 
> from a separate context as a pointer, which would require that behind the 
> user's back we would be munging this expression to:
> 
> *local_or_global_variable_pointer = 100
> 
> We wanted to avoid having to do that everywhere, and the solution to that was 
> to use C++ references when a variable was mentioned in an expression. That's 
> the harder bit you are going to have to solve to get rid of C++ in the basic 
> C-family expression evaluator.

Yes, this sounds like a more complicated issue. Perhaps we could fake it by 
pretending `bar` is a global variable and then rewriting the access in the 
resulting IR (I think we do something similar for function calls already)?

https://github.com/llvm/llvm-project/pull/156648
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [clang] remove IsDefaulted bit from TemplateArgument (PR #155120)

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


@@ -48,7 +48,7 @@ int main() {
 // COMMON-SAME: templateParams: ![[PARAM:[0-9]+]]
 // COMMON:  ![[PARAM]] = !{![[TEMPL_TYPE_PARAM:[0-9]+]]}
 // GDB: ![[TEMPL_TYPE_PARAM]] = !DITemplateTypeParameter(name: "T", 
type: ![[BAR_INT_TY]])
-// LLDB:![[TEMPL_TYPE_PARAM]] = !DITemplateTypeParameter(name: "T", 
type: ![[BAR_INT_TY]])
+// LLDB:![[TEMPL_TYPE_PARAM]] = !DITemplateTypeParameter(name: "T", 
type: ![[FOO_INT]])

Michael137 wrote:

This means the type would be `Foo` instead of `BarInt`. That's not ideal

https://github.com/llvm/llvm-project/pull/155120
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [clang][Mangle] Inject structor type into mangled name when mangling for LLDB JIT expressions (PR #155485)

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

Michael137 wrote:

friendly ping

https://github.com/llvm/llvm-project/pull/155485
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits


@@ -1873,6 +1873,18 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
+if (!class_specialization_decl) {
+  if (log) {
+dwarf->GetObjectFile()->GetModule()->LogMessage(
+log,
+"SymbolFileDWARF({0:p}) - Specialization for "
+"clang::ClassTemplateDecl({1:p}) already exists.",
+static_cast(this),
+static_cast(class_template_decl));

tgs-sc wrote:

Addressed

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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


@@ -1873,6 +1873,17 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
+if (!class_specialization_decl) {
+  if (log) {
+dwarf->GetObjectFile()->GetModule()->LogMessage(
+log,
+"SymbolFileDWARF({0:p}) - Specialization for "
+"clang::ClassTemplateDecl({1}, {2:p}) already exists.",

Michael137 wrote:

```suggestion
"SymbolFileDWARF({0:p}) - Failed to create specialization for "
"clang::ClassTemplateDecl({1}, {2:p}).",
```

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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


@@ -1676,6 +1676,13 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl(
   class_template_specialization_decl->setInstantiationOf(class_template_decl);
   class_template_specialization_decl->setTemplateArgs(
   TemplateArgumentList::CreateCopy(ast, args));
+  // Specialization exists, so return nullptr.

Michael137 wrote:

```suggestion
```

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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

Michael137 wrote:

> @Michael137, do you think that this PR(#154134) is still needed?

I'll comment on that PR

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits

https://github.com/tgs-sc updated 
https://github.com/llvm/llvm-project/pull/154123

>From f076aea3116c72d8c3bdf2c8e5b151b0df73036a Mon Sep 17 00:00:00 2001
From: Timur Golubovich 
Date: Mon, 8 Sep 2025 14:43:50 +0300
Subject: [PATCH] [lldb][DWARFASTParserClang] Added a check for the
 specialization existence

While debugging an application with incorrect dwarf information, where
DW_TAG_template_value_parameter was lost, I found that lldb does not
check that the corresponding specialization exists. As a result, at the
stage when ASTImporter works, the type is completed in such a way that
it inherits from itself. And during the calculation of layout, an
infinite recursion occurs. To catch this error, I added a corresponding check
at the stage of restoring the type from dwarf information.
---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  13 +
 .../TypeSystem/Clang/TypeSystemClang.cpp  |   8 +
 .../unittests/SymbolFile/DWARF/CMakeLists.txt |   3 +-
 .../DWARF/DWARFASTParserClangTests.cpp|  34 +
 .../Inputs/DW_AT_spec_decl_exists-test.yaml   | 677 ++
 5 files changed, 734 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_spec_decl_exists-test.yaml

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index c76d67b47b336..b51b5d4f3bcbf 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1873,6 +1873,19 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
+// If we got nullptr, then such specialization already exists.
+if (!class_specialization_decl) {
+  if (log) {
+dwarf->GetObjectFile()->GetModule()->LogMessage(
+log,
+"SymbolFileDWARF({0:p}) - Specialization for "
+"clang::ClassTemplateDecl({1:p}) already exists.",
+static_cast(this),
+static_cast(class_template_decl));
+  }
+  return TypeSP();
+}
+
 m_ast.SetMetadata(class_template_decl, metadata);
 m_ast.SetMetadata(class_specialization_decl, metadata);
   }
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 82e07bb8e0ffb..cb3a1906e81e3 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1676,6 +1676,14 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl(
   class_template_specialization_decl->setInstantiationOf(class_template_decl);
   class_template_specialization_decl->setTemplateArgs(
   TemplateArgumentList::CreateCopy(ast, args));
+  void *InsertPos = nullptr;
+  if (!class_template_decl->findSpecialization(args, InsertPos)) {
+// Add this specialization to the class template.
+class_template_decl->AddSpecialization(class_template_specialization_decl,
+   InsertPos);
+  } else
+// Specialization exists, so return nullptr.
+return nullptr;
   ast.getTypeDeclType(class_template_specialization_decl, nullptr);
   class_template_specialization_decl->setDeclName(
   class_template_decl->getDeclName());
diff --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt 
b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index eb2e00adba64b..88492188e794b 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -27,6 +27,7 @@ add_lldb_unittest(SymbolFileDWARFTests
 
 set(test_inputs
test-dwarf.exe
-   DW_AT_default_value-test.yaml)
+   DW_AT_default_value-test.yaml
+   DW_AT_spec_decl_exists-test.yaml)
 
 add_unittest_inputs(SymbolFileDWARFTests "${test_inputs}")
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
index d608a57382096..3b9fbbe6f6254 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -599,6 +599,40 @@ TEST_F(DWARFASTParserClangTests, 
TestDefaultTemplateParamParsing) {
   }
 }
 
+TEST_F(DWARFASTParserClangTests, TestSpecDeclExistsError) {
+  // Tests that parsing a ClassTemplateSpecializationDecl that already exists
+  // is handled gracefully.
+  auto BufferOrError = llvm::MemoryBuffer::getFile(
+  GetInputFilePath("DW_AT_spec_decl_exists-test.yaml"), /*IsText=*/true);
+  ASSERT_TRUE(BufferOrError);
+  YAMLModuleTester t(BufferOrError.get()->getBuffer());
+
+  DWARFUnit *unit = t.GetDwarfUnit();
+  ASSERT_NE(unit, nullptr);
+  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();
+  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);
+  DWARFDIE cu_die(unit, cu_entry);
+
+  auto holder = std::make_unique(

[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits

https://github.com/tgs-sc updated 
https://github.com/llvm/llvm-project/pull/154123

>From 795c01cbfeb6c92c27d674970db938528fd25a56 Mon Sep 17 00:00:00 2001
From: Timur Golubovich 
Date: Mon, 8 Sep 2025 14:43:50 +0300
Subject: [PATCH] [lldb][DWARFASTParserClang] Added a check for the
 specialization existence

While debugging an application with incorrect dwarf information, where
DW_TAG_template_value_parameter was lost, I found that lldb does not
check that the corresponding specialization exists. As a result, at the
stage when ASTImporter works, the type is completed in such a way that
it inherits from itself. And during the calculation of layout, an
infinite recursion occurs. To catch this error, I added a corresponding check
at the stage of restoring the type from dwarf information.
---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  11 +
 .../TypeSystem/Clang/TypeSystemClang.cpp  |   5 +
 .../unittests/SymbolFile/DWARF/CMakeLists.txt |   3 +-
 .../DWARF/DWARFASTParserClangTests.cpp|  34 +
 .../Inputs/DW_AT_spec_decl_exists-test.yaml   | 677 ++
 5 files changed, 729 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_spec_decl_exists-test.yaml

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index a429ea848b7f7..88440dc2a3198 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1899,6 +1899,17 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 m_ast.CreateClassTemplateSpecializationDecl(
 containing_decl_ctx, GetOwningClangModule(die), 
class_template_decl,
 tag_decl_kind, template_param_infos);
+if (!class_specialization_decl) {
+  if (log) {
+dwarf->GetObjectFile()->GetModule()->LogMessage(
+log,
+"SymbolFileDWARF({0:p}) - Failed to create specialization for "
+"clang::ClassTemplateDecl({1}, {2:p}).",
+this, llvm::StringRef(attrs.name), class_template_decl);
+  }
+  return TypeSP();
+}
+
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index c4a917f59fb88..2d4f1ebd86128 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1674,6 +1674,11 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl(
   class_template_specialization_decl->setInstantiationOf(class_template_decl);
   class_template_specialization_decl->setTemplateArgs(
   TemplateArgumentList::CreateCopy(ast, args));
+  void *InsertPos = nullptr;
+  if (class_template_decl->findSpecialization(args, InsertPos))
+return nullptr;
+  class_template_decl->AddSpecialization(class_template_specialization_decl,
+ InsertPos);
   class_template_specialization_decl->setDeclName(
   class_template_decl->getDeclName());
 
diff --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt 
b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index eb2e00adba64b..88492188e794b 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -27,6 +27,7 @@ add_lldb_unittest(SymbolFileDWARFTests
 
 set(test_inputs
test-dwarf.exe
-   DW_AT_default_value-test.yaml)
+   DW_AT_default_value-test.yaml
+   DW_AT_spec_decl_exists-test.yaml)
 
 add_unittest_inputs(SymbolFileDWARFTests "${test_inputs}")
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
index 0cae01de2902a..1abce6999874e 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -599,6 +599,40 @@ TEST_F(DWARFASTParserClangTests, 
TestDefaultTemplateParamParsing) {
   }
 }
 
+TEST_F(DWARFASTParserClangTests, TestSpecDeclExistsError) {
+  // Tests that parsing a ClassTemplateSpecializationDecl that already exists
+  // is handled gracefully.
+  auto BufferOrError = llvm::MemoryBuffer::getFile(
+  GetInputFilePath("DW_AT_spec_decl_exists-test.yaml"), /*IsText=*/true);
+  ASSERT_TRUE(BufferOrError);
+  YAMLModuleTester t(BufferOrError.get()->getBuffer());
+
+  DWARFUnit *unit = t.GetDwarfUnit();
+  ASSERT_NE(unit, nullptr);
+  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();
+  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);
+  DWARFDIE cu_die(unit, cu_entry);
+
+  auto holder = std::make_unique("ast");
+  auto &ast_ctx = *holder->GetAST();
+  DWARFASTParserClangStub ast_parser(ast_ctx);
+
+  llvm::SmallVector specializations;
+  for (DWARFDIE die : cu_die.children()) {
+SymbolCont

[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits


@@ -0,0 +1,10 @@
+# REQUIRES: target=riscv32-{{.*}}
+
+# RUN: %lldb -b -o "disassemble -b -n main" %p/Inputs/riscv_xqci.out | 
FileCheck %s

DavidSpickett wrote:

There is also a setting:
```
  target.disassembly-features -- Specify additional CPU features for 
disassembling.
```
We should pull the feature list from that if `-Y` is not specified. At least, I 
assume that's what we do, the help docs ideally would say so.

https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits


@@ -1593,6 +1620,13 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec 
&arch,
 features_str += "+a,+m,";
   }
 
+  llvm::StringRef additional_features = arch.GetDisassemblyFeatures();
+  // Prepend the additional_features if it's not already in the features_str to
+  // avoid duplicates.
+  if (!additional_features.empty()) {
+UpdateFeatureString(additional_features, features_str);

DavidSpickett wrote:

Also inline the getter:
UpdateFeatureString(arch.GetDisassemblyFeatures(), features_str);

https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits


@@ -1284,6 +1285,54 @@ 
ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
   return error;
 }
 
+void ObjectFileELF::ParseRISCVAttributes(DataExtractor &data, uint64_t length,

DavidSpickett wrote:

`const DataExtractor &data` if you can.

https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits


@@ -0,0 +1,10 @@
+# REQUIRES: target=riscv32-{{.*}}
+
+# RUN: %lldb -b -o "disassemble -b -n main" %p/Inputs/riscv_xqci.out | 
FileCheck %s
+
+# CHECK: 051f 0058   qc.e.li a0, 0x58
+# CHECK: 1516  qc.extu a0, a0, 0x6, 0x0
+
+# RUN: %lldb -b -o "disassemble -b -n main -Y -xqci,+c" 
%p/Inputs/riscv_xqci.out | FileCheck --check-prefix=CHECK-NOXQCI %s

DavidSpickett wrote:

There should be some test here to show what happens if the user does 
`+foo,-foo,+foo`. I would expect it to result in foo being enabled.

https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits


@@ -1446,6 +1446,33 @@ bool 
DisassemblerLLVMC::MCDisasmInstance::IsAuthenticated(
   return InstrDesc.isAuthenticated() || IsBrkC47x;
 }
 
+void DisassemblerLLVMC::UpdateFeatureString(llvm::StringRef 
additional_features,
+std::string &features) {
+  // Allow users to override default additional features.
+  for (llvm::StringRef flag : llvm::split(additional_features, ",")) {
+flag = flag.trim();
+if (flag.empty())
+  continue;
+// By default, if both +flag and -flag are present in the feature string,
+// disassembler keeps the feature enabled (+flag).
+// To respect user intent, we make -flag(user) take priority over the
+// default +flag coming from ELF.
+bool add_flag = true;
+if (flag.starts_with('+')) {
+  std::string disable_flag = "-" + flag.substr(1).str();

DavidSpickett wrote:

If flag starts with plus and it's at least two characters, only then do the 
rest.

https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits




DavidSpickett wrote:

As in:
obj2yaml the file you have
yaml2obj and make the test work
cut bits out of the yaml
repeat until it's as small as you can reasonably get it

https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits


@@ -0,0 +1,10 @@
+# REQUIRES: target=riscv32-{{.*}}
+
+# RUN: %lldb -b -o "disassemble -b -n main" %p/Inputs/riscv_xqci.out | 
FileCheck %s
+
+# CHECK: 051f 0058   qc.e.li a0, 0x58
+# CHECK: 1516  qc.extu a0, a0, 0x6, 0x0

DavidSpickett wrote:

Also CHECK-NOT to make sure you don't get unknown here. I know in theory it 
shouldn't be a problem but it'll prevent us printing it twice or whatever.

https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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

Michael137 wrote:

Based on the test failure in `TestCppTemplateArguments.py` maybe we need to 
return the `ClassTemplateDeclSpecialization` that we found, instead of 
returning `nullptr`. We would create a new `TypeSP` for it, but that shouldn't 
be an issue i think

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits


@@ -1446,6 +1446,33 @@ bool 
DisassemblerLLVMC::MCDisasmInstance::IsAuthenticated(
   return InstrDesc.isAuthenticated() || IsBrkC47x;
 }
 
+void DisassemblerLLVMC::UpdateFeatureString(llvm::StringRef 
additional_features,
+std::string &features) {
+  // Allow users to override default additional features.
+  for (llvm::StringRef flag : llvm::split(additional_features, ",")) {
+flag = flag.trim();
+if (flag.empty())
+  continue;
+// By default, if both +flag and -flag are present in the feature string,
+// disassembler keeps the feature enabled (+flag).
+// To respect user intent, we make -flag(user) take priority over the
+// default +flag coming from ELF.
+bool add_flag = true;
+if (flag.starts_with('+')) {
+  std::string disable_flag = "-" + flag.substr(1).str();
+  if (features.find(disable_flag) != std::string::npos) {
+add_flag = false;
+  }

DavidSpickett wrote:

add_flag = features.find(disable_flag) == std::string::npos;

https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][elf-core][ARM] Add support for VFP registers (PR #155956)

2025-09-08 Thread David Spickett via lldb-commits

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

LGTM

https://github.com/llvm/llvm-project/pull/155956
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFC] Architecture plugins should report the vector element order (PR #157198)

2025-09-08 Thread David Spickett via lldb-commits

DavidSpickett wrote:

I can confirm that AArch64 Neon and SVE work as stated:

> B2.9.3.2 Endianness in SIMD operations
> 
> ...The four elements appear in the register in array order, with the
> lowest indexed element fetched from the lowest address. The order of bytes in 
> the elements depends on the endianness
> configuration, as shown in Figure B2-3. Therefore, the **order of the 
> elements in the registers is the same regardless of the
> endianness configuration**.
> 
> B2.9.3.3 Endianness in SVE operations
> 
> Rules on byte and element order of SIMD load and store instructions apply to 
> SVE load and store instructions.

Do we know what vector extension s390x has and what order it uses?

https://github.com/llvm/llvm-project/pull/157198
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits


@@ -1873,6 +1874,24 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
+// Try to find an existing specialization with these template arguments and
+// template parameter list.
+void *InsertPos = nullptr;
+llvm::ArrayRef args =
+template_param_infos.GetArgs();
+if (!args.empty() &&
+!class_template_decl->findSpecialization(args, InsertPos))
+  // Add this specialization to the class template.
+  class_template_decl->AddSpecialization(class_specialization_decl,
+ InsertPos);
+else {
+  module_sp->ReportError("SymbolFileDWARF({0:p}) - Specialization for "

tgs-sc wrote:

Addressed

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits


@@ -599,6 +599,39 @@ TEST_F(DWARFASTParserClangTests, 
TestDefaultTemplateParamParsing) {
   }
 }
 
+TEST_F(DWARFASTParserClangTests, TestSpecDeclExistsError) {
+  // Tests checking error if ClassTemplateSpecializationDecl already exists.
+  auto BufferOrError = llvm::MemoryBuffer::getFile(
+  GetInputFilePath("DW_AT_spec_decl_exists-test.yaml"), /*IsText=*/true);
+  ASSERT_TRUE(BufferOrError);
+  YAMLModuleTester t(BufferOrError.get()->getBuffer());
+
+  DWARFUnit *unit = t.GetDwarfUnit();
+  ASSERT_NE(unit, nullptr);
+  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();
+  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);
+  DWARFDIE cu_die(unit, cu_entry);
+
+  auto holder = std::make_unique("ast");
+  auto &ast_ctx = *holder->GetAST();
+  DWARFASTParserClangStub ast_parser(ast_ctx);
+
+  llvm::SmallVector types;
+  for (DWARFDIE die : cu_die.children()) {
+if (die.Tag() == DW_TAG_structure_type) {

tgs-sc wrote:

Addressed

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits

https://github.com/tgs-sc updated 
https://github.com/llvm/llvm-project/pull/154123

>From a2390655ad8a77ef9f1087e24089e36d8925e604 Mon Sep 17 00:00:00 2001
From: Timur Golubovich 
Date: Mon, 18 Aug 2025 17:29:01 +0300
Subject: [PATCH 1/3] [lldb][DWARFASTParserClang] Added a check for the
 specialization existence

While debugging an application with incorrect dwarf information, where
DW_TAG_template_value_parameter was lost, I found that lldb does not
check that the corresponding specialization exists. As a result, at the
stage when ASTImporter works, the type is completed in such a way that
it inherits from itself. And during the calculation of layout, an
infinite recursion occurs. To catch this error, I added a corresponding check
at the stage of restoring the type from dwarf information.
---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  18 +
 .../unittests/SymbolFile/DWARF/CMakeLists.txt |   3 +-
 .../DWARF/DWARFASTParserClangTests.cpp|  33 +
 .../Inputs/DW_AT_spec_decl_exists-test.yaml   | 675 ++
 4 files changed, 728 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_spec_decl_exists-test.yaml

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index c76d67b47b336..153730f05f3cd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1873,6 +1873,24 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
+// Try to find an existing specialization with these template arguments and
+// template parameter list.
+void *InsertPos = nullptr;
+llvm::ArrayRef args =
+template_param_infos.GetArgs();
+if (!args.empty() &&
+!class_template_decl->findSpecialization(args, InsertPos))
+  // Add this specialization to the class template.
+  class_template_decl->AddSpecialization(class_specialization_decl,
+ InsertPos);
+else {
+  dwarf->GetObjectFile()->GetModule()->LogMessage(
+  "SymbolFileDWARF({0:p}) - Specialization for "
+  "clang::ClassTemplateDecl({1:p}) already exists.",
+  static_cast(this), static_cast(class_template_decl));
+  return TypeSP();
+}
+
 m_ast.SetMetadata(class_template_decl, metadata);
 m_ast.SetMetadata(class_specialization_decl, metadata);
   }
diff --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt 
b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index eb2e00adba64b..88492188e794b 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -27,6 +27,7 @@ add_lldb_unittest(SymbolFileDWARFTests
 
 set(test_inputs
test-dwarf.exe
-   DW_AT_default_value-test.yaml)
+   DW_AT_default_value-test.yaml
+   DW_AT_spec_decl_exists-test.yaml)
 
 add_unittest_inputs(SymbolFileDWARFTests "${test_inputs}")
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
index d608a57382096..7886c5f16a053 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -599,6 +599,39 @@ TEST_F(DWARFASTParserClangTests, 
TestDefaultTemplateParamParsing) {
   }
 }
 
+TEST_F(DWARFASTParserClangTests, TestSpecDeclExistsError) {
+  // Tests checking error if ClassTemplateSpecializationDecl already exists.
+  auto BufferOrError = llvm::MemoryBuffer::getFile(
+  GetInputFilePath("DW_AT_spec_decl_exists-test.yaml"), /*IsText=*/true);
+  ASSERT_TRUE(BufferOrError);
+  YAMLModuleTester t(BufferOrError.get()->getBuffer());
+
+  DWARFUnit *unit = t.GetDwarfUnit();
+  ASSERT_NE(unit, nullptr);
+  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();
+  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);
+  DWARFDIE cu_die(unit, cu_entry);
+
+  auto holder = std::make_unique("ast");
+  auto &ast_ctx = *holder->GetAST();
+  DWARFASTParserClangStub ast_parser(ast_ctx);
+
+  llvm::SmallVector types;
+  for (DWARFDIE die : cu_die.children()) {
+if (die.Tag() == DW_TAG_structure_type) {
+  SymbolContext sc;
+  bool new_type = false;
+  auto type = ast_parser.ParseTypeFromDWARF(sc, die, &new_type);
+  types.push_back(std::move(type));
+}
+  }
+
+  ASSERT_EQ(types.size(), 3U);
+  ASSERT_NE(types[0], nullptr);
+  ASSERT_NE(types[1], nullptr);
+  ASSERT_EQ(types[2], nullptr);
+}
+
 TEST_F(DWARFASTParserClangTests, TestUniqueDWARFASTTypeMap_CppInsertMapFind) {
   // This tests the behaviour of UniqueDWARFASTTypeMap under
   // following scenario:
diff --git 
a/lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_spec_decl_exists-test.yaml 
b/lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_spec_decl_exi

[Lldb-commits] [lldb] [lldb][test] Prevent TestqOffsets.py picking up host binaries (PR #157432)

2025-09-08 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett edited 
https://github.com/llvm/llvm-project/pull/157432
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] Add AArch64 support to the premerge tests (PR #155274)

2025-09-08 Thread Tom Stellard via lldb-commits

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/155274

>From 57697a66cfdddf2028c7260f1ce61ecacc550d00 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 25 Aug 2025 17:15:36 +
Subject: [PATCH 01/64] Add AArch64 support to the premerge tests

---
 .github/workflows/premerge.yaml | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 9d925517a7211..6d83573702a79 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -28,7 +28,13 @@ jobs:
 if: >-
 github.repository_owner == 'llvm' &&
 (github.event_name != 'pull_request' || github.event.action != 
'closed')
-runs-on: llvm-premerge-linux-runners
+matrix:
+  runs-on:
+- llvm-premerge-linux-runners
+- depot-ubuntu-24.04-arm-64
+runs-on: ${{ matrix.runs-on }}
+container:
+  image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') && 
"ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent" ) || null }}
 steps:
   - name: Checkout LLVM
 uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 
v5.0.0

>From 8ba375b2d80614f4a769af1b417bf21f1712786c Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 25 Aug 2025 17:20:38 +
Subject: [PATCH 02/64] Fix typo

---
 .github/workflows/premerge.yaml | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 6d83573702a79..f88dbc6143ab4 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -28,10 +28,11 @@ jobs:
 if: >-
 github.repository_owner == 'llvm' &&
 (github.event_name != 'pull_request' || github.event.action != 
'closed')
-matrix:
-  runs-on:
-- llvm-premerge-linux-runners
-- depot-ubuntu-24.04-arm-64
+strategy:
+  matrix:
+runs-on:
+  - llvm-premerge-linux-runners
+  - depot-ubuntu-24.04-arm-64
 runs-on: ${{ matrix.runs-on }}
 container:
   image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') && 
"ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent" ) || null }}

>From af39d1af7635196606ceaeff6a2cf1db72e142e4 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 25 Aug 2025 17:21:51 +
Subject: [PATCH 03/64] Fix quotes

---
 .github/workflows/premerge.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index f88dbc6143ab4..914713bb4a352 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -35,7 +35,7 @@ jobs:
   - depot-ubuntu-24.04-arm-64
 runs-on: ${{ matrix.runs-on }}
 container:
-  image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') && 
"ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent" ) || null }}
+  image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') && 
'ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent' ) || null }}
 steps:
   - name: Checkout LLVM
 uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 
v5.0.0

>From 0330faf41115cab59d8667dbe77bf9414ea3455c Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 25 Aug 2025 17:24:18 +
Subject: [PATCH 04/64] Fix container name

---
 .github/workflows/premerge.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 914713bb4a352..edb7248d792fe 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -35,7 +35,7 @@ jobs:
   - depot-ubuntu-24.04-arm-64
 runs-on: ${{ matrix.runs-on }}
 container:
-  image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') && 
'ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent' ) || null }}
+  image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') && 
format('ghcr.io/{}/arm64v8/ci-ubuntu-24.04-agent',github.repository_owner) ) || 
null }}
 steps:
   - name: Checkout LLVM
 uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 
v5.0.0

>From 0492ee60484cd594f80b6cadcb7ebc5755b6710c Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 25 Aug 2025 17:29:25 +
Subject: [PATCH 05/64] Fix format string

---
 .github/workflows/premerge.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index edb7248d792fe..28d79518bc1df 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -35,7 +35,7 @@ jobs:
   - depot-ubuntu-24.04-arm-64
 runs-on: ${{ matrix.runs-on }}
 container:
-  image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') && 
format('ghcr.io/{}/arm64v8/ci-ub

[Lldb-commits] [lldb] [lldb][NFC] Fix style issues with StackID.h (PR #157483)

2025-09-08 Thread Felipe de Azevedo Piovezan via lldb-commits

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

Some comments were "suffixed" to member variable declarations; these are moved 
to before the variable.

Some constructors and operators were just defaulted and not necessary.

Some comments dividing the class into logical sections, like "// constructors 
and destructors", were not applied everywhere. These were removed. They are 
used in some parts of LLDB, but are the exception.

An include was not needed.

>From f191b28aad0e3e2f925cffabbe42148ebd26e019 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Mon, 8 Sep 2025 07:43:38 -0700
Subject: [PATCH] [lldb][NFC] Fix style issues with StackID.h

Some comments were "suffixed" to member variable declarations; these are
moved to before the variable.

Some constructors and operators were just defaulted and not necessary.

Some comments dividing the class into logical sections, like "//
constructors and destructors", were not applied everywhere. These were
removed. They are used in some parts of LLDB, but are the exception.

An include was not needed.
---
 lldb/include/lldb/Target/StackID.h | 50 ++
 1 file changed, 16 insertions(+), 34 deletions(-)

diff --git a/lldb/include/lldb/Target/StackID.h 
b/lldb/include/lldb/Target/StackID.h
index fddbc8e48dfdc..4b49964853f7b 100644
--- a/lldb/include/lldb/Target/StackID.h
+++ b/lldb/include/lldb/Target/StackID.h
@@ -10,7 +10,6 @@
 #define LLDB_TARGET_STACKID_H
 
 #include "lldb/Core/AddressRange.h"
-#include "lldb/lldb-private.h"
 
 namespace lldb_private {
 
@@ -18,15 +17,11 @@ class Process;
 
 class StackID {
 public:
-  // Constructors and Destructors
   StackID() = default;
 
   explicit StackID(lldb::addr_t pc, lldb::addr_t cfa,
SymbolContextScope *symbol_scope, Process *process);
 
-  StackID(const StackID &rhs)
-  : m_pc(rhs.m_pc), m_cfa(rhs.m_cfa), m_symbol_scope(rhs.m_symbol_scope) {}
-
   ~StackID() = default;
 
   lldb::addr_t GetPC() const { return m_pc; }
@@ -51,41 +46,28 @@ class StackID {
 
   void Dump(Stream *s);
 
-  // Operators
-  const StackID &operator=(const StackID &rhs) {
-if (this != &rhs) {
-  m_pc = rhs.m_pc;
-  m_cfa = rhs.m_cfa;
-  m_symbol_scope = rhs.m_symbol_scope;
-}
-return *this;
-  }
-
 protected:
   friend class StackFrame;
 
   void SetPC(lldb::addr_t pc, Process *process);
   void SetCFA(lldb::addr_t cfa, Process *process);
 
-  lldb::addr_t m_pc =
-  LLDB_INVALID_ADDRESS; // The pc value for the function/symbol for this
-// frame. This will
-  // only get used if the symbol scope is nullptr (the code where we are
-  // stopped is not represented by any function or symbol in any shared
-  // library).
-  lldb::addr_t m_cfa =
-  LLDB_INVALID_ADDRESS; // The call frame address (stack pointer) value
-// at the beginning of the function that uniquely
-// identifies this frame (along with m_symbol_scope
-// below)
-  SymbolContextScope *m_symbol_scope =
-  nullptr; // If nullptr, there is no block or symbol for this frame.
-   // If not nullptr, this will either be the scope for the
-   // lexical block for the frame, or the scope for the
-   // symbol. Symbol context scopes are always be unique
-   // pointers since the are part of the Block and Symbol
-   // objects and can easily be used to tell if a stack ID
-   // is the same as another.
+  // The pc value for the function/symbol for this frame. This will only get
+  // used if the symbol scope is nullptr (the code where we are stopped is not
+  // represented by any function or symbol in any shared library).
+  lldb::addr_t m_pc = LLDB_INVALID_ADDRESS;
+
+  // The call frame address (stack pointer) value at the beginning of the
+  // function that uniquely identifies this frame (along with m_symbol_scope
+  // below)
+  lldb::addr_t m_cfa = LLDB_INVALID_ADDRESS;
+
+  // If nullptr, there is no block or symbol for this frame. If not nullptr,
+  // this will either be the scope for the lexical block for the frame, or the
+  // scope for the symbol. Symbol context scopes are always be unique pointers
+  // since the are part of the Block and Symbol objects and can easily be used
+  // to tell if a stack ID is the same as another.
+  SymbolContextScope *m_symbol_scope = nullptr;
 };
 
 bool operator==(const StackID &lhs, const StackID &rhs);

___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits


@@ -1725,6 +1725,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
   const dw_tag_t tag = die.Tag();
   SymbolFileDWARF *dwarf = die.GetDWARF();
   LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU());
+  ModuleSP module_sp = dwarf->GetObjectFile()->GetModule();

tgs-sc wrote:

Addressed

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFC] Fix style issues with StackID.h (PR #157483)

2025-09-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)


Changes

Some comments were "suffixed" to member variable declarations; these are moved 
to before the variable.

Some constructors and operators were just defaulted and not necessary.

Some comments dividing the class into logical sections, like "// constructors 
and destructors", were not applied everywhere. These were removed. They are 
used in some parts of LLDB, but are the exception.

An include was not needed.

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


1 Files Affected:

- (modified) lldb/include/lldb/Target/StackID.h (+16-34) 


``diff
diff --git a/lldb/include/lldb/Target/StackID.h 
b/lldb/include/lldb/Target/StackID.h
index fddbc8e48dfdc..4b49964853f7b 100644
--- a/lldb/include/lldb/Target/StackID.h
+++ b/lldb/include/lldb/Target/StackID.h
@@ -10,7 +10,6 @@
 #define LLDB_TARGET_STACKID_H
 
 #include "lldb/Core/AddressRange.h"
-#include "lldb/lldb-private.h"
 
 namespace lldb_private {
 
@@ -18,15 +17,11 @@ class Process;
 
 class StackID {
 public:
-  // Constructors and Destructors
   StackID() = default;
 
   explicit StackID(lldb::addr_t pc, lldb::addr_t cfa,
SymbolContextScope *symbol_scope, Process *process);
 
-  StackID(const StackID &rhs)
-  : m_pc(rhs.m_pc), m_cfa(rhs.m_cfa), m_symbol_scope(rhs.m_symbol_scope) {}
-
   ~StackID() = default;
 
   lldb::addr_t GetPC() const { return m_pc; }
@@ -51,41 +46,28 @@ class StackID {
 
   void Dump(Stream *s);
 
-  // Operators
-  const StackID &operator=(const StackID &rhs) {
-if (this != &rhs) {
-  m_pc = rhs.m_pc;
-  m_cfa = rhs.m_cfa;
-  m_symbol_scope = rhs.m_symbol_scope;
-}
-return *this;
-  }
-
 protected:
   friend class StackFrame;
 
   void SetPC(lldb::addr_t pc, Process *process);
   void SetCFA(lldb::addr_t cfa, Process *process);
 
-  lldb::addr_t m_pc =
-  LLDB_INVALID_ADDRESS; // The pc value for the function/symbol for this
-// frame. This will
-  // only get used if the symbol scope is nullptr (the code where we are
-  // stopped is not represented by any function or symbol in any shared
-  // library).
-  lldb::addr_t m_cfa =
-  LLDB_INVALID_ADDRESS; // The call frame address (stack pointer) value
-// at the beginning of the function that uniquely
-// identifies this frame (along with m_symbol_scope
-// below)
-  SymbolContextScope *m_symbol_scope =
-  nullptr; // If nullptr, there is no block or symbol for this frame.
-   // If not nullptr, this will either be the scope for the
-   // lexical block for the frame, or the scope for the
-   // symbol. Symbol context scopes are always be unique
-   // pointers since the are part of the Block and Symbol
-   // objects and can easily be used to tell if a stack ID
-   // is the same as another.
+  // The pc value for the function/symbol for this frame. This will only get
+  // used if the symbol scope is nullptr (the code where we are stopped is not
+  // represented by any function or symbol in any shared library).
+  lldb::addr_t m_pc = LLDB_INVALID_ADDRESS;
+
+  // The call frame address (stack pointer) value at the beginning of the
+  // function that uniquely identifies this frame (along with m_symbol_scope
+  // below)
+  lldb::addr_t m_cfa = LLDB_INVALID_ADDRESS;
+
+  // If nullptr, there is no block or symbol for this frame. If not nullptr,
+  // this will either be the scope for the lexical block for the frame, or the
+  // scope for the symbol. Symbol context scopes are always be unique pointers
+  // since the are part of the Block and Symbol objects and can easily be used
+  // to tell if a stack ID is the same as another.
+  SymbolContextScope *m_symbol_scope = nullptr;
 };
 
 bool operator==(const StackID &lhs, const StackID &rhs);

``




https://github.com/llvm/llvm-project/pull/157483
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Default-initialize all fields of lldb_dap::protocol::Symbol. (PR #157150)

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

walter-erquinigo wrote:

thanks!

https://github.com/llvm/llvm-project/pull/157150
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits


@@ -1873,6 +1874,24 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
+// Try to find an existing specialization with these template arguments and
+// template parameter list.
+void *InsertPos = nullptr;
+llvm::ArrayRef args =
+template_param_infos.GetArgs();
+if (!args.empty() &&
+!class_template_decl->findSpecialization(args, InsertPos))
+  // Add this specialization to the class template.
+  class_template_decl->AddSpecialization(class_specialization_decl,
+ InsertPos);

tgs-sc wrote:

I am afraid no as if we have already found specialization in this function, we 
should return nullptr. And as I see this may cause errors.

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test] Prevent TestqOffsets.py picking up host binaries (PR #157432)

2025-09-08 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> would runCmd("platform select remote-linux") have the same effect?

This does work.

@tstellar can you confirm that this PR fixes the test for you?

https://github.com/llvm/llvm-project/pull/157432
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add some vector operations to the IRInterpreter (PR #155000)

2025-09-08 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> For testing the endianess, I'm not sure we have PPC LLDB buildbots that would 
> test this

Debian will build PPC little endian once in a while and somewhere in the depths 
of IBM there might be a machine but I've never seen a bug report from one.

Also not sure what endians they ever supported. ISTR Linux is only supported on 
LE now but AIX is BE only.

https://github.com/llvm/llvm-project/pull/155000
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add some vector operations to the IRInterpreter (PR #155000)

2025-09-08 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> I'm not sure we can. The problem arises from transferring LLVM-IR values 
> to/from the targets memory. If we don't have the target consuming/producing 
> that memory then our test could just be consistently-wrong and pass anyway.

We can simulate a gdb-remote that's one of these unique architectures. It could 
check that the memory writes contain the right order of elements.

Sometimes it's not possible because we have to mock too much stuff, but you can 
look at 
`lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py` and 
`lldb/test/API/commands/expression/TestRegisterExpressionEndian.py` as examples.

https://github.com/llvm/llvm-project/pull/155000
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits


@@ -1676,6 +1676,13 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl(
   class_template_specialization_decl->setInstantiationOf(class_template_decl);
   class_template_specialization_decl->setTemplateArgs(
   TemplateArgumentList::CreateCopy(ast, args));
+  // Specialization exists, so return nullptr.

tgs-sc wrote:

Addressed

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libcxx] [libcxxabi] [lld] [lldb] [llvm] [Inclusive Language] migrate "sanity" checks to "soundness" checks (PR #156995)

2025-09-08 Thread via lldb-commits

C0rn3j wrote:

Replacing `sanity` with `sound`, as in `sound of mind`, a *direct synonym* with 
the exact same connotation, seems like it'd do more harm than good.

https://github.com/user-attachments/assets/28533e29-d9a7-42c4-a4dd-cedb03ad4a22";
 />


https://github.com/llvm/llvm-project/pull/156995
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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


@@ -1676,6 +1676,13 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl(
   class_template_specialization_decl->setInstantiationOf(class_template_decl);
   class_template_specialization_decl->setTemplateArgs(
   TemplateArgumentList::CreateCopy(ast, args));
+  // Specialization exists, so return nullptr.
+  void *InsertPos = nullptr;
+  if (class_template_decl->findSpecialization(args, InsertPos))
+return nullptr;
+  // Add this specialization to the class template.

Michael137 wrote:

```suggestion
```

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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


@@ -1873,6 +1874,24 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
+// Try to find an existing specialization with these template arguments and
+// template parameter list.
+void *InsertPos = nullptr;
+llvm::ArrayRef args =
+template_param_infos.GetArgs();
+if (!args.empty() &&
+!class_template_decl->findSpecialization(args, InsertPos))
+  // Add this specialization to the class template.
+  class_template_decl->AddSpecialization(class_specialization_decl,
+ InsertPos);
+else {
+  module_sp->ReportError("SymbolFileDWARF({0:p}) - Specialization for "

Michael137 wrote:

I don't think we should be reporting this to the user console. Particularly, a 
user wouldn't really be aware of what a `Specialization for 
clang::ClassTemplateDecl` is and what the issue is with it already existing.

Lets just `LogConsole` here for now

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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


@@ -0,0 +1,675 @@
+# struct Type {};
+# 
+# template  struct _Optional_payload;
+# 
+# template  struct _Optional_payload<_Tp, true, false, false> {};
+# 
+# template 
+# struct _Optional_payload<_Tp, false, _Copy, _Move>
+# : _Optional_payload<_Tp, true, false, false> {};
+# 
+# int main() {
+#   _Optional_payload X;
+# }
+#
+# YAML generated on Linux using obj2yaml on the above program
+# compiled with G++.

Michael137 wrote:

Lets add a comment saying this is malformed DWARF that is missing 
`DW_TAG_template_value_parameter` entries, which is important for the test 
because that makes the two specializations structurally match in the AST.

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [clang] remove IsDefaulted bit from TemplateArgument (PR #155120)

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


@@ -2125,9 +2125,9 @@ bool DWARFASTParserClang::ParseTemplateDIE(
   if (tag == DW_TAG_template_value_parameter && uval64_valid) {
 if (auto value = MakeAPValue(ast, clang_type, uval64)) {
   template_param_infos.InsertArg(
-  name, clang::TemplateArgument(
-ast, ClangUtil::GetQualType(clang_type),
-std::move(*value), is_default_template_arg));
+  name,
+  clang::TemplateArgument(ast, ClangUtil::GetQualType(clang_type),
+  std::move(*value)));

Michael137 wrote:

This is where the problem that we fixed originally lies. LLDB needs to 
communicate to Clang that a `TemplateArgument` corresponds to a defaulted 
value. That's encoded in DWARF. Setting it on `TemplateArgument` here was the 
only way to tell Clang's `TypePrinter` about this (AFAIK). I'm aware that the 
defaulted-ness is already encoded in the AST elsewhere, but because of the way 
that templates are encoded in DWARF, we can't really make use of that. Long 
story short, we can't call `setDefaultArgument` from LLDB. Of course I'm happy 
to consider alternatives if we can make the test-cases work as they do now

https://github.com/llvm/llvm-project/pull/155120
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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


@@ -1873,6 +1874,24 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
+// Try to find an existing specialization with these template arguments and
+// template parameter list.
+void *InsertPos = nullptr;
+llvm::ArrayRef args =
+template_param_infos.GetArgs();
+if (!args.empty() &&
+!class_template_decl->findSpecialization(args, InsertPos))
+  // Add this specialization to the class template.
+  class_template_decl->AddSpecialization(class_specialization_decl,
+ InsertPos);

Michael137 wrote:

Can we move this into `CreateClassTemplateSpecializationDecl`? That's where we 
also `setInstantiationOf`.

That way we could even test this functionality in `TestTypeSystemClang`

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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


@@ -1873,6 +1874,24 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
+// Try to find an existing specialization with these template arguments and
+// template parameter list.
+void *InsertPos = nullptr;
+llvm::ArrayRef args =
+template_param_infos.GetArgs();
+if (!args.empty() &&
+!class_template_decl->findSpecialization(args, InsertPos))
+  // Add this specialization to the class template.
+  class_template_decl->AddSpecialization(class_specialization_decl,
+ InsertPos);

Michael137 wrote:

Not sure I understand. What's preventing us from calling `findSpecialization` 
inside `CreateClassTemplateSpecializationDecl `?

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits


@@ -1284,6 +1285,54 @@ 
ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
   return error;
 }
 
+void ObjectFileELF::ParseRISCVAttributes(DataExtractor &data, uint64_t length,
+ ArchSpec &arch_spec) {
+  lldb::offset_t offset = 0;
+
+  uint8_t format_version = data.GetU8(&offset);
+  if (format_version != llvm::ELFAttrs::Format_Version)
+return;
+
+  offset = offset + sizeof(uint32_t); // Section Length
+  llvm::StringRef vendor_name = data.GetCStr(&offset);
+
+  if (vendor_name != "riscv")
+return;

DavidSpickett wrote:

Previously you do:
```
read thing
if thing is not whatever
  return
```
With no blank line before the if. I like that style, do that here.

https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits


@@ -617,6 +617,13 @@ void ArchSpec::SetFlags(const std::string &elf_abi) {
   SetFlags(flag);
 }
 
+void ArchSpec::SetDisassemblyFeatures(std::string additional_features) {

DavidSpickett wrote:

This name is misleading. Set implies overwrite.

`AddDisassemblyFeatures` allows you to be vague about how it's added.

Also, do you ever call this with more than one feature? I don't think so and if 
so, make all this singular so that's clear.

https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits


@@ -1446,6 +1446,33 @@ bool 
DisassemblerLLVMC::MCDisasmInstance::IsAuthenticated(
   return InstrDesc.isAuthenticated() || IsBrkC47x;
 }
 
+void DisassemblerLLVMC::UpdateFeatureString(llvm::StringRef 
additional_features,

DavidSpickett wrote:

If this is only called from this class, it should be static and not be a class 
member function.

https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits


@@ -1446,6 +1446,33 @@ bool 
DisassemblerLLVMC::MCDisasmInstance::IsAuthenticated(
   return InstrDesc.isAuthenticated() || IsBrkC47x;
 }
 
+void DisassemblerLLVMC::UpdateFeatureString(llvm::StringRef 
additional_features,
+std::string &features) {
+  // Allow users to override default additional features.
+  for (llvm::StringRef flag : llvm::split(additional_features, ",")) {
+flag = flag.trim();
+if (flag.empty())
+  continue;
+// By default, if both +flag and -flag are present in the feature string,
+// disassembler keeps the feature enabled (+flag).
+// To respect user intent, we make -flag(user) take priority over the
+// default +flag coming from ELF.
+bool add_flag = true;
+if (flag.starts_with('+')) {
+  std::string disable_flag = "-" + flag.substr(1).str();

DavidSpickett wrote:

If my feature string is `+,` (just a plus, no feature name) then this goes 
out of bounds.

https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett edited 
https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits


@@ -1593,6 +1620,13 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec 
&arch,
 features_str += "+a,+m,";
   }
 
+  llvm::StringRef additional_features = arch.GetDisassemblyFeatures();
+  // Prepend the additional_features if it's not already in the features_str to
+  // avoid duplicates.
+  if (!additional_features.empty()) {
+UpdateFeatureString(additional_features, features_str);

DavidSpickett wrote:

UpdateFeatureString will just return early if additional_features is empty, so 
I'd just call it without a check.

https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test] Prevent TestqOffsets.py picking up host binaries (PR #157432)

2025-09-08 Thread Pavel Labath via lldb-commits

labath wrote:

> I'll try it but I have a suspicion we have code that says "anything on 
> localhost must be the host machine".

I hope we don't. The code I'm targetting is in 
TargetList::CreateTargetInternal, which gives preference to the selected 
platform.

https://github.com/llvm/llvm-project/pull/157432
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] d2e1539 - [lldb][test] Disable another part of TestDAP_step.py on Windows

2025-09-08 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2025-09-08T13:58:40Z
New Revision: d2e153981e62fb2ea781ef456ff744f9893e0733

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

LOG: [lldb][test] Disable another part of TestDAP_step.py on Windows

Flakey on our Windows on Arm bot:
https://lab.llvm.org/buildbot/#/builders/141/builds/11377

ERROR: test_step_over_inlined_function 
(TestDAP_step.TestDAP_step.test_step_over_inlined_function)

   Test stepping over when the program counter is in another file.

--

Traceback (most recent call last):

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py",
 line 2090, in tearDown

Base.tearDown(self)

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py",
 line 1105, in tearDown

hook()  # try the plain call and hope it works

^^

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\tools\lldb-dap\lldbdap_testcase.py",
 line 521, in cleanup

self.dap_server.terminate()

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\tools\lldb-dap\dap_server.py",
 line 1602, in terminate

raise DebugAdapterProcessError(process.returncode)

dap_server.DebugAdapterProcessError: lldb-dap returned non-zero exit status 1.

Config=aarch64-C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe

--

See #137660.

Added: 


Modified: 
lldb/test/API/tools/lldb-dap/step/TestDAP_step.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-dap/step/TestDAP_step.py 
b/lldb/test/API/tools/lldb-dap/step/TestDAP_step.py
index 5c055f679aedc..3a747c3995665 100644
--- a/lldb/test/API/tools/lldb-dap/step/TestDAP_step.py
+++ b/lldb/test/API/tools/lldb-dap/step/TestDAP_step.py
@@ -84,6 +84,7 @@ def test_step(self):
 # only step one thread that is at the breakpoint and stop
 break
 
+@skipIfWindows
 def test_step_over_inlined_function(self):
 """
 Test stepping over when the program counter is in another file.



___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] bf51a4d - [lldb][NFC] clang-format DisassemblerLLVMC.cpp

2025-09-08 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2025-09-08T12:39:07Z
New Revision: bf51a4df728fb5386b0305ce05353cf7e3eb3f01

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

LOG: [lldb][NFC] clang-format DisassemblerLLVMC.cpp

Noticed these bits in a PR I'm reviewing. Might as well fix them now.

Added: 


Modified: 
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp 
b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
index e11019401baef..66d0a50985be7 100644
--- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -559,7 +559,7 @@ class InstructionLLVMC : public lldb_private::Instruction {
   lldb::InstructionControlFlowKind
   GetControlFlowKind(const lldb_private::ExecutionContext *exe_ctx) override {
 DisassemblerScope disasm(*this, exe_ctx);
-if (disasm){
+if (disasm) {
   if (disasm->GetArchitecture().GetMachine() == llvm::Triple::x86)
 return x86::GetControlFlowKind(/*is_64b=*/false, m_opcode);
   else if (disasm->GetArchitecture().GetMachine() == llvm::Triple::x86_64)
@@ -1608,9 +1608,8 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
   // thumb instruction disassembler.
   if (llvm_arch == llvm::Triple::arm) {
 std::string thumb_triple(thumb_arch.GetTriple().getTriple());
-m_alternate_disasm_up =
-MCDisasmInstance::Create(thumb_triple.c_str(), "", 
features_str.c_str(),
- flavor, *this);
+m_alternate_disasm_up = MCDisasmInstance::Create(
+thumb_triple.c_str(), "", features_str.c_str(), flavor, *this);
 if (!m_alternate_disasm_up)
   m_disasm_up.reset();
 



___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test] Prevent TestqOffsets.py picking up host binaries (PR #157432)

2025-09-08 Thread Pavel Labath via lldb-commits

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


https://github.com/llvm/llvm-project/pull/157432
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test] StepUntil disable test for unsupported linkers. (PR #157474)

2025-09-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)


Changes

`INSERT BEFORE` keyword is not supported in current versions gold and mold 
linkers. Since we cannot confirm accurately what linker and version is 
available on the system and when it will be supported. We test it with a sample 
program using the script keywords.

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


2 Files Affected:

- (modified) lldb/test/API/functionalities/thread/step_until/TestStepUntil.py 
(+40) 
- (modified) 
lldb/test/API/functionalities/thread/step_until/TestStepUntilAPI.py (+43) 


``diff
diff --git a/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py 
b/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py
index 965da02ed0f98..90f207b5d4660 100644
--- a/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py
+++ b/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py
@@ -1,11 +1,50 @@
 """Test stepping over vrs. hitting breakpoints & subsequent stepping in 
various forms."""
 
+from typing import Optional
 
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
+import tempfile
+
+
+def linker_script_syntax_unsupported() -> Optional[str]:
+"""Current versions of mold and gold linker does not support some syntax of
+linker scripts, this maybe supported in future versions. check if it 
compiles,
+if not it is not supported.
+"""
+with tempfile.TemporaryDirectory() as tmpdir:
+output_path = os.path.join(tmpdir, "linker_support.out")
+linker_script_path = os.path.join(tmpdir, "test.ld")
+
+with open(linker_script_path, "w") as linker_script:
+linker_script.write(
+"SECTIONS {.text.ordered : { *(.text.ordered) *(.text.foo) } } 
INSERT BEFORE .text;"
+)
+
+compiler_cmd = subprocess.Popen(
+[
+lldbplatformutil.getCompiler(),
+f"-o {output_path}",
+"-ffunction-sections",
+f"-Wl,--script={linker_script_path}",
+"-xc",
+"-",
+],
+shell=True,
+universal_newlines=True,
+stdin=subprocess.PIPE,
+stdout=subprocess.PIPE,
+stderr=subprocess.PIPE,
+)
+_, comp_err = compiler_cmd.communicate(
+"int foo() { return 1; } int main() { return 0; }"
+)
 
+if len(comp_err) != 0:
+return str(tmpdir) + " " + comp_err
+return None
 
 class StepUntilTestCase(TestBase):
 def setUp(self):
@@ -112,6 +151,7 @@ def test_bad_line(self):
 @no_debug_info_test
 @skipIf(oslist=lldbplatformutil.getDarwinOSTriples() + ["windows"])
 @skipIf(archs=no_match(["x86_64", "aarch64"]))
+@skipTestIfFn(linker_script_syntax_unsupported)
 def test_bad_line_discontinuous(self):
 """Test that we get an error if attempting to step outside the current
 function -- and the function is discontinuous"""
diff --git 
a/lldb/test/API/functionalities/thread/step_until/TestStepUntilAPI.py 
b/lldb/test/API/functionalities/thread/step_until/TestStepUntilAPI.py
index 59e028acf014c..44e764c43cd20 100644
--- a/lldb/test/API/functionalities/thread/step_until/TestStepUntilAPI.py
+++ b/lldb/test/API/functionalities/thread/step_until/TestStepUntilAPI.py
@@ -1,8 +1,48 @@
+from typing import Optional
+
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
+import tempfile
+
+
+def linker_script_syntax_unsupported() -> Optional[str]:
+"""Current versions of mold and gold linker does not support some syntax of
+linker scripts, this maybe supported in future versions. check if it 
compiles,
+if not it is not supported.
+"""
+with tempfile.TemporaryDirectory() as tmpdir:
+output_path = os.path.join(tmpdir, "linker_support.out")
+linker_script_path = os.path.join(tmpdir, "test.ld")
+
+with open(linker_script_path, "w") as linker_script:
+linker_script.write(
+"SECTIONS {.text.ordered : { *(.text.ordered) *(.text.foo) } } 
INSERT BEFORE .text;"
+)
+
+compiler_cmd = subprocess.Popen(
+[
+lldbplatformutil.getCompiler(),
+f"-o {output_path}",
+"-ffunction-sections",
+f"-Wl,--script={linker_script_path}",
+"-xc",
+"-",
+],
+shell=True,
+universal_newlines=True,
+stdin=subprocess.PIPE,
+stdout=subprocess.PIPE,
+stderr=subprocess.PIPE,
+)
+_, comp_err = compiler_cmd.communicate(
+"int foo() { return 1; } int main() { return 0; }"
+)
 
+if len(comp_err) != 0:
+return comp_

[Lldb-commits] [lldb] [lldb][test] Prevent TestqOffsets.py picking up host binaries (PR #157432)

2025-09-08 Thread David Spickett via lldb-commits

DavidSpickett wrote:

I'll try it but I have a suspicion we have code that says "anything on 
localhost must be the host machine".

https://github.com/llvm/llvm-project/pull/157432
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] b45f1fb - [lldb][test] Disable part of TestDAP_stepInTargets.py

2025-09-08 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2025-09-08T15:20:15Z
New Revision: b45f1fb377636a34c01e34b89341c97d19975554

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

LOG: [lldb][test] Disable part of TestDAP_stepInTargets.py

Flakey on our Windows on Arm bot:
https://lab.llvm.org/buildbot/#/builders/141/builds/11378

==

ERROR: test_supported_capability_other_archs 
(TestDAP_stepInTargets.TestDAP_stepInTargets.test_supported_capability_other_archs)

--

Traceback (most recent call last):

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py",
 line 2090, in tearDown

Base.tearDown(self)

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py",
 line 1105, in tearDown

hook()  # try the plain call and hope it works

^^

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\tools\lldb-dap\lldbdap_testcase.py",
 line 521, in cleanup

self.dap_server.terminate()

  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\tools\lldb-dap\dap_server.py",
 line 1602, in terminate

raise DebugAdapterProcessError(process.returncode)

dap_server.DebugAdapterProcessError: lldb-dap returned non-zero exit status 1.

Config=aarch64-C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe

--

See #137660

Added: 


Modified: 
lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py

Removed: 




diff  --git 
a/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py 
b/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py
index 03b79a805d341..a386afee21eb1 100644
--- a/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py
+++ b/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py
@@ -102,6 +102,7 @@ def test_supported_capability_x86_arch(self):
 self.continue_to_exit()
 
 @skipIf(archs=["x86", "x86_64"])
+@skipIfWindows
 def test_supported_capability_other_archs(self):
 program = self.getBuildArtifact("a.out")
 self.build_and_launch(program)



___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test] Prevent TestqOffsets.py picking up host binaries (PR #157432)

2025-09-08 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett edited 
https://github.com/llvm/llvm-project/pull/157432
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFC] Fix style issues with StackID.h (PR #157483)

2025-09-08 Thread Felipe de Azevedo Piovezan via lldb-commits

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

>From 668e90948beabe437ea283b84ae0ffc9ea7c4a78 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Mon, 8 Sep 2025 07:43:38 -0700
Subject: [PATCH 1/2] [lldb][NFC] Fix style issues with StackID.h

Some comments were "suffixed" to member variable declarations; these are
moved to before the variable.

Some constructors and operators were just defaulted and not necessary.

Some comments dividing the class into logical sections, like "//
constructors and destructors", were not applied everywhere. These were
removed. They are used in some parts of LLDB, but are the exception.

An include was not needed.

The operator != can be defined in terms of ==.
---
 lldb/include/lldb/Target/StackID.h | 50 ++
 lldb/source/Target/StackID.cpp | 11 +--
 2 files changed, 17 insertions(+), 44 deletions(-)

diff --git a/lldb/include/lldb/Target/StackID.h 
b/lldb/include/lldb/Target/StackID.h
index fddbc8e48dfdc..4b49964853f7b 100644
--- a/lldb/include/lldb/Target/StackID.h
+++ b/lldb/include/lldb/Target/StackID.h
@@ -10,7 +10,6 @@
 #define LLDB_TARGET_STACKID_H
 
 #include "lldb/Core/AddressRange.h"
-#include "lldb/lldb-private.h"
 
 namespace lldb_private {
 
@@ -18,15 +17,11 @@ class Process;
 
 class StackID {
 public:
-  // Constructors and Destructors
   StackID() = default;
 
   explicit StackID(lldb::addr_t pc, lldb::addr_t cfa,
SymbolContextScope *symbol_scope, Process *process);
 
-  StackID(const StackID &rhs)
-  : m_pc(rhs.m_pc), m_cfa(rhs.m_cfa), m_symbol_scope(rhs.m_symbol_scope) {}
-
   ~StackID() = default;
 
   lldb::addr_t GetPC() const { return m_pc; }
@@ -51,41 +46,28 @@ class StackID {
 
   void Dump(Stream *s);
 
-  // Operators
-  const StackID &operator=(const StackID &rhs) {
-if (this != &rhs) {
-  m_pc = rhs.m_pc;
-  m_cfa = rhs.m_cfa;
-  m_symbol_scope = rhs.m_symbol_scope;
-}
-return *this;
-  }
-
 protected:
   friend class StackFrame;
 
   void SetPC(lldb::addr_t pc, Process *process);
   void SetCFA(lldb::addr_t cfa, Process *process);
 
-  lldb::addr_t m_pc =
-  LLDB_INVALID_ADDRESS; // The pc value for the function/symbol for this
-// frame. This will
-  // only get used if the symbol scope is nullptr (the code where we are
-  // stopped is not represented by any function or symbol in any shared
-  // library).
-  lldb::addr_t m_cfa =
-  LLDB_INVALID_ADDRESS; // The call frame address (stack pointer) value
-// at the beginning of the function that uniquely
-// identifies this frame (along with m_symbol_scope
-// below)
-  SymbolContextScope *m_symbol_scope =
-  nullptr; // If nullptr, there is no block or symbol for this frame.
-   // If not nullptr, this will either be the scope for the
-   // lexical block for the frame, or the scope for the
-   // symbol. Symbol context scopes are always be unique
-   // pointers since the are part of the Block and Symbol
-   // objects and can easily be used to tell if a stack ID
-   // is the same as another.
+  // The pc value for the function/symbol for this frame. This will only get
+  // used if the symbol scope is nullptr (the code where we are stopped is not
+  // represented by any function or symbol in any shared library).
+  lldb::addr_t m_pc = LLDB_INVALID_ADDRESS;
+
+  // The call frame address (stack pointer) value at the beginning of the
+  // function that uniquely identifies this frame (along with m_symbol_scope
+  // below)
+  lldb::addr_t m_cfa = LLDB_INVALID_ADDRESS;
+
+  // If nullptr, there is no block or symbol for this frame. If not nullptr,
+  // this will either be the scope for the lexical block for the frame, or the
+  // scope for the symbol. Symbol context scopes are always be unique pointers
+  // since the are part of the Block and Symbol objects and can easily be used
+  // to tell if a stack ID is the same as another.
+  SymbolContextScope *m_symbol_scope = nullptr;
 };
 
 bool operator==(const StackID &lhs, const StackID &rhs);
diff --git a/lldb/source/Target/StackID.cpp b/lldb/source/Target/StackID.cpp
index b1795970802ae..f879276527dda 100644
--- a/lldb/source/Target/StackID.cpp
+++ b/lldb/source/Target/StackID.cpp
@@ -63,16 +63,7 @@ bool lldb_private::operator==(const StackID &lhs, const 
StackID &rhs) {
 }
 
 bool lldb_private::operator!=(const StackID &lhs, const StackID &rhs) {
-  if (lhs.GetCallFrameAddress() != rhs.GetCallFrameAddress())
-return true;
-
-  SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope();
-  SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope();
-
-  if (lhs_scope == nullptr && rhs_scope == nullptr)
-return lhs.GetPC() != rhs.GetPC();
-
-  return lhs_scope != rhs_scope;
+  return !(lhs == rhs);
 }
 

[Lldb-commits] [clang] [lldb] [clang][Mangle] Inject structor type into mangled name when mangling for LLDB JIT expressions (PR #155485)

2025-09-08 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.


https://github.com/llvm/llvm-project/pull/155485
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][NativePDB] Mark blocks as parsed after parsing (PR #157493)

2025-09-08 Thread via lldb-commits

https://github.com/Nerixyz created 
https://github.com/llvm/llvm-project/pull/157493

After parsing blocks in a function, the blocks should be marked as parsed for 
them to be dumped (see 
[Function::Dump](https://github.com/llvm/llvm-project/blob/e6aefbec782dbb57f72eb0ae399ed944fe49db2e/lldb/source/Symbol/Function.cpp#L446-L447)).
 As explained in 
https://github.com/llvm/llvm-project/issues/114906#issuecomment-3255016266, 
this happens (accidentally?) in the DIA plugin when parsing variables, because 
it calls `function.GetBlock(can_create=true)` which marks blocks as parsed. In 
the native plugin, this was never called, so blocks and variables were never 
included in the `lldb-test symbols` output.

The `variables.test` for the DIA plugin tests this. One difference between the 
plugins is how they specify the location of local variables. This causes the 
output of the native plugin to be two lines per variable, whereas the DIA 
plugin has one line:
```
(native):
02C4B7593020:   Variable{0x1c81}, name = "var_arg1", type = 
{0744} 0x02C4B6CA7900 (int), scope = parameter, location = 
0x:
[0x00014000102c, 0x00014000103e): DW_OP_breg7 RSP+8
```
```
(DIA):
02778C827EE0:   Variable{0x001b}, name = "var_arg1", type = 
{0005} 0x02778C1FBAB0 (int), scope = parameter, decl = 
VariablesTest.cpp:32, location = DW_OP_breg7 RSP+8
```
In the test, I filtered lines starting with spaces followed by `[0x`, so we can 
still use `CHECK-NEXT`.

---

Another difference between the plugins is that DIA marks the `this` pointer as 
artificial (equivalent to DWARF). This is done if a variable's object kind is 
`ObjectPtr` 
([source](https://github.com/llvm/llvm-project/blob/ab898f32c60689d1d47d0b6de66c30d3476994bb/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp#L1050)).
 As far as I know, there isn't anything in the debug info that says "this 
variable is the `this` pointer" other than the name/type of a variable and the 
type of the function.

>From 231f9228f9559ec0daff83745af0dc8aa7765ec8 Mon Sep 17 00:00:00 2001
From: Nerixyz 
Date: Mon, 8 Sep 2025 17:19:23 +0200
Subject: [PATCH] [LLDB][NativePDB] Mark blocks as parsed after parsing

---
 .../NativePDB/SymbolFileNativePDB.cpp |  2 ++
 lldb/test/Shell/SymbolFile/PDB/variables.test | 34 ---
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 112eb06e462fc..81b2818fa07bd 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -1624,6 +1624,8 @@ size_t SymbolFileNativePDB::ParseBlocksRecursive(Function 
&func) {
   for (uint64_t uid : remove_uids) {
 m_inline_sites.erase(uid);
   }
+
+  func.GetBlock(false).SetBlockInfoHasBeenParsed(true, true);
   return count;
 }
 
diff --git a/lldb/test/Shell/SymbolFile/PDB/variables.test 
b/lldb/test/Shell/SymbolFile/PDB/variables.test
index 9ee10f75c7e38..970d714c29c3b 100644
--- a/lldb/test/Shell/SymbolFile/PDB/variables.test
+++ b/lldb/test/Shell/SymbolFile/PDB/variables.test
@@ -2,15 +2,27 @@ REQUIRES: system-windows, msvc
 RUN: mkdir -p %t.dir
 RUN: %build --compiler=clang-cl --mode=compile --arch=64 --nodefaultlib 
--output=%t.dir/VariablesTest.cpp.obj %S/Inputs/VariablesTest.cpp
 RUN: %build --compiler=msvc --mode=link --arch=64 --nodefaultlib 
--output=%t.dir/VariablesTest.cpp.exe %t.dir/VariablesTest.cpp.obj
-RUN: lldb-test symbols %t.dir/VariablesTest.cpp.exe > %t.dir/VariablesTest.out
-RUN: FileCheck --check-prefix=GLOBALS --input-file=%t.dir/VariablesTest.out %s
-RUN: FileCheck --check-prefix=FUNC-F --input-file=%t.dir/VariablesTest.out %s
-RUN: FileCheck --check-prefix=FUNC-MAIN --input-file=%t.dir/VariablesTest.out 
%s
-RUN: FileCheck --check-prefix=FUNC-CONSTRUCTOR 
--input-file=%t.dir/VariablesTest.out %s
-RUN: FileCheck --check-prefix=FUNC-MEMBER 
--input-file=%t.dir/VariablesTest.out %s
+# Note: The native plugin creates a location list for variables that's only 
valid for the function.
+#   The DIA plugin creates a location expression that's always valid. This 
causes DIA to output
+#   one line per variable where the native plugin would output two (the 
second would contain the
+#   location information). This removes the second line from the output of 
the native plugin.
+#   It's done in both cases, because LLDB might not be compiled with the 
DIA SDK in which case
+#   the native plugin is always used.
+RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols 
%t.dir/VariablesTest.cpp.exe | sed '/^ \+\[0x/d' > %t.dir/VariablesTest.DIA.out
+RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols 
%t.dir/VariablesTest.cpp.exe | sed '/^ \+\[0x/d' > 
%t.dir/VariablesTest.Native.out
+RUN: FileCheck --check-prefix=GLOBALS 
--input-file=%t.dir/Variables

[Lldb-commits] [lldb] [lldb][NFC] Fix style issues with StackID.h (PR #157483)

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


@@ -51,41 +46,28 @@ class StackID {
 
   void Dump(Stream *s);
 
-  // Operators
-  const StackID &operator=(const StackID &rhs) {
-if (this != &rhs) {
-  m_pc = rhs.m_pc;
-  m_cfa = rhs.m_cfa;
-  m_symbol_scope = rhs.m_symbol_scope;
-}
-return *this;
-  }
-
 protected:
   friend class StackFrame;
 
   void SetPC(lldb::addr_t pc, Process *process);
   void SetCFA(lldb::addr_t cfa, Process *process);
 
-  lldb::addr_t m_pc =
-  LLDB_INVALID_ADDRESS; // The pc value for the function/symbol for this
-// frame. This will
-  // only get used if the symbol scope is nullptr (the code where we are
-  // stopped is not represented by any function or symbol in any shared
-  // library).
-  lldb::addr_t m_cfa =
-  LLDB_INVALID_ADDRESS; // The call frame address (stack pointer) value
-// at the beginning of the function that uniquely
-// identifies this frame (along with m_symbol_scope
-// below)
-  SymbolContextScope *m_symbol_scope =
-  nullptr; // If nullptr, there is no block or symbol for this frame.
-   // If not nullptr, this will either be the scope for the
-   // lexical block for the frame, or the scope for the
-   // symbol. Symbol context scopes are always be unique
-   // pointers since the are part of the Block and Symbol
-   // objects and can easily be used to tell if a stack ID
-   // is the same as another.
+  // The pc value for the function/symbol for this frame. This will only get

Michael137 wrote:

We could turn these into doxygen comments by making them `///`

https://github.com/llvm/llvm-project/pull/157483
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits

https://github.com/tgs-sc updated 
https://github.com/llvm/llvm-project/pull/154123

>From 407331b05499cdc1f232cc9e7e3990b38a3923b5 Mon Sep 17 00:00:00 2001
From: Timur Golubovich 
Date: Mon, 8 Sep 2025 14:43:50 +0300
Subject: [PATCH] [lldb][DWARFASTParserClang] Added a check for the
 specialization existence

While debugging an application with incorrect dwarf information, where
DW_TAG_template_value_parameter was lost, I found that lldb does not
check that the corresponding specialization exists. As a result, at the
stage when ASTImporter works, the type is completed in such a way that
it inherits from itself. And during the calculation of layout, an
infinite recursion occurs. To catch this error, I added a corresponding check
at the stage of restoring the type from dwarf information.
---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  12 +
 .../TypeSystem/Clang/TypeSystemClang.cpp  |   8 +
 .../unittests/SymbolFile/DWARF/CMakeLists.txt |   3 +-
 .../DWARF/DWARFASTParserClangTests.cpp|  34 +
 .../Inputs/DW_AT_spec_decl_exists-test.yaml   | 677 ++
 5 files changed, 733 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_spec_decl_exists-test.yaml

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index c76d67b47b336..50c045ab40986 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1873,6 +1873,18 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
+if (!class_specialization_decl) {
+  if (log) {
+dwarf->GetObjectFile()->GetModule()->LogMessage(
+log,
+"SymbolFileDWARF({0:p}) - Specialization for "
+"clang::ClassTemplateDecl({1:p}) already exists.",
+static_cast(this),
+static_cast(class_template_decl));
+  }
+  return TypeSP();
+}
+
 m_ast.SetMetadata(class_template_decl, metadata);
 m_ast.SetMetadata(class_specialization_decl, metadata);
   }
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 82e07bb8e0ffb..cb3a1906e81e3 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1676,6 +1676,14 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl(
   class_template_specialization_decl->setInstantiationOf(class_template_decl);
   class_template_specialization_decl->setTemplateArgs(
   TemplateArgumentList::CreateCopy(ast, args));
+  void *InsertPos = nullptr;
+  if (!class_template_decl->findSpecialization(args, InsertPos)) {
+// Add this specialization to the class template.
+class_template_decl->AddSpecialization(class_template_specialization_decl,
+   InsertPos);
+  } else
+// Specialization exists, so return nullptr.
+return nullptr;
   ast.getTypeDeclType(class_template_specialization_decl, nullptr);
   class_template_specialization_decl->setDeclName(
   class_template_decl->getDeclName());
diff --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt 
b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index eb2e00adba64b..88492188e794b 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -27,6 +27,7 @@ add_lldb_unittest(SymbolFileDWARFTests
 
 set(test_inputs
test-dwarf.exe
-   DW_AT_default_value-test.yaml)
+   DW_AT_default_value-test.yaml
+   DW_AT_spec_decl_exists-test.yaml)
 
 add_unittest_inputs(SymbolFileDWARFTests "${test_inputs}")
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
index d608a57382096..3b9fbbe6f6254 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -599,6 +599,40 @@ TEST_F(DWARFASTParserClangTests, 
TestDefaultTemplateParamParsing) {
   }
 }
 
+TEST_F(DWARFASTParserClangTests, TestSpecDeclExistsError) {
+  // Tests that parsing a ClassTemplateSpecializationDecl that already exists
+  // is handled gracefully.
+  auto BufferOrError = llvm::MemoryBuffer::getFile(
+  GetInputFilePath("DW_AT_spec_decl_exists-test.yaml"), /*IsText=*/true);
+  ASSERT_TRUE(BufferOrError);
+  YAMLModuleTester t(BufferOrError.get()->getBuffer());
+
+  DWARFUnit *unit = t.GetDwarfUnit();
+  ASSERT_NE(unit, nullptr);
+  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();
+  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);
+  DWARFDIE cu_die(unit, cu_entry);
+
+  auto holder = std::make_unique("ast");
+  auto &ast_ctx = *holder->GetAST();
+  DWARFASTParserClang

[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits

https://github.com/tgs-sc updated 
https://github.com/llvm/llvm-project/pull/154123

>From f86f3acf76227f618c36147c260ae5fb72fc9e80 Mon Sep 17 00:00:00 2001
From: Timur Golubovich 
Date: Mon, 18 Aug 2025 17:29:01 +0300
Subject: [PATCH 1/2] [lldb][DWARFASTParserClang] Added a check for the
 specialization existence

While debugging an application with incorrect dwarf information, where
DW_TAG_template_value_parameter was lost, I found that lldb does not
check that the corresponding specialization exists. As a result, at the
stage when ASTImporter works, the type is completed in such a way that
it inherits from itself. And during the calculation of layout, an
infinite recursion occurs. To catch this error, I added a corresponding check
at the stage of restoring the type from dwarf information.
---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  25 +-
 .../unittests/SymbolFile/DWARF/CMakeLists.txt |   3 +-
 .../DWARF/DWARFASTParserClangTests.cpp|  33 +
 .../Inputs/DW_AT_spec_decl_exists-test.yaml   | 675 ++
 4 files changed, 732 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_spec_decl_exists-test.yaml

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index c76d67b47b336..c3937929ff1f0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1725,6 +1725,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
   const dw_tag_t tag = die.Tag();
   SymbolFileDWARF *dwarf = die.GetDWARF();
   LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU());
+  ModuleSP module_sp = dwarf->GetObjectFile()->GetModule();
   Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
 
   ConstString unique_typename(attrs.name);
@@ -1735,7 +1736,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 GetUniqueTypeNameAndDeclaration(die, cu_language, unique_typename,
 unique_decl);
 if (log) {
-  dwarf->GetObjectFile()->GetModule()->LogMessage(
+  module_sp->LogMessage(
   log, "SymbolFileDWARF({0:p}) - {1:x16}: {2} has unique name: {3} ",
   static_cast(this), die.GetID(), DW_TAG_value_to_name(tag),
   unique_typename.AsCString());
@@ -1806,7 +1807,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 
 if (type_sp) {
   if (log) {
-dwarf->GetObjectFile()->GetModule()->LogMessage(
+module_sp->LogMessage(
 log,
 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" is an "
 "incomplete objc type, complete type is {5:x8}",
@@ -1856,7 +1857,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 attrs.name.GetCString(), tag_decl_kind, template_param_infos);
 if (!class_template_decl) {
   if (log) {
-dwarf->GetObjectFile()->GetModule()->LogMessage(
+module_sp->LogMessage(
 log,
 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" "
 "clang::ClassTemplateDecl failed to return a decl.",
@@ -1873,6 +1874,24 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
+// Try to find an existing specialization with these template arguments and
+// template parameter list.
+void *InsertPos = nullptr;
+llvm::ArrayRef args =
+template_param_infos.GetArgs();
+if (!args.empty() &&
+!class_template_decl->findSpecialization(args, InsertPos))
+  // Add this specialization to the class template.
+  class_template_decl->AddSpecialization(class_specialization_decl,
+ InsertPos);
+else {
+  module_sp->ReportError("SymbolFileDWARF({0:p}) - Specialization for "
+ "clang::ClassTemplateDecl({1:p}) already exists.",
+ static_cast(this),
+ static_cast(class_template_decl));
+  return TypeSP();
+}
+
 m_ast.SetMetadata(class_template_decl, metadata);
 m_ast.SetMetadata(class_specialization_decl, metadata);
   }
diff --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt 
b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index eb2e00adba64b..88492188e794b 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -27,6 +27,7 @@ add_lldb_unittest(SymbolFileDWARFTests
 
 set(test_inputs
test-dwarf.exe
-   DW_AT_default_value-test.yaml)
+   DW_AT_default_value-test.yaml
+   DW_AT_spec_decl_exists-test.yaml)
 
 add_unittest_inputs(SymbolFileDWARFTests "${test_inputs}")
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp

[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)

2025-09-08 Thread David Spickett via lldb-commits


@@ -0,0 +1,10 @@
+# REQUIRES: target=riscv32-{{.*}}
+
+# RUN: %lldb -b -o "disassemble -b -n main" %p/Inputs/riscv_xqci.out | 
FileCheck %s
+
+# CHECK: 051f 0058   qc.e.li a0, 0x58
+# CHECK: 1516  qc.extu a0, a0, 0x6, 0x0

DavidSpickett wrote:

Maybe the alignment here is due to the way we print tabs and spaces but I think 
you can make the mnemonics line up and FileCheck will be fine with it.

If not, it's ok as is, it just looks weird to me.

https://github.com/llvm/llvm-project/pull/147990
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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


@@ -599,6 +599,39 @@ TEST_F(DWARFASTParserClangTests, 
TestDefaultTemplateParamParsing) {
   }
 }
 
+TEST_F(DWARFASTParserClangTests, TestSpecDeclExistsError) {
+  // Tests checking error if ClassTemplateSpecializationDecl already exists.
+  auto BufferOrError = llvm::MemoryBuffer::getFile(
+  GetInputFilePath("DW_AT_spec_decl_exists-test.yaml"), /*IsText=*/true);
+  ASSERT_TRUE(BufferOrError);
+  YAMLModuleTester t(BufferOrError.get()->getBuffer());
+
+  DWARFUnit *unit = t.GetDwarfUnit();
+  ASSERT_NE(unit, nullptr);
+  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();
+  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);
+  DWARFDIE cu_die(unit, cu_entry);
+
+  auto holder = std::make_unique("ast");
+  auto &ast_ctx = *holder->GetAST();
+  DWARFASTParserClangStub ast_parser(ast_ctx);
+
+  llvm::SmallVector types;
+  for (DWARFDIE die : cu_die.children()) {
+if (die.Tag() == DW_TAG_structure_type) {

Michael137 wrote:

How about also checking that:
```
llvm::StringRef(die.GetName()).starts_with("_Optional_payload")
```
So you don't parse the `struct Type`. Then you just assert that one of the 
types is `nullptr` and the other isn't. Makes the test a bit clearer

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Track CFA pointer metadata in StackID (PR #157498)

2025-09-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)


Changes

In this commit:

9c8e71644227 [lldb] Make StackID call Fix{Code,Data} pointers (#152796)

We made StackID keep track of the CFA without any pointer metadata in it. This 
is necessary when comparing two StackIDs to determine which one is "younger".

However, the CFA inside StackIDs is also used in other contexts through the 
method StackID::GetCallFrameAddress. One notable case is DWARFExpression: the 
computation of `DW_OP_call_frame_address` is done using StackID. This feeds 
into many other places, e.g. expression evaluation (which may require a signed 
pointer). As such, StackID must be able to provide both versions of the CFA.

In the spirit of allowing consumers of pointers to decide what to do with 
pointer metadata, this patch changes StackID to store both versions of the cfa 
pointer. Two getter methods are provided, and all call sites except 
DWARFExpression preserve their existing behavior (stripped pointer). Other 
alternatives were considered:

* Just store the raw pointer. This would require changing the comparisong 
operator `<` to also receive a Process, as the comparison requires stripped 
pointers. It wasn't clear if all call-sites had a non-null process, whereas we 
know we have a process when creating a StackID.

* Store a weak pointer to the process inside the class, and then strip metadata 
as needed. This would require a `weak_ptr::lock` in many operations of LLDB, 
and it felt wasteful. It also prevents stripping of the pointer if the process 
has gone away.

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


5 Files Affected:

- (modified) lldb/include/lldb/Target/StackID.h (+9-2) 
- (modified) lldb/source/API/SBFrame.cpp (+1-1) 
- (modified) lldb/source/Expression/DWARFExpression.cpp (+1-1) 
- (modified) lldb/source/Target/StackFrameList.cpp (+1-1) 
- (modified) lldb/source/Target/StackID.cpp (+7-4) 


``diff
diff --git a/lldb/include/lldb/Target/StackID.h 
b/lldb/include/lldb/Target/StackID.h
index c2a5d733dcd69..754f80d001647 100644
--- a/lldb/include/lldb/Target/StackID.h
+++ b/lldb/include/lldb/Target/StackID.h
@@ -26,7 +26,11 @@ class StackID {
 
   lldb::addr_t GetPC() const { return m_pc; }
 
-  lldb::addr_t GetCallFrameAddress() const { return m_cfa; }
+  lldb::addr_t GetCallFrameAddressWithMetadata() const {
+return m_cfa_with_metadata;
+  }
+
+  lldb::addr_t GetCallFrameAddressWithoutMetadata() const { return m_cfa; }
 
   SymbolContextScope *GetSymbolContextScope() const { return m_symbol_scope; }
 
@@ -59,9 +63,12 @@ class StackID {
 
   /// The call frame address (stack pointer) value at the beginning of the
   /// function that uniquely identifies this frame (along with m_symbol_scope
-  /// below)
+  /// below).
   lldb::addr_t m_cfa = LLDB_INVALID_ADDRESS;
 
+  /// The cfa with metadata (i.e. prior to Process::FixAddress).
+  lldb::addr_t m_cfa_with_metadata = LLDB_INVALID_ADDRESS;
+
   /// If nullptr, there is no block or symbol for this frame. If not nullptr,
   /// this will either be the scope for the lexical block for the frame, or the
   /// scope for the symbol. Symbol context scopes are always be unique pointers
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index b6724bb0c4119..42dbed490a33d 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/lldb/source/API/SBFrame.cpp
@@ -267,7 +267,7 @@ lldb::addr_t SBFrame::GetCFA() const {
   }
 
   if (StackFrame *frame = exe_ctx->GetFramePtr())
-return frame->GetStackID().GetCallFrameAddress();
+return frame->GetStackID().GetCallFrameAddressWithoutMetadata();
   return LLDB_INVALID_ADDRESS;
 }
 
diff --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 332cf2c86024a..5040351f4975b 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2195,7 +2195,7 @@ llvm::Expected DWARFExpression::Evaluate(
 // Note that we don't have to parse FDEs because this DWARF expression
 // is commonly evaluated with a valid stack frame.
 StackID id = frame->GetStackID();
-addr_t cfa = id.GetCallFrameAddress();
+addr_t cfa = id.GetCallFrameAddressWithMetadata();
 if (cfa != LLDB_INVALID_ADDRESS) {
   stack.push_back(Scalar(cfa));
   stack.back().SetValueType(Value::ValueType::LoadAddress);
diff --git a/lldb/source/Target/StackFrameList.cpp 
b/lldb/source/Target/StackFrameList.cpp
index d83c90582ba9c..3ed73a3b0afdb 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -449,7 +449,7 @@ bool StackFrameList::FetchFramesUpTo(uint32_t end_idx,
 }
   } else {
 unwind_frame_sp = m_frames.front();
-cfa = unwind_frame_sp->m_id.GetCallFrameAddress();
+cfa = unwind_frame_sp->m_id.GetCallFrameAddressWithoutMetadata();
   }
 } else {
  

[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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


@@ -1725,6 +1725,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
   const dw_tag_t tag = die.Tag();
   SymbolFileDWARF *dwarf = die.GetDWARF();
   LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU());
+  ModuleSP module_sp = dwarf->GetObjectFile()->GetModule();

Michael137 wrote:

Please revert these drive-by changes

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test] Enable non-address bit WritePointerToMemory test on Linux (PR #157435)

2025-09-08 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/157435

>From 528fbe2b518b586283ffa6ce93674dbf346687d7 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 8 Sep 2025 12:03:58 +
Subject: [PATCH 1/2] [lldb][test] Enable non-address bit WritePointerToMemory
 test on Linux

First added in #153585 for Darwin only. All Linux AArch64 systems also
have Top Byte Ignore enabled in userspace so the test "just works" there.

FreeBSD has very recently gained Top Byte Ignore support:
https://github.com/freebsd/freebsd-src/commit/4c6c27d3fb4ad15931aae2eaf8e624aed99a3fd9

However it's so recent, I don't want to assume it'll be available on
any random FreeBSD system out there.

There isn't really a good place to put this test, so I put it in the
top level of API, next to the other non-address bit test that didn't
have a good home either.
---
 .../Makefile  | 0
 .../TestArmPointerMetadataStripping.py| 8 +---
 .../extra_symbols.json| 0
 .../main.c| 0
 4 files changed, 5 insertions(+), 3 deletions(-)
 rename lldb/test/API/{macosx/arm-pointer-metadata-stripping => 
pointer-nonaddressable-bits}/Makefile (100%)
 rename lldb/test/API/{macosx/arm-pointer-metadata-stripping => 
pointer-nonaddressable-bits}/TestArmPointerMetadataStripping.py (82%)
 rename lldb/test/API/{macosx/arm-pointer-metadata-stripping => 
pointer-nonaddressable-bits}/extra_symbols.json (100%)
 rename lldb/test/API/{macosx/arm-pointer-metadata-stripping => 
pointer-nonaddressable-bits}/main.c (100%)

diff --git a/lldb/test/API/macosx/arm-pointer-metadata-stripping/Makefile 
b/lldb/test/API/pointer-nonaddressable-bits/Makefile
similarity index 100%
rename from lldb/test/API/macosx/arm-pointer-metadata-stripping/Makefile
rename to lldb/test/API/pointer-nonaddressable-bits/Makefile
diff --git 
a/lldb/test/API/macosx/arm-pointer-metadata-stripping/TestArmPointerMetadataStripping.py
 b/lldb/test/API/pointer-nonaddressable-bits/TestArmPointerMetadataStripping.py
similarity index 82%
rename from 
lldb/test/API/macosx/arm-pointer-metadata-stripping/TestArmPointerMetadataStripping.py
rename to 
lldb/test/API/pointer-nonaddressable-bits/TestArmPointerMetadataStripping.py
index f61945b3eb4c9..21caf7195412a 100644
--- 
a/lldb/test/API/macosx/arm-pointer-metadata-stripping/TestArmPointerMetadataStripping.py
+++ 
b/lldb/test/API/pointer-nonaddressable-bits/TestArmPointerMetadataStripping.py
@@ -5,9 +5,11 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-
-@skipUnlessDarwin
-@skipIf(archs=no_match(["arm64", "arm64e"]))
+# On AArch64 systems, unused top bits of pointers can be used for other things.
+@skipIf(archs=no_match(["aarch64", "arm64", "arm64e"]))
+# Only run this test on systems where Top Byte Ignore is known to be enabled
+# and widely available (FreeBSD has support but only since recently).
+@skipUnlessPlatform(["linux"] + lldbplatformutil.getDarwinOSTriples())
 class TestArmPointerMetadataStripping(TestBase):
 # Use extra_symbols.json as a template to add a new symbol whose address
 # contains non-zero high order bits set.
diff --git 
a/lldb/test/API/macosx/arm-pointer-metadata-stripping/extra_symbols.json 
b/lldb/test/API/pointer-nonaddressable-bits/extra_symbols.json
similarity index 100%
rename from 
lldb/test/API/macosx/arm-pointer-metadata-stripping/extra_symbols.json
rename to lldb/test/API/pointer-nonaddressable-bits/extra_symbols.json
diff --git a/lldb/test/API/macosx/arm-pointer-metadata-stripping/main.c 
b/lldb/test/API/pointer-nonaddressable-bits/main.c
similarity index 100%
rename from lldb/test/API/macosx/arm-pointer-metadata-stripping/main.c
rename to lldb/test/API/pointer-nonaddressable-bits/main.c

>From 4222f074681b9590732cc3972cebb55396b4efed Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 8 Sep 2025 13:23:54 +
Subject: [PATCH 2/2] format

---
 .../TestArmPointerMetadataStripping.py   | 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/lldb/test/API/pointer-nonaddressable-bits/TestArmPointerMetadataStripping.py 
b/lldb/test/API/pointer-nonaddressable-bits/TestArmPointerMetadataStripping.py
index 21caf7195412a..059fd9cf4ba7f 100644
--- 
a/lldb/test/API/pointer-nonaddressable-bits/TestArmPointerMetadataStripping.py
+++ 
b/lldb/test/API/pointer-nonaddressable-bits/TestArmPointerMetadataStripping.py
@@ -5,6 +5,7 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
+
 # On AArch64 systems, unused top bits of pointers can be used for other things.
 @skipIf(archs=no_match(["aarch64", "arm64", "arm64e"]))
 # Only run this test on systems where Top Byte Ignore is known to be enabled

___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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

Michael137 wrote:

> @Michael137, probably we should return finding and adding specialization in 
> DWARFASTParserClang.cpp?

That would be equivalent to the way your current version handles this right? I 
don't see how that would change anything.

I now realize this is trickier than expected. E.g., the infinite recursion 
actually reproduces with valid DWARF. Consider:
```
template  struct Foo;

template <> struct Foo<__bf16> {};

template <> struct Foo<_Float16> : Foo<__bf16> {};

int main() {
  Foo<_Float16> f1;
  return 0;
}
```

This will crash:
```
clang++ main.cpp -g
lldb a.out -o "br se -p return -X main" -o run -o "expr f1"
```

I haven't stepped through LLDB in this case but what I suspect is happening is 
that `__bf16` and `_Float16` both are floating point types with the same 
bit-size we just pretend they both are `__fp16` (via 
`GetBuiltinTypeForEncodingAndBitSize` most likely). So we have the same issue 
as your malformed DWARF case where a template specialization derives from 
another specialization but in the AST that LLDB creates the base specialization 
has the same template parameter types as the derived class.

There are some defensive checks against creating duplicate decls which relies 
on typenames: 
https://github.com/llvm/llvm-project/blob/39572f5e9168b1b44c2f9078494616fed8752086/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp#L1934-L1944

However, in my reproducer it doesn't work because in DWARF the typenames differ:
```
DW_AT_name  ("Foo<_Float16>")
...
DW_AT_name  ("Foo<__bf16>")
```
It's just that in the LLDB AST, the template parameter types don't match what 
we encoded in the structure's name in DWARF.

My first instinct is that we might need to adjust the heuristics of the 
`GetUniqueDWARFASTTypeMap` to account for this. But I haven't thought this 
through enough to know whether this is possible/desirable.

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Track CFA pointer metadata in StackID (PR #157498)

2025-09-08 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan converted_to_draft 
https://github.com/llvm/llvm-project/pull/157498
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFC] Fix style issues with StackID.h (PR #157483)

2025-09-08 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan closed 
https://github.com/llvm/llvm-project/pull/157483
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][test] StepUntil disable test for unsupported linkers. (PR #157474)

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

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

`INSERT BEFORE` keyword is not supported in current versions gold and mold 
linkers. Since we cannot confirm accurately what linker and version is 
available on the system and when it will be supported. We test it with a sample 
program using the script keywords.

>From bfd997d47c554c3b33d1d7de184e202571d388a6 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Mon, 8 Sep 2025 15:23:25 +0100
Subject: [PATCH] [lldb][test] StepUntil disable test for unsupported linkers.

`INSERT BEFORE` keyword is not supported in current versions gold and mold 
linkers. Since we cannot confirm accurately what linker and version is 
available on the system and when it will be supported. We test it with a sample 
program using the script keywords.
---
 .../thread/step_until/TestStepUntil.py| 40 +
 .../thread/step_until/TestStepUntilAPI.py | 43 +++
 2 files changed, 83 insertions(+)

diff --git a/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py 
b/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py
index 965da02ed0f98..90f207b5d4660 100644
--- a/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py
+++ b/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py
@@ -1,11 +1,50 @@
 """Test stepping over vrs. hitting breakpoints & subsequent stepping in 
various forms."""
 
+from typing import Optional
 
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
+import tempfile
+
+
+def linker_script_syntax_unsupported() -> Optional[str]:
+"""Current versions of mold and gold linker does not support some syntax of
+linker scripts, this maybe supported in future versions. check if it 
compiles,
+if not it is not supported.
+"""
+with tempfile.TemporaryDirectory() as tmpdir:
+output_path = os.path.join(tmpdir, "linker_support.out")
+linker_script_path = os.path.join(tmpdir, "test.ld")
+
+with open(linker_script_path, "w") as linker_script:
+linker_script.write(
+"SECTIONS {.text.ordered : { *(.text.ordered) *(.text.foo) } } 
INSERT BEFORE .text;"
+)
+
+compiler_cmd = subprocess.Popen(
+[
+lldbplatformutil.getCompiler(),
+f"-o {output_path}",
+"-ffunction-sections",
+f"-Wl,--script={linker_script_path}",
+"-xc",
+"-",
+],
+shell=True,
+universal_newlines=True,
+stdin=subprocess.PIPE,
+stdout=subprocess.PIPE,
+stderr=subprocess.PIPE,
+)
+_, comp_err = compiler_cmd.communicate(
+"int foo() { return 1; } int main() { return 0; }"
+)
 
+if len(comp_err) != 0:
+return str(tmpdir) + " " + comp_err
+return None
 
 class StepUntilTestCase(TestBase):
 def setUp(self):
@@ -112,6 +151,7 @@ def test_bad_line(self):
 @no_debug_info_test
 @skipIf(oslist=lldbplatformutil.getDarwinOSTriples() + ["windows"])
 @skipIf(archs=no_match(["x86_64", "aarch64"]))
+@skipTestIfFn(linker_script_syntax_unsupported)
 def test_bad_line_discontinuous(self):
 """Test that we get an error if attempting to step outside the current
 function -- and the function is discontinuous"""
diff --git 
a/lldb/test/API/functionalities/thread/step_until/TestStepUntilAPI.py 
b/lldb/test/API/functionalities/thread/step_until/TestStepUntilAPI.py
index 59e028acf014c..44e764c43cd20 100644
--- a/lldb/test/API/functionalities/thread/step_until/TestStepUntilAPI.py
+++ b/lldb/test/API/functionalities/thread/step_until/TestStepUntilAPI.py
@@ -1,8 +1,48 @@
+from typing import Optional
+
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
+import tempfile
+
+
+def linker_script_syntax_unsupported() -> Optional[str]:
+"""Current versions of mold and gold linker does not support some syntax of
+linker scripts, this maybe supported in future versions. check if it 
compiles,
+if not it is not supported.
+"""
+with tempfile.TemporaryDirectory() as tmpdir:
+output_path = os.path.join(tmpdir, "linker_support.out")
+linker_script_path = os.path.join(tmpdir, "test.ld")
+
+with open(linker_script_path, "w") as linker_script:
+linker_script.write(
+"SECTIONS {.text.ordered : { *(.text.ordered) *(.text.foo) } } 
INSERT BEFORE .text;"
+)
+
+compiler_cmd = subprocess.Popen(
+[
+lldbplatformutil.getCompiler(),
+f"-o {output_path}",
+"-ffunction-sections",
+f"-Wl,--script={linker_script_path}",
+"-xc",
+"-",
+

[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits

tgs-sc wrote:

Seems like problem is in `GetBuiltinTypeForDWARFEncodingAndBitSize` where we 
ignore type_name for DW_ATE_float. I think that we should take into account 
type_name there.

https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

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

https://github.com/Michael137 auto_merge_disabled 
https://github.com/llvm/llvm-project/pull/154123
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Added a check for the specialization existence (PR #154123)

2025-09-08 Thread via lldb-commits

https://github.com/tgs-sc updated 
https://github.com/llvm/llvm-project/pull/154123

>From cc0df387c22a7be4539707ecf4e20713e65d4b06 Mon Sep 17 00:00:00 2001
From: Timur Golubovich 
Date: Mon, 8 Sep 2025 14:43:50 +0300
Subject: [PATCH] [lldb][DWARFASTParserClang] Added a check for the
 specialization existence

While debugging an application with incorrect dwarf information, where
DW_TAG_template_value_parameter was lost, I found that lldb does not
check that the corresponding specialization exists. As a result, at the
stage when ASTImporter works, the type is completed in such a way that
it inherits from itself. And during the calculation of layout, an
infinite recursion occurs. To catch this error, I added a corresponding check
at the stage of restoring the type from dwarf information.
---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  11 +
 .../TypeSystem/Clang/TypeSystemClang.cpp  |   5 +
 .../unittests/SymbolFile/DWARF/CMakeLists.txt |   3 +-
 .../DWARF/DWARFASTParserClangTests.cpp|  34 +
 .../Inputs/DW_AT_spec_decl_exists-test.yaml   | 677 ++
 5 files changed, 729 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_spec_decl_exists-test.yaml

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index a429ea848b7f7..88440dc2a3198 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1899,6 +1899,17 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
 m_ast.CreateClassTemplateSpecializationDecl(
 containing_decl_ctx, GetOwningClangModule(die), 
class_template_decl,
 tag_decl_kind, template_param_infos);
+if (!class_specialization_decl) {
+  if (log) {
+dwarf->GetObjectFile()->GetModule()->LogMessage(
+log,
+"SymbolFileDWARF({0:p}) - Failed to create specialization for "
+"clang::ClassTemplateDecl({1}, {2:p}).",
+this, llvm::StringRef(attrs.name), class_template_decl);
+  }
+  return TypeSP();
+}
+
 clang_type =
 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
 
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index c4a917f59fb88..3a284747ea901 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1674,6 +1674,11 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl(
   class_template_specialization_decl->setInstantiationOf(class_template_decl);
   class_template_specialization_decl->setTemplateArgs(
   TemplateArgumentList::CreateCopy(ast, args));
+  void *insert_pos = nullptr;
+  if (auto* found = class_template_decl->findSpecialization(args, insert_pos))
+return found;
+  class_template_decl->AddSpecialization(class_template_specialization_decl,
+ insert_pos);
   class_template_specialization_decl->setDeclName(
   class_template_decl->getDeclName());
 
diff --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt 
b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index eb2e00adba64b..88492188e794b 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -27,6 +27,7 @@ add_lldb_unittest(SymbolFileDWARFTests
 
 set(test_inputs
test-dwarf.exe
-   DW_AT_default_value-test.yaml)
+   DW_AT_default_value-test.yaml
+   DW_AT_spec_decl_exists-test.yaml)
 
 add_unittest_inputs(SymbolFileDWARFTests "${test_inputs}")
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
index 0cae01de2902a..1abce6999874e 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -599,6 +599,40 @@ TEST_F(DWARFASTParserClangTests, 
TestDefaultTemplateParamParsing) {
   }
 }
 
+TEST_F(DWARFASTParserClangTests, TestSpecDeclExistsError) {
+  // Tests that parsing a ClassTemplateSpecializationDecl that already exists
+  // is handled gracefully.
+  auto BufferOrError = llvm::MemoryBuffer::getFile(
+  GetInputFilePath("DW_AT_spec_decl_exists-test.yaml"), /*IsText=*/true);
+  ASSERT_TRUE(BufferOrError);
+  YAMLModuleTester t(BufferOrError.get()->getBuffer());
+
+  DWARFUnit *unit = t.GetDwarfUnit();
+  ASSERT_NE(unit, nullptr);
+  const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE();
+  ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit);
+  DWARFDIE cu_die(unit, cu_entry);
+
+  auto holder = std::make_unique("ast");
+  auto &ast_ctx = *holder->GetAST();
+  DWARFASTParserClangStub ast_parser(ast_ctx);
+
+  llvm::SmallVector specializations;
+  for (DWARFDIE die : cu_die.children()) {

[Lldb-commits] [lldb] [lldb-dap] Add new optional argument `time-to-live` when using `--connection` (PR #156803)

2025-09-08 Thread via lldb-commits


@@ -327,6 +366,11 @@ serveConnection(const Socket::SocketProtocol &protocol, 
const std::string &name,
   std::unique_lock lock(dap_sessions_mutex);
   dap_sessions.erase(&loop);
   std::notify_all_at_thread_exit(dap_sessions_condition, std::move(lock));
+
+  // Start the countdown to kill the server at the end of each connection.

jeffreytan81 wrote:

Just realize that we used `loop.AddCallback` to run the callback at the main 
loop thread not each DAP's worker thread. Then the race condition mentioned 
above won't happen and no synchronization is required. 

https://github.com/llvm/llvm-project/pull/156803
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][NativePDB] Mark blocks as parsed after parsing (PR #157493)

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

Michael137 wrote:

> As far as I know, there isn't anything in the debug info that says "this 
> variable is the this pointer" other than the name/type of a variable and the 
> type of the function.

How does the DIA PDB plugin do it then? Why can't the native plugin use 
`PDB_DataKind::ObjectPtr`?

https://github.com/llvm/llvm-project/pull/157493
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


  1   2   >