[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread Michael Buch via lldb-commits


@@ -1036,12 +1036,18 @@ void ObjectFilePECOFF::CreateSections(SectionList 
&unified_section_list) {
 m_sections_up->AddSection(header_sp);
 unified_section_list.AddSection(header_sp);
 
+std::vector truncated_dwarf_sections;
 const uint32_t nsects = m_sect_headers.size();
 for (uint32_t idx = 0; idx < nsects; ++idx) {
   llvm::StringRef sect_name = GetSectionName(m_sect_headers[idx]);
   ConstString const_sect_name(sect_name);
   SectionType section_type = GetSectionType(sect_name, 
m_sect_headers[idx]);
 
+  // Detect unknown sections matching ^\.debug_[a-z]$
+  if (section_type == eSectionTypeOther && sect_name.size() == 8 &&

Michael137 wrote:

Do we need the `size == 8` and `isLower` checks here? Probably unlikely, but 
could the truncation change in the future to a different size?

Could we just check the section_type and prefix and issue a warning saying 
"unrecognized section, possibly got truncated"?

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


[Lldb-commits] [lldb] 18f667d - Revert "[lldb/cmake] Plugin layering enforcement mechanism (#144543)"

2025-06-23 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2025-06-23T12:07:10+02:00
New Revision: 18f667d804144e74d3ba2c67ee6f3610916002a8

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

LOG: Revert "[lldb/cmake] Plugin layering enforcement mechanism (#144543)"

Causes failures on several bots.

This reverts commits 714b2fdf3a385e5b9a95c435f56b1696ec3ec9e8 and
e7c1da7c8ef31c258619c1668062985e7ae83b70.

Added: 


Modified: 
lldb/CMakeLists.txt
lldb/docs/resources/contributing.rst
lldb/source/Plugins/ABI/CMakeLists.txt
lldb/source/Plugins/Architecture/CMakeLists.txt
lldb/source/Plugins/Disassembler/CMakeLists.txt
lldb/source/Plugins/DynamicLoader/CMakeLists.txt
lldb/source/Plugins/ExpressionParser/CMakeLists.txt
lldb/source/Plugins/Instruction/CMakeLists.txt
lldb/source/Plugins/InstrumentationRuntime/CMakeLists.txt
lldb/source/Plugins/JITLoader/CMakeLists.txt
lldb/source/Plugins/Language/CMakeLists.txt
lldb/source/Plugins/LanguageRuntime/CMakeLists.txt
lldb/source/Plugins/MemoryHistory/CMakeLists.txt
lldb/source/Plugins/ObjectContainer/CMakeLists.txt
lldb/source/Plugins/ObjectFile/CMakeLists.txt
lldb/source/Plugins/OperatingSystem/CMakeLists.txt
lldb/source/Plugins/Platform/CMakeLists.txt
lldb/source/Plugins/Process/CMakeLists.txt
lldb/source/Plugins/Process/Utility/CMakeLists.txt
lldb/source/Plugins/REPL/CMakeLists.txt
lldb/source/Plugins/RegisterTypeBuilder/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/CMakeLists.txt
lldb/source/Plugins/StructuredData/CMakeLists.txt
lldb/source/Plugins/SymbolFile/CMakeLists.txt
lldb/source/Plugins/SymbolLocator/CMakeLists.txt
lldb/source/Plugins/SymbolVendor/CMakeLists.txt
lldb/source/Plugins/SystemRuntime/CMakeLists.txt
lldb/source/Plugins/Trace/CMakeLists.txt
lldb/source/Plugins/TraceExporter/CMakeLists.txt
lldb/source/Plugins/TypeSystem/CMakeLists.txt
lldb/source/Plugins/UnwindAssembly/CMakeLists.txt

Removed: 
lldb/cmake/modules/LLDBLayeringCheck.cmake



diff  --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index e3b72e94d4beb..2aaf75dd87bc3 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -37,7 +37,6 @@ endif()
 
 include(LLDBConfig)
 include(AddLLDB)
-include(LLDBLayeringCheck)
 
 set(LLDB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
 
@@ -128,8 +127,6 @@ add_subdirectory(source)
 add_subdirectory(tools)
 add_subdirectory(docs)
 
-check_lldb_plugin_layering()
-
 if (LLDB_ENABLE_PYTHON)
   if(LLDB_BUILD_FRAMEWORK)
 set(lldb_python_target_dir 
"${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")

diff  --git a/lldb/cmake/modules/LLDBLayeringCheck.cmake 
b/lldb/cmake/modules/LLDBLayeringCheck.cmake
deleted file mode 100644
index 1669f6150cca9..0
--- a/lldb/cmake/modules/LLDBLayeringCheck.cmake
+++ /dev/null
@@ -1,74 +0,0 @@
-define_property(DIRECTORY PROPERTY LLDB_PLUGIN_KIND
-  BRIEF_DOCS "LLDB plugin kind (Process, SymbolFile, etc.")
-define_property(TARGET PROPERTY LLDB_PLUGIN_KIND INHERITED
-  BRIEF_DOCS "LLDB plugin kind (Process, SymbolFile, etc.")
-
-define_property(DIRECTORY PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES
-  BRIEF_DOCS "LLDB plugin kinds which the plugin can depend on")
-define_property(TARGET PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES INHERITED
-  BRIEF_DOCS "LLDB plugin kinds which the plugin can depend on")
-
-define_property(DIRECTORY PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES
-  BRIEF_DOCS "LLDB plugin kinds which are depended on for historic reasons.")
-define_property(TARGET PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES INHERITED
-  BRIEF_DOCS "LLDB plugin kinds which are depended on for historic reasons.")
-
-option(LLDB_GENERATE_PLUGIN_DEP_GRAPH OFF)
-
-function(check_lldb_plugin_layering)
-  get_property(plugins GLOBAL PROPERTY LLDB_PLUGINS)
-  foreach(plugin ${plugins})
-get_property(plugin_kind TARGET ${plugin} PROPERTY LLDB_PLUGIN_KIND)
-get_property(acceptable_deps TARGET ${plugin}
-  PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES)
-get_property(tolerated_deps TARGET ${plugin}
-  PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES)
-
-# A plugin is always permitted to depend on its own kind for the purposes
-# subclassing. Ideally the intra-kind dependencies should not form a loop,
-# but we're not checking that here.
-list(APPEND acceptable_deps ${plugin_kind})
-
-list(APPEND all_plugin_kinds ${plugin_kind})
-
-get_property(link_libs TARGET ${plugin} PROPERTY LINK_LIBRARIES)
-foreach(link_lib ${link_libs})
-  if(link_lib IN_LIST plugins)
-get_property(lib_kind TARGET ${link_lib} PROPERTY LLDB_PLUGIN_KIND)
-if (lib_kind)
-  if (lib_kind IN_LIST acceptable_deps)
-set(dep_kin

[Lldb-commits] [lldb] [LLDB] Update DIL to pass current 'frame var' tests. (PR #145055)

2025-06-23 Thread Pavel Labath via lldb-commits


@@ -178,11 +178,40 @@ ASTNodeUP DILParser::ParsePrimaryExpression() {
   }
 
   if (CurToken().Is(Token::l_paren)) {
-m_dil_lexer.Advance();
-auto expr = ParseExpression();
-Expect(Token::r_paren);
-m_dil_lexer.Advance();
-return expr;
+// Check in case this is an anonynmous namespace
+if (m_dil_lexer.LookAhead(1).Is(Token::identifier) &&
+(m_dil_lexer.LookAhead(1).GetSpelling() == "anonymous") &&
+m_dil_lexer.LookAhead(2).Is(Token::identifier) &&
+(m_dil_lexer.LookAhead(2).GetSpelling() == "namespace") &&
+m_dil_lexer.LookAhead(3).Is(Token::r_paren) &&
+m_dil_lexer.LookAhead(4).Is(Token::coloncolon)) {
+  m_dil_lexer.Advance(4);
+
+  std::string identifier = "(anonymous namespace)";
+  Expect(Token::coloncolon);
+  // Save the source location for the diagnostics message.
+  uint32_t loc = CurToken().GetLocation();
+  m_dil_lexer.Advance();
+  assert(
+  (CurToken().Is(Token::identifier) || CurToken().Is(Token::l_paren)) 
&&
+  "Expected an identifier or anonymous namespeace, but not found.");

labath wrote:

No -- I don't think I am -- I just made lldb crash with this assertion.

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


[Lldb-commits] [lldb] [LLDB] Update DIL to pass current 'frame var' tests. (PR #145055)

2025-06-23 Thread Pavel Labath via lldb-commits


@@ -178,11 +178,40 @@ ASTNodeUP DILParser::ParsePrimaryExpression() {
   }
 
   if (CurToken().Is(Token::l_paren)) {
-m_dil_lexer.Advance();
-auto expr = ParseExpression();
-Expect(Token::r_paren);
-m_dil_lexer.Advance();
-return expr;
+// Check in case this is an anonynmous namespace
+if (m_dil_lexer.LookAhead(1).Is(Token::identifier) &&
+(m_dil_lexer.LookAhead(1).GetSpelling() == "anonymous") &&
+m_dil_lexer.LookAhead(2).Is(Token::identifier) &&
+(m_dil_lexer.LookAhead(2).GetSpelling() == "namespace") &&
+m_dil_lexer.LookAhead(3).Is(Token::r_paren) &&
+m_dil_lexer.LookAhead(4).Is(Token::coloncolon)) {
+  m_dil_lexer.Advance(4);
+
+  std::string identifier = "(anonymous namespace)";

labath wrote:

Instead of basically inlining a part of ParseIdExpression, could we find a way 
to delegate to it? What would happen if we changed the check on line 172 to say 
"if next token is :: or identifier *OR* next 4 tokens are '(anonymous 
namespace)'" ?

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


[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread David Spickett via lldb-commits


@@ -173,6 +173,22 @@
 help="Specify the C/C++ standard.",
 )
 
+parser.add_argument(

DavidSpickett wrote:

Do these need to be build script arguments or is there a catch all 
`--extra-args ...` that we could use instead?

Given that only this test requires these options at this time.

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


[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread David Spickett via lldb-commits


@@ -173,6 +173,22 @@
 help="Specify the C/C++ standard.",
 )
 
+parser.add_argument(

DavidSpickett wrote:

That said, there's some pros to having all the compile flags in this file but I 
have to assume there are tests passing arbitrary flags anyway.

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


[Lldb-commits] [lldb] [LLDB] Update DIL to pass current 'frame var' tests. (PR #145055)

2025-06-23 Thread Pavel Labath via lldb-commits


@@ -178,11 +178,40 @@ ASTNodeUP DILParser::ParsePrimaryExpression() {
   }
 
   if (CurToken().Is(Token::l_paren)) {
-m_dil_lexer.Advance();
-auto expr = ParseExpression();
-Expect(Token::r_paren);
-m_dil_lexer.Advance();
-return expr;
+// Check in case this is an anonynmous namespace
+if (m_dil_lexer.LookAhead(1).Is(Token::identifier) &&
+(m_dil_lexer.LookAhead(1).GetSpelling() == "anonymous") &&
+m_dil_lexer.LookAhead(2).Is(Token::identifier) &&
+(m_dil_lexer.LookAhead(2).GetSpelling() == "namespace") &&
+m_dil_lexer.LookAhead(3).Is(Token::r_paren) &&
+m_dil_lexer.LookAhead(4).Is(Token::coloncolon)) {
+  m_dil_lexer.Advance(4);
+
+  std::string identifier = "(anonymous namespace)";
+  Expect(Token::coloncolon);
+  // Save the source location for the diagnostics message.
+  uint32_t loc = CurToken().GetLocation();
+  m_dil_lexer.Advance();
+  assert(
+  (CurToken().Is(Token::identifier) || CurToken().Is(Token::l_paren)) 
&&
+  "Expected an identifier or anonymous namespeace, but not found.");

labath wrote:

An assert is fine for an internal invariant, but this looks like its checking 
the next token in the stream. That's can't be right. Or am I misunderstanding 
something?

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


[Lldb-commits] [lldb] e7c1da7 - [lldb/cmake] Plugin layering enforcement mechanism (#144543)

2025-06-23 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-06-23T11:31:26+02:00
New Revision: e7c1da7c8ef31c258619c1668062985e7ae83b70

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

LOG: [lldb/cmake] Plugin layering enforcement mechanism (#144543)

Some inter-plugin dependencies are okay, others are not. Yet others not,
but we're sort of stuck with them. The idea is to be able to prevent
backsliding while making sure that acceptable dependencies are..
accepted. For context, see
https://github.com/llvm/llvm-project/pull/139170 and the attached
changes to the documentation.

Added: 
lldb/cmake/modules/LLDBLayeringCheck.cmake

Modified: 
lldb/CMakeLists.txt
lldb/docs/resources/contributing.rst
lldb/source/Plugins/ABI/CMakeLists.txt
lldb/source/Plugins/Architecture/CMakeLists.txt
lldb/source/Plugins/Disassembler/CMakeLists.txt
lldb/source/Plugins/DynamicLoader/CMakeLists.txt
lldb/source/Plugins/ExpressionParser/CMakeLists.txt
lldb/source/Plugins/Instruction/CMakeLists.txt
lldb/source/Plugins/InstrumentationRuntime/CMakeLists.txt
lldb/source/Plugins/JITLoader/CMakeLists.txt
lldb/source/Plugins/Language/CMakeLists.txt
lldb/source/Plugins/LanguageRuntime/CMakeLists.txt
lldb/source/Plugins/MemoryHistory/CMakeLists.txt
lldb/source/Plugins/ObjectContainer/CMakeLists.txt
lldb/source/Plugins/ObjectFile/CMakeLists.txt
lldb/source/Plugins/OperatingSystem/CMakeLists.txt
lldb/source/Plugins/Platform/CMakeLists.txt
lldb/source/Plugins/Process/CMakeLists.txt
lldb/source/Plugins/Process/Utility/CMakeLists.txt
lldb/source/Plugins/REPL/CMakeLists.txt
lldb/source/Plugins/RegisterTypeBuilder/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/CMakeLists.txt
lldb/source/Plugins/StructuredData/CMakeLists.txt
lldb/source/Plugins/SymbolFile/CMakeLists.txt
lldb/source/Plugins/SymbolLocator/CMakeLists.txt
lldb/source/Plugins/SymbolVendor/CMakeLists.txt
lldb/source/Plugins/SystemRuntime/CMakeLists.txt
lldb/source/Plugins/Trace/CMakeLists.txt
lldb/source/Plugins/TraceExporter/CMakeLists.txt
lldb/source/Plugins/TypeSystem/CMakeLists.txt
lldb/source/Plugins/UnwindAssembly/CMakeLists.txt

Removed: 




diff  --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 2aaf75dd87bc3..e3b72e94d4beb 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -37,6 +37,7 @@ endif()
 
 include(LLDBConfig)
 include(AddLLDB)
+include(LLDBLayeringCheck)
 
 set(LLDB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
 
@@ -127,6 +128,8 @@ add_subdirectory(source)
 add_subdirectory(tools)
 add_subdirectory(docs)
 
+check_lldb_plugin_layering()
+
 if (LLDB_ENABLE_PYTHON)
   if(LLDB_BUILD_FRAMEWORK)
 set(lldb_python_target_dir 
"${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")

diff  --git a/lldb/cmake/modules/LLDBLayeringCheck.cmake 
b/lldb/cmake/modules/LLDBLayeringCheck.cmake
new file mode 100644
index 0..082bbe37a980f
--- /dev/null
+++ b/lldb/cmake/modules/LLDBLayeringCheck.cmake
@@ -0,0 +1,68 @@
+define_property(DIRECTORY PROPERTY LLDB_PLUGIN_KIND)
+define_property(TARGET PROPERTY LLDB_PLUGIN_KIND INHERITED)
+
+define_property(DIRECTORY PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES)
+define_property(TARGET PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES INHERITED)
+
+define_property(DIRECTORY PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES)
+define_property(TARGET PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES INHERITED)
+
+option(LLDB_GENERATE_PLUGIN_DEP_GRAPH OFF)
+
+function(check_lldb_plugin_layering)
+  get_property(plugins GLOBAL PROPERTY LLDB_PLUGINS)
+  foreach(plugin ${plugins})
+get_property(plugin_kind TARGET ${plugin} PROPERTY LLDB_PLUGIN_KIND)
+get_property(acceptable_deps TARGET ${plugin}
+  PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES)
+get_property(tolerated_deps TARGET ${plugin}
+  PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES)
+
+# A plugin is always permitted to depend on its own kind for the purposes
+# subclassing. Ideally the intra-kind dependencies should not form a loop,
+# but we're not checking that here.
+list(APPEND acceptable_deps ${plugin_kind})
+
+list(APPEND all_plugin_kinds ${plugin_kind})
+
+get_property(link_libs TARGET ${plugin} PROPERTY LINK_LIBRARIES)
+foreach(link_lib ${link_libs})
+  if(link_lib IN_LIST plugins)
+get_property(lib_kind TARGET ${link_lib} PROPERTY LLDB_PLUGIN_KIND)
+if (lib_kind)
+  if (lib_kind IN_LIST acceptable_deps)
+set(dep_kind green)
+  elseif (lib_kind IN_LIST tolerated_deps)
+set(dep_kind yellow)
+  else()
+set(dep_kind red)
+message(SEND_ERROR "Plugin ${plugin} cannot depend on ${lib_kind} "
+ 

[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread Martin Storsjö via lldb-commits

mstorsjo wrote:

> truncate the section names, as [sections in PE/COFF executable images can't 
> be longer than 8 
> bytes](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#section-table-section-headers).

First off, this probably meant to say "section names can't be longer than 8 
bytes", not the sections themselves.

Then, this is on the level of nitpickery, but I think it's good to get the 
details right: If the names can't be longer than 8 bytes, then it would seem 
like it would be a hard limit that can't be overcome by using a different 
linker. As this is the PR description, which ends up as the commit message once 
this is merged, it's worth the effort to get the wording correct.

Not sure what the best wording would be here, though... "Section names in 
PE/COFF executable images can't be longer than 8 bytes officially, although 
other linkers do support creating that, and GDB/LLDB do support reading longer 
names." Or something along those lines?

And the same nuance for the warning message:

> ```
> warning: (x86_64) foo.exe contains 5 truncated DWARF sections (.debug_a, 
> .debug_i, .debug_r, .debug_s, .debug_l).
> Note: Executable images on Windows can't include the required names when 
> linking with the default link.exe. A third party linker like lld-link is 
> required (compile with -fuse-ld=lld-link on Clang).
> ```

Perhaps `s/can't/don't/` to fix the same detail here?

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


[Lldb-commits] [lldb] [lldb] add plugin names to process save-core error output. (PR #143126)

2025-06-23 Thread David Spickett via lldb-commits

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

LGTM

Fix the tab completion if you want to, and if you don't, raise an issue for it.

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


[Lldb-commits] [lldb] [lldb] Disable flaky TestDetachResumes.py on Windows x86_64 (PR #145301)

2025-06-23 Thread David Spickett via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] Reapply "[lldb/cmake] Plugin layering enforcement mechanism (#144543)" (PR #145305)

2025-06-23 Thread Pavel Labath via lldb-commits

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

The only difference from the original PR are the added BRIEF and FULL_DOCS 
arguments to define_property, which are required for cmake<3.23.

>From be3083de00796539976b1bbfe25f90693296bd89 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 23 Jun 2025 12:13:54 +0200
Subject: [PATCH] Reapply "[lldb/cmake] Plugin layering enforcement mechanism
 (#144543)"

The only difference from the original PR are the added BRIEF and
FULL_DOCS arguments to define_property, which are required for
cmake<3.23.
---
 lldb/CMakeLists.txt   |  3 +
 lldb/cmake/modules/LLDBLayeringCheck.cmake| 76 +++
 lldb/docs/resources/contributing.rst  | 50 
 lldb/source/Plugins/ABI/CMakeLists.txt|  6 ++
 .../Plugins/Architecture/CMakeLists.txt   |  2 +
 .../Plugins/Disassembler/CMakeLists.txt   |  2 +
 .../Plugins/DynamicLoader/CMakeLists.txt  |  7 ++
 .../Plugins/ExpressionParser/CMakeLists.txt   |  2 +
 .../source/Plugins/Instruction/CMakeLists.txt |  2 +
 .../InstrumentationRuntime/CMakeLists.txt |  2 +
 lldb/source/Plugins/JITLoader/CMakeLists.txt  |  3 +
 lldb/source/Plugins/Language/CMakeLists.txt   |  6 ++
 .../Plugins/LanguageRuntime/CMakeLists.txt|  3 +
 .../Plugins/MemoryHistory/CMakeLists.txt  |  2 +
 .../Plugins/ObjectContainer/CMakeLists.txt|  2 +
 lldb/source/Plugins/ObjectFile/CMakeLists.txt |  2 +
 .../Plugins/OperatingSystem/CMakeLists.txt|  2 +
 lldb/source/Plugins/Platform/CMakeLists.txt   |  7 ++
 lldb/source/Plugins/Process/CMakeLists.txt|  5 ++
 .../Plugins/Process/Utility/CMakeLists.txt|  3 +
 lldb/source/Plugins/REPL/CMakeLists.txt   |  3 +
 .../RegisterTypeBuilder/CMakeLists.txt|  2 +
 .../Plugins/ScriptInterpreter/CMakeLists.txt  |  2 +
 .../Plugins/StructuredData/CMakeLists.txt |  2 +
 lldb/source/Plugins/SymbolFile/CMakeLists.txt |  7 ++
 .../Plugins/SymbolLocator/CMakeLists.txt  |  2 +
 .../Plugins/SymbolVendor/CMakeLists.txt   |  3 +
 .../Plugins/SystemRuntime/CMakeLists.txt  |  3 +
 lldb/source/Plugins/Trace/CMakeLists.txt  |  2 +
 .../Plugins/TraceExporter/CMakeLists.txt  |  2 +
 lldb/source/Plugins/TypeSystem/CMakeLists.txt |  4 +
 .../Plugins/UnwindAssembly/CMakeLists.txt |  2 +
 32 files changed, 221 insertions(+)
 create mode 100644 lldb/cmake/modules/LLDBLayeringCheck.cmake

diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 2aaf75dd87bc3..e3b72e94d4beb 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -37,6 +37,7 @@ endif()
 
 include(LLDBConfig)
 include(AddLLDB)
+include(LLDBLayeringCheck)
 
 set(LLDB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
 
@@ -127,6 +128,8 @@ add_subdirectory(source)
 add_subdirectory(tools)
 add_subdirectory(docs)
 
+check_lldb_plugin_layering()
+
 if (LLDB_ENABLE_PYTHON)
   if(LLDB_BUILD_FRAMEWORK)
 set(lldb_python_target_dir 
"${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")
diff --git a/lldb/cmake/modules/LLDBLayeringCheck.cmake 
b/lldb/cmake/modules/LLDBLayeringCheck.cmake
new file mode 100644
index 0..c09b95d98b66f
--- /dev/null
+++ b/lldb/cmake/modules/LLDBLayeringCheck.cmake
@@ -0,0 +1,76 @@
+foreach (scope DIRECTORY TARGET)
+  define_property(${scope} PROPERTY LLDB_PLUGIN_KIND INHERITED
+BRIEF_DOCS "LLDB plugin kind (Process, SymbolFile, etc."
+FULL_DOCS  "see lldb/docs/resources/contributing.rst"
+  )
+
+  define_property(${scope} PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES 
INHERITED
+BRIEF_DOCS "LLDB plugin kinds which the plugin can depend on"
+FULL_DOCS  "see lldb/docs/resources/contributing.rst"
+  )
+
+  define_property(${scope} PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES 
INHERITED
+BRIEF_DOCS "LLDB plugin kinds which are depended on for historic reasons."
+FULL_DOCS  "see lldb/docs/resources/contributing.rst"
+  )
+endforeach()
+
+option(LLDB_GENERATE_PLUGIN_DEP_GRAPH OFF)
+
+function(check_lldb_plugin_layering)
+  get_property(plugins GLOBAL PROPERTY LLDB_PLUGINS)
+  foreach (plugin ${plugins})
+get_property(plugin_kind TARGET ${plugin} PROPERTY LLDB_PLUGIN_KIND)
+get_property(acceptable_deps TARGET ${plugin}
+  PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES)
+get_property(tolerated_deps TARGET ${plugin}
+  PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES)
+
+# A plugin is always permitted to depend on its own kind for the purposes
+# subclassing. Ideally the intra-kind dependencies should not form a loop,
+# but we're not checking that here.
+list(APPEND acceptable_deps ${plugin_kind})
+
+list(APPEND all_plugin_kinds ${plugin_kind})
+
+get_property(link_libs TARGET ${plugin} PROPERTY LINK_LIBRARIES)
+foreach (link_lib ${link_libs})
+  if(link_lib IN_LIST plugins)
+get_property(lib_kind TARGET ${link_lib} PROPERTY LLDB_PLUGIN_KIND)
+if (lib_kind)
+  if (lib_kind 

[Lldb-commits] [lldb] Reapply "[lldb/cmake] Plugin layering enforcement mechanism (#144543)" (PR #145305)

2025-06-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

The only difference from the original PR are the added BRIEF and FULL_DOCS 
arguments to define_property, which are required for cmake<3.23.

---

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


32 Files Affected:

- (modified) lldb/CMakeLists.txt (+3) 
- (added) lldb/cmake/modules/LLDBLayeringCheck.cmake (+76) 
- (modified) lldb/docs/resources/contributing.rst (+50) 
- (modified) lldb/source/Plugins/ABI/CMakeLists.txt (+6) 
- (modified) lldb/source/Plugins/Architecture/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/Disassembler/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/DynamicLoader/CMakeLists.txt (+7) 
- (modified) lldb/source/Plugins/ExpressionParser/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/Instruction/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/InstrumentationRuntime/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/JITLoader/CMakeLists.txt (+3) 
- (modified) lldb/source/Plugins/Language/CMakeLists.txt (+6) 
- (modified) lldb/source/Plugins/LanguageRuntime/CMakeLists.txt (+3) 
- (modified) lldb/source/Plugins/MemoryHistory/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/ObjectContainer/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/ObjectFile/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/OperatingSystem/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/Platform/CMakeLists.txt (+7) 
- (modified) lldb/source/Plugins/Process/CMakeLists.txt (+5) 
- (modified) lldb/source/Plugins/Process/Utility/CMakeLists.txt (+3) 
- (modified) lldb/source/Plugins/REPL/CMakeLists.txt (+3) 
- (modified) lldb/source/Plugins/RegisterTypeBuilder/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/ScriptInterpreter/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/StructuredData/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/SymbolFile/CMakeLists.txt (+7) 
- (modified) lldb/source/Plugins/SymbolLocator/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/SymbolVendor/CMakeLists.txt (+3) 
- (modified) lldb/source/Plugins/SystemRuntime/CMakeLists.txt (+3) 
- (modified) lldb/source/Plugins/Trace/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/TraceExporter/CMakeLists.txt (+2) 
- (modified) lldb/source/Plugins/TypeSystem/CMakeLists.txt (+4) 
- (modified) lldb/source/Plugins/UnwindAssembly/CMakeLists.txt (+2) 


``diff
diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 2aaf75dd87bc3..e3b72e94d4beb 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -37,6 +37,7 @@ endif()
 
 include(LLDBConfig)
 include(AddLLDB)
+include(LLDBLayeringCheck)
 
 set(LLDB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
 
@@ -127,6 +128,8 @@ add_subdirectory(source)
 add_subdirectory(tools)
 add_subdirectory(docs)
 
+check_lldb_plugin_layering()
+
 if (LLDB_ENABLE_PYTHON)
   if(LLDB_BUILD_FRAMEWORK)
 set(lldb_python_target_dir 
"${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")
diff --git a/lldb/cmake/modules/LLDBLayeringCheck.cmake 
b/lldb/cmake/modules/LLDBLayeringCheck.cmake
new file mode 100644
index 0..c09b95d98b66f
--- /dev/null
+++ b/lldb/cmake/modules/LLDBLayeringCheck.cmake
@@ -0,0 +1,76 @@
+foreach (scope DIRECTORY TARGET)
+  define_property(${scope} PROPERTY LLDB_PLUGIN_KIND INHERITED
+BRIEF_DOCS "LLDB plugin kind (Process, SymbolFile, etc."
+FULL_DOCS  "see lldb/docs/resources/contributing.rst"
+  )
+
+  define_property(${scope} PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES 
INHERITED
+BRIEF_DOCS "LLDB plugin kinds which the plugin can depend on"
+FULL_DOCS  "see lldb/docs/resources/contributing.rst"
+  )
+
+  define_property(${scope} PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES 
INHERITED
+BRIEF_DOCS "LLDB plugin kinds which are depended on for historic reasons."
+FULL_DOCS  "see lldb/docs/resources/contributing.rst"
+  )
+endforeach()
+
+option(LLDB_GENERATE_PLUGIN_DEP_GRAPH OFF)
+
+function(check_lldb_plugin_layering)
+  get_property(plugins GLOBAL PROPERTY LLDB_PLUGINS)
+  foreach (plugin ${plugins})
+get_property(plugin_kind TARGET ${plugin} PROPERTY LLDB_PLUGIN_KIND)
+get_property(acceptable_deps TARGET ${plugin}
+  PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES)
+get_property(tolerated_deps TARGET ${plugin}
+  PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES)
+
+# A plugin is always permitted to depend on its own kind for the purposes
+# subclassing. Ideally the intra-kind dependencies should not form a loop,
+# but we're not checking that here.
+list(APPEND acceptable_deps ${plugin_kind})
+
+list(APPEND all_plugin_kinds ${plugin_kind})
+
+get_property(link_libs TARGET ${plugin} PROPERTY LINK_LIBRARIES)
+foreach (link_lib ${link_libs})
+  if(link_lib IN_LIST plugins)
+get_property(lib_kind TARGET ${link_lib} PROPERTY LLDB_PLUGIN_KIND)
+if

[Lldb-commits] [lldb] [lldb] Disable flaky TestDetachResumes.py on Windows x86_64 (PR #145301)

2025-06-23 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Remove GDBRemoteCommunication::ConnectLocally (PR #145293)

2025-06-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

Originally added for reproducers, it is now only used for test code.

While we could make it a test helper, I think that after #145015 it is 
simple enough to not be needed.

Also squeeze in a change to make ConnectionFileDescriptor accept a 
unique_ptr.

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


11 Files Affected:

- (modified) lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h 
(+1-6) 
- (modified) lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp (+5-8) 
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
(+2-16) 
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h 
(-3) 
- (modified) lldb/tools/lldb-server/lldb-platform.cpp (+2-2) 
- (modified) lldb/unittests/Core/CommunicationTest.cpp (+2-2) 
- (modified) lldb/unittests/Host/ConnectionFileDescriptorTest.cpp (+3-3) 
- (modified) lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp 
(+7-2) 
- (modified) 
lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp (+7-2) 
- (modified) lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp 
(+8-2) 
- (modified) lldb/unittests/tools/lldb-server/tests/TestClient.cpp (+2-1) 


``diff
diff --git a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h 
b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
index b771f9c3f45a2..df0e196fea688 100644
--- a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
+++ b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
@@ -18,13 +18,10 @@
 #include "lldb/Host/Pipe.h"
 #include "lldb/Host/Socket.h"
 #include "lldb/Utility/Connection.h"
-#include "lldb/Utility/IOObject.h"
 
 namespace lldb_private {
 
 class Status;
-class Socket;
-class SocketAddress;
 
 class ConnectionFileDescriptor : public Connection {
 public:
@@ -35,7 +32,7 @@ class ConnectionFileDescriptor : public Connection {
 
   ConnectionFileDescriptor(int fd, bool owns_fd);
 
-  ConnectionFileDescriptor(Socket *socket);
+  ConnectionFileDescriptor(std::unique_ptr socket_up);
 
   ~ConnectionFileDescriptor() override;
 
@@ -136,8 +133,6 @@ class ConnectionFileDescriptor : public Connection {
   std::string m_uri;
 
 private:
-  void InitializeSocket(Socket *socket);
-
   ConnectionFileDescriptor(const ConnectionFileDescriptor &) = delete;
   const ConnectionFileDescriptor &
   operator=(const ConnectionFileDescriptor &) = delete;
diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp 
b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index ae935dda5af4e..57dce44812c89 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -72,9 +72,11 @@ ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, 
bool owns_fd)
   OpenCommandPipe();
 }
 
-ConnectionFileDescriptor::ConnectionFileDescriptor(Socket *socket)
-: Connection(), m_pipe(), m_mutex(), m_shutting_down(false) {
-  InitializeSocket(socket);
+ConnectionFileDescriptor::ConnectionFileDescriptor(
+std::unique_ptr socket_up)
+: m_shutting_down(false) {
+  m_uri = socket_up->GetRemoteConnectionURI();
+  m_io_sp = std::move(socket_up);
 }
 
 ConnectionFileDescriptor::~ConnectionFileDescriptor() {
@@ -796,8 +798,3 @@ ConnectionStatus 
ConnectionFileDescriptor::ConnectSerialPort(
 #endif // LLDB_ENABLE_POSIX
   llvm_unreachable("this function should be only called w/ LLDB_ENABLE_POSIX");
 }
-
-void ConnectionFileDescriptor::InitializeSocket(Socket *socket) {
-  m_io_sp.reset(socket);
-  m_uri = socket->GetRemoteConnectionURI();
-}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index d1f57cc22d8bd..0d3ead840b080 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1128,8 +1128,8 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
 Socket *accepted_socket = nullptr;
 error = sock_up->Accept(/*timeout=*/std::nullopt, accepted_socket);
 if (accepted_socket) {
-  SetConnection(
-  std::make_unique(accepted_socket));
+  SetConnection(std::make_unique(
+  std::unique_ptr(accepted_socket)));
 }
   }
 
@@ -1138,20 +1138,6 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
 
 void GDBRemoteCommunication::DumpHistory(Stream &strm) { m_history.Dump(strm); 
}
 
-llvm::Error
-GDBRemoteCommunication::ConnectLocally(GDBRemoteCommunication &client,
-   GDBRemoteCommunication &server) {
-  llvm::Expected pair = Socket::CreatePair();
-  if (!pair)
-return pair.takeError();
-
-  client.SetConnection(
-  std::make_unique(pair->first.release()));
-  server.SetConnection(
-  std::make_unique(pair->second.relea

[Lldb-commits] [lldb] [lldb] Remove GDBRemoteCommunication::ConnectLocally (PR #145293)

2025-06-23 Thread Pavel Labath via lldb-commits

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

Originally added for reproducers, it is now only used for test code.

While we could make it a test helper, I think that after #145015 it is simple 
enough to not be needed.

Also squeeze in a change to make ConnectionFileDescriptor accept a 
unique_ptr.

>From a1c32e3bcdf9355f6564754ed9e77880002289d5 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 23 Jun 2025 10:53:15 +0200
Subject: [PATCH] [lldb] Remove GDBRemoteCommunication::ConnectLocally

Originally added for reproducers, it is now only used for test code.

While we could make it a test helper, I think that after #145015 it is
simple enough to not be needed.

Also squeeze in a change to make ConnectionFileDescriptor accept a
unique_ptr.
---
 .../Host/posix/ConnectionFileDescriptorPosix.h |  7 +--
 .../posix/ConnectionFileDescriptorPosix.cpp| 13 +
 .../gdb-remote/GDBRemoteCommunication.cpp  | 18 ++
 .../gdb-remote/GDBRemoteCommunication.h|  3 ---
 lldb/tools/lldb-server/lldb-platform.cpp   |  4 ++--
 lldb/unittests/Core/CommunicationTest.cpp  |  4 ++--
 .../Host/ConnectionFileDescriptorTest.cpp  |  6 +++---
 .../gdb-remote/GDBRemoteClientBaseTest.cpp |  9 +++--
 .../GDBRemoteCommunicationClientTest.cpp   |  9 +++--
 .../gdb-remote/GDBRemoteCommunicationTest.cpp  | 10 --
 .../tools/lldb-server/tests/TestClient.cpp |  3 ++-
 11 files changed, 39 insertions(+), 47 deletions(-)

diff --git a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h 
b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
index b771f9c3f45a2..df0e196fea688 100644
--- a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
+++ b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
@@ -18,13 +18,10 @@
 #include "lldb/Host/Pipe.h"
 #include "lldb/Host/Socket.h"
 #include "lldb/Utility/Connection.h"
-#include "lldb/Utility/IOObject.h"
 
 namespace lldb_private {
 
 class Status;
-class Socket;
-class SocketAddress;
 
 class ConnectionFileDescriptor : public Connection {
 public:
@@ -35,7 +32,7 @@ class ConnectionFileDescriptor : public Connection {
 
   ConnectionFileDescriptor(int fd, bool owns_fd);
 
-  ConnectionFileDescriptor(Socket *socket);
+  ConnectionFileDescriptor(std::unique_ptr socket_up);
 
   ~ConnectionFileDescriptor() override;
 
@@ -136,8 +133,6 @@ class ConnectionFileDescriptor : public Connection {
   std::string m_uri;
 
 private:
-  void InitializeSocket(Socket *socket);
-
   ConnectionFileDescriptor(const ConnectionFileDescriptor &) = delete;
   const ConnectionFileDescriptor &
   operator=(const ConnectionFileDescriptor &) = delete;
diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp 
b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index ae935dda5af4e..57dce44812c89 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -72,9 +72,11 @@ ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, 
bool owns_fd)
   OpenCommandPipe();
 }
 
-ConnectionFileDescriptor::ConnectionFileDescriptor(Socket *socket)
-: Connection(), m_pipe(), m_mutex(), m_shutting_down(false) {
-  InitializeSocket(socket);
+ConnectionFileDescriptor::ConnectionFileDescriptor(
+std::unique_ptr socket_up)
+: m_shutting_down(false) {
+  m_uri = socket_up->GetRemoteConnectionURI();
+  m_io_sp = std::move(socket_up);
 }
 
 ConnectionFileDescriptor::~ConnectionFileDescriptor() {
@@ -796,8 +798,3 @@ ConnectionStatus 
ConnectionFileDescriptor::ConnectSerialPort(
 #endif // LLDB_ENABLE_POSIX
   llvm_unreachable("this function should be only called w/ LLDB_ENABLE_POSIX");
 }
-
-void ConnectionFileDescriptor::InitializeSocket(Socket *socket) {
-  m_io_sp.reset(socket);
-  m_uri = socket->GetRemoteConnectionURI();
-}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index d1f57cc22d8bd..0d3ead840b080 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1128,8 +1128,8 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
 Socket *accepted_socket = nullptr;
 error = sock_up->Accept(/*timeout=*/std::nullopt, accepted_socket);
 if (accepted_socket) {
-  SetConnection(
-  std::make_unique(accepted_socket));
+  SetConnection(std::make_unique(
+  std::unique_ptr(accepted_socket)));
 }
   }
 
@@ -1138,20 +1138,6 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
 
 void GDBRemoteCommunication::DumpHistory(Stream &strm) { m_history.Dump(strm); 
}
 
-llvm::Error
-GDBRemoteCommunication::ConnectLocally(GDBRemoteCommunication &client,
-   GDBRemoteCommunication &server) {
-  llvm::Expected pair = Socket:

[Lldb-commits] [lldb] Reland "[lldb][target] Add progress report for wait-attaching to proc… (PR #145111)

2025-06-23 Thread David Spickett via lldb-commits

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

The Linux CI failure is real and reproduces locally. I'm looking for a way to 
make it work.

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


[Lldb-commits] [lldb] c5629f2 - [lldb] Add Socket::CreatePair (#145015)

2025-06-23 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-06-23T10:51:26+02:00
New Revision: c5629f2b600488e1aee3f8c9f2266523b460367f

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

LOG: [lldb] Add Socket::CreatePair (#145015)

It creates a pair of connected sockets using the simplest mechanism for
the given platform (TCP on windows, socketpair(2) elsewhere).

Main motivation is to remove the ugly platform-specific code in
ProcessGDBRemote::LaunchAndConnectToDebugserver, but it can also be used
in other places where we need to create a pair of connected sockets.

Added: 


Modified: 
lldb/include/lldb/Host/Socket.h
lldb/include/lldb/Host/common/TCPSocket.h
lldb/include/lldb/Host/posix/DomainSocket.h
lldb/source/Host/common/Socket.cpp
lldb/source/Host/common/TCPSocket.cpp
lldb/source/Host/posix/DomainSocket.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/unittests/Core/CommunicationTest.cpp
lldb/unittests/Host/SocketTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h
index c313aa4f6d26b..89953ee7fd5b6 100644
--- a/lldb/include/lldb/Host/Socket.h
+++ b/lldb/include/lldb/Host/Socket.h
@@ -106,6 +106,10 @@ class Socket : public IOObject {
   static std::unique_ptr Create(const SocketProtocol protocol,
 Status &error);
 
+  using Pair = std::pair, std::unique_ptr>;
+  static llvm::Expected
+  CreatePair(std::optional protocol = std::nullopt);
+
   virtual Status Connect(llvm::StringRef name) = 0;
   virtual Status Listen(llvm::StringRef name, int backlog) = 0;
 

diff  --git a/lldb/include/lldb/Host/common/TCPSocket.h 
b/lldb/include/lldb/Host/common/TCPSocket.h
index cb950c0015ea6..353e538d0552b 100644
--- a/lldb/include/lldb/Host/common/TCPSocket.h
+++ b/lldb/include/lldb/Host/common/TCPSocket.h
@@ -23,6 +23,10 @@ class TCPSocket : public Socket {
   TCPSocket(NativeSocket socket, bool should_close);
   ~TCPSocket() override;
 
+  using Pair =
+  std::pair, std::unique_ptr>;
+  static llvm::Expected CreatePair();
+
   // returns port number or 0 if error
   uint16_t GetLocalPortNumber() const;
 

diff  --git a/lldb/include/lldb/Host/posix/DomainSocket.h 
b/lldb/include/lldb/Host/posix/DomainSocket.h
index a840d474429ec..cfb31922367c5 100644
--- a/lldb/include/lldb/Host/posix/DomainSocket.h
+++ b/lldb/include/lldb/Host/posix/DomainSocket.h
@@ -19,6 +19,10 @@ class DomainSocket : public Socket {
   DomainSocket(NativeSocket socket, bool should_close);
   explicit DomainSocket(bool should_close);
 
+  using Pair =
+  std::pair, std::unique_ptr>;
+  static llvm::Expected CreatePair();
+
   Status Connect(llvm::StringRef name) override;
   Status Listen(llvm::StringRef name, int backlog) override;
 

diff  --git a/lldb/source/Host/common/Socket.cpp 
b/lldb/source/Host/common/Socket.cpp
index 5c5cd653c3d9e..2b23fd1e6e57e 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -234,6 +234,23 @@ std::unique_ptr Socket::Create(const 
SocketProtocol protocol,
   return socket_up;
 }
 
+llvm::Expected
+Socket::CreatePair(std::optional protocol) {
+  constexpr SocketProtocol kBestProtocol =
+  LLDB_ENABLE_POSIX ? ProtocolUnixDomain : ProtocolTcp;
+  switch (protocol.value_or(kBestProtocol)) {
+  case ProtocolTcp:
+return TCPSocket::CreatePair();
+#if LLDB_ENABLE_POSIX
+  case ProtocolUnixDomain:
+  case ProtocolUnixAbstract:
+return DomainSocket::CreatePair();
+#endif
+  default:
+return llvm::createStringError("Unsupported protocol");
+  }
+}
+
 llvm::Expected>
 Socket::TcpConnect(llvm::StringRef host_and_port) {
   Log *log = GetLog(LLDBLog::Connection);

diff  --git a/lldb/source/Host/common/TCPSocket.cpp 
b/lldb/source/Host/common/TCPSocket.cpp
index 3d0dea1c61dd6..c144f3c501d7f 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -52,6 +52,32 @@ TCPSocket::TCPSocket(NativeSocket socket, bool should_close)
 
 TCPSocket::~TCPSocket() { CloseListenSockets(); }
 
+llvm::Expected TCPSocket::CreatePair() {
+  auto listen_socket_up = std::make_unique(true);
+  if (Status error = listen_socket_up->Listen("localhost:0", 5); error.Fail())
+return error.takeError();
+
+  std::string connect_address =
+  llvm::StringRef(listen_socket_up->GetListeningConnectionURI()[0])
+  .split("://")
+  .second.str();
+
+  auto connect_socket_up = std::make_unique(true);
+  if (Status error = connect_socket_up->Connect(connect_address); error.Fail())
+return error.takeError();
+
+  // Connection has already been made above, so a short timeout is sufficient.
+  Socket *accept_socket;
+  if (Status error =
+  listen_socket_up->Accept(std::chrono::second

[Lldb-commits] [lldb] [lldb] Add Socket::CreatePair (PR #145015)

2025-06-23 Thread Pavel Labath via lldb-commits


@@ -106,6 +106,10 @@ class Socket : public IOObject {
   static std::unique_ptr Create(const SocketProtocol protocol,
 Status &error);
 
+  static llvm::Expected<
+  std::pair, std::unique_ptr>>

labath wrote:

Good idea. That means I can also get rid of all the autos I was too lazy to 
type.

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


[Lldb-commits] [lldb] [lldb] Use Socket::CreatePair for launching debugserver (PR #145017)

2025-06-23 Thread Pavel Labath via lldb-commits

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

>From c4923f70478b5274e114642841fd9d3683b67d39 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Fri, 20 Jun 2025 10:29:23 +0200
Subject: [PATCH] [lldb] Use Socket::CreatePair for launching debugserver

This lets get rid of platform-specific code in ProcessGDBRemote and use the
same code path (module differences in socket types) everywhere. It also unlocks
further cleanups in the debugserver launching code.
---
 .../Process/gdb-remote/ProcessGDBRemote.cpp   | 145 +++---
 1 file changed, 55 insertions(+), 90 deletions(-)

diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index f18bdd5175f2e..4e3569a5e7987 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3447,115 +3447,80 @@ ProcessGDBRemote::EstablishConnectionIfNeeded(const 
ProcessInfo &process_info) {
   }
   return error;
 }
-#if !defined(_WIN32)
-#define USE_SOCKETPAIR_FOR_LOCAL_CONNECTION 1
-#endif
-
-#ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
-static bool SetCloexecFlag(int fd) {
-#if defined(FD_CLOEXEC)
-  int flags = ::fcntl(fd, F_GETFD);
-  if (flags == -1)
-return false;
-  return (::fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == 0);
-#else
-  return false;
-#endif
-}
-#endif
 
 Status ProcessGDBRemote::LaunchAndConnectToDebugserver(
 const ProcessInfo &process_info) {
   using namespace std::placeholders; // For _1, _2, etc.
 
-  Status error;
-  if (m_debugserver_pid == LLDB_INVALID_PROCESS_ID) {
-// If we locate debugserver, keep that located version around
-static FileSpec g_debugserver_file_spec;
+  if (m_debugserver_pid != LLDB_INVALID_PROCESS_ID)
+return Status();
 
-ProcessLaunchInfo debugserver_launch_info;
-// Make debugserver run in its own session so signals generated by special
-// terminal key sequences (^C) don't affect debugserver.
-debugserver_launch_info.SetLaunchInSeparateProcessGroup(true);
+  ProcessLaunchInfo debugserver_launch_info;
+  // Make debugserver run in its own session so signals generated by special
+  // terminal key sequences (^C) don't affect debugserver.
+  debugserver_launch_info.SetLaunchInSeparateProcessGroup(true);
 
-const std::weak_ptr this_wp =
-std::static_pointer_cast(shared_from_this());
-debugserver_launch_info.SetMonitorProcessCallback(
-std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3));
-debugserver_launch_info.SetUserID(process_info.GetUserID());
+  const std::weak_ptr this_wp =
+  std::static_pointer_cast(shared_from_this());
+  debugserver_launch_info.SetMonitorProcessCallback(
+  std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3));
+  debugserver_launch_info.SetUserID(process_info.GetUserID());
 
 #if defined(__APPLE__)
-// On macOS 11, we need to support x86_64 applications translated to
-// arm64. We check whether a binary is translated and spawn the correct
-// debugserver accordingly.
-int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
-  static_cast(process_info.GetProcessID()) };
-struct kinfo_proc processInfo;
-size_t bufsize = sizeof(processInfo);
-if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), &processInfo,
-   &bufsize, NULL, 0) == 0 && bufsize > 0) {
-  if (processInfo.kp_proc.p_flag & P_TRANSLATED) {
-FileSpec 
rosetta_debugserver("/Library/Apple/usr/libexec/oah/debugserver");
-debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
-  }
+  // On macOS 11, we need to support x86_64 applications translated to
+  // arm64. We check whether a binary is translated and spawn the correct
+  // debugserver accordingly.
+  int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID,
+   static_cast(process_info.GetProcessID())};
+  struct kinfo_proc processInfo;
+  size_t bufsize = sizeof(processInfo);
+  if (sysctl(mib, (unsigned)(sizeof(mib) / sizeof(int)), &processInfo, 
&bufsize,
+ NULL, 0) == 0 &&
+  bufsize > 0) {
+if (processInfo.kp_proc.p_flag & P_TRANSLATED) {
+  FileSpec rosetta_debugserver(
+  "/Library/Apple/usr/libexec/oah/debugserver");
+  debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
 }
+  }
 #endif
 
-shared_fd_t communication_fd = SharedSocket::kInvalidFD;
-#ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
-// Use a socketpair on non-Windows systems for security and performance
-// reasons.
-int sockets[2]; /* the pair of socket descriptors */
-if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) == -1) {
-  error = Status::FromErrno();
-  return error;
-}
+  llvm::Expected socket_pair = Socket::CreatePair();
+  if (!socket_pair)
+return Status::FromError(socket_pair.takeError());
 
-int our_socket = sockets[0];
-int gdb_so

[Lldb-commits] [lldb] [lldb] Use Socket::CreatePair for launching debugserver (PR #145017)

2025-06-23 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] 9844085 - [lldb] Migrate away from ValueRange(std::nullopt) (NFC) (#145245)

2025-06-23 Thread via lldb-commits

Author: Kazu Hirata
Date: 2025-06-22T16:31:34-07:00
New Revision: 9844085ea8132eae1086eaf55894db3904c189be

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

LOG: [lldb] Migrate away from ValueRange(std::nullopt) (NFC) (#145245)

ArrayRef has a constructor that accepts std::nullopt.  This
constructor dates back to the days when we still had llvm::Optional.

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.

This patch takes care of the lldb side of migration.

Added: 


Modified: 
lldb/source/Symbol/Function.cpp

Removed: 




diff  --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index 4fc793750f84f..6114eccd935ee 100644
--- a/lldb/source/Symbol/Function.cpp
+++ b/lldb/source/Symbol/Function.cpp
@@ -343,7 +343,7 @@ llvm::ArrayRef> 
Function::GetCallEdges() {
   Block &block = GetBlock(/*can_create*/true);
   SymbolFile *sym_file = block.GetSymbolFile();
   if (!sym_file)
-return std::nullopt;
+return {};
 
   // Lazily read call site information from the SymbolFile.
   m_call_edges = sym_file->ParseCallEdgesInFunction(GetID());



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


[Lldb-commits] [lldb] [LLDB] Update DIL to handle smart pointers; add more tests. (PR #143786)

2025-06-23 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett commented:

I've disabled a lot of tests on this bot for what was/is probably this issue, 
so this will be a helpful warning I think.

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


[Lldb-commits] [lldb] 714b2fd - [lldb] Add BRIEF_DOCS for cmake properties defined in #144543

2025-06-23 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2025-06-23T11:39:20+02:00
New Revision: 714b2fdf3a385e5b9a95c435f56b1696ec3ec9e8

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

LOG: [lldb] Add BRIEF_DOCS for cmake properties defined in #144543

It seems some cmake versions require it.

Added: 


Modified: 
lldb/cmake/modules/LLDBLayeringCheck.cmake

Removed: 




diff  --git a/lldb/cmake/modules/LLDBLayeringCheck.cmake 
b/lldb/cmake/modules/LLDBLayeringCheck.cmake
index 082bbe37a980f..1669f6150cca9 100644
--- a/lldb/cmake/modules/LLDBLayeringCheck.cmake
+++ b/lldb/cmake/modules/LLDBLayeringCheck.cmake
@@ -1,11 +1,17 @@
-define_property(DIRECTORY PROPERTY LLDB_PLUGIN_KIND)
-define_property(TARGET PROPERTY LLDB_PLUGIN_KIND INHERITED)
+define_property(DIRECTORY PROPERTY LLDB_PLUGIN_KIND
+  BRIEF_DOCS "LLDB plugin kind (Process, SymbolFile, etc.")
+define_property(TARGET PROPERTY LLDB_PLUGIN_KIND INHERITED
+  BRIEF_DOCS "LLDB plugin kind (Process, SymbolFile, etc.")
 
-define_property(DIRECTORY PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES)
-define_property(TARGET PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES INHERITED)
+define_property(DIRECTORY PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES
+  BRIEF_DOCS "LLDB plugin kinds which the plugin can depend on")
+define_property(TARGET PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES INHERITED
+  BRIEF_DOCS "LLDB plugin kinds which the plugin can depend on")
 
-define_property(DIRECTORY PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES)
-define_property(TARGET PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES INHERITED)
+define_property(DIRECTORY PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES
+  BRIEF_DOCS "LLDB plugin kinds which are depended on for historic reasons.")
+define_property(TARGET PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES INHERITED
+  BRIEF_DOCS "LLDB plugin kinds which are depended on for historic reasons.")
 
 option(LLDB_GENERATE_PLUGIN_DEP_GRAPH OFF)
 



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


[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb/cmake] Plugin layering enforcement mechanism (PR #144543)

2025-06-23 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

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

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


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/8/12 (2258 of 2267)
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/9/12 (2259 of 2267)
PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/0/2 (2260 of 2267)
PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/1/2 (2261 of 2267)
PASS: lldb-unit :: Utility/./UtilityTests/4/9 (2262 of 2267)
PASS: lldb-unit :: Target/./TargetTests/11/14 (2263 of 2267)
PASS: lldb-unit :: Host/./HostTests/6/8 (2264 of 2267)
PASS: lldb-unit :: Host/./HostTests/4/8 (2265 of 2267)
PASS: lldb-unit :: Process/gdb-remote/./ProcessGdbRemoteTests/8/9 (2266 of 2267)
UNRESOLVED: lldb-api :: tools/lldb-server/TestLldbGdbServer.py (2267 of 2267)
 TEST 'lldb-api :: tools/lldb-server/TestLldbGdbServer.py' 
FAILED 
Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
--env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--arch aarch64 --build-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil 
--make /usr/bin/gmake --llvm-tools-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --cmake-build-type 
Release 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-server
 -p TestLldbGdbServer.py
--
Exit Code: 1

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

--
Command Output (stderr):
--
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hc_then_Csignal_signals_correct_thread_launch_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hc_then_Csignal_signals_correct_thread_launch_llgs 
(TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_another_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_minus_one_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_zero_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_switches_to_3_threads_launch_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_switches_to_3_threads_launch_llgs 
(TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_and_p_thread_suffix_work_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_and_p_thread_suffix_work_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_writes_all_gpr_registers_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
cat

[Lldb-commits] [lldb] 5c22793 - [lldb-dap][test] Refactor runInTerminal Tests. (#144954)

2025-06-23 Thread via lldb-commits

Author: Ebuka Ezike
Date: 2025-06-23T10:32:46+01:00
New Revision: 5c22793eadd8758d589eafd1cbbb2897ab8b3c8b

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

LOG: [lldb-dap][test] Refactor runInTerminal Tests. (#144954)

Replace `isTestSupported` function with `skipIfBuildType` annotation.

Test that uses the `IsTestSupported` function are no longer run, as the
size of lldb-dap binary is now more than `1mb`.

Update the broken test. 

Fixes #108621  

We could probably check if the test now passes on `linux arm` since it
was disabled because it timed out. I experienced the timeout after
replacing the `IsTestSupported` with `skipIfBuildType`.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py
lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
lldb/test/API/tools/lldb-dap/runInTerminal/main.c

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 6d32491eaa5e9..0fe36cd4bc71f 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -179,9 +179,13 @@ def encode_content(cls, s: str) -> bytes:
 @classmethod
 def validate_response(cls, command, response):
 if command["command"] != response["command"]:
-raise ValueError("command mismatch in response")
+raise ValueError(
+f"command mismatch in response {command['command']} != 
{response['command']}"
+)
 if command["seq"] != response["request_seq"]:
-raise ValueError("seq mismatch in response")
+raise ValueError(
+f"seq mismatch in response {command['seq']} != 
{response['request_seq']}"
+)
 
 def _read_packet_thread(self):
 done = False
@@ -404,8 +408,8 @@ def send_recv(self, command):
 self.reverse_requests.append(response_or_request)
 if response_or_request["command"] == "runInTerminal":
 subprocess.Popen(
-response_or_request["arguments"]["args"],
-env=response_or_request["arguments"]["env"],
+response_or_request["arguments"].get("args"),
+env=response_or_request["arguments"].get("env", {}),
 )
 self.send_packet(
 {

diff  --git 
a/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py 
b/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py
index e23d34bd99308..3ba7deb285de9 100644
--- a/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py
@@ -2,23 +2,35 @@
 Test lldb-dap RestartRequest.
 """
 
-import os
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import line_number
+from typing import Dict, Any, List
+
 import lldbdap_testcase
+from lldbsuite.test.decorators import skipIfWindows, skipIf, skipIfBuildType
+from lldbsuite.test.lldbtest import line_number
 
 
+@skipIfBuildType(["debug"])
 class TestDAP_restart_runInTerminal(lldbdap_testcase.DAPTestCaseBase):
-def isTestSupported(self):
-try:
-# We skip this test for debug builds because it takes too long
-# parsing lldb's own debug info. Release builds are fine.
-# Checking the size of the lldb-dap binary seems to be a decent
-# proxy for a quick detection. It should be far less than 1 MB in
-# Release builds.
-return os.path.getsize(os.environ["LLDBDAP_EXEC"]) < 100
-except:
-return False
+def verify_stopped_on_entry(self, stopped_events: List[Dict[str, Any]]):
+seen_stopped_event = 0
+for stopped_event in stopped_events:
+body = stopped_event.get("body")
+if body is None:
+continue
+
+reason = body.get("reason")
+if reason is None:
+continue
+
+self.assertNotEqual(
+reason,
+"breakpoint",
+'verify stop after restart isn\'t "main" breakpoint',
+)
+if reason == "entry":
+seen_stopped_event += 1
+
+self.assertEqual(seen_stopped_event, 1, "expect only one stopped entry 
event.")
 
 @skipIfWindows
 @skipIf(oslist=["linux"], archs=["arm$"])  # Always times out on buildbot
@@ -27,8 +39,6 @@ def test_basic_functionality(self):
 Test bas

[Lldb-commits] [lldb] [lldb/cmake] Plugin layering enforcement mechanism (PR #144543)

2025-06-23 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread David Spickett via lldb-commits


@@ -1071,6 +1077,15 @@ void ObjectFilePECOFF::CreateSections(SectionList 
&unified_section_list) {
   m_sections_up->AddSection(section_sp);
   unified_section_list.AddSection(section_sp);
 }
+
+if (!truncated_dwarf_sections.empty())
+  module_sp->ReportWarning(
+  "contains {} truncated DWARF sections ({}).\n"
+  "Executable images on Windows can't include the required names "
+  "when linking with the default link.exe. A third party linker like "
+  "lld-link is required (compile with -fuse-ld=lld-link on Clang).",

DavidSpickett wrote:

I understand this as written but it would benefit from rephrasing to be clearer 
without extra context. Also the names are truncated not the section data, which 
this implies.

How about:
```
contains {} DWARF sections with truncated names ({}).\n
Windows executable (PECOFF) images produced by link.exe cannot include the 
required section names due to a restriction on section name length. A third 
party linker like lld-link is required (compile with -fuse-ld=lld-link when 
using Clang)."
```

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


[Lldb-commits] [lldb] [lldb] add plugin names to process save-core error output. (PR #143126)

2025-06-23 Thread David Spickett via lldb-commits


@@ -843,11 +843,28 @@ Status PluginManager::SaveCore(const lldb::ProcessSP 
&process_sp,
   }
 
   // Check to see if any of the object file plugins tried and failed to save.
-  // If none ran, set the error message.
-  if (error.Success())
-error = Status::FromErrorString(
-"no ObjectFile plugins were able to save a core for this process");
-  return error;
+  // if any failure, return the error message.
+  if (error.Fail())
+return error;
+
+  // Report only for the plugin that was specified.
+  if (!plugin_name.empty())
+return Status::FromErrorStringWithFormatv(
+"The \"{}\" plugin is not able to save a core for this process.",
+plugin_name);
+
+  return Status::FromErrorString(
+  "no ObjectFile plugins were able to save a core for this process");
+}

DavidSpickett wrote:

These two errors don't have test coverage.

> "The \"{}\" plugin is not able to save a core for this process."

To hit this one we'd need a plugin that can save a core, but not for this 
process.

> "no ObjectFile plugins were able to save a core for this process"

Same thing but there needs to be > 1 plugin that tried.

And the original error doesn't have coverage either, presumably because no one 
has the appetite to inject a problem into a process. Which is fair enough.

So yes these don't have coverage but it's not the end of the world if someone 
gets the wrong one so I'm not going to demand tests for them.

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


[Lldb-commits] [lldb] [lldb] Disable flaky TestDetachResumes.py on Windows x86_64 (PR #145301)

2025-06-23 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman created 
https://github.com/llvm/llvm-project/pull/145301

See #144891 for details.

>From 7d1bbcc0f16a67612439dc3133c361f2582ac25b Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Mon, 23 Jun 2025 13:58:08 +0400
Subject: [PATCH] [lldb] Disable flaky TestDetachResumes.py on Windows x86_64

See #144891 for details.
---
 .../API/commands/process/detach-resumes/TestDetachResumes.py | 5 +
 1 file changed, 5 insertions(+)

diff --git a/lldb/test/API/commands/process/detach-resumes/TestDetachResumes.py 
b/lldb/test/API/commands/process/detach-resumes/TestDetachResumes.py
index 57727294ddc3d..db730574124b6 100644
--- a/lldb/test/API/commands/process/detach-resumes/TestDetachResumes.py
+++ b/lldb/test/API/commands/process/detach-resumes/TestDetachResumes.py
@@ -12,6 +12,11 @@
 class DetachResumesTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
+@skipIf(
+oslist=["windows"],
+archs=["x86_64"],
+bugnumber="github.com/llvm/llvm-project/issues/144891",
+)
 def test_detach_resumes(self):
 self.build()
 exe = self.getBuildArtifact()

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


[Lldb-commits] [lldb] [lldb] Disable flaky TestDetachResumes.py on Windows x86_64 (PR #145301)

2025-06-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

See #144891 for details.

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


1 Files Affected:

- (modified) lldb/test/API/commands/process/detach-resumes/TestDetachResumes.py 
(+5) 


``diff
diff --git a/lldb/test/API/commands/process/detach-resumes/TestDetachResumes.py 
b/lldb/test/API/commands/process/detach-resumes/TestDetachResumes.py
index 57727294ddc3d..db730574124b6 100644
--- a/lldb/test/API/commands/process/detach-resumes/TestDetachResumes.py
+++ b/lldb/test/API/commands/process/detach-resumes/TestDetachResumes.py
@@ -12,6 +12,11 @@
 class DetachResumesTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
+@skipIf(
+oslist=["windows"],
+archs=["x86_64"],
+bugnumber="github.com/llvm/llvm-project/issues/144891",
+)
 def test_detach_resumes(self):
 self.build()
 exe = self.getBuildArtifact()

``




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


[Lldb-commits] [lldb] [lldb] Use Socket::CreatePair for launching debugserver (PR #145017)

2025-06-23 Thread Pavel Labath via lldb-commits

labath wrote:

> LGTM
> 
> I think we must mention in the description the main functional change that 
> now we are always using --fd for gdbserver on Windows instead of the back 
> connection.

Thanks. Good point, updated the PR description.

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


[Lldb-commits] [lldb] [lldb] Add Socket::CreatePair (PR #145015)

2025-06-23 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Update DIL to pass current 'frame var' tests. (PR #145055)

2025-06-23 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Update DIL to pass current 'frame var' tests. (PR #145055)

2025-06-23 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap][test] Refactor runInTerminal Tests. (PR #144954)

2025-06-23 Thread Ebuka Ezike via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Update DIL to pass current 'frame var' tests. (PR #145055)

2025-06-23 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

If the test you found the anonymous namespace issue it is explicitly testing 
the handling of anonymous namespaces, then this is fine. However, if it's doing 
that as a side-effect of testing something else, then it may be nice to have an 
explicit test case for it. (Particularly as the anonymous namespace thing can 
appear in other positions as well (`ns1::(anonymous namespace)::foo`, 
`(anonymous namespace)::ns::(anonymous namespace)::foo`, etc.)

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Support constant index encoding of DW_AT_object_pointer (PR #144998)

2025-06-23 Thread Michael Buch via lldb-commits

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

>From 2c54344a0bf7c7937166820ae0ada92c4e4445cb Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 29 Jan 2025 12:15:35 +
Subject: [PATCH 1/8] [lldb][DWARFASTParserClang] Support constant index
 encoding of DW_AT_object_pointer

Starting with https://github.com/llvm/llvm-project/pull/124790, Clang
emits `DW_AT_object_pointer` encoded as integer constants rather than
DIE references. This patch accounts for this.
---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  47 +++--
 .../x86/explicit-member-function-quals.cpp|  21 +-
 .../DWARF/DWARFASTParserClangTests.cpp| 196 ++
 3 files changed, 244 insertions(+), 20 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index a4cb608edd8b4..1e86629e0f730 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -170,23 +170,46 @@ DWARFASTParserClang::GetObjectParameter(const DWARFDIE 
&subprogram,
   if (!decl_ctx_die.IsStructUnionOrClass())
 return {};
 
-  if (DWARFDIE object_parameter =
-  subprogram.GetAttributeValueAsReferenceDIE(DW_AT_object_pointer))
-return object_parameter;
+  // The DW_AT_object_pointer may be either encoded as a reference to a DIE,
+  // in which case that's the object parameter we want. Or it can be a constant
+  // index of the parameter.
+  std::optional object_pointer_index;
+  DWARFFormValue form_value;
+  if (subprogram.GetDIE()->GetAttributeValue(
+  subprogram.GetCU(), DW_AT_object_pointer, form_value,
+  /*end_attr_offset_ptr=*/nullptr, /*check_elaborating_dies=*/true)) {
+if (auto ref = form_value.Reference())
+  return ref;
+
+object_pointer_index = form_value.Unsigned();
+  }
+
+  // Try to find the DW_TAG_formal_parameter via object_pointer_index.
+  DWARFDIE object_pointer;
+  size_t param_index = 0;
+  for (const auto &child : subprogram.children()) {
+if (child.Tag() != DW_TAG_formal_parameter)
+  continue;
 
-  // If no DW_AT_object_pointer was specified, assume the implicit object
-  // parameter is the first parameter to the function, is called "this" and is
-  // artificial (which is what most compilers would generate).
-  auto children = subprogram.children();
-  auto it = llvm::find_if(children, [](const DWARFDIE &child) {
-return child.Tag() == DW_TAG_formal_parameter;
-  });
+if (param_index == object_pointer_index.value_or(0))
+  object_pointer = child;
+
+++param_index;
+  }
 
-  if (it == children.end())
+  // No formal parameter found for object pointer index.
+  // Nothing to be done.
+  if (!object_pointer)
 return {};
 
-  DWARFDIE object_pointer = *it;
+  // We found the object pointer encoded via DW_AT_object_pointer.
+  // No need for the remaining heuristics.
+  if (object_pointer_index)
+return object_pointer;
 
+  // If no DW_AT_object_pointer was specified, assume the implicit object
+  // parameter is the first parameter to the function, is called "this" and is
+  // artificial (which is what most compilers would generate).
   if (!object_pointer.GetAttributeValueAsUnsigned(DW_AT_artificial, 0))
 return {};
 
diff --git 
a/lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp
index 33001db69f83e..f89f0f4a4f0bf 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/explicit-member-function-quals.cpp
@@ -1,4 +1,9 @@
 // XFAIL: *
+//
+// FIXME: Explicit object parameter is not shown in
+// type lookup output. This is because we don't attach
+// valid source locations to decls in the DWARF AST,
+// so the ParmVarDecl::isExplicitObjectParameter fails.
 
 // Tests that we correctly deduce the CV-quals and storage
 // class of explicit object member functions.
@@ -8,15 +13,15 @@
 //
 // CHECK:  (lldb) type lookup Foo
 // CHECK-NEXT: struct Foo {
-// CHECK-NEXT:  void Method(Foo);
-// CHECK-NEXT:  void cMethod(const Foo &) const;
-// CHECK-NEXT:  void vMethod(volatile Foo &) volatile;
-// CHECK-NEXT:  void cvMethod(const volatile Foo &) const volatile;
+// CHECK-NEXT:  void Method(this Foo);
+// CHECK-NEXT:  void cMethod(this const Foo &) const;
+// CHECK-NEXT:  void vMethod(this volatile Foo &) volatile;
+// CHECK-NEXT:  void cvMethod(this const volatile Foo &) const volatile;
 // CHECK-NEXT: }
 
 struct Foo {
-  void Method(this Foo) {}
-  void cMethod(this Foo const &) {}
-  void vMethod(this Foo volatile &) {}
-  void cvMethod(this Foo const volatile &) {}
+  [[gnu::always_inline]] void Method(this Foo) {}
+  [[gnu::always_inline]] void cMethod(this Foo const &) {}
+  [[gnu::always_inline]] void vMethod(this Foo volatile

[Lldb-commits] [lldb] [lldb] Add Socket::CreatePair (PR #145015)

2025-06-23 Thread Pavel Labath via lldb-commits


@@ -52,6 +52,34 @@ TCPSocket::TCPSocket(NativeSocket socket, bool should_close)
 
 TCPSocket::~TCPSocket() { CloseListenSockets(); }
 
+llvm::Expected<
+std::pair, std::unique_ptr>>
+TCPSocket::CreatePair() {
+  auto listen_socket_up = std::make_unique(true);
+  if (Status error = listen_socket_up->Listen("localhost:0", 5); error.Fail())
+return error.takeError();
+
+  std::string connect_address =
+  llvm::StringRef(listen_socket_up->GetListeningConnectionURI()[0])
+  .split("://")
+  .second.str();
+
+  auto connect_socket_up = std::make_unique(true);
+  if (Status error = connect_socket_up->Connect(connect_address); error.Fail())
+return error.takeError();
+
+  // Connection has already been made above, so a short timeout is sufficient.
+  Socket *accept_socket;
+  if (Status error =
+  listen_socket_up->Accept(std::chrono::seconds(1), accept_socket);

labath wrote:

No reason. I sort of actually have a patch stack for a major overhaul of the 
socket classes, and it fixes this (among other things). This PR is kind of a 
part of a very long and windy way of upstreaming it. :)

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


[Lldb-commits] [lldb] [lldb] Add Socket::CreatePair (PR #145015)

2025-06-23 Thread Pavel Labath via lldb-commits

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

>From 54ef8f5e1ff3f3ea28605ffb9a90f0b0aa6b52af Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Thu, 19 Jun 2025 21:44:02 +0200
Subject: [PATCH 1/2] [lldb] Add Socket::CreatePair

It creates a pair of connected sockets using the simplest mechanism for
the given platform (TCP on windows, socketpair(2) elsewhere).

Main motivation is to remove the ugly platform-specific code in
ProcessGDBRemote::LaunchAndConnectToDebugserver, but it can also be used
in other places where we need to create a pair of connected sockets.
---
 lldb/include/lldb/Host/Socket.h   |  4 +++
 lldb/include/lldb/Host/common/TCPSocket.h |  4 +++
 lldb/include/lldb/Host/posix/DomainSocket.h   |  4 +++
 lldb/source/Host/common/Socket.cpp| 17 +
 lldb/source/Host/common/TCPSocket.cpp | 28 +++
 lldb/source/Host/posix/DomainSocket.cpp   | 29 +++
 .../gdb-remote/GDBRemoteCommunication.cpp | 36 +--
 lldb/unittests/Core/CommunicationTest.cpp | 26 --
 lldb/unittests/Host/SocketTest.cpp| 35 ++
 9 files changed, 144 insertions(+), 39 deletions(-)

diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h
index c313aa4f6d26b..14a9660ed30b7 100644
--- a/lldb/include/lldb/Host/Socket.h
+++ b/lldb/include/lldb/Host/Socket.h
@@ -106,6 +106,10 @@ class Socket : public IOObject {
   static std::unique_ptr Create(const SocketProtocol protocol,
 Status &error);
 
+  static llvm::Expected<
+  std::pair, std::unique_ptr>>
+  CreatePair(std::optional protocol = std::nullopt);
+
   virtual Status Connect(llvm::StringRef name) = 0;
   virtual Status Listen(llvm::StringRef name, int backlog) = 0;
 
diff --git a/lldb/include/lldb/Host/common/TCPSocket.h 
b/lldb/include/lldb/Host/common/TCPSocket.h
index cb950c0015ea6..e81cb82dbcba1 100644
--- a/lldb/include/lldb/Host/common/TCPSocket.h
+++ b/lldb/include/lldb/Host/common/TCPSocket.h
@@ -23,6 +23,10 @@ class TCPSocket : public Socket {
   TCPSocket(NativeSocket socket, bool should_close);
   ~TCPSocket() override;
 
+  static llvm::Expected<
+  std::pair, std::unique_ptr>>
+  CreatePair();
+
   // returns port number or 0 if error
   uint16_t GetLocalPortNumber() const;
 
diff --git a/lldb/include/lldb/Host/posix/DomainSocket.h 
b/lldb/include/lldb/Host/posix/DomainSocket.h
index a840d474429ec..c3a6a64bbdef8 100644
--- a/lldb/include/lldb/Host/posix/DomainSocket.h
+++ b/lldb/include/lldb/Host/posix/DomainSocket.h
@@ -19,6 +19,10 @@ class DomainSocket : public Socket {
   DomainSocket(NativeSocket socket, bool should_close);
   explicit DomainSocket(bool should_close);
 
+  static llvm::Expected<
+  std::pair, std::unique_ptr>>
+  CreatePair();
+
   Status Connect(llvm::StringRef name) override;
   Status Listen(llvm::StringRef name, int backlog) override;
 
diff --git a/lldb/source/Host/common/Socket.cpp 
b/lldb/source/Host/common/Socket.cpp
index 5c5cd653c3d9e..c9dec0f8ea22a 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -234,6 +234,23 @@ std::unique_ptr Socket::Create(const 
SocketProtocol protocol,
   return socket_up;
 }
 
+llvm::Expected, std::unique_ptr>>
+Socket::CreatePair(std::optional protocol) {
+  constexpr SocketProtocol kBestProtocol =
+  LLDB_ENABLE_POSIX ? ProtocolUnixDomain : ProtocolTcp;
+  switch (protocol.value_or(kBestProtocol)) {
+  case ProtocolTcp:
+return TCPSocket::CreatePair();
+#if LLDB_ENABLE_POSIX
+  case ProtocolUnixDomain:
+  case ProtocolUnixAbstract:
+return DomainSocket::CreatePair();
+#endif
+  default:
+return llvm::createStringError("Unsupported protocol");
+  }
+}
+
 llvm::Expected>
 Socket::TcpConnect(llvm::StringRef host_and_port) {
   Log *log = GetLog(LLDBLog::Connection);
diff --git a/lldb/source/Host/common/TCPSocket.cpp 
b/lldb/source/Host/common/TCPSocket.cpp
index 3d0dea1c61dd6..34f249746149e 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -52,6 +52,34 @@ TCPSocket::TCPSocket(NativeSocket socket, bool should_close)
 
 TCPSocket::~TCPSocket() { CloseListenSockets(); }
 
+llvm::Expected<
+std::pair, std::unique_ptr>>
+TCPSocket::CreatePair() {
+  auto listen_socket_up = std::make_unique(true);
+  if (Status error = listen_socket_up->Listen("localhost:0", 5); error.Fail())
+return error.takeError();
+
+  std::string connect_address =
+  llvm::StringRef(listen_socket_up->GetListeningConnectionURI()[0])
+  .split("://")
+  .second.str();
+
+  auto connect_socket_up = std::make_unique(true);
+  if (Status error = connect_socket_up->Connect(connect_address); error.Fail())
+return error.takeError();
+
+  // Connection has already been made above, so a short timeout is sufficient.
+  Socket *accept_socket;
+  if (Status error =
+  listen_s

[Lldb-commits] [lldb] [LLDB] Update DIL to handle smart pointers; add more tests. (PR #143786)

2025-06-23 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

The code looks good. I just have issues with the test(s). Please, see inline 
comments.

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


[Lldb-commits] [lldb] [LLDB] Update DIL to handle smart pointers; add more tests. (PR #143786)

2025-06-23 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Update DIL to handle smart pointers; add more tests. (PR #143786)

2025-06-23 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,26 @@
+#include 
+
+struct NodeS;
+
+// Fake smart pointer definition.
+class smart_ptr {
+public:
+  NodeS *__ptr_;

labath wrote:

This is technically a reserved identifier. Let's just use `ptr`.

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


[Lldb-commits] [lldb] [LLDB] Update DIL to handle smart pointers; add more tests. (PR #143786)

2025-06-23 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,32 @@
+import lldb
+
+
+class smartPtrSynthProvider:
+def __init__(self, valobj, dict):
+self.valobj = valobj
+
+def num_children(self):
+return 1
+
+def get_child_at_index(self, index):
+if index == 0:
+return self.valobj.GetChildMemberWithName("__ptr_")
+if index == 1:
+internal_child = self.valobj.GetChildMemberWithName("__ptr_")
+if not internal_child:
+return None
+value_type = internal_child.GetType().GetPointerType()
+cast_ptr_sp = internal_child.Cast(value_type)
+value = internal_child.Dereference()
+return value

labath wrote:

The cast, is a noop, right? Any reason to not remove it?

```suggestion
return internal_child.Dereference()
```

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


[Lldb-commits] [lldb] [LLDB] Update DIL to handle smart pointers; add more tests. (PR #143786)

2025-06-23 Thread Pavel Labath via lldb-commits




labath wrote:

I have a bit of an issue with the test name and location, I think it sets up 
the wrong expectations. The DIL should be language agnostic, so it shouldn't 
work (only) with (c++) smart pointers. Even in c++ you have non-pointer types 
that can be "dereferenced" (std::optional, for one).

The DIL should work with with any type which provides a synthetic dereference 
operator, so if we're going to have a folder for all DIL tests, this test 
(which uses *a* type with a synthetic deref op) should be there. And to drive 
the point home, I think it ought to be called something like 
`TestSyntheticDeref.py`.

OTOH, I believe tests for std::shared/unique_ptr would be better off in 
test/API/functionalities/data-formatter/data-formatter-stl, where we that 
operations on that specific type work. Then you can compare them with the 
existing test for these types (and their data formatters). If your testing 
something not covered by the existing test, just add it there. Otherwise, 
delete it

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


[Lldb-commits] [lldb] [LLDB] Update DIL to handle smart pointers; add more tests. (PR #143786)

2025-06-23 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,34 @@
+"""
+Test DIL pointer dereferencing.
+"""
+
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test import lldbutil
+
+import os
+import shutil
+import time
+
+
+class TestFrameVarDILPointerDereference(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_frame_var(self):
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "Set a breakpoint here", lldb.SBFileSpec("main.cpp")
+)
+
+self.runCmd("settings set target.experimental.use-DIL true")
+self.expect_var_path("*p_int0", value="0")
+self.expect_var_path("*cp_int5", value="5")
+self.expect_var_path("&pp_void0[2]", type="void **")
+self.expect_var_path("**pp_int0", value="0")
+self.expect_var_path("&**pp_int0", type="int *")

labath wrote:

Since the goal here is to explicitly check handling pointer arithmetic, you may 
want to add additional checks for the values you get this way. 
`expect_var_path` returns the SBValue it has located, so you could do something 
like:
```
pp_void0_2_got = self.expect_var_path("&pp_void0[2]", type="void **")
pp_void0_2_exp = self.expect_var_path("pp_void0_2", type="void **") # 
Initialized in C++ code to point to the same value
self.assertEqual(pp_void0_2_got.GetValueAsAddress(), 
pp_void0_2_exp.GetValueAsAddress())
```

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


[Lldb-commits] [lldb] [LLDB] Update DIL to pass current 'frame var' tests. (PR #145055)

2025-06-23 Thread Pavel Labath via lldb-commits


@@ -178,11 +178,40 @@ ASTNodeUP DILParser::ParsePrimaryExpression() {
   }
 
   if (CurToken().Is(Token::l_paren)) {
-m_dil_lexer.Advance();
-auto expr = ParseExpression();
-Expect(Token::r_paren);
-m_dil_lexer.Advance();
-return expr;
+// Check in case this is an anonynmous namespace
+if (m_dil_lexer.LookAhead(1).Is(Token::identifier) &&
+(m_dil_lexer.LookAhead(1).GetSpelling() == "anonymous") &&
+m_dil_lexer.LookAhead(2).Is(Token::identifier) &&
+(m_dil_lexer.LookAhead(2).GetSpelling() == "namespace") &&
+m_dil_lexer.LookAhead(3).Is(Token::r_paren) &&
+m_dil_lexer.LookAhead(4).Is(Token::coloncolon)) {
+  m_dil_lexer.Advance(4);
+
+  std::string identifier = "(anonymous namespace)";
+  Expect(Token::coloncolon);
+  // Save the source location for the diagnostics message.
+  uint32_t loc = CurToken().GetLocation();
+  m_dil_lexer.Advance();
+  assert(
+  (CurToken().Is(Token::identifier) || CurToken().Is(Token::l_paren)) 
&&
+  "Expected an identifier or anonymous namespeace, but not found.");

labath wrote:

```
(lldb) frame variable 'lldb::(anonymous namespace)::a'
lldb: /home/pavelo/ll/mono/lldb/source/ValueObject/DILParser.cpp:235: 
std::string lldb_private::dil::DILP
arser::ParseNestedNameSpecifier(): Assertion `(CurToken().Is(Token::identifier) 
|| CurToken().Is(Token::l
_paren)) && "Expected an identifier or anonymous namespace, but not found."' 
failed.
```

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


[Lldb-commits] [lldb] [lldb/cmake] Plugin layering enforcement mechanism (PR #144543)

2025-06-23 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`cross-project-tests-sie-ubuntu-dwarf5` running on `doug-worker-1b` while 
building `lldb` at step 4 "cmake-configure".

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


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

```
Step 4 (cmake-configure) failure: cmake (failure)
...
-- Looking for gettid
-- Looking for gettid - found
-- Not building llvm-mt because libxml2 is not available
-- Failed to find LLVM FileCheck
-- Google Benchmark version: v0.0.0, normalized to 0.0.0
-- Looking for shm_open in rt
-- Looking for shm_open in rt - found
-- Performing Test HAVE_CXX_FLAG_WALL
-- Performing Test HAVE_CXX_FLAG_WALL - Success
-- Performing Test HAVE_CXX_FLAG_WEXTRA
-- Performing Test HAVE_CXX_FLAG_WEXTRA - Success
-- Performing Test HAVE_CXX_FLAG_WSHADOW
-- Performing Test HAVE_CXX_FLAG_WSHADOW - Success
-- Performing Test HAVE_CXX_FLAG_WFLOAT_EQUAL
-- Performing Test HAVE_CXX_FLAG_WFLOAT_EQUAL - Success
-- Performing Test HAVE_CXX_FLAG_WOLD_STYLE_CAST
-- Performing Test HAVE_CXX_FLAG_WOLD_STYLE_CAST - Success
-- Performing Test HAVE_CXX_FLAG_WSUGGEST_OVERRIDE
-- Performing Test HAVE_CXX_FLAG_WSUGGEST_OVERRIDE - Success
-- Performing Test HAVE_CXX_FLAG_PEDANTIC
-- Performing Test HAVE_CXX_FLAG_PEDANTIC - Success
-- Performing Test HAVE_CXX_FLAG_PEDANTIC_ERRORS
-- Performing Test HAVE_CXX_FLAG_PEDANTIC_ERRORS - Success
-- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32
-- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32 - Failed
-- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING
-- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING - Success
-- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED_DECLARATIONS
-- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED_DECLARATIONS - Success
-- Performing Test HAVE_CXX_FLAG_FNO_EXCEPTIONS
-- Performing Test HAVE_CXX_FLAG_FNO_EXCEPTIONS - Success
-- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING
-- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING - Success
-- Performing Test HAVE_CXX_FLAG_WD654
-- Performing Test HAVE_CXX_FLAG_WD654 - Failed
-- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY
-- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY - Failed
-- Performing Test HAVE_CXX_FLAG_COVERAGE
-- Performing Test HAVE_CXX_FLAG_COVERAGE - Success
-- Compiling and running to test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Compiling and running to test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX -- success
-- Compiling and running to test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Compiling and running to test HAVE_PTHREAD_AFFINITY
-- Performing Test HAVE_PTHREAD_AFFINITY -- success
-- Configuring incomplete, errors occurred!
See also 
"/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/CMakeFiles/CMakeOutput.log".
See also 
"/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/CMakeFiles/CMakeError.log".

```



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


[Lldb-commits] [lldb] Reapply "[lldb/cmake] Plugin layering enforcement mechanism (#144543)" (PR #145305)

2025-06-23 Thread Pavel Labath via lldb-commits

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

>From be3083de00796539976b1bbfe25f90693296bd89 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 23 Jun 2025 12:13:54 +0200
Subject: [PATCH 1/2] Reapply "[lldb/cmake] Plugin layering enforcement
 mechanism (#144543)"

The only difference from the original PR are the added BRIEF and
FULL_DOCS arguments to define_property, which are required for
cmake<3.23.
---
 lldb/CMakeLists.txt   |  3 +
 lldb/cmake/modules/LLDBLayeringCheck.cmake| 76 +++
 lldb/docs/resources/contributing.rst  | 50 
 lldb/source/Plugins/ABI/CMakeLists.txt|  6 ++
 .../Plugins/Architecture/CMakeLists.txt   |  2 +
 .../Plugins/Disassembler/CMakeLists.txt   |  2 +
 .../Plugins/DynamicLoader/CMakeLists.txt  |  7 ++
 .../Plugins/ExpressionParser/CMakeLists.txt   |  2 +
 .../source/Plugins/Instruction/CMakeLists.txt |  2 +
 .../InstrumentationRuntime/CMakeLists.txt |  2 +
 lldb/source/Plugins/JITLoader/CMakeLists.txt  |  3 +
 lldb/source/Plugins/Language/CMakeLists.txt   |  6 ++
 .../Plugins/LanguageRuntime/CMakeLists.txt|  3 +
 .../Plugins/MemoryHistory/CMakeLists.txt  |  2 +
 .../Plugins/ObjectContainer/CMakeLists.txt|  2 +
 lldb/source/Plugins/ObjectFile/CMakeLists.txt |  2 +
 .../Plugins/OperatingSystem/CMakeLists.txt|  2 +
 lldb/source/Plugins/Platform/CMakeLists.txt   |  7 ++
 lldb/source/Plugins/Process/CMakeLists.txt|  5 ++
 .../Plugins/Process/Utility/CMakeLists.txt|  3 +
 lldb/source/Plugins/REPL/CMakeLists.txt   |  3 +
 .../RegisterTypeBuilder/CMakeLists.txt|  2 +
 .../Plugins/ScriptInterpreter/CMakeLists.txt  |  2 +
 .../Plugins/StructuredData/CMakeLists.txt |  2 +
 lldb/source/Plugins/SymbolFile/CMakeLists.txt |  7 ++
 .../Plugins/SymbolLocator/CMakeLists.txt  |  2 +
 .../Plugins/SymbolVendor/CMakeLists.txt   |  3 +
 .../Plugins/SystemRuntime/CMakeLists.txt  |  3 +
 lldb/source/Plugins/Trace/CMakeLists.txt  |  2 +
 .../Plugins/TraceExporter/CMakeLists.txt  |  2 +
 lldb/source/Plugins/TypeSystem/CMakeLists.txt |  4 +
 .../Plugins/UnwindAssembly/CMakeLists.txt |  2 +
 32 files changed, 221 insertions(+)
 create mode 100644 lldb/cmake/modules/LLDBLayeringCheck.cmake

diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 2aaf75dd87bc3..e3b72e94d4beb 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -37,6 +37,7 @@ endif()
 
 include(LLDBConfig)
 include(AddLLDB)
+include(LLDBLayeringCheck)
 
 set(LLDB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
 
@@ -127,6 +128,8 @@ add_subdirectory(source)
 add_subdirectory(tools)
 add_subdirectory(docs)
 
+check_lldb_plugin_layering()
+
 if (LLDB_ENABLE_PYTHON)
   if(LLDB_BUILD_FRAMEWORK)
 set(lldb_python_target_dir 
"${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")
diff --git a/lldb/cmake/modules/LLDBLayeringCheck.cmake 
b/lldb/cmake/modules/LLDBLayeringCheck.cmake
new file mode 100644
index 0..c09b95d98b66f
--- /dev/null
+++ b/lldb/cmake/modules/LLDBLayeringCheck.cmake
@@ -0,0 +1,76 @@
+foreach (scope DIRECTORY TARGET)
+  define_property(${scope} PROPERTY LLDB_PLUGIN_KIND INHERITED
+BRIEF_DOCS "LLDB plugin kind (Process, SymbolFile, etc."
+FULL_DOCS  "see lldb/docs/resources/contributing.rst"
+  )
+
+  define_property(${scope} PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES 
INHERITED
+BRIEF_DOCS "LLDB plugin kinds which the plugin can depend on"
+FULL_DOCS  "see lldb/docs/resources/contributing.rst"
+  )
+
+  define_property(${scope} PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES 
INHERITED
+BRIEF_DOCS "LLDB plugin kinds which are depended on for historic reasons."
+FULL_DOCS  "see lldb/docs/resources/contributing.rst"
+  )
+endforeach()
+
+option(LLDB_GENERATE_PLUGIN_DEP_GRAPH OFF)
+
+function(check_lldb_plugin_layering)
+  get_property(plugins GLOBAL PROPERTY LLDB_PLUGINS)
+  foreach (plugin ${plugins})
+get_property(plugin_kind TARGET ${plugin} PROPERTY LLDB_PLUGIN_KIND)
+get_property(acceptable_deps TARGET ${plugin}
+  PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES)
+get_property(tolerated_deps TARGET ${plugin}
+  PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES)
+
+# A plugin is always permitted to depend on its own kind for the purposes
+# subclassing. Ideally the intra-kind dependencies should not form a loop,
+# but we're not checking that here.
+list(APPEND acceptable_deps ${plugin_kind})
+
+list(APPEND all_plugin_kinds ${plugin_kind})
+
+get_property(link_libs TARGET ${plugin} PROPERTY LINK_LIBRARIES)
+foreach (link_lib ${link_libs})
+  if(link_lib IN_LIST plugins)
+get_property(lib_kind TARGET ${link_lib} PROPERTY LLDB_PLUGIN_KIND)
+if (lib_kind)
+  if (lib_kind IN_LIST acceptable_deps)
+set(dep_kind green)
+  elseif (lib_kind IN_LIST tolerated_deps)
+set(dep_kind ye

[Lldb-commits] [lldb] [lldb] upgrade HandleFrameFormatVariable callees to llvm::Expected (PR #144731)

2025-06-23 Thread Charles Zablit via lldb-commits

https://github.com/charles-zablit updated 
https://github.com/llvm/llvm-project/pull/144731

>From 3c9a3e5e9af0c9d58783c11490bda473ada84ef3 Mon Sep 17 00:00:00 2001
From: Charles Zablit 
Date: Wed, 18 Jun 2025 16:41:40 +0100
Subject: [PATCH 01/12] [lldb] upgrade HandleFrameFormatVariable callees to
 llvm::Expected

---
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 266 --
 1 file changed, 110 insertions(+), 156 deletions(-)

diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 0f18abb47591d..1810c07652a2b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -236,199 +236,140 @@ static bool PrettyPrintFunctionNameWithArgs(Stream 
&out_stream,
   return true;
 }
 
-static std::optional
-GetDemangledBasename(const SymbolContext &sc) {
+static llvm::Expected>
+GetAndValidateInfo(const SymbolContext &sc) {
   Mangled mangled = sc.GetPossiblyInlinedFunctionName();
   if (!mangled)
-return std::nullopt;
+return llvm::createStringError("Function does not have a mangled name.");
 
   auto demangled_name = mangled.GetDemangledName().GetStringRef();
   if (demangled_name.empty())
-return std::nullopt;
+return llvm::createStringError("Function does not have a demangled name.");
 
   const std::optional &info = mangled.GetDemangledInfo();
   if (!info)
-return std::nullopt;
+return llvm::createStringError("Function does not have demangled info.");
 
   // Function without a basename is nonsense.
   if (!info->hasBasename())
-return std::nullopt;
+return llvm::createStringError("Info do not have basename range.");
 
-  return demangled_name.slice(info->BasenameRange.first,
-  info->BasenameRange.second);
+  return std::make_pair(demangled_name, *info);
 }
 
-static std::optional
-GetDemangledTemplateArguments(const SymbolContext &sc) {
-  Mangled mangled = sc.GetPossiblyInlinedFunctionName();
-  if (!mangled)
-return std::nullopt;
+static llvm::Expected
+GetDemangledBasename(const SymbolContext &sc) {
+  auto info_or_err = GetAndValidateInfo(sc);
+  if (!info_or_err)
+return info_or_err.takeError();
 
-  auto demangled_name = mangled.GetDemangledName().GetStringRef();
-  if (demangled_name.empty())
-return std::nullopt;
+  auto [demangled_name, info] = *info_or_err;
 
-  const std::optional &info = mangled.GetDemangledInfo();
-  if (!info)
-return std::nullopt;
+  return demangled_name.slice(info.BasenameRange.first,
+  info.BasenameRange.second);
+}
 
-  // Function without a basename is nonsense.
-  if (!info->hasBasename())
-return std::nullopt;
+static llvm::Expected
+GetDemangledTemplateArguments(const SymbolContext &sc) {
+  auto info_or_err = GetAndValidateInfo(sc);
+  if (!info_or_err)
+return info_or_err.takeError();
+
+  auto [demangled_name, info] = *info_or_err;
 
-  if (info->ArgumentsRange.first < info->BasenameRange.second)
-return std::nullopt;
+  if (info.ArgumentsRange.first < info.BasenameRange.second)
+return llvm::createStringError("Arguments in info are invalid.");
 
-  return demangled_name.slice(info->BasenameRange.second,
-  info->ArgumentsRange.first);
+  return demangled_name.slice(info.BasenameRange.second,
+  info.ArgumentsRange.first);
 }
 
-static std::optional
+static llvm::Expected
 GetDemangledReturnTypeLHS(const SymbolContext &sc) {
-  Mangled mangled = sc.GetPossiblyInlinedFunctionName();
-  if (!mangled)
-return std::nullopt;
+  auto info_or_err = GetAndValidateInfo(sc);
+  if (!info_or_err)
+return info_or_err.takeError();
 
-  auto demangled_name = mangled.GetDemangledName().GetStringRef();
-  if (demangled_name.empty())
-return std::nullopt;
+  auto [demangled_name, info] = *info_or_err;
 
-  const std::optional &info = mangled.GetDemangledInfo();
-  if (!info)
-return std::nullopt;
+  if (info.ScopeRange.first >= demangled_name.size())
+return llvm::createStringError("Scope range is invalid.");
 
-  // Function without a basename is nonsense.
-  if (!info->hasBasename())
-return std::nullopt;
-
-  if (info->ScopeRange.first >= demangled_name.size())
-return std::nullopt;
-
-  return demangled_name.substr(0, info->ScopeRange.first);
+  return demangled_name.substr(0, info.ScopeRange.first);
 }
 
-static std::optional
+static llvm::Expected
 GetDemangledFunctionQualifiers(const SymbolContext &sc) {
-  Mangled mangled = sc.GetPossiblyInlinedFunctionName();
-  if (!mangled)
-return std::nullopt;
+  auto info_or_err = GetAndValidateInfo(sc);
+  if (!info_or_err)
+return info_or_err.takeError();
 
-  auto demangled_name = mangled.GetDemangledName().GetStringRef();
-  if (demangled_name.empty())
-return std::nullopt;
+  auto [demangled_name, info] = *info_or_err;
 
-  const std

[Lldb-commits] [lldb] [lldb][DWARF] Support retrieving DW_FORM_implicit_const value with DWARFDebugInfoEntry::GetAttributeValue (PR #145328)

2025-06-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

`DWARFFormValue::ExtractValue` has nothing to extract for 
`DW_FORM_implicit_const` since the value is stored in the abbreviation. 
`DWARFFormValue` expects the user to have set the value of the implicit_const. 
This patch does so in `GetAttributeValue`.

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


2 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (+3) 
- (modified) lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp (+58) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 8217c85f86014..13b68e747b1ce 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -403,6 +403,9 @@ dw_offset_t DWARFDebugInfoEntry::GetAttributeValue(
   const dw_offset_t attr_offset = offset;
   form_value.SetUnit(cu);
   form_value.SetForm(abbrevDecl->getFormByIndex(idx));
+  if (abbrevDecl->getAttrIsImplicitConstByIndex(idx))
+form_value.SetValue(abbrevDecl->getAttrImplicitConstValueByIndex(idx));
+
   if (form_value.ExtractValue(data, &offset)) {
 if (end_attr_offset_ptr)
   *end_attr_offset_ptr = offset;
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
index 3f61d1607073c..0da26d99ad383 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
@@ -395,6 +395,64 @@ TEST(DWARFDIETest, GetContextInFunction) {
   testing::ElementsAre(make_struct("struct_t")));
 }
 
+TEST(DWARFDIETest, GetAttributeValue_ImplicitConst) {
+  // Make sure we can correctly retrieve the value of an attribute
+  // that has a DW_FORM_implicit_const form.
+
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- ''
+  debug_abbrev:
+- ID:  0
+  Table:
+- Code:0x1
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+- Code:0x2
+  Tag: DW_TAG_subprogram
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_string
+- Attribute:   DW_AT_object_pointer
+  Form:DW_FORM_implicit_const
+  Value:   5
+  debug_info:
+- Version: 5
+  UnitType:DW_UT_compile
+  AddrSize:8
+  Entries:
+- AbbrCode:0x1
+- AbbrCode:0x2
+  Values:
+- Value:   0xDEADBEEFDEADBEEF
+  CStr:func
+- AbbrCode:0x0)";
+
+  YAMLModuleTester t(yamldata);
+  auto *symbol_file =
+  llvm::cast(t.GetModule()->GetSymbolFile());
+  DWARFUnit *unit = symbol_file->DebugInfo().GetUnitAtIndex(0);
+  ASSERT_TRUE(unit);
+
+  DWARFDIE subprogram = unit->DIE().GetFirstChild();
+  ASSERT_TRUE(subprogram);
+  dw_offset_t end_attr_offset;
+  DWARFFormValue form_value;
+  dw_offset_t offset = subprogram.GetDIE()->GetAttributeValue(
+  unit, DW_AT_object_pointer, form_value, &end_attr_offset);
+  EXPECT_EQ(form_value.Unsigned(), 5U);
+  EXPECT_GT(offset, 0U);
+  EXPECT_GT(end_attr_offset, 0U);
+}
+
 struct GetAttributesTestFixture : public testing::TestWithParam {};
 
 TEST_P(GetAttributesTestFixture, TestGetAttributes_IterationOrder) {

``




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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Support constant index encoding of DW_AT_object_pointer (PR #144998)

2025-06-23 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Disable flaky TestDetachResumes.py on Windows x86_64 (PR #145301)

2025-06-23 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] 6d8d4cf - [lldb] Disable flaky TestDetachResumes.py on Windows x86_64 (#145301)

2025-06-23 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2025-06-23T15:25:08+04:00
New Revision: 6d8d4cf9a46b3729732736ffe288f6b722d85121

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

LOG: [lldb] Disable flaky TestDetachResumes.py on Windows x86_64 (#145301)

See #144891 for details.

Added: 


Modified: 
lldb/test/API/commands/process/detach-resumes/TestDetachResumes.py

Removed: 




diff  --git 
a/lldb/test/API/commands/process/detach-resumes/TestDetachResumes.py 
b/lldb/test/API/commands/process/detach-resumes/TestDetachResumes.py
index 57727294ddc3d..db730574124b6 100644
--- a/lldb/test/API/commands/process/detach-resumes/TestDetachResumes.py
+++ b/lldb/test/API/commands/process/detach-resumes/TestDetachResumes.py
@@ -12,6 +12,11 @@
 class DetachResumesTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
+@skipIf(
+oslist=["windows"],
+archs=["x86_64"],
+bugnumber="github.com/llvm/llvm-project/issues/144891",
+)
 def test_detach_resumes(self):
 self.build()
 exe = self.getBuildArtifact()



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


[Lldb-commits] [lldb] Reapply "[lldb/cmake] Plugin layering enforcement mechanism (#144543)" (PR #145305)

2025-06-23 Thread David Spickett via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread via lldb-commits


@@ -1036,12 +1036,18 @@ void ObjectFilePECOFF::CreateSections(SectionList 
&unified_section_list) {
 m_sections_up->AddSection(header_sp);
 unified_section_list.AddSection(header_sp);
 
+std::vector truncated_dwarf_sections;
 const uint32_t nsects = m_sect_headers.size();
 for (uint32_t idx = 0; idx < nsects; ++idx) {
   llvm::StringRef sect_name = GetSectionName(m_sect_headers[idx]);
   ConstString const_sect_name(sect_name);
   SectionType section_type = GetSectionType(sect_name, 
m_sect_headers[idx]);
 
+  // Detect unknown sections matching ^\.debug_[a-z]$
+  if (section_type == eSectionTypeOther && sect_name.size() == 8 &&

Nerixyz wrote:

> Probably unlikely, but could the truncation change in the future to a 
> different size?

The truncation will always be 8 bytes, because that's how much space the 
section name has in the PE/COFF section header - it's basically a `char 
name[8]` field. For longer names, the linker has to write the section name into 
the string table and set the name in the section header to `/n` where `n` is 
the offset in the string table.

> Could we just check the section_type and prefix and issue a warning saying 
> "unrecognized section, possibly got truncated"?

That could be an additional diagnostic for unknown DWARF sections (should 
probably be there for other object files as well). If the section name is 8 
bytes, however, we can be sure this is from someone using link.exe.

As an extension, this could be present for `.lldbformatters` and 
`.lldbsummaries` as well. In this specific case, the matching could also 
consider `.lldbfor` and `.lldbsum`, because there are only two.

> Do we need the `size == 8` and `isLower` checks here?

We need the size check, but I removed the isLower check, because the indicator 
for DWARF is `.debug_`.

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


[Lldb-commits] [lldb] [lldb] upgrade HandleFrameFormatVariable callees to llvm::Expected (PR #144731)

2025-06-23 Thread Charles Zablit via lldb-commits

https://github.com/charles-zablit updated 
https://github.com/llvm/llvm-project/pull/144731

>From 3c9a3e5e9af0c9d58783c11490bda473ada84ef3 Mon Sep 17 00:00:00 2001
From: Charles Zablit 
Date: Wed, 18 Jun 2025 16:41:40 +0100
Subject: [PATCH 01/13] [lldb] upgrade HandleFrameFormatVariable callees to
 llvm::Expected

---
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 266 --
 1 file changed, 110 insertions(+), 156 deletions(-)

diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 0f18abb47591d..1810c07652a2b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -236,199 +236,140 @@ static bool PrettyPrintFunctionNameWithArgs(Stream 
&out_stream,
   return true;
 }
 
-static std::optional
-GetDemangledBasename(const SymbolContext &sc) {
+static llvm::Expected>
+GetAndValidateInfo(const SymbolContext &sc) {
   Mangled mangled = sc.GetPossiblyInlinedFunctionName();
   if (!mangled)
-return std::nullopt;
+return llvm::createStringError("Function does not have a mangled name.");
 
   auto demangled_name = mangled.GetDemangledName().GetStringRef();
   if (demangled_name.empty())
-return std::nullopt;
+return llvm::createStringError("Function does not have a demangled name.");
 
   const std::optional &info = mangled.GetDemangledInfo();
   if (!info)
-return std::nullopt;
+return llvm::createStringError("Function does not have demangled info.");
 
   // Function without a basename is nonsense.
   if (!info->hasBasename())
-return std::nullopt;
+return llvm::createStringError("Info do not have basename range.");
 
-  return demangled_name.slice(info->BasenameRange.first,
-  info->BasenameRange.second);
+  return std::make_pair(demangled_name, *info);
 }
 
-static std::optional
-GetDemangledTemplateArguments(const SymbolContext &sc) {
-  Mangled mangled = sc.GetPossiblyInlinedFunctionName();
-  if (!mangled)
-return std::nullopt;
+static llvm::Expected
+GetDemangledBasename(const SymbolContext &sc) {
+  auto info_or_err = GetAndValidateInfo(sc);
+  if (!info_or_err)
+return info_or_err.takeError();
 
-  auto demangled_name = mangled.GetDemangledName().GetStringRef();
-  if (demangled_name.empty())
-return std::nullopt;
+  auto [demangled_name, info] = *info_or_err;
 
-  const std::optional &info = mangled.GetDemangledInfo();
-  if (!info)
-return std::nullopt;
+  return demangled_name.slice(info.BasenameRange.first,
+  info.BasenameRange.second);
+}
 
-  // Function without a basename is nonsense.
-  if (!info->hasBasename())
-return std::nullopt;
+static llvm::Expected
+GetDemangledTemplateArguments(const SymbolContext &sc) {
+  auto info_or_err = GetAndValidateInfo(sc);
+  if (!info_or_err)
+return info_or_err.takeError();
+
+  auto [demangled_name, info] = *info_or_err;
 
-  if (info->ArgumentsRange.first < info->BasenameRange.second)
-return std::nullopt;
+  if (info.ArgumentsRange.first < info.BasenameRange.second)
+return llvm::createStringError("Arguments in info are invalid.");
 
-  return demangled_name.slice(info->BasenameRange.second,
-  info->ArgumentsRange.first);
+  return demangled_name.slice(info.BasenameRange.second,
+  info.ArgumentsRange.first);
 }
 
-static std::optional
+static llvm::Expected
 GetDemangledReturnTypeLHS(const SymbolContext &sc) {
-  Mangled mangled = sc.GetPossiblyInlinedFunctionName();
-  if (!mangled)
-return std::nullopt;
+  auto info_or_err = GetAndValidateInfo(sc);
+  if (!info_or_err)
+return info_or_err.takeError();
 
-  auto demangled_name = mangled.GetDemangledName().GetStringRef();
-  if (demangled_name.empty())
-return std::nullopt;
+  auto [demangled_name, info] = *info_or_err;
 
-  const std::optional &info = mangled.GetDemangledInfo();
-  if (!info)
-return std::nullopt;
+  if (info.ScopeRange.first >= demangled_name.size())
+return llvm::createStringError("Scope range is invalid.");
 
-  // Function without a basename is nonsense.
-  if (!info->hasBasename())
-return std::nullopt;
-
-  if (info->ScopeRange.first >= demangled_name.size())
-return std::nullopt;
-
-  return demangled_name.substr(0, info->ScopeRange.first);
+  return demangled_name.substr(0, info.ScopeRange.first);
 }
 
-static std::optional
+static llvm::Expected
 GetDemangledFunctionQualifiers(const SymbolContext &sc) {
-  Mangled mangled = sc.GetPossiblyInlinedFunctionName();
-  if (!mangled)
-return std::nullopt;
+  auto info_or_err = GetAndValidateInfo(sc);
+  if (!info_or_err)
+return info_or_err.takeError();
 
-  auto demangled_name = mangled.GetDemangledName().GetStringRef();
-  if (demangled_name.empty())
-return std::nullopt;
+  auto [demangled_name, info] = *info_or_err;
 
-  const std

[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread via lldb-commits

https://github.com/Nerixyz updated 
https://github.com/llvm/llvm-project/pull/145175

>From ebd8542451e1a0ecee83be48d4a630aff2ee3390 Mon Sep 17 00:00:00 2001
From: Nerixyz 
Date: Sat, 21 Jun 2025 17:36:58 +0200
Subject: [PATCH] [LLDB] Warn about truncated DWARF section names on Windows

---
 .../ObjectFile/PECOFF/ObjectFilePECOFF.cpp| 16 +
 .../Shell/ObjectFile/PECOFF/lit.local.cfg |  2 +-
 .../Shell/ObjectFile/PECOFF/truncated-dwarf.c |  7 
 lldb/test/Shell/helper/build.py   | 33 ---
 4 files changed, 52 insertions(+), 6 deletions(-)
 create mode 100644 lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c

diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp 
b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 4984445dcbab9..e4e59a8c7bdd5 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -1036,12 +1036,18 @@ void ObjectFilePECOFF::CreateSections(SectionList 
&unified_section_list) {
 m_sections_up->AddSection(header_sp);
 unified_section_list.AddSection(header_sp);
 
+std::vector truncated_dwarf_sections;
 const uint32_t nsects = m_sect_headers.size();
 for (uint32_t idx = 0; idx < nsects; ++idx) {
   llvm::StringRef sect_name = GetSectionName(m_sect_headers[idx]);
   ConstString const_sect_name(sect_name);
   SectionType section_type = GetSectionType(sect_name, 
m_sect_headers[idx]);
 
+  // Detect unknown sections matching ".debug_*"
+  if (section_type == eSectionTypeOther && sect_name.size() == 8 &&
+  sect_name.starts_with(".debug_"))
+truncated_dwarf_sections.emplace_back(sect_name);
+
   SectionSP section_sp(new Section(
   module_sp,   // Module to which this section belongs
   this,// Object file to which this section belongs
@@ -1071,6 +1077,16 @@ void ObjectFilePECOFF::CreateSections(SectionList 
&unified_section_list) {
   m_sections_up->AddSection(section_sp);
   unified_section_list.AddSection(section_sp);
 }
+
+if (!truncated_dwarf_sections.empty())
+  module_sp->ReportWarning(
+  "contains {} DWARF sections with truncated names ({}).\nWindows "
+  "executable (PECOFF) images produced by the default link.exe don't "
+  "include the required section names. A third party linker like "
+  "lld-link is required (compile with -fuse-ld=lld-link when using "
+  "Clang).",
+  truncated_dwarf_sections.size(),
+  llvm::join(truncated_dwarf_sections, ", "));
   }
 }
 
diff --git a/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg 
b/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg
index 9ef350be1dee2..1ae00d07fc3e6 100644
--- a/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg
+++ b/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.yaml', '.test']
+config.suffixes = ['.yaml', '.test', '.c']
diff --git a/lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c 
b/lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c
new file mode 100644
index 0..43dc252739ebc
--- /dev/null
+++ b/lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c
@@ -0,0 +1,7 @@
+// REQUIRES: target-windows
+// RUN: %build --compiler=clang-cl --force-dwarf-symbols --force-ms-link -o 
%t.exe -- %s
+// RUN: %lldb -f %t.exe 2>&1 | FileCheck %s
+
+int main(void) {}
+
+// CHECK: warning: {{.*}} contains 4 DWARF sections with truncated names 
(.debug_{{[a-z]}}, .debug_{{[a-z]}}, .debug_{{[a-z]}}, .debug_{{[a-z]}})
diff --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index caaa14f90af1c..c73aa8a11b396 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -173,6 +173,22 @@
 help="Specify the C/C++ standard.",
 )
 
+parser.add_argument(
+"--force-dwarf-symbols",
+dest="force_dwarf_symbols",
+action="store_true",
+default=False,
+help="When compiling with clang-cl on Windows, use DWARF instead of 
CodeView",
+)
+
+parser.add_argument(
+"--force-ms-link",
+dest="force_ms_link",
+action="store_true",
+default=False,
+help="When compiling with clang-cl on Windows, always use link.exe",
+)
+
 
 args = parser.parse_args(args=sys.argv[1:])
 
@@ -379,15 +395,20 @@ def __init__(self, toolchain_type, args):
 )
 
 if self.mode == "link" or self.mode == "compile-and-link":
-self.linker = (
-self._find_linker("link")
-if toolchain_type == "msvc"
-else self._find_linker("lld-link", args.tools_dir)
-)
+if toolchain_type == "msvc" or args.force_ms_link:
+search_paths = []
+if toolchain_type != "msvc":
+search_paths.append(
+os.path.dirname(find_executable("cl", args.tools_dir))
+)
+ 

[Lldb-commits] [lldb] [lldb] upgrade HandleFrameFormatVariable callees to llvm::Expected (PR #144731)

2025-06-23 Thread Charles Zablit via lldb-commits


@@ -74,24 +74,48 @@ struct DemangledNameInfo {
 return BasenameRange.second > BasenameRange.first;
   }
 
+  /// Returns \c true if `BasenameRange` is empty.
+  bool isBasenameEmpty() const {
+return BasenameRange.first == BasenameRange.second;

charles-zablit wrote:

Switched to `>` instead of `>=` for `hasBasename`. This "fixed" the tests that 
I originally broke 👍 

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


[Lldb-commits] [lldb] Reland "[lldb][target] Add progress report for wait-attaching to proc… (PR #145111)

2025-06-23 Thread David Spickett via lldb-commits

DavidSpickett wrote:

The test waits forever trying to attach, the AsyncInterrupt doesn't stop it 
doing that. I thought maybe these "threads" were not actually parallel so I 
tried multiprocessing, same result (also I'm not sure this would work because 
it uses a separate process).

I wonder if you would be better off actually attaching to something. Then you 
don't have to do all this waiting around, the progress message should still be 
there.

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


[Lldb-commits] [lldb] Reapply "[lldb/cmake] Plugin layering enforcement mechanism (#144543)" (PR #145305)

2025-06-23 Thread Pavel Labath via lldb-commits

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

>From be3083de00796539976b1bbfe25f90693296bd89 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 23 Jun 2025 12:13:54 +0200
Subject: [PATCH 1/3] Reapply "[lldb/cmake] Plugin layering enforcement
 mechanism (#144543)"

The only difference from the original PR are the added BRIEF and
FULL_DOCS arguments to define_property, which are required for
cmake<3.23.
---
 lldb/CMakeLists.txt   |  3 +
 lldb/cmake/modules/LLDBLayeringCheck.cmake| 76 +++
 lldb/docs/resources/contributing.rst  | 50 
 lldb/source/Plugins/ABI/CMakeLists.txt|  6 ++
 .../Plugins/Architecture/CMakeLists.txt   |  2 +
 .../Plugins/Disassembler/CMakeLists.txt   |  2 +
 .../Plugins/DynamicLoader/CMakeLists.txt  |  7 ++
 .../Plugins/ExpressionParser/CMakeLists.txt   |  2 +
 .../source/Plugins/Instruction/CMakeLists.txt |  2 +
 .../InstrumentationRuntime/CMakeLists.txt |  2 +
 lldb/source/Plugins/JITLoader/CMakeLists.txt  |  3 +
 lldb/source/Plugins/Language/CMakeLists.txt   |  6 ++
 .../Plugins/LanguageRuntime/CMakeLists.txt|  3 +
 .../Plugins/MemoryHistory/CMakeLists.txt  |  2 +
 .../Plugins/ObjectContainer/CMakeLists.txt|  2 +
 lldb/source/Plugins/ObjectFile/CMakeLists.txt |  2 +
 .../Plugins/OperatingSystem/CMakeLists.txt|  2 +
 lldb/source/Plugins/Platform/CMakeLists.txt   |  7 ++
 lldb/source/Plugins/Process/CMakeLists.txt|  5 ++
 .../Plugins/Process/Utility/CMakeLists.txt|  3 +
 lldb/source/Plugins/REPL/CMakeLists.txt   |  3 +
 .../RegisterTypeBuilder/CMakeLists.txt|  2 +
 .../Plugins/ScriptInterpreter/CMakeLists.txt  |  2 +
 .../Plugins/StructuredData/CMakeLists.txt |  2 +
 lldb/source/Plugins/SymbolFile/CMakeLists.txt |  7 ++
 .../Plugins/SymbolLocator/CMakeLists.txt  |  2 +
 .../Plugins/SymbolVendor/CMakeLists.txt   |  3 +
 .../Plugins/SystemRuntime/CMakeLists.txt  |  3 +
 lldb/source/Plugins/Trace/CMakeLists.txt  |  2 +
 .../Plugins/TraceExporter/CMakeLists.txt  |  2 +
 lldb/source/Plugins/TypeSystem/CMakeLists.txt |  4 +
 .../Plugins/UnwindAssembly/CMakeLists.txt |  2 +
 32 files changed, 221 insertions(+)
 create mode 100644 lldb/cmake/modules/LLDBLayeringCheck.cmake

diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 2aaf75dd87bc3..e3b72e94d4beb 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -37,6 +37,7 @@ endif()
 
 include(LLDBConfig)
 include(AddLLDB)
+include(LLDBLayeringCheck)
 
 set(LLDB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
 
@@ -127,6 +128,8 @@ add_subdirectory(source)
 add_subdirectory(tools)
 add_subdirectory(docs)
 
+check_lldb_plugin_layering()
+
 if (LLDB_ENABLE_PYTHON)
   if(LLDB_BUILD_FRAMEWORK)
 set(lldb_python_target_dir 
"${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")
diff --git a/lldb/cmake/modules/LLDBLayeringCheck.cmake 
b/lldb/cmake/modules/LLDBLayeringCheck.cmake
new file mode 100644
index 0..c09b95d98b66f
--- /dev/null
+++ b/lldb/cmake/modules/LLDBLayeringCheck.cmake
@@ -0,0 +1,76 @@
+foreach (scope DIRECTORY TARGET)
+  define_property(${scope} PROPERTY LLDB_PLUGIN_KIND INHERITED
+BRIEF_DOCS "LLDB plugin kind (Process, SymbolFile, etc."
+FULL_DOCS  "see lldb/docs/resources/contributing.rst"
+  )
+
+  define_property(${scope} PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES 
INHERITED
+BRIEF_DOCS "LLDB plugin kinds which the plugin can depend on"
+FULL_DOCS  "see lldb/docs/resources/contributing.rst"
+  )
+
+  define_property(${scope} PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES 
INHERITED
+BRIEF_DOCS "LLDB plugin kinds which are depended on for historic reasons."
+FULL_DOCS  "see lldb/docs/resources/contributing.rst"
+  )
+endforeach()
+
+option(LLDB_GENERATE_PLUGIN_DEP_GRAPH OFF)
+
+function(check_lldb_plugin_layering)
+  get_property(plugins GLOBAL PROPERTY LLDB_PLUGINS)
+  foreach (plugin ${plugins})
+get_property(plugin_kind TARGET ${plugin} PROPERTY LLDB_PLUGIN_KIND)
+get_property(acceptable_deps TARGET ${plugin}
+  PROPERTY LLDB_ACCEPTABLE_PLUGIN_DEPENDENCIES)
+get_property(tolerated_deps TARGET ${plugin}
+  PROPERTY LLDB_TOLERATED_PLUGIN_DEPENDENCIES)
+
+# A plugin is always permitted to depend on its own kind for the purposes
+# subclassing. Ideally the intra-kind dependencies should not form a loop,
+# but we're not checking that here.
+list(APPEND acceptable_deps ${plugin_kind})
+
+list(APPEND all_plugin_kinds ${plugin_kind})
+
+get_property(link_libs TARGET ${plugin} PROPERTY LINK_LIBRARIES)
+foreach (link_lib ${link_libs})
+  if(link_lib IN_LIST plugins)
+get_property(lib_kind TARGET ${link_lib} PROPERTY LLDB_PLUGIN_KIND)
+if (lib_kind)
+  if (lib_kind IN_LIST acceptable_deps)
+set(dep_kind green)
+  elseif (lib_kind IN_LIST tolerated_deps)
+set(dep_kind ye

[Lldb-commits] [lldb] [lldb-dap] Fix source references (PR #144364)

2025-06-23 Thread Ebuka Ezike via lldb-commits

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

>From 69545a26a9b1d7ee67818c2285bd942f94357203 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Mon, 16 Jun 2025 11:00:05 +0100
Subject: [PATCH 1/4] [lldb-dap] Fix source references

The protocol expects that `sourceReference` be less than `(2^31)-1`, but we 
currently represent memory address as source reference, this can be truncated 
either when sending through json or by the client. Instead, generate new source 
references based on the memory address.

Make the `CreateSource` function return an optional source.

# Conflicts:
#   lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
---
 .../TestDAP_breakpointAssembly.py | 14 ++---
 lldb/tools/lldb-dap/Breakpoint.cpp|  7 ++-
 lldb/tools/lldb-dap/DAP.cpp   | 19 +++
 lldb/tools/lldb-dap/DAP.h |  7 ++-
 .../Handler/DisassembleRequestHandler.cpp | 16 +++---
 .../Handler/LocationsRequestHandler.cpp   | 22 +++-
 .../lldb-dap/Handler/SourceRequestHandler.cpp | 32 +++-
 .../Handler/StackTraceRequestHandler.cpp  |  2 +-
 lldb/tools/lldb-dap/JSONUtils.cpp | 12 +++--
 lldb/tools/lldb-dap/JSONUtils.h   |  5 +-
 .../lldb-dap/Protocol/ProtocolRequests.h  |  2 +-
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  2 +-
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  3 +-
 lldb/tools/lldb-dap/ProtocolUtils.cpp | 51 ---
 lldb/tools/lldb-dap/ProtocolUtils.h   | 13 +++--
 lldb/tools/lldb-dap/SourceBreakpoint.cpp  |  8 ++-
 16 files changed, 152 insertions(+), 63 deletions(-)

diff --git 
a/lldb/test/API/tools/lldb-dap/breakpoint-assembly/TestDAP_breakpointAssembly.py
 
b/lldb/test/API/tools/lldb-dap/breakpoint-assembly/TestDAP_breakpointAssembly.py
index 8bccc2bcf4156..674bfe4199b4a 100644
--- 
a/lldb/test/API/tools/lldb-dap/breakpoint-assembly/TestDAP_breakpointAssembly.py
+++ 
b/lldb/test/API/tools/lldb-dap/breakpoint-assembly/TestDAP_breakpointAssembly.py
@@ -67,19 +67,19 @@ def test_break_on_invalid_source_reference(self):
 "Invalid sourceReference.",
 )
 
-# Verify that setting a breakpoint on a source reference without a 
symbol also fails
+# Verify that setting a breakpoint on a source reference that is not 
created fails
 response = self.dap_server.request_setBreakpoints(
-Source(source_reference=0), [1]
+Source(source_reference=200), [1]
 )
 self.assertIsNotNone(response)
 breakpoints = response["body"]["breakpoints"]
 self.assertEqual(len(breakpoints), 1)
-breakpoint = breakpoints[0]
+break_point = breakpoints[0]
 self.assertFalse(
-breakpoint["verified"], "Expected breakpoint to not be verified"
+break_point["verified"], "Expected breakpoint to not be verified"
 )
-self.assertIn("message", breakpoint, "Expected message to be present")
+self.assertIn("message", break_point, "Expected message to be present")
 self.assertEqual(
-breakpoint["message"],
-"Breakpoints in assembly without a valid symbol are not supported 
yet.",
+break_point["message"],
+"Invalid sourceReference.",
 )
diff --git a/lldb/tools/lldb-dap/Breakpoint.cpp 
b/lldb/tools/lldb-dap/Breakpoint.cpp
index ef5646c4c3d16..e1b073405ebb2 100644
--- a/lldb/tools/lldb-dap/Breakpoint.cpp
+++ b/lldb/tools/lldb-dap/Breakpoint.cpp
@@ -64,8 +64,11 @@ protocol::Breakpoint Breakpoint::ToProtocolBreakpoint() {
 "0x" + llvm::utohexstr(bp_addr.GetLoadAddress(m_bp.GetTarget()));
 breakpoint.instructionReference = formatted_addr;
 
-auto source = CreateSource(bp_addr, m_dap.target);
-if (!IsAssemblySource(source)) {
+std::optional source =
+CreateSource(bp_addr, m_dap.target, [this](lldb::addr_t addr) {
+  return m_dap.CreateSourceReference(addr);
+});
+if (source && !IsAssemblySource(*source)) {
   auto line_entry = bp_addr.GetLineEntry();
   const auto line = line_entry.GetLine();
   if (line != LLDB_INVALID_LINE_NUMBER)
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index c171b55951cb5..f0aad2ffef706 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -497,6 +497,25 @@ DAP::SendFormattedOutput(OutputType o, const char *format, 
...) {
   o, llvm::StringRef(buffer, std::min(actual_length, 
sizeof(buffer;
 }
 
+int32_t DAP::CreateSourceReference(lldb::addr_t address) {
+  auto iter = llvm::find(source_references, address);
+  if (iter != source_references.end())
+return std::distance(source_references.begin(), iter) + 1;
+
+  source_references.emplace_back(address);
+  return static_cast(source_references.size());
+}
+
+std::optional DAP::GetSourceReferenceAddress(int32_t reference) {
+  if (reference <= LLDB_DAP_IN

[Lldb-commits] [lldb] Reapply "[lldb/cmake] Plugin layering enforcement mechanism (#144543)" (PR #145305)

2025-06-23 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][DWARF] Support retrieving DW_FORM_implicit_const value with DWARFDebugInfoEntry::GetAttributeValue (PR #145328)

2025-06-23 Thread Michael Buch via lldb-commits

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

`DWARFFormValue::ExtractValue` has nothing to extract for 
`DW_FORM_implicit_const` since the value is stored in the abbreviation. 
`DWARFFormValue` expects the user to have set the value of the implicit_const. 
This patch does so in `GetAttributeValue`.

>From 77e83f6b3257c9cd387b773dc86c4ca8e23051b5 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 23 Jun 2025 14:19:16 +0100
Subject: [PATCH] [lldb][DWARF] Support retrieving DW_FORM_implicit_const value
 with DWARFDebugInfoEntry::GetAttributeValue

`DWARFFormValue::ExtractValue` has nothing to extract for
`DW_FORM_implicit_const` since the value is stored in the abbreviation.
`DWARFFormValue` expects the user to have set the value of the
implicit_const. This patch does so in `GetAttributeValue`.
---
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.cpp  |  3 +
 .../SymbolFile/DWARF/DWARFDIETest.cpp | 58 +++
 2 files changed, 61 insertions(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 8217c85f86014..13b68e747b1ce 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -403,6 +403,9 @@ dw_offset_t DWARFDebugInfoEntry::GetAttributeValue(
   const dw_offset_t attr_offset = offset;
   form_value.SetUnit(cu);
   form_value.SetForm(abbrevDecl->getFormByIndex(idx));
+  if (abbrevDecl->getAttrIsImplicitConstByIndex(idx))
+form_value.SetValue(abbrevDecl->getAttrImplicitConstValueByIndex(idx));
+
   if (form_value.ExtractValue(data, &offset)) {
 if (end_attr_offset_ptr)
   *end_attr_offset_ptr = offset;
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
index 3f61d1607073c..0da26d99ad383 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
@@ -395,6 +395,64 @@ TEST(DWARFDIETest, GetContextInFunction) {
   testing::ElementsAre(make_struct("struct_t")));
 }
 
+TEST(DWARFDIETest, GetAttributeValue_ImplicitConst) {
+  // Make sure we can correctly retrieve the value of an attribute
+  // that has a DW_FORM_implicit_const form.
+
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- ''
+  debug_abbrev:
+- ID:  0
+  Table:
+- Code:0x1
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+- Code:0x2
+  Tag: DW_TAG_subprogram
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_string
+- Attribute:   DW_AT_object_pointer
+  Form:DW_FORM_implicit_const
+  Value:   5
+  debug_info:
+- Version: 5
+  UnitType:DW_UT_compile
+  AddrSize:8
+  Entries:
+- AbbrCode:0x1
+- AbbrCode:0x2
+  Values:
+- Value:   0xDEADBEEFDEADBEEF
+  CStr:func
+- AbbrCode:0x0)";
+
+  YAMLModuleTester t(yamldata);
+  auto *symbol_file =
+  llvm::cast(t.GetModule()->GetSymbolFile());
+  DWARFUnit *unit = symbol_file->DebugInfo().GetUnitAtIndex(0);
+  ASSERT_TRUE(unit);
+
+  DWARFDIE subprogram = unit->DIE().GetFirstChild();
+  ASSERT_TRUE(subprogram);
+  dw_offset_t end_attr_offset;
+  DWARFFormValue form_value;
+  dw_offset_t offset = subprogram.GetDIE()->GetAttributeValue(
+  unit, DW_AT_object_pointer, form_value, &end_attr_offset);
+  EXPECT_EQ(form_value.Unsigned(), 5U);
+  EXPECT_GT(offset, 0U);
+  EXPECT_GT(end_attr_offset, 0U);
+}
+
 struct GetAttributesTestFixture : public testing::TestWithParam {};
 
 TEST_P(GetAttributesTestFixture, TestGetAttributes_IterationOrder) {

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


[Lldb-commits] [lldb] [lldb] Remove GDBRemoteCommunication::ConnectLocally (PR #145293)

2025-06-23 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] upgrade HandleFrameFormatVariable callees to llvm::Expected (PR #144731)

2025-06-23 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Add type summaries for MSVC STL strings (PR #143177)

2025-06-23 Thread Michael Buch via lldb-commits


@@ -1372,6 +1373,36 @@ static void 
LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   "${var.__y_} ${var.__m_} ${var.__wdl_}")));
 }
 
+static void RegisterStdStringSummaryProvider(
+const lldb::TypeCategoryImplSP &category_sp, llvm::StringRef string_ty,
+llvm::StringRef char_ty, lldb::TypeSummaryImplSP summary_sp) {
+  auto makeSpecifier = [](llvm::StringRef name) {
+return std::make_shared(
+name, eFormatterMatchExact);
+  };
+
+  category_sp->AddTypeSummary(makeSpecifier(string_ty), summary_sp);
+
+  // std::basic_string
+  category_sp->AddTypeSummary(
+  makeSpecifier((llvm::Twine("std::basic_string<") + char_ty + ">").str()),
+  summary_sp);
+  // std::basic_string,std::allocator >
+  category_sp->AddTypeSummary(
+  makeSpecifier((llvm::Twine("std::basic_string<") + char_ty +

Michael137 wrote:

Would using `llvm::formatv` here help with readability?

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


[Lldb-commits] [lldb] [lldb] upgrade HandleFrameFormatVariable callees to llvm::Expected (PR #144731)

2025-06-23 Thread Michael Buch via lldb-commits


@@ -74,24 +74,48 @@ struct DemangledNameInfo {
 return BasenameRange.second > BasenameRange.first;
   }
 
+  /// Returns \c true if `BasenameRange` is empty.
+  bool isBasenameEmpty() const {
+return BasenameRange.first == BasenameRange.second;

Michael137 wrote:

Thanks for adjusting. Mostly looks good now

Though I don't think `hasBasename` should allow for `start == end`. That's the 
one range that all `DemangledInfo` objects need to have to be considered valid. 
Could we keep that as `end > start`? I don't think that should break anything

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


[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread via lldb-commits

https://github.com/Nerixyz updated 
https://github.com/llvm/llvm-project/pull/145175

>From 39fa8adfc78c76a73ac1762eed31eecca789e8b6 Mon Sep 17 00:00:00 2001
From: Nerixyz 
Date: Sat, 21 Jun 2025 17:36:58 +0200
Subject: [PATCH] [LLDB] Warn about truncated DWARF section names on Windows

---
 .../ObjectFile/PECOFF/ObjectFilePECOFF.cpp| 16 +
 .../Shell/ObjectFile/PECOFF/lit.local.cfg |  2 +-
 .../Shell/ObjectFile/PECOFF/truncated-dwarf.c |  7 
 lldb/test/Shell/helper/build.py   | 33 ---
 4 files changed, 52 insertions(+), 6 deletions(-)
 create mode 100644 lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c

diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp 
b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 4984445dcbab9..17e5956bf668e 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -1036,12 +1036,18 @@ void ObjectFilePECOFF::CreateSections(SectionList 
&unified_section_list) {
 m_sections_up->AddSection(header_sp);
 unified_section_list.AddSection(header_sp);
 
+std::vector truncated_dwarf_sections;
 const uint32_t nsects = m_sect_headers.size();
 for (uint32_t idx = 0; idx < nsects; ++idx) {
   llvm::StringRef sect_name = GetSectionName(m_sect_headers[idx]);
   ConstString const_sect_name(sect_name);
   SectionType section_type = GetSectionType(sect_name, 
m_sect_headers[idx]);
 
+  // Detect unknown sections matching ".debug_*"
+  if (section_type == eSectionTypeOther && sect_name.size() == 8 &&
+  sect_name.starts_with(".debug_"))
+truncated_dwarf_sections.emplace_back(sect_name);
+
   SectionSP section_sp(new Section(
   module_sp,   // Module to which this section belongs
   this,// Object file to which this section belongs
@@ -1071,6 +1077,16 @@ void ObjectFilePECOFF::CreateSections(SectionList 
&unified_section_list) {
   m_sections_up->AddSection(section_sp);
   unified_section_list.AddSection(section_sp);
 }
+
+if (!truncated_dwarf_sections.empty())
+  module_sp->ReportWarning(
+  "contains {} DWARF sections with truncated names ({}).\nWindows "
+  "executable (PECOFF) images produced by the default link.exe can't "
+  "include the required section names. A third party linker like "
+  "lld-link is required (compile with -fuse-ld=lld-link when using "
+  "Clang).",
+  truncated_dwarf_sections.size(),
+  llvm::join(truncated_dwarf_sections, ", "));
   }
 }
 
diff --git a/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg 
b/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg
index 9ef350be1dee2..1ae00d07fc3e6 100644
--- a/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg
+++ b/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.yaml', '.test']
+config.suffixes = ['.yaml', '.test', '.c']
diff --git a/lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c 
b/lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c
new file mode 100644
index 0..43dc252739ebc
--- /dev/null
+++ b/lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c
@@ -0,0 +1,7 @@
+// REQUIRES: target-windows
+// RUN: %build --compiler=clang-cl --force-dwarf-symbols --force-ms-link -o 
%t.exe -- %s
+// RUN: %lldb -f %t.exe 2>&1 | FileCheck %s
+
+int main(void) {}
+
+// CHECK: warning: {{.*}} contains 4 DWARF sections with truncated names 
(.debug_{{[a-z]}}, .debug_{{[a-z]}}, .debug_{{[a-z]}}, .debug_{{[a-z]}})
diff --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index caaa14f90af1c..c73aa8a11b396 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -173,6 +173,22 @@
 help="Specify the C/C++ standard.",
 )
 
+parser.add_argument(
+"--force-dwarf-symbols",
+dest="force_dwarf_symbols",
+action="store_true",
+default=False,
+help="When compiling with clang-cl on Windows, use DWARF instead of 
CodeView",
+)
+
+parser.add_argument(
+"--force-ms-link",
+dest="force_ms_link",
+action="store_true",
+default=False,
+help="When compiling with clang-cl on Windows, always use link.exe",
+)
+
 
 args = parser.parse_args(args=sys.argv[1:])
 
@@ -379,15 +395,20 @@ def __init__(self, toolchain_type, args):
 )
 
 if self.mode == "link" or self.mode == "compile-and-link":
-self.linker = (
-self._find_linker("link")
-if toolchain_type == "msvc"
-else self._find_linker("lld-link", args.tools_dir)
-)
+if toolchain_type == "msvc" or args.force_ms_link:
+search_paths = []
+if toolchain_type != "msvc":
+search_paths.append(
+os.path.dirname(find_executable("cl", args.tools_dir))
+)
+ 

[Lldb-commits] [lldb] [lldb][nfc] Improve duplicated code in unexecuted breakpoint detection (PR #128724)

2025-06-23 Thread Felipe de Azevedo Piovezan via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread via lldb-commits


@@ -1071,6 +1077,15 @@ void ObjectFilePECOFF::CreateSections(SectionList 
&unified_section_list) {
   m_sections_up->AddSection(section_sp);
   unified_section_list.AddSection(section_sp);
 }
+
+if (!truncated_dwarf_sections.empty())
+  module_sp->ReportWarning(
+  "contains {} truncated DWARF sections ({}).\n"
+  "Executable images on Windows can't include the required names "
+  "when linking with the default link.exe. A third party linker like "
+  "lld-link is required (compile with -fuse-ld=lld-link on Clang).",

Nerixyz wrote:

Updated the message now to a mix of this and the one @mstorsjo suggested:

```
contains {} DWARF sections with truncated names ({}).\n
Windows executable (PECOFF) images produced by the default link.exe can't 
include the required section names. A third party linker like lld-link is 
required (compile with -fuse-ld=lld-link when using Clang).
```

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


[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread via lldb-commits


@@ -173,6 +173,22 @@
 help="Specify the C/C++ standard.",
 )
 
+parser.add_argument(

Nerixyz wrote:

There are no extra arguments here (unless I missed them). At least 
`--force-ms-link` would still need to be required because the script will use 
`lld-link` if `clang-cl` is the compiler.

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


[Lldb-commits] [lldb] [lldb][AArch64] Handle core file tag segments missing tag data (PR #145338)

2025-06-23 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/145338

In the same way that memory regions may be known from a core file but not 
readable, tag segments can also have no content. For example:

$ readelf --segments core
<...>
Program Headers:
  Type   Offset VirtAddr   PhysAddr
 FileSizMemSiz  Flags  Align
<...>
  LOAD   0x2000 0x93899000 0x
 0x 0x1000  RW 0x1000
<...>
  LOPROC+0x2 0x8000 0x93899000 0x
 0x 0x1000 0x0

This happens if you have a restricted coredump filter or size limit.

The area of virtual memory this segment covers is 0x1000, or 4096 bytes aka one 
tagged page. It's FileSiz would normally be 0x80. Tags are packed 2 per byte 
and granules are 16 bytes. 4096 / 16 / 2 = 128 or 0x80.

But here it has no data, and in theory a corrupt file might have some data but 
not all. This triggered an assert in UnpackTagsFromCoreFileSegment and crashed 
lldb.

To fix this I have made UnpackTagsFromCoreFileSegment return an expected and 
returned an error in this case instead of asserting. This will be seen by the 
user, as shown in the added API test.

>From 4b5a55eb2d7e8430eca4b76644b08fe705fbfec6 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 23 Jun 2025 14:29:53 +
Subject: [PATCH] [lldb][AArch64] Handle core file tag segments missing tag
 data

In the same way that memory regions may be known from a core file
but not readable, tag segments can also have no content. For example:

$ readelf --segments core
<...>
Program Headers:
  Type   Offset VirtAddr   PhysAddr
 FileSizMemSiz  Flags  Align
<...>
  LOAD   0x2000 0x93899000 0x
 0x 0x1000  RW 0x1000
<...>
  LOPROC+0x2 0x8000 0x93899000 0x
 0x 0x1000 0x0

This happens if you have a restricted coredump filter or size limit.

The area of virtual memory this segment covers is 0x1000, or 4096
bytes aka one tagged page. It's FileSiz would normally be 0x80.
Tags are packed 2 per byte and granules are 16 bytes. 4096 / 16 / 2 = 128
or 0x80.

But here it has no data, and in theory a corrupt file might have some
data but not all. This triggered an assert in UnpackTagsFromCoreFileSegment
and crashed lldb.

To fix this I have made UnpackTagsFromCoreFileSegment return an expected
and returned an error in this case instead of asserting. This will be seen
by the user, as shown in the added API test.
---
 lldb/include/lldb/Target/MemoryTagManager.h   |  12 +++--
 .../Utility/MemoryTagManagerAArch64MTE.cpp|  10 ++--
 .../Utility/MemoryTagManagerAArch64MTE.h  |   2 +-
 .../TestAArch64LinuxMTEMemoryTagCoreFile.py   |  24 +
 .../aarch64/mte_core_file/core.mte.notags | Bin 0 -> 32768 bytes
 .../MemoryTagManagerAArch64MTETest.cpp|  51 ++
 6 files changed, 81 insertions(+), 18 deletions(-)
 create mode 100644 lldb/test/API/linux/aarch64/mte_core_file/core.mte.notags

diff --git a/lldb/include/lldb/Target/MemoryTagManager.h 
b/lldb/include/lldb/Target/MemoryTagManager.h
index 6bd4180fff703..587e5ef4199d4 100644
--- a/lldb/include/lldb/Target/MemoryTagManager.h
+++ b/lldb/include/lldb/Target/MemoryTagManager.h
@@ -122,11 +122,15 @@ class MemoryTagManager {
   //
   // 'reader' will always be a wrapper around a CoreFile in real use
   // but allows testing without having to mock a CoreFile.
+  //
+  // This call may fail in the case that the core file segment does not contain
+  // enough data to read all the tags.
   typedef std::function CoreReaderFn;
-  std::vector virtual UnpackTagsFromCoreFileSegment(
-  CoreReaderFn reader, lldb::addr_t tag_segment_virtual_address,
-  lldb::addr_t tag_segment_data_address, lldb::addr_t addr,
-  size_t len) const = 0;
+  llvm::
+  Expected> virtual 
UnpackTagsFromCoreFileSegment(
+  CoreReaderFn reader, lldb::addr_t tag_segment_virtual_address,
+  lldb::addr_t tag_segment_data_address, lldb::addr_t addr,
+  size_t len) const = 0;
 
   // Pack uncompressed tags into their storage format (e.g. for gdb QMemTags).
   // Checks that each tag is within the expected value range.
diff --git a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp 
b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
index 7e25bc4ea2a28..9f60675e51904 100644
--- a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
+++ b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
@@ -247,7 +247,7 @@ MemoryTagManagerAArch64MTE::UnpackTagsData(const 
std::vector &tags,
   return unpacked;
 }

[Lldb-commits] [lldb] [lldb][AArch64] Handle core file tag segments missing tag data (PR #145338)

2025-06-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

In the same way that memory regions may be known from a core file but not 
readable, tag segments can also have no content. For example:

$ readelf --segments core
<...>
Program Headers:
  Type   Offset VirtAddr   PhysAddr
 FileSizMemSiz  Flags  Align
<...>
  LOAD   0x2000 0x93899000 0x
 0x 0x1000  RW 0x1000
<...>
  LOPROC+0x2 0x8000 0x93899000 0x
 0x 0x1000 0x0

This happens if you have a restricted coredump filter or size limit.

The area of virtual memory this segment covers is 0x1000, or 4096 bytes aka one 
tagged page. It's FileSiz would normally be 0x80. Tags are packed 2 per byte 
and granules are 16 bytes. 4096 / 16 / 2 = 128 or 0x80.

But here it has no data, and in theory a corrupt file might have some data but 
not all. This triggered an assert in UnpackTagsFromCoreFileSegment and crashed 
lldb.

To fix this I have made UnpackTagsFromCoreFileSegment return an expected and 
returned an error in this case instead of asserting. This will be seen by the 
user, as shown in the added API test.

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


6 Files Affected:

- (modified) lldb/include/lldb/Target/MemoryTagManager.h (+8-4) 
- (modified) lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp 
(+7-3) 
- (modified) lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h 
(+1-1) 
- (modified) 
lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py
 (+24) 
- (added) lldb/test/API/linux/aarch64/mte_core_file/core.mte.notags () 
- (modified) lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp 
(+41-10) 


``diff
diff --git a/lldb/include/lldb/Target/MemoryTagManager.h 
b/lldb/include/lldb/Target/MemoryTagManager.h
index 6bd4180fff703..587e5ef4199d4 100644
--- a/lldb/include/lldb/Target/MemoryTagManager.h
+++ b/lldb/include/lldb/Target/MemoryTagManager.h
@@ -122,11 +122,15 @@ class MemoryTagManager {
   //
   // 'reader' will always be a wrapper around a CoreFile in real use
   // but allows testing without having to mock a CoreFile.
+  //
+  // This call may fail in the case that the core file segment does not contain
+  // enough data to read all the tags.
   typedef std::function CoreReaderFn;
-  std::vector virtual UnpackTagsFromCoreFileSegment(
-  CoreReaderFn reader, lldb::addr_t tag_segment_virtual_address,
-  lldb::addr_t tag_segment_data_address, lldb::addr_t addr,
-  size_t len) const = 0;
+  llvm::
+  Expected> virtual 
UnpackTagsFromCoreFileSegment(
+  CoreReaderFn reader, lldb::addr_t tag_segment_virtual_address,
+  lldb::addr_t tag_segment_data_address, lldb::addr_t addr,
+  size_t len) const = 0;
 
   // Pack uncompressed tags into their storage format (e.g. for gdb QMemTags).
   // Checks that each tag is within the expected value range.
diff --git a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp 
b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
index 7e25bc4ea2a28..9f60675e51904 100644
--- a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
+++ b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
@@ -247,7 +247,7 @@ MemoryTagManagerAArch64MTE::UnpackTagsData(const 
std::vector &tags,
   return unpacked;
 }
 
-std::vector
+llvm::Expected>
 MemoryTagManagerAArch64MTE::UnpackTagsFromCoreFileSegment(
 CoreReaderFn reader, lldb::addr_t tag_segment_virtual_address,
 lldb::addr_t tag_segment_data_address, lldb::addr_t addr,
@@ -290,8 +290,12 @@ MemoryTagManagerAArch64MTE::UnpackTagsFromCoreFileSegment(
   const size_t bytes_copied =
   reader(tag_segment_data_address + file_offset_in_bytes, 
tag_bytes_to_read,
  tag_data.data());
-  UNUSED_IF_ASSERT_DISABLED(bytes_copied);
-  assert(bytes_copied == tag_bytes_to_read);
+  if (bytes_copied != tag_bytes_to_read) {
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"Could not read tags from core file segment. Segment "
+"is missing some or all tag data.");
+  }
 
   std::vector tags;
   tags.reserve(2 * tag_data.size());
diff --git a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h 
b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h
index 365e176e5b1da..79d24ce78ecee 100644
--- a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h
+++ b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h
@@ -44,7 +44,7 @@ class MemoryTagManagerAArch64MTE : public MemoryTagManager {
   UnpackTagsData(const std::vector &tags,
  size_t granules = 0) const override;
 
-  std::vector
+  llvm

[Lldb-commits] [lldb] [lldb][AArch64] Handle core file tag segments missing tag data (PR #145338)

2025-06-23 Thread David Spickett via lldb-commits

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

>From 4b5a55eb2d7e8430eca4b76644b08fe705fbfec6 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 23 Jun 2025 14:29:53 +
Subject: [PATCH 1/2] [lldb][AArch64] Handle core file tag segments missing tag
 data

In the same way that memory regions may be known from a core file
but not readable, tag segments can also have no content. For example:

$ readelf --segments core
<...>
Program Headers:
  Type   Offset VirtAddr   PhysAddr
 FileSizMemSiz  Flags  Align
<...>
  LOAD   0x2000 0x93899000 0x
 0x 0x1000  RW 0x1000
<...>
  LOPROC+0x2 0x8000 0x93899000 0x
 0x 0x1000 0x0

This happens if you have a restricted coredump filter or size limit.

The area of virtual memory this segment covers is 0x1000, or 4096
bytes aka one tagged page. It's FileSiz would normally be 0x80.
Tags are packed 2 per byte and granules are 16 bytes. 4096 / 16 / 2 = 128
or 0x80.

But here it has no data, and in theory a corrupt file might have some
data but not all. This triggered an assert in UnpackTagsFromCoreFileSegment
and crashed lldb.

To fix this I have made UnpackTagsFromCoreFileSegment return an expected
and returned an error in this case instead of asserting. This will be seen
by the user, as shown in the added API test.
---
 lldb/include/lldb/Target/MemoryTagManager.h   |  12 +++--
 .../Utility/MemoryTagManagerAArch64MTE.cpp|  10 ++--
 .../Utility/MemoryTagManagerAArch64MTE.h  |   2 +-
 .../TestAArch64LinuxMTEMemoryTagCoreFile.py   |  24 +
 .../aarch64/mte_core_file/core.mte.notags | Bin 0 -> 32768 bytes
 .../MemoryTagManagerAArch64MTETest.cpp|  51 ++
 6 files changed, 81 insertions(+), 18 deletions(-)
 create mode 100644 lldb/test/API/linux/aarch64/mte_core_file/core.mte.notags

diff --git a/lldb/include/lldb/Target/MemoryTagManager.h 
b/lldb/include/lldb/Target/MemoryTagManager.h
index 6bd4180fff703..587e5ef4199d4 100644
--- a/lldb/include/lldb/Target/MemoryTagManager.h
+++ b/lldb/include/lldb/Target/MemoryTagManager.h
@@ -122,11 +122,15 @@ class MemoryTagManager {
   //
   // 'reader' will always be a wrapper around a CoreFile in real use
   // but allows testing without having to mock a CoreFile.
+  //
+  // This call may fail in the case that the core file segment does not contain
+  // enough data to read all the tags.
   typedef std::function CoreReaderFn;
-  std::vector virtual UnpackTagsFromCoreFileSegment(
-  CoreReaderFn reader, lldb::addr_t tag_segment_virtual_address,
-  lldb::addr_t tag_segment_data_address, lldb::addr_t addr,
-  size_t len) const = 0;
+  llvm::
+  Expected> virtual 
UnpackTagsFromCoreFileSegment(
+  CoreReaderFn reader, lldb::addr_t tag_segment_virtual_address,
+  lldb::addr_t tag_segment_data_address, lldb::addr_t addr,
+  size_t len) const = 0;
 
   // Pack uncompressed tags into their storage format (e.g. for gdb QMemTags).
   // Checks that each tag is within the expected value range.
diff --git a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp 
b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
index 7e25bc4ea2a28..9f60675e51904 100644
--- a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
+++ b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
@@ -247,7 +247,7 @@ MemoryTagManagerAArch64MTE::UnpackTagsData(const 
std::vector &tags,
   return unpacked;
 }
 
-std::vector
+llvm::Expected>
 MemoryTagManagerAArch64MTE::UnpackTagsFromCoreFileSegment(
 CoreReaderFn reader, lldb::addr_t tag_segment_virtual_address,
 lldb::addr_t tag_segment_data_address, lldb::addr_t addr,
@@ -290,8 +290,12 @@ MemoryTagManagerAArch64MTE::UnpackTagsFromCoreFileSegment(
   const size_t bytes_copied =
   reader(tag_segment_data_address + file_offset_in_bytes, 
tag_bytes_to_read,
  tag_data.data());
-  UNUSED_IF_ASSERT_DISABLED(bytes_copied);
-  assert(bytes_copied == tag_bytes_to_read);
+  if (bytes_copied != tag_bytes_to_read) {
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"Could not read tags from core file segment. Segment "
+"is missing some or all tag data.");
+  }
 
   std::vector tags;
   tags.reserve(2 * tag_data.size());
diff --git a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h 
b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h
index 365e176e5b1da..79d24ce78ecee 100644
--- a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h
+++ b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h
@@ -44,7 +44,7 @@ class MemoryTagManagerAArch64MTE : public MemoryTagManager {
   UnpackTagsData

[Lldb-commits] [lldb] [lldb][AArch64] Handle core file tag segments missing tag data (PR #145338)

2025-06-23 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][AArch64] Handle core file tag segments missing tag data (PR #145338)

2025-06-23 Thread David Spickett via lldb-commits

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

>From 4b5a55eb2d7e8430eca4b76644b08fe705fbfec6 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 23 Jun 2025 14:29:53 +
Subject: [PATCH 1/3] [lldb][AArch64] Handle core file tag segments missing tag
 data

In the same way that memory regions may be known from a core file
but not readable, tag segments can also have no content. For example:

$ readelf --segments core
<...>
Program Headers:
  Type   Offset VirtAddr   PhysAddr
 FileSizMemSiz  Flags  Align
<...>
  LOAD   0x2000 0x93899000 0x
 0x 0x1000  RW 0x1000
<...>
  LOPROC+0x2 0x8000 0x93899000 0x
 0x 0x1000 0x0

This happens if you have a restricted coredump filter or size limit.

The area of virtual memory this segment covers is 0x1000, or 4096
bytes aka one tagged page. It's FileSiz would normally be 0x80.
Tags are packed 2 per byte and granules are 16 bytes. 4096 / 16 / 2 = 128
or 0x80.

But here it has no data, and in theory a corrupt file might have some
data but not all. This triggered an assert in UnpackTagsFromCoreFileSegment
and crashed lldb.

To fix this I have made UnpackTagsFromCoreFileSegment return an expected
and returned an error in this case instead of asserting. This will be seen
by the user, as shown in the added API test.
---
 lldb/include/lldb/Target/MemoryTagManager.h   |  12 +++--
 .../Utility/MemoryTagManagerAArch64MTE.cpp|  10 ++--
 .../Utility/MemoryTagManagerAArch64MTE.h  |   2 +-
 .../TestAArch64LinuxMTEMemoryTagCoreFile.py   |  24 +
 .../aarch64/mte_core_file/core.mte.notags | Bin 0 -> 32768 bytes
 .../MemoryTagManagerAArch64MTETest.cpp|  51 ++
 6 files changed, 81 insertions(+), 18 deletions(-)
 create mode 100644 lldb/test/API/linux/aarch64/mte_core_file/core.mte.notags

diff --git a/lldb/include/lldb/Target/MemoryTagManager.h 
b/lldb/include/lldb/Target/MemoryTagManager.h
index 6bd4180fff703..587e5ef4199d4 100644
--- a/lldb/include/lldb/Target/MemoryTagManager.h
+++ b/lldb/include/lldb/Target/MemoryTagManager.h
@@ -122,11 +122,15 @@ class MemoryTagManager {
   //
   // 'reader' will always be a wrapper around a CoreFile in real use
   // but allows testing without having to mock a CoreFile.
+  //
+  // This call may fail in the case that the core file segment does not contain
+  // enough data to read all the tags.
   typedef std::function CoreReaderFn;
-  std::vector virtual UnpackTagsFromCoreFileSegment(
-  CoreReaderFn reader, lldb::addr_t tag_segment_virtual_address,
-  lldb::addr_t tag_segment_data_address, lldb::addr_t addr,
-  size_t len) const = 0;
+  llvm::
+  Expected> virtual 
UnpackTagsFromCoreFileSegment(
+  CoreReaderFn reader, lldb::addr_t tag_segment_virtual_address,
+  lldb::addr_t tag_segment_data_address, lldb::addr_t addr,
+  size_t len) const = 0;
 
   // Pack uncompressed tags into their storage format (e.g. for gdb QMemTags).
   // Checks that each tag is within the expected value range.
diff --git a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp 
b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
index 7e25bc4ea2a28..9f60675e51904 100644
--- a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
+++ b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
@@ -247,7 +247,7 @@ MemoryTagManagerAArch64MTE::UnpackTagsData(const 
std::vector &tags,
   return unpacked;
 }
 
-std::vector
+llvm::Expected>
 MemoryTagManagerAArch64MTE::UnpackTagsFromCoreFileSegment(
 CoreReaderFn reader, lldb::addr_t tag_segment_virtual_address,
 lldb::addr_t tag_segment_data_address, lldb::addr_t addr,
@@ -290,8 +290,12 @@ MemoryTagManagerAArch64MTE::UnpackTagsFromCoreFileSegment(
   const size_t bytes_copied =
   reader(tag_segment_data_address + file_offset_in_bytes, 
tag_bytes_to_read,
  tag_data.data());
-  UNUSED_IF_ASSERT_DISABLED(bytes_copied);
-  assert(bytes_copied == tag_bytes_to_read);
+  if (bytes_copied != tag_bytes_to_read) {
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"Could not read tags from core file segment. Segment "
+"is missing some or all tag data.");
+  }
 
   std::vector tags;
   tags.reserve(2 * tag_data.size());
diff --git a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h 
b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h
index 365e176e5b1da..79d24ce78ecee 100644
--- a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h
+++ b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h
@@ -44,7 +44,7 @@ class MemoryTagManagerAArch64MTE : public MemoryTagManager {
   UnpackTagsData

[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread David Spickett via lldb-commits


@@ -173,6 +173,22 @@
 help="Specify the C/C++ standard.",
 )
 
+parser.add_argument(

DavidSpickett wrote:

Ok, these are fine then.

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


[Lldb-commits] [lldb] [lldb] Remove an unused local variable (NFC) (PR #145212)

2025-06-23 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread David Spickett via lldb-commits

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

LGTM.

Whether it can be extended to other known sections, that's up to you, but in 
its current DWARF specific form I like it.

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


[Lldb-commits] [lldb] [lldb-dap] Fix DAPError (PR #145010)

2025-06-23 Thread Jonas Devlieghere via lldb-commits

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

LGTM. I would suggest making the title of this PR a bit more descriptive (e.g. 
"Fix URL label in DAPError") before merging. 

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


[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread David Spickett via lldb-commits


@@ -1071,6 +1077,15 @@ void ObjectFilePECOFF::CreateSections(SectionList 
&unified_section_list) {
   m_sections_up->AddSection(section_sp);
   unified_section_list.AddSection(section_sp);
 }
+
+if (!truncated_dwarf_sections.empty())
+  module_sp->ReportWarning(
+  "contains {} truncated DWARF sections ({}).\n"
+  "Executable images on Windows can't include the required names "
+  "when linking with the default link.exe. A third party linker like "
+  "lld-link is required (compile with -fuse-ld=lld-link on Clang).",

DavidSpickett wrote:

Looks good now.

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


[Lldb-commits] [lldb] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Actually, add an entry to 
https://github.com/llvm/llvm-project/blob/main/llvm/docs/ReleaseNotes.md#changes-to-lldb
 as well.

It's not something I'd normally put in the release notes but it may appear in 
existing workflows when people update. If it's in the release notes we can 
refer them back to that to prove that it's expected to be there.

For example:
* LLDB now detects when the names of known DWARF sections in a PECOFF file have 
been truncated by link.exe, and advises the user how to avoid this.

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


[Lldb-commits] [lldb] [lldb-dap][test] Refactor runInTerminal Tests. (PR #144954)

2025-06-23 Thread Ivan Tadeu Ferreira Antunes Filho via lldb-commits


@@ -2,23 +2,35 @@
 Test lldb-dap RestartRequest.
 """
 
-import os
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import line_number
+from typing import Dict, Any, List
+
 import lldbdap_testcase
+from lldbsuite.test.decorators import skipIfWindows, skipIf, skipIfBuildType
+from lldbsuite.test.lldbtest import line_number
 
 
+@skipIfBuildType(["debug"])

itf wrote:

Currently I'm seeing errors because of this change when the config is None. 
I've created a PR:  https://github.com/llvm/llvm-project/pull/145342

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


[Lldb-commits] [lldb] [lldb] Add support for NoneType to decorator skipIfBuildType (PR #145342)

2025-06-23 Thread John Harrison via lldb-commits

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


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


[Lldb-commits] [lldb] [llvm] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-23 Thread via lldb-commits

https://github.com/Nerixyz updated 
https://github.com/llvm/llvm-project/pull/145175

>From 72f30f6d2a1dfb5523bafd4a535b078b3de5cfc6 Mon Sep 17 00:00:00 2001
From: Nerixyz 
Date: Sat, 21 Jun 2025 17:36:58 +0200
Subject: [PATCH] [LLDB] Warn about truncated DWARF section names on Windows

---
 .../ObjectFile/PECOFF/ObjectFilePECOFF.cpp| 16 +
 .../Shell/ObjectFile/PECOFF/lit.local.cfg |  2 +-
 .../Shell/ObjectFile/PECOFF/truncated-dwarf.c |  7 
 lldb/test/Shell/helper/build.py   | 33 ---
 llvm/docs/ReleaseNotes.md |  2 ++
 5 files changed, 54 insertions(+), 6 deletions(-)
 create mode 100644 lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c

diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp 
b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 4984445dcbab9..e4e59a8c7bdd5 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -1036,12 +1036,18 @@ void ObjectFilePECOFF::CreateSections(SectionList 
&unified_section_list) {
 m_sections_up->AddSection(header_sp);
 unified_section_list.AddSection(header_sp);
 
+std::vector truncated_dwarf_sections;
 const uint32_t nsects = m_sect_headers.size();
 for (uint32_t idx = 0; idx < nsects; ++idx) {
   llvm::StringRef sect_name = GetSectionName(m_sect_headers[idx]);
   ConstString const_sect_name(sect_name);
   SectionType section_type = GetSectionType(sect_name, 
m_sect_headers[idx]);
 
+  // Detect unknown sections matching ".debug_*"
+  if (section_type == eSectionTypeOther && sect_name.size() == 8 &&
+  sect_name.starts_with(".debug_"))
+truncated_dwarf_sections.emplace_back(sect_name);
+
   SectionSP section_sp(new Section(
   module_sp,   // Module to which this section belongs
   this,// Object file to which this section belongs
@@ -1071,6 +1077,16 @@ void ObjectFilePECOFF::CreateSections(SectionList 
&unified_section_list) {
   m_sections_up->AddSection(section_sp);
   unified_section_list.AddSection(section_sp);
 }
+
+if (!truncated_dwarf_sections.empty())
+  module_sp->ReportWarning(
+  "contains {} DWARF sections with truncated names ({}).\nWindows "
+  "executable (PECOFF) images produced by the default link.exe don't "
+  "include the required section names. A third party linker like "
+  "lld-link is required (compile with -fuse-ld=lld-link when using "
+  "Clang).",
+  truncated_dwarf_sections.size(),
+  llvm::join(truncated_dwarf_sections, ", "));
   }
 }
 
diff --git a/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg 
b/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg
index 9ef350be1dee2..1ae00d07fc3e6 100644
--- a/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg
+++ b/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.yaml', '.test']
+config.suffixes = ['.yaml', '.test', '.c']
diff --git a/lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c 
b/lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c
new file mode 100644
index 0..43dc252739ebc
--- /dev/null
+++ b/lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c
@@ -0,0 +1,7 @@
+// REQUIRES: target-windows
+// RUN: %build --compiler=clang-cl --force-dwarf-symbols --force-ms-link -o 
%t.exe -- %s
+// RUN: %lldb -f %t.exe 2>&1 | FileCheck %s
+
+int main(void) {}
+
+// CHECK: warning: {{.*}} contains 4 DWARF sections with truncated names 
(.debug_{{[a-z]}}, .debug_{{[a-z]}}, .debug_{{[a-z]}}, .debug_{{[a-z]}})
diff --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index caaa14f90af1c..c73aa8a11b396 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -173,6 +173,22 @@
 help="Specify the C/C++ standard.",
 )
 
+parser.add_argument(
+"--force-dwarf-symbols",
+dest="force_dwarf_symbols",
+action="store_true",
+default=False,
+help="When compiling with clang-cl on Windows, use DWARF instead of 
CodeView",
+)
+
+parser.add_argument(
+"--force-ms-link",
+dest="force_ms_link",
+action="store_true",
+default=False,
+help="When compiling with clang-cl on Windows, always use link.exe",
+)
+
 
 args = parser.parse_args(args=sys.argv[1:])
 
@@ -379,15 +395,20 @@ def __init__(self, toolchain_type, args):
 )
 
 if self.mode == "link" or self.mode == "compile-and-link":
-self.linker = (
-self._find_linker("link")
-if toolchain_type == "msvc"
-else self._find_linker("lld-link", args.tools_dir)
-)
+if toolchain_type == "msvc" or args.force_ms_link:
+search_paths = []
+if toolchain_type != "msvc":
+search_paths.append(
+os.path.dirname(find_executable("

[Lldb-commits] [lldb] [lldb][DWARF] Support retrieving DW_FORM_implicit_const value with DWARFDebugInfoEntry::GetAttributeValue (PR #145328)

2025-06-23 Thread Adrian Prantl via lldb-commits

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


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


[Lldb-commits] [lldb] Reland "[lldb][DWARF] Remove object_pointer from ParsedDWARFAttributes (#145065)" (PR #145126)

2025-06-23 Thread Adrian Prantl via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Fix flaky test (PR #145231)

2025-06-23 Thread Ebuka Ezike via lldb-commits


@@ -310,7 +310,7 @@ serveConnection(const Socket::SocketProtocol &protocol, 
const std::string &name,
 "DAP session (" + client_name +
 ") error: ");
   }
-
+  io->Close();

da-viper wrote:

Shoudn't this get closed via RAII when it is out of scope ? 
https://github.com/llvm/llvm-project/blob/1128a4fd2c3a70ba61eead2ce093a9c31aa2970e/lldb/source/Host/common/Socket.cpp#L173-L175

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


[Lldb-commits] [lldb] [lldb] Fix FindProcessImpl() for iOS simulators (PR #139174)

2025-06-23 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Fix URL label and error code in DAPError (PR #145010)

2025-06-23 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Fix flaky test (PR #145231)

2025-06-23 Thread via lldb-commits

https://github.com/DrSergei updated 
https://github.com/llvm/llvm-project/pull/145231

>From b3b919db7333ee20bc640e1b4b5a701891cc6443 Mon Sep 17 00:00:00 2001
From: Druzhkov Sergei 
Date: Thu, 19 Jun 2025 15:50:27 +0300
Subject: [PATCH] [lldb-dap] Fix flaky test

---
 lldb/test/API/tools/lldb-dap/server/TestDAP_server.py | 4 +++-
 lldb/tools/lldb-dap/tool/lldb-dap.cpp | 2 --
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py 
b/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py
index ed17044a220d4..2b0923db9cf82 100644
--- a/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py
+++ b/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py
@@ -101,7 +101,9 @@ def test_server_interrupt(self):
 # Interrupt the server which should disconnect all clients.
 process.send_signal(signal.SIGINT)
 
-self.dap_server.wait_for_terminated()
+# Wait for both events since they can happen in any order.
+self.dap_server.wait_for_event(["terminated", "exited"])
+self.dap_server.wait_for_event(["terminated", "exited"])
 self.assertIsNotNone(
 self.dap_server.exit_status,
 "Process exited before interrupting lldb-dap server",
diff --git a/lldb/tools/lldb-dap/tool/lldb-dap.cpp 
b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
index 9b9de5e21a742..af7080845239b 100644
--- a/lldb/tools/lldb-dap/tool/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
@@ -342,8 +342,6 @@ serveConnection(const Socket::SocketProtocol &protocol, 
const std::string &name,
  << " disconnected failed: "
  << llvm::toString(std::move(error)) << "\n";
   }
-  // Close the socket to ensure the DAP::Loop read finishes.
-  sock->Close();
 }
   }
 

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


[Lldb-commits] [lldb] [lldb] Fix SBMemoryRegionInfoListExtensions iter to yield unique refe… (PR #144815)

2025-06-23 Thread via lldb-commits

github-actions[bot] wrote:



@zyn-li Congratulations on having your first Pull Request (PR) merged into the 
LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a 
problem with a build, you may receive a report in an email or a comment on this 
PR.

Please check whether problems have been caused by your change specifically, as 
the builds can include changes from many authors. It is not uncommon for your 
change to be included in a build that fails due to someone else's changes, or 
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself. This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


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


[Lldb-commits] [lldb] ff865b6 - [lldb] Fix SBMemoryRegionInfoListExtensions iter to yield unique refe… (#144815)

2025-06-23 Thread via lldb-commits

Author: Zyn
Date: 2025-06-23T13:02:51-05:00
New Revision: ff865b639af05e366b108c7acb034e3d0e069376

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

LOG: [lldb] Fix SBMemoryRegionInfoListExtensions iter to yield unique refe… 
(#144815)

Added: 


Modified: 
lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i
lldb/test/API/python_api/find_in_memory/TestFindInMemory.py

Removed: 




diff  --git a/lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i 
b/lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i
index 29c0179c0ffe3..f565f45880119 100644
--- a/lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i
+++ b/lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i
@@ -9,8 +9,8 @@
   '''Iterate over all the memory regions in a lldb.SBMemoryRegionInfoList 
object.'''
   import lldb
   size = self.GetSize()
-  region = lldb.SBMemoryRegionInfo()
   for i in range(size):
+region = lldb.SBMemoryRegionInfo()
 self.GetMemoryRegionAtIndex(i, region)
 yield region
 %}

diff  --git a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py 
b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
index 1ef37d2ec9898..74de46dee98a5 100644
--- a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
+++ b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
@@ -154,14 +154,35 @@ def test_find_in_memory_unaligned(self):
 self.assertEqual(addr, lldb.LLDB_INVALID_ADDRESS)
 
 def test_memory_info_list_iterable(self):
-"""Make sure the SBMemoryRegionInfoList is iterable"""
+"""Make sure the SBMemoryRegionInfoList is iterable and each yielded 
object is unique"""
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 
 info_list = self.process.GetMemoryRegions()
 self.assertTrue(info_list.GetSize() > 0)
+
+collected_info = []
 try:
 for info in info_list:
-pass
+collected_info.append(info)
 except Exception:
 self.fail("SBMemoryRegionInfoList is not iterable")
+
+for i in range(len(collected_info)):
+region = lldb.SBMemoryRegionInfo()
+info_list.GetMemoryRegionAtIndex(i, region)
+
+self.assertEqual(
+collected_info[i],
+region,
+f"items {i}: iterator data should match index access data",
+)
+
+self.assertTrue(
+len(collected_info) >= 2, "Test requires at least 2 memory regions"
+)
+self.assertNotEqual(
+collected_info[0].GetRegionBase(),
+collected_info[1].GetRegionBase(),
+"Different items should have 
diff erent base addresses",
+)



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


[Lldb-commits] [lldb] [lldb] Fix SBMemoryRegionInfoListExtensions iter to yield unique refe… (PR #144815)

2025-06-23 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Eliminate check for HasLoadedSections (NFC) (PR #145366)

2025-06-23 Thread Jonas Devlieghere via lldb-commits

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

We can omit the call to Target::HasLoadedSections as Address::HasLoadedSections 
already "does the right thing" and returns LLDB_INVALID_ADDRESS if no sections 
are loaded.

>From 1df38e3639abcd0c009024e6d495113b421a520a Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Mon, 23 Jun 2025 10:17:17 -0700
Subject: [PATCH] [lldb] Eliminate check for HasLoadedSections (NFC)

We can omit the call to Target::HasLoadedSections as
Address::HasLoadedSections already "does the right thing" and returns
LLDB_INVALID_ADDRESS if no sections are loaded.
---
 lldb/source/Core/FormatEntity.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 8e3c3c18863fa..ca389bc88cf79 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -470,9 +470,7 @@ static bool DumpAddressAndContent(Stream &s, const 
SymbolContext *sc,
   bool print_file_addr_or_load_addr) {
   Target *target = Target::GetTargetFromContexts(exe_ctx, sc);
 
-  addr_t vaddr = LLDB_INVALID_ADDRESS;
-  if (target && target->HasLoadedSections())
-vaddr = addr.GetLoadAddress(target);
+  addr_t vaddr = addr.GetLoadAddress(target);
   if (vaddr == LLDB_INVALID_ADDRESS)
 vaddr = addr.GetFileAddress();
   if (vaddr == LLDB_INVALID_ADDRESS)

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


[Lldb-commits] [lldb] [lldb] Eliminate check for HasLoadedSections (NFC) (PR #145366)

2025-06-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

We can omit the call to Target::HasLoadedSections as Address::HasLoadedSections 
already "does the right thing" and returns LLDB_INVALID_ADDRESS if no sections 
are loaded.

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


1 Files Affected:

- (modified) lldb/source/Core/FormatEntity.cpp (+1-3) 


``diff
diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 8e3c3c18863fa..ca389bc88cf79 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -470,9 +470,7 @@ static bool DumpAddressAndContent(Stream &s, const 
SymbolContext *sc,
   bool print_file_addr_or_load_addr) {
   Target *target = Target::GetTargetFromContexts(exe_ctx, sc);
 
-  addr_t vaddr = LLDB_INVALID_ADDRESS;
-  if (target && target->HasLoadedSections())
-vaddr = addr.GetLoadAddress(target);
+  addr_t vaddr = addr.GetLoadAddress(target);
   if (vaddr == LLDB_INVALID_ADDRESS)
 vaddr = addr.GetFileAddress();
   if (vaddr == LLDB_INVALID_ADDRESS)

``




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


  1   2   >