[Lldb-commits] [lldb] [lldb] Add additional assertions to TestVTableValue.test_overwrite_vtable (PR #118719)

2024-12-04 Thread Alex Langford via lldb-commits

https://github.com/bulbazord created 
https://github.com/llvm/llvm-project/pull/118719

If this test fails, you're likely going to see something like "Assertion Error: 
A != B" which doesn't really give much explanation for why this failed.

Instead of ignoring the error, we should assert that it succeeded. This will 
lead to a better error message, for example:
`AssertionError: 'memory write failed for 0x102d7c018' is not success`

>From 7a4761dd3e4eb51c2c419852a48f99d1b1ad9127 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Wed, 4 Dec 2024 16:04:36 -0800
Subject: [PATCH] [lldb] Add additional assertions to
 TestVTableValue.test_overwrite_vtable

If this test fails, you're likely going to see something like "Assertion
Error: A != B" which doesn't really give much explanation for why this
failed.

Instead of ignoring the error, we should assert that it succeeded. This
will lead to a better error message, for example:
`AssertionError: 'memory write failed for 0x102d7c018' is not success`
---
 lldb/test/API/functionalities/vtable/TestVTableValue.py | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/functionalities/vtable/TestVTableValue.py 
b/lldb/test/API/functionalities/vtable/TestVTableValue.py
index bfc910614afa9e..f0076ea28f7599 100644
--- a/lldb/test/API/functionalities/vtable/TestVTableValue.py
+++ b/lldb/test/API/functionalities/vtable/TestVTableValue.py
@@ -2,7 +2,6 @@
 Make sure the getting a variable path works and doesn't crash.
 """
 
-
 import lldb
 import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.decorators import *
@@ -142,7 +141,12 @@ def test_overwrite_vtable(self):
 "\x01\x01\x01\x01\x01\x01\x01\x01" if is_64bit else 
"\x01\x01\x01\x01"
 )
 error = lldb.SBError()
-process.WriteMemory(vtable_addr, data, error)
+bytes_written = process.WriteMemory(vtable_addr, data, error)
+
+self.assertSuccess(error)
+self.assertGreater(
+bytes_written, 0, "Failed to overwrite first entry in vtable"
+)
 
 scribbled_child = vtable.GetChildAtIndex(0)
 self.assertEqual(

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


[Lldb-commits] [lldb] [lldb] Add additional assertions to TestVTableValue.test_overwrite_vtable (PR #118719)

2024-12-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Alex Langford (bulbazord)


Changes

If this test fails, you're likely going to see something like "Assertion Error: 
A != B" which doesn't really give much explanation for why this failed.

Instead of ignoring the error, we should assert that it succeeded. This will 
lead to a better error message, for example:
`AssertionError: 'memory write failed for 0x102d7c018' is not success`

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


1 Files Affected:

- (modified) lldb/test/API/functionalities/vtable/TestVTableValue.py (+6-2) 


``diff
diff --git a/lldb/test/API/functionalities/vtable/TestVTableValue.py 
b/lldb/test/API/functionalities/vtable/TestVTableValue.py
index bfc910614afa9e..f0076ea28f7599 100644
--- a/lldb/test/API/functionalities/vtable/TestVTableValue.py
+++ b/lldb/test/API/functionalities/vtable/TestVTableValue.py
@@ -2,7 +2,6 @@
 Make sure the getting a variable path works and doesn't crash.
 """
 
-
 import lldb
 import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.decorators import *
@@ -142,7 +141,12 @@ def test_overwrite_vtable(self):
 "\x01\x01\x01\x01\x01\x01\x01\x01" if is_64bit else 
"\x01\x01\x01\x01"
 )
 error = lldb.SBError()
-process.WriteMemory(vtable_addr, data, error)
+bytes_written = process.WriteMemory(vtable_addr, data, error)
+
+self.assertSuccess(error)
+self.assertGreater(
+bytes_written, 0, "Failed to overwrite first entry in vtable"
+)
 
 scribbled_child = vtable.GetChildAtIndex(0)
 self.assertEqual(

``




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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-04 Thread via lldb-commits


@@ -6754,12 +6754,12 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
   llvm::StringRef field_name = field->getName();
   if (field_name.empty()) {
 CompilerType field_type = GetType(field->getType());
+std::vector save_indices = child_indexes;
 child_indexes.push_back(child_idx);
 if (field_type.GetIndexOfChildMemberWithName(
 name, omit_empty_base_classes, child_indexes))
   return child_indexes.size();
-child_indexes.pop_back();
-
+child_indexes = save_indices;

cmtice wrote:

Done.

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


[Lldb-commits] [lldb] 095c3c9 - [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (#117808)

2024-12-04 Thread via lldb-commits

Author: cmtice
Date: 2024-12-04T10:49:12-08:00
New Revision: 095c3c9d6ec349815563d47f951d4590b3d18333

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

LOG: [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. 
(#117808)

LLDB can crash in TypeSystemClang::GetIndexOfChildMemberWithName, at a
point where it pushes an index onto the child_indexes vector, tries to
call itself recursively, then tries to pop the entry from child_indexes.
The problem is that the recursive call can clear child_indexes, so that
this code ends up trying to pop an already empty vector. This change
saves the old vector before the push, then restores the saved vector
rather than trying to pop.

Added: 
lldb/test/API/commands/target/anon-struct/Makefile
lldb/test/API/commands/target/anon-struct/TestTargetVarAnonStruct.py
lldb/test/API/commands/target/anon-struct/main.cpp

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

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 1a77c7cf9161a0..46c2002fe139d0 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -6754,12 +6754,12 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
   llvm::StringRef field_name = field->getName();
   if (field_name.empty()) {
 CompilerType field_type = GetType(field->getType());
+std::vector save_indices = child_indexes;
 child_indexes.push_back(child_idx);
 if (field_type.GetIndexOfChildMemberWithName(
 name, omit_empty_base_classes, child_indexes))
   return child_indexes.size();
-child_indexes.pop_back();
-
+child_indexes = std::move(save_indices);
   } else if (field_name == name) {
 // We have to add on the number of base classes to this index!
 child_indexes.push_back(

diff  --git a/lldb/test/API/commands/target/anon-struct/Makefile 
b/lldb/test/API/commands/target/anon-struct/Makefile
new file mode 100644
index 00..8b20bcb050
--- /dev/null
+++ b/lldb/test/API/commands/target/anon-struct/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/commands/target/anon-struct/TestTargetVarAnonStruct.py 
b/lldb/test/API/commands/target/anon-struct/TestTargetVarAnonStruct.py
new file mode 100644
index 00..869081dc6e5e4c
--- /dev/null
+++ b/lldb/test/API/commands/target/anon-struct/TestTargetVarAnonStruct.py
@@ -0,0 +1,33 @@
+"""
+Test handling of Anonymous Structs, especially that they don't crash lldb.
+"""
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+import os
+import shutil
+import time
+
+
+class TestFrameVarAnonStruct(TestBase):
+# If your test case doesn't stress debug info, then
+# set this to true.  That way it won't be run once for
+# each debug info format.
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_frame_var(self):
+self.build()
+self.do_test()
+
+def do_test(self):
+target = self.createTestTarget()
+
+# Verify that we don't crash in this case.
+self.expect(
+"target variable 'b.x'",
+error=True,
+substrs=["can't find global variable 'b.x'"],
+)

diff  --git a/lldb/test/API/commands/target/anon-struct/main.cpp 
b/lldb/test/API/commands/target/anon-struct/main.cpp
new file mode 100644
index 00..fbe26ea0ab8752
--- /dev/null
+++ b/lldb/test/API/commands/target/anon-struct/main.cpp
@@ -0,0 +1,14 @@
+struct A {
+  struct {
+int x = 1;
+  };
+} a;
+
+struct B {
+  // Anonymous struct inherits another struct.
+  struct : public A {
+int z = 3;
+  };
+} b;
+
+int main(int argc, char **argv) { return 0; }



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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-04 Thread via lldb-commits

https://github.com/cmtice closed 
https://github.com/llvm/llvm-project/pull/117808
___
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 links to LLVM issue tracked and pull requests (PR #118681)

2024-12-04 Thread Alex Langford via lldb-commits

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

Makes sense to me.

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


[Lldb-commits] [lldb] [lldb/DWARF] s/DWARFRangeList/llvm::DWARFAddressRangeVector (PR #116620)

2024-12-04 Thread Alex Langford via lldb-commits

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

Looks ok to me. Thanks!

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


[Lldb-commits] [lldb] 9302043 - [lldb-dap] Fix links to LLVM issue tracker and pull requests (#118681)

2024-12-04 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-12-04T11:04:05-08:00
New Revision: 9302043bef24519b95ffce86569ca7c7c97300e9

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

LOG: [lldb-dap] Fix links to LLVM issue tracker and pull requests (#118681)

Currently, the link to the issue tracker takes you to the Github source
repository, rather than the Github issue tracker. This fixes the link
and includes the lldb-dap label in both the issue and PR URL.

Added: 


Modified: 
lldb/tools/lldb-dap/README.md

Removed: 




diff  --git a/lldb/tools/lldb-dap/README.md b/lldb/tools/lldb-dap/README.md
index 8196dfdd5073c8..123869a033724f 100644
--- a/lldb/tools/lldb-dap/README.md
+++ b/lldb/tools/lldb-dap/README.md
@@ -324,8 +324,8 @@ API for handling a custom event from an extension.
 ## Contributing
 
 `lldb-dap` and `lldb` are developed under the umbrella of the [LLVM 
project](https://llvm.org/).
-The source code is [part of the LLVM 
repository](https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-dap) 
on Github.
-We use Github's [issue 
tracker](https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-dap) 
and patches can be submitted via [pull 
requests](https://github.com/llvm/llvm-project/pulls).
+The source code is part of the [LLVM 
repository](https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-dap) 
on Github.
+We use Github's [issue 
tracker](https://github.com/llvm/llvm-project/issues?q=label%3Alldb-dap) and 
patches can be submitted via [pull 
requests](https://github.com/llvm/llvm-project/pulls?q=label%3Alldb-dap).
 Furthermore, there is a [LLDB 
category](https://discourse.llvm.org/c/subprojects/lldb/8) on the LLVM 
discourse forum.
 
 For instructions on how to get started with development on lldb-dap, see the 
"[Contributing to lldb-dap](https://lldb.llvm.org/resources/lldbdap.html)"



___
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 links to LLVM issue tracker and pull requests (PR #118681)

2024-12-04 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere edited 
https://github.com/llvm/llvm-project/pull/118681
___
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 links to LLVM issue tracker and pull requests (PR #118681)

2024-12-04 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [lldb] [lldb] When using Socket to listen on `localhost:0` on systems supporting ting ipv4 and ipv6 the second socket to initialize will not update the listening address correctly after

2024-12-04 Thread John Harrison via lldb-commits

ashgti wrote:

118673 Should fix the fature

https://github.com/llvm/llvm-project/pull/118565
___
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 links to LLVM issue tracker and pull requests (PR #118681)

2024-12-04 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] 2e425bf - Reapply "[lldb][dwarf] Compute fully qualified names on simplified template names with DWARFTypePrinter (#117071)"

2024-12-04 Thread Zequan Wu via lldb-commits

Author: Zequan Wu
Date: 2024-12-04T13:05:36-08:00
New Revision: 2e425bf629f80c8f8582c266d25a384e7549198d

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

LOG: Reapply "[lldb][dwarf] Compute fully qualified names on simplified 
template names with DWARFTypePrinter (#117071)"

9de73b20404f0b2db1cbf70d164cfe0789d5bb94 lands a fix to DWARFTypePrinter that 
is used by lldb in this change.

Added: 
lldb/test/Shell/SymbolFile/DWARF/x86/simplified-template-names.cpp

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
llvm/lib/DebugInfo/DWARF/DWARFDie.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index d9bdeb560e1220..37c1132c1c9f9a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -45,6 +45,7 @@
 #include "clang/AST/Type.h"
 #include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/DebugInfo/DWARF/DWARFTypePrinter.h"
 #include "llvm/Demangle/Demangle.h"
 
 #include 
@@ -826,11 +827,11 @@ std::string 
DWARFASTParserClang::GetDIEClassTemplateParams(DWARFDIE die) {
   if (llvm::StringRef(die.GetName()).contains("<"))
 return {};
 
-  TypeSystemClang::TemplateParameterInfos template_param_infos;
-  if (ParseTemplateParameterInfos(die, template_param_infos))
-return m_ast.PrintTemplateParams(template_param_infos);
-
-  return {};
+  std::string name;
+  llvm::raw_string_ostream os(name);
+  llvm::DWARFTypePrinter type_printer(os);
+  type_printer.appendAndTerminateTemplateParameters(die);
+  return name;
 }
 
 void DWARFASTParserClang::MapDeclDIEToDefDIE(
@@ -1618,9 +1619,9 @@ void DWARFASTParserClang::GetUniqueTypeNameAndDeclaration(
 case DW_TAG_structure_type:
 case DW_TAG_union_type: {
   if (const char *class_union_struct_name = parent_decl_ctx_die.GetName()) 
{
-qualified_name.insert(
-0, GetDIEClassTemplateParams(parent_decl_ctx_die));
 qualified_name.insert(0, "::");
+qualified_name.insert(0,
+  GetDIEClassTemplateParams(parent_decl_ctx_die));
 qualified_name.insert(0, class_union_struct_name);
   }
   parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
@@ -1673,6 +1674,12 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
   if (attrs.name) {
 GetUniqueTypeNameAndDeclaration(die, cu_language, unique_typename,
 unique_decl);
+if (log) {
+  dwarf->GetObjectFile()->GetModule()->LogMessage(
+  log, "SymbolFileDWARF({0:p}) - {1:x16}: {2} has unique name: {3} ",
+  static_cast(this), die.GetID(), DW_TAG_value_to_name(tag),
+  unique_typename.AsCString());
+}
 if (UniqueDWARFASTType *unique_ast_entry_type =
 dwarf->GetUniqueDWARFASTTypeMap().Find(
 unique_typename, die, unique_decl, byte_size,

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
index 235343d2271223..d92de658a49e89 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
@@ -24,9 +24,11 @@ class DWARFUnit;
 class DWARFDebugInfoEntry;
 class DWARFDeclContext;
 class SymbolFileDWARF;
+class DWARFFormValue;
 
 class DWARFBaseDIE {
 public:
+  using DWARFFormValue = dwarf::DWARFFormValue;
   DWARFBaseDIE() = default;
 
   DWARFBaseDIE(DWARFUnit *cu, DWARFDebugInfoEntry *die)
@@ -117,6 +119,12 @@ class DWARFBaseDIE {
   enum class Recurse : bool { no, yes };
   DWARFAttributes GetAttributes(Recurse recurse = Recurse::yes) const;
 
+  // The following methods use LLVM naming convension in order to be are used 
by
+  // LLVM libraries.
+  dw_tag_t getTag() const { return Tag(); }
+
+  const char *getShortName() const { return GetName(); }
+
 protected:
   DWARFUnit *m_cu = nullptr;
   DWARFDebugInfoEntry *m_die = nullptr;

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
inde

[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)

2024-12-04 Thread John Harrison via lldb-commits

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

>From 547549573aba86c9bf9b9c2c189d49a3d8f62413 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 2 Dec 2024 08:36:52 -0800
Subject: [PATCH 1/2] [lldb-dap] Refactoring lldb-dap listening mode to support
 multiple connections.

This adjusts the lldb-dap listening mode to allow for multiple connections. 
Each client gets a new instanceo of DAP and an associated lldb::SBDebugger 
instance.
---
 .../test/tools/lldb-dap/dap_server.py |  91 +++--
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  29 +-
 lldb/test/API/tools/lldb-dap/server/Makefile  |   3 +
 .../tools/lldb-dap/server/TestDAP_server.py   |  72 
 lldb/test/API/tools/lldb-dap/server/main.c|   6 +
 lldb/tools/lldb-dap/CMakeLists.txt|   9 +-
 lldb/tools/lldb-dap/DAP.cpp   | 103 +++---
 lldb/tools/lldb-dap/DAP.h |  70 ++--
 lldb/tools/lldb-dap/IOStream.cpp  |  27 +-
 lldb/tools/lldb-dap/IOStream.h|   8 +-
 lldb/tools/lldb-dap/Options.td|  13 +-
 lldb/tools/lldb-dap/OutputRedirector.cpp  |  44 ++-
 lldb/tools/lldb-dap/OutputRedirector.h|  35 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  | 313 +++---
 14 files changed, 555 insertions(+), 268 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/server/Makefile
 create mode 100644 lldb/test/API/tools/lldb-dap/server/TestDAP_server.py
 create mode 100644 lldb/test/API/tools/lldb-dap/server/main.c

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 c29992ce9c7848..37679462118531 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
@@ -903,7 +903,7 @@ def request_setBreakpoints(self, file_path, line_array, 
data=None):
 "sourceModified": False,
 }
 if line_array is not None:
-args_dict["lines"] = "%s" % line_array
+args_dict["lines"] = line_array
 breakpoints = []
 for i, line in enumerate(line_array):
 breakpoint_data = None
@@ -1150,38 +1150,42 @@ def request_setInstructionBreakpoints(self, 
memory_reference=[]):
 }
 return self.send_recv(command_dict)
 
+
 class DebugAdaptorServer(DebugCommunication):
 def __init__(
 self,
 executable=None,
-port=None,
+launch=True,
+connection=None,
 init_commands=[],
 log_file=None,
 env=None,
 ):
 self.process = None
-if executable is not None:
-adaptor_env = os.environ.copy()
-if env is not None:
-adaptor_env.update(env)
-
-if log_file:
-adaptor_env["LLDBDAP_LOG"] = log_file
-self.process = subprocess.Popen(
-[executable],
-stdin=subprocess.PIPE,
-stdout=subprocess.PIPE,
-stderr=subprocess.PIPE,
-env=adaptor_env,
+if launch:
+self.process, connection = DebugAdaptorServer.launch(
+executable,
+connection=connection,
+log_file=log_file,
+env=env,
 )
+
+if connection:
+if connection.startswith("unix-connect://"):  # 
unix-connect:///path
+s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+s.connect(connection.removeprefix("unix-connect://"))
+elif connection.startswith("connection://"):  # 
connection://[host]:port
+host, port = 
connection.removeprefix("connection://").rsplit(":", 1)
+# create_connection with try both ipv4 and ipv6.
+s = socket.create_connection((host.strip("[]"), int(port)))
+else:
+raise ValueError("invalid connection: {}".format(connection))
 DebugCommunication.__init__(
-self, self.process.stdout, self.process.stdin, init_commands, 
log_file
+self, s.makefile("rb"), s.makefile("wb"), init_commands, 
log_file
 )
-elif port is not None:
-s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-s.connect(("127.0.0.1", port))
+else:
 DebugCommunication.__init__(
-self, s.makefile("r"), s.makefile("w"), init_commands
+self, self.process.stdout, self.process.stdin, init_commands, 
log_file
 )
 
 def get_pid(self):
@@ -1196,6 +1200,53 @@ def terminate(self):
 self.process.wait()
 self.process = None
 
+@classmethod
+def launch(
+cls, executable: str, /, connection=None, log_file=None, env=None
+) -> tuple[subprocess.Popen, str]:
+adaptor_env = os

[Lldb-commits] [lldb] [LLDB] Fix error returns in CastToBasicType and CastToEnumType in ValueObject. (PR #117401)

2024-12-04 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl commented:

Thanks!

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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-04 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-04 Thread Michael Buch via lldb-commits


@@ -0,0 +1,19 @@
+struct A {
+  struct {
+int x = 1;
+  };
+  int y = 2;

Michael137 wrote:

Is `y` necessary for the reproducer?

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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-04 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-04 Thread Michael Buch via lldb-commits


@@ -0,0 +1,19 @@
+struct A {
+  struct {
+int x = 1;
+  };
+  int y = 2;
+} a;
+
+struct B {
+  // Anonymous struct inherits another struct.
+  struct : public A {
+int z = 3;
+  };
+  int w = 4;

Michael137 wrote:

Are `w` and `a` necessary for the reproducer?

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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-04 Thread Michael Buch via lldb-commits

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

LGTM, happy to postpone clean up this function in a separate PR.

Left some comments on the test

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


[Lldb-commits] [lldb] [LLDB] Fix error returns in CastToBasicType and CastToEnumType in ValueObject. (PR #117401)

2024-12-04 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb/DWARF] s/DWARFRangeList/llvm::DWARFAddressRangeVector (PR #116620)

2024-12-04 Thread Pavel Labath via lldb-commits

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

>From 5cca8f301abde9333715e97d671afc23d75b9acd Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 18 Nov 2024 14:33:40 +0100
Subject: [PATCH] [lldb/DWARF] s/DWARFRangeList/llvm::DWARFAddressRangeVector

The main difference is that the llvm class (just a std::vector in
disguise) is not sorted. It turns out this isn't an issue because the
callers either:
- ignore the range list;
- convert it to a different format (which is then sorted);
- or query the minimum value (which is faster than sorting)

The last case is something I want to get rid of in a followup as a part
of removing the assumption that function's entry point is also its
lowest address.
---
 lldb/include/lldb/Core/dwarf.h|  3 -
 lldb/source/Plugins/SymbolFile/DWARF/DIERef.h |  3 +-
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  3 +-
 .../SymbolFile/DWARF/DWARFCompileUnit.cpp | 19 ++--
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 43 +
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   | 11 ++-
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.cpp  | 96 +--
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.h| 20 ++--
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp| 67 ++---
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  7 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 81 +---
 11 files changed, 185 insertions(+), 168 deletions(-)

diff --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h
index e162a090ba7c97..4de5c8f24db02c 100644
--- a/lldb/include/lldb/Core/dwarf.h
+++ b/lldb/include/lldb/Core/dwarf.h
@@ -9,7 +9,6 @@
 #ifndef LLDB_CORE_DWARF_H
 #define LLDB_CORE_DWARF_H
 
-#include "lldb/Utility/RangeMap.h"
 #include 
 
 // Get the DWARF constant definitions from llvm
@@ -40,6 +39,4 @@ typedef uint64_t dw_offset_t; // Dwarf Debug Information 
Entry offset for any
 
 #define DW_EH_PE_MASK_ENCODING 0x0F
 
-typedef lldb_private::RangeVector DWARFRangeList;
-
 #endif // LLDB_CORE_DWARF_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
index ad443aacb46ecc..69be0aa1280c16 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
@@ -10,7 +10,8 @@
 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DIEREF_H
 
 #include "lldb/Core/dwarf.h"
-#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-types.h"
 #include 
 #include 
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index d9bdeb560e1220..05d994ae82d8d4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -45,6 +45,7 @@
 #include "clang/AST/Type.h"
 #include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
 #include "llvm/Demangle/Demangle.h"
 
 #include 
@@ -2353,7 +2354,7 @@ 
DWARFASTParserClang::ConstructDemangledNameFromDWARF(const DWARFDIE &die) {
 
 Function *DWARFASTParserClang::ParseFunctionFromDWARF(
 CompileUnit &comp_unit, const DWARFDIE &die, AddressRanges func_ranges) {
-  DWARFRangeList unused_func_ranges;
+  llvm::DWARFAddressRangesVector unused_func_ranges;
   const char *name = nullptr;
   const char *mangled = nullptr;
   std::optional decl_file;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index ec4c297cf7e164..7f2edbfa95feef 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -8,11 +8,13 @@
 
 #include "DWARFCompileUnit.h"
 #include "DWARFDebugAranges.h"
+#include "LogChannelDWARF.h"
 #include "SymbolFileDWARFDebugMap.h"
 
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/LineTable.h"
 #include "lldb/Utility/Stream.h"
+#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -41,14 +43,17 @@ void DWARFCompileUnit::BuildAddressRangeTable(
 
   const dw_offset_t cu_offset = GetOffset();
   if (die) {
-DWARFRangeList ranges =
+llvm::Expected ranges =
 die->GetAttributeAddressRanges(this, /*check_hi_lo_pc=*/true);
-for (const DWARFRangeList::Entry &range : ranges)
-  debug_aranges->AppendRange(cu_offset, range.GetRangeBase(),
- range.GetRangeEnd());
-
-if (!ranges.IsEmpty())
-  return;
+if (ranges) {
+  for (const llvm::DWARFAddressRange &range : *ranges)
+debug_aranges->AppendRange(cu_offset, range.LowPC, range.HighPC);
+  if (!ranges->empty())
+return;
+} else {
+  LLDB_LOG_ERROR(GetLog(DWARFLog::DebugInfo), ranges.takeError(),
+ "{1:x}: {0}", cu_offset);
+}
   }
 
  

[Lldb-commits] [lldb] [lldb/DWARF] s/DWARFRangeList/llvm::DWARFAddressRangeVector (PR #116620)

2024-12-04 Thread Pavel Labath via lldb-commits

labath wrote:

Rebased on top of other changes. Ping :)

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


[Lldb-commits] [lldb] [lldb/DWARF] s/DWARFRangeList/llvm::DWARFAddressRangeVector (PR #116620)

2024-12-04 Thread Pavel Labath via lldb-commits

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

>From 5cca8f301abde9333715e97d671afc23d75b9acd Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 18 Nov 2024 14:33:40 +0100
Subject: [PATCH 1/2] [lldb/DWARF]
 s/DWARFRangeList/llvm::DWARFAddressRangeVector

The main difference is that the llvm class (just a std::vector in
disguise) is not sorted. It turns out this isn't an issue because the
callers either:
- ignore the range list;
- convert it to a different format (which is then sorted);
- or query the minimum value (which is faster than sorting)

The last case is something I want to get rid of in a followup as a part
of removing the assumption that function's entry point is also its
lowest address.
---
 lldb/include/lldb/Core/dwarf.h|  3 -
 lldb/source/Plugins/SymbolFile/DWARF/DIERef.h |  3 +-
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  3 +-
 .../SymbolFile/DWARF/DWARFCompileUnit.cpp | 19 ++--
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 43 +
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   | 11 ++-
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.cpp  | 96 +--
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.h| 20 ++--
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp| 67 ++---
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  7 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 81 +---
 11 files changed, 185 insertions(+), 168 deletions(-)

diff --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h
index e162a090ba7c97..4de5c8f24db02c 100644
--- a/lldb/include/lldb/Core/dwarf.h
+++ b/lldb/include/lldb/Core/dwarf.h
@@ -9,7 +9,6 @@
 #ifndef LLDB_CORE_DWARF_H
 #define LLDB_CORE_DWARF_H
 
-#include "lldb/Utility/RangeMap.h"
 #include 
 
 // Get the DWARF constant definitions from llvm
@@ -40,6 +39,4 @@ typedef uint64_t dw_offset_t; // Dwarf Debug Information 
Entry offset for any
 
 #define DW_EH_PE_MASK_ENCODING 0x0F
 
-typedef lldb_private::RangeVector DWARFRangeList;
-
 #endif // LLDB_CORE_DWARF_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
index ad443aacb46ecc..69be0aa1280c16 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
@@ -10,7 +10,8 @@
 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DIEREF_H
 
 #include "lldb/Core/dwarf.h"
-#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-types.h"
 #include 
 #include 
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index d9bdeb560e1220..05d994ae82d8d4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -45,6 +45,7 @@
 #include "clang/AST/Type.h"
 #include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
 #include "llvm/Demangle/Demangle.h"
 
 #include 
@@ -2353,7 +2354,7 @@ 
DWARFASTParserClang::ConstructDemangledNameFromDWARF(const DWARFDIE &die) {
 
 Function *DWARFASTParserClang::ParseFunctionFromDWARF(
 CompileUnit &comp_unit, const DWARFDIE &die, AddressRanges func_ranges) {
-  DWARFRangeList unused_func_ranges;
+  llvm::DWARFAddressRangesVector unused_func_ranges;
   const char *name = nullptr;
   const char *mangled = nullptr;
   std::optional decl_file;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index ec4c297cf7e164..7f2edbfa95feef 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -8,11 +8,13 @@
 
 #include "DWARFCompileUnit.h"
 #include "DWARFDebugAranges.h"
+#include "LogChannelDWARF.h"
 #include "SymbolFileDWARFDebugMap.h"
 
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/LineTable.h"
 #include "lldb/Utility/Stream.h"
+#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -41,14 +43,17 @@ void DWARFCompileUnit::BuildAddressRangeTable(
 
   const dw_offset_t cu_offset = GetOffset();
   if (die) {
-DWARFRangeList ranges =
+llvm::Expected ranges =
 die->GetAttributeAddressRanges(this, /*check_hi_lo_pc=*/true);
-for (const DWARFRangeList::Entry &range : ranges)
-  debug_aranges->AppendRange(cu_offset, range.GetRangeBase(),
- range.GetRangeEnd());
-
-if (!ranges.IsEmpty())
-  return;
+if (ranges) {
+  for (const llvm::DWARFAddressRange &range : *ranges)
+debug_aranges->AppendRange(cu_offset, range.LowPC, range.HighPC);
+  if (!ranges->empty())
+return;
+} else {
+  LLDB_LOG_ERROR(GetLog(DWARFLog::DebugInfo), ranges.takeError(),
+ "{1:x}: {0}", cu_offset);
+}
   }

[Lldb-commits] [lldb] [lldb/DWARF] s/DWARFRangeList/llvm::DWARFAddressRangeVector (PR #116620)

2024-12-04 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 0adab6b1af5b1874099b1e97fdcea2ce5020d79a 
5cca8f301abde9333715e97d671afc23d75b9acd --extensions h,cpp -- 
lldb/include/lldb/Core/dwarf.h lldb/source/Plugins/SymbolFile/DWARF/DIERef.h 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 1efac9cb74..7bcb0e8351 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3202,9 +3202,9 @@ size_t SymbolFileDWARF::ParseBlocksRecursive(Function 
&func) {
 // We can't use the file address from the Function object as (in the OSO
 // case) it will already be remapped to the main module.
 if (llvm::Expected ranges =
-function_die.GetDIE()->GetAttributeAddressRanges(
-function_die.GetCU(),
-/*check_hi_lo_pc=*/true)) {
+function_die.GetDIE()->GetAttributeAddressRanges(
+function_die.GetCU(),
+/*check_hi_lo_pc=*/true)) {
   if (ranges->empty())
 return 0;
   // TODO: Use the first range instead.

``




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


[Lldb-commits] [lldb] [lldb] (Prepare to) speed up dwarf indexing (PR #118657)

2024-12-04 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] (Prepare to) speed up dwarf indexing (PR #118657)

2024-12-04 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 0adab6b1af5b1874099b1e97fdcea2ce5020d79a 
6a9384e47441117cff7b2903b4ad8bdfd11f06b4 --extensions cpp -- 
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 03a031626a..5b325e30be 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -82,7 +82,6 @@ void ManualDWARFIndex::Index() {
   Progress progress("Manually indexing DWARF", module_desc.GetData(),
 total_progress);
 
-
   // Share one thread pool across operations to avoid the overhead of
   // recreating the threads.
   llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool());

``




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


[Lldb-commits] [lldb] [lldb] (Prepare to) speed up dwarf indexing (PR #118657)

2024-12-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

Indexing a single DWARF unit is a fairly small task, which means the overhead 
of enqueueing a task for each unit is not negligible (mainly because introduces 
a lot of synchronization points for queue management, memory allocation etc.). 
This is particularly true for if the binary was built with type units, as these 
are usually very small.

This essentially brings us back to the state before 
https://reviews.llvm.org/D78337, but the new implementation is built on the 
llvm ThreadPool, and I've added a small improvement -- we now construct one 
"index set" per thread instead of one per unit, which should lower the memory 
usage (fewer small allocations) and make the subsequent merge step faster.

On its own this patch doesn't actually change the performance characteristics 
because we still have one choke point -- progress reporting. I'm leaving that 
for a separate patch, but I've tried that simply removing the progress 
reporting gives us about a 30-60% speed boost.

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


1 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp (+42-31) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 0be19ab29ef082..03a031626ab154 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -23,6 +23,7 @@
 #include "lldb/Utility/Timer.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/ThreadPool.h"
+#include 
 #include 
 
 using namespace lldb_private;
@@ -81,44 +82,54 @@ void ManualDWARFIndex::Index() {
   Progress progress("Manually indexing DWARF", module_desc.GetData(),
 total_progress);
 
-  std::vector sets(units_to_index.size());
-
-  // Keep memory down by clearing DIEs for any units if indexing
-  // caused us to load the unit's DIEs.
-  std::vector> clear_cu_dies(
-  units_to_index.size());
-  auto parser_fn = [&](size_t cu_idx) {
-IndexUnit(*units_to_index[cu_idx], dwp_dwarf, sets[cu_idx]);
-progress.Increment();
-  };
-
-  auto extract_fn = [&](size_t cu_idx) {
-clear_cu_dies[cu_idx] = units_to_index[cu_idx]->ExtractDIEsScoped();
-progress.Increment();
-  };
 
   // Share one thread pool across operations to avoid the overhead of
   // recreating the threads.
   llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool());
+  const size_t num_threads = Debugger::GetThreadPool().getMaxConcurrency();
+
+  // Run a function for each compile unit in parallel using as many threads as
+  // are available. This is significantly faster than submiting a new task for
+  // each unit.
+  auto for_each_unit = [&](auto &&fn) {
+std::atomic next_cu_idx = 0;
+auto wrapper = [&fn, &next_cu_idx, &units_to_index,
+&progress](size_t worker_id) {
+  size_t cu_idx;
+  while ((cu_idx = next_cu_idx.fetch_add(1, std::memory_order_relaxed)) <
+ units_to_index.size()) {
+fn(worker_id, cu_idx, units_to_index[cu_idx]);
+progress.Increment();
+  }
+};
 
-  // Create a task runner that extracts dies for each DWARF unit in a
-  // separate thread.
-  // First figure out which units didn't have their DIEs already
-  // parsed and remember this.  If no DIEs were parsed prior to this index
-  // function call, we are going to want to clear the CU dies after we are
-  // done indexing to make sure we don't pull in all DWARF dies, but we need
-  // to wait until all units have been indexed in case a DIE in one
-  // unit refers to another and the indexes accesses those DIEs.
-  for (size_t i = 0; i < units_to_index.size(); ++i)
-task_group.async(extract_fn, i);
-  task_group.wait();
+for (size_t i = 0; i < num_threads; ++i)
+  task_group.async(wrapper, i);
 
-  // Now create a task runner that can index each DWARF unit in a
-  // separate thread so we can index quickly.
-  for (size_t i = 0; i < units_to_index.size(); ++i)
-task_group.async(parser_fn, i);
-  task_group.wait();
+task_group.wait();
+  };
 
+  // Extract dies for all DWARFs unit in parallel.  Figure out which units
+  // didn't have their DIEs already parsed and remember this.  If no DIEs were
+  // parsed prior to this index function call, we are going to want to clear 
the
+  // CU dies after we are done indexing to make sure we don't pull in all DWARF
+  // dies, but we need to wait until all units have been indexed in case a DIE
+  // in one unit refers to another and the indexes accesses those DIEs.
+  std::vector> clear_cu_dies(
+  units_to_index.size());
+  for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
+clear_cu_dies[idx] = unit->ExtractDIEsScoped();
+  });
+
+  // Now index all DWARF unit in parallel.
+  std::vector sets(num

[Lldb-commits] [lldb] 4e80c53 - [lldb][tests] Fix passing pthread library to a linker for some API tests (#118530)

2024-12-04 Thread via lldb-commits

Author: Vladislav Dzhidzhoev
Date: 2024-12-04T16:55:28+01:00
New Revision: 4e80c532c613cc93a43dcf71eaf6a30f96c27b6c

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

LOG: [lldb][tests] Fix passing pthread library to a linker for some API tests 
(#118530)

Specify ENABLE_THREADS := YES within test's Makefile instead of passing
-lpthread explicitly via the compiler's CFLAGS options.

Refactoring fix.

Co-authored-by: Vladimir Vereschaka 

Added: 


Modified: 

lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/Makefile

lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/Makefile
lldb/test/API/functionalities/process_save_core_minidump/Makefile
lldb/test/API/tools/lldb-dap/threads/Makefile

Removed: 




diff  --git 
a/lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/Makefile
 
b/lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/Makefile
index 57d926b37d45cf..bee03ac62a60fb 100644
--- 
a/lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/Makefile
+++ 
b/lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/Makefile
@@ -1,5 +1,6 @@
 C_SOURCES := main.c
 
-CFLAGS_EXTRAS := -march=armv8-a+sve+sme -lpthread
+CFLAGS_EXTRAS := -march=armv8-a+sve+sme
+ENABLE_THREADS := YES
 
 include Makefile.rules

diff  --git 
a/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/Makefile
 
b/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/Makefile
index efa5ca913f6e2d..1c65300b737388 100644
--- 
a/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/Makefile
+++ 
b/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/Makefile
@@ -1,5 +1,6 @@
 C_SOURCES := main.c
 
-CFLAGS_EXTRAS := -march=armv8-a+sve -lpthread
+CFLAGS_EXTRAS := -march=armv8-a+sve
+ENABLE_THREADS := YES
 
 include Makefile.rules

diff  --git a/lldb/test/API/functionalities/process_save_core_minidump/Makefile 
b/lldb/test/API/functionalities/process_save_core_minidump/Makefile
index 2d177981fdde16..e9a26189f5dad5 100644
--- a/lldb/test/API/functionalities/process_save_core_minidump/Makefile
+++ b/lldb/test/API/functionalities/process_save_core_minidump/Makefile
@@ -1,6 +1,6 @@
 CXX_SOURCES := main.cpp
 
-CFLAGS_EXTRAS := -lpthread
+ENABLE_THREADS := YES
 
 include Makefile.rules
 

diff  --git a/lldb/test/API/tools/lldb-dap/threads/Makefile 
b/lldb/test/API/tools/lldb-dap/threads/Makefile
index 121868fa8ec338..aa6b054685d615 100644
--- a/lldb/test/API/tools/lldb-dap/threads/Makefile
+++ b/lldb/test/API/tools/lldb-dap/threads/Makefile
@@ -1,4 +1,5 @@
 C_SOURCES := main.c
-CFLAGS_EXTRAS := -lpthread
+
+ENABLE_THREADS := YES
 
 include Makefile.rules



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


[Lldb-commits] [lldb] [lldb][tests] Fix passing pthread library to a linker for some API tests (PR #118530)

2024-12-04 Thread Vladislav Dzhidzhoev via lldb-commits

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


[Lldb-commits] [lldb] [lldb] (Prepare to) speed up dwarf indexing (PR #118657)

2024-12-04 Thread Pavel Labath via lldb-commits

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

Indexing a single DWARF unit is a fairly small task, which means the overhead 
of enqueueing a task for each unit is not negligible (mainly because introduces 
a lot of synchronization points for queue management, memory allocation etc.). 
This is particularly true for if the binary was built with type units, as these 
are usually very small.

This essentially brings us back to the state before 
https://reviews.llvm.org/D78337, but the new implementation is built on the 
llvm ThreadPool, and I've added a small improvement -- we now construct one 
"index set" per thread instead of one per unit, which should lower the memory 
usage (fewer small allocations) and make the subsequent merge step faster.

On its own this patch doesn't actually change the performance characteristics 
because we still have one choke point -- progress reporting. I'm leaving that 
for a separate patch, but I've tried that simply removing the progress 
reporting gives us about a 30-60% speed boost.

>From 6a9384e47441117cff7b2903b4ad8bdfd11f06b4 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 2 Dec 2024 12:44:24 +
Subject: [PATCH] [lldb] (Prepare to) speed up dwarf indexing

Indexing a single DWARF unit is a fairly small task, which means the
overhead of enqueueing a task for each unit is not negligible (mainly
because introduces a lot of synchronization points for queue management,
memory allocation etc.). This is particularly true for if the binary was
built with type units, as these are usually very small.

This essentially brings us back to the state before
https://reviews.llvm.org/D78337, but the new implementation is built on
the llvm ThreadPool, and I've added a small improvement -- we now
construct one "index set" per thread instead of one per unit, which
should lower the memory usage (fewer small allocations) and make the
subsequent merge step faster.

On its own this patch doesn't actually change the performance
characteristics because we still have one choke point -- progress
reporting. I'm leaving that for a separate patch, but I've tried that
simply removing the progress reporting gives us about a 30-60% speed
boost.
---
 .../SymbolFile/DWARF/ManualDWARFIndex.cpp | 73 +++
 1 file changed, 42 insertions(+), 31 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 0be19ab29ef082..03a031626ab154 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -23,6 +23,7 @@
 #include "lldb/Utility/Timer.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/ThreadPool.h"
+#include 
 #include 
 
 using namespace lldb_private;
@@ -81,44 +82,54 @@ void ManualDWARFIndex::Index() {
   Progress progress("Manually indexing DWARF", module_desc.GetData(),
 total_progress);
 
-  std::vector sets(units_to_index.size());
-
-  // Keep memory down by clearing DIEs for any units if indexing
-  // caused us to load the unit's DIEs.
-  std::vector> clear_cu_dies(
-  units_to_index.size());
-  auto parser_fn = [&](size_t cu_idx) {
-IndexUnit(*units_to_index[cu_idx], dwp_dwarf, sets[cu_idx]);
-progress.Increment();
-  };
-
-  auto extract_fn = [&](size_t cu_idx) {
-clear_cu_dies[cu_idx] = units_to_index[cu_idx]->ExtractDIEsScoped();
-progress.Increment();
-  };
 
   // Share one thread pool across operations to avoid the overhead of
   // recreating the threads.
   llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool());
+  const size_t num_threads = Debugger::GetThreadPool().getMaxConcurrency();
+
+  // Run a function for each compile unit in parallel using as many threads as
+  // are available. This is significantly faster than submiting a new task for
+  // each unit.
+  auto for_each_unit = [&](auto &&fn) {
+std::atomic next_cu_idx = 0;
+auto wrapper = [&fn, &next_cu_idx, &units_to_index,
+&progress](size_t worker_id) {
+  size_t cu_idx;
+  while ((cu_idx = next_cu_idx.fetch_add(1, std::memory_order_relaxed)) <
+ units_to_index.size()) {
+fn(worker_id, cu_idx, units_to_index[cu_idx]);
+progress.Increment();
+  }
+};
 
-  // Create a task runner that extracts dies for each DWARF unit in a
-  // separate thread.
-  // First figure out which units didn't have their DIEs already
-  // parsed and remember this.  If no DIEs were parsed prior to this index
-  // function call, we are going to want to clear the CU dies after we are
-  // done indexing to make sure we don't pull in all DWARF dies, but we need
-  // to wait until all units have been indexed in case a DIE in one
-  // unit refers to another and the indexes accesses those DIEs.
-  for (size_t i = 0; i < units_to_index.size(); ++i)
-task_group.async(extract_fn, i);

[Lldb-commits] [lldb] [LLDB] Fix error returns in CastToBasicType and CastToEnumType in ValueObject. (PR #117401)

2024-12-04 Thread via lldb-commits

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


[Lldb-commits] [lldb] ba43a10 - [LLDB] Fix error returns in CastToBasicType and CastToEnumType in ValueObject. (#117401)

2024-12-04 Thread via lldb-commits

Author: cmtice
Date: 2024-12-04T08:11:10-08:00
New Revision: ba43a102a929eb8aae60580e14f3192a705e1805

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

LOG: [LLDB] Fix error returns in CastToBasicType and CastToEnumType in 
ValueObject. (#117401)

Update the error returns in ValueObject::CastToBasicType and
ValueObject::CastToEnumType to create new errors and return a
ValueObjectConstResult with the error, rather tnan updating the error in
(and returning) the input ValueObject.

Added: 


Modified: 
lldb/source/ValueObject/ValueObject.cpp

Removed: 




diff  --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index 86172ad1b561f9..2864af107b925f 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -3194,17 +3194,17 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
   GetCompilerType().IsPointerType() || GetCompilerType().IsNullPtrType();
   bool is_float = GetCompilerType().IsFloat();
   bool is_integer = GetCompilerType().IsInteger();
+  ExecutionContext exe_ctx(GetExecutionContextRef());
 
-  if (!type.IsScalarType()) {
-m_error = Status::FromErrorString("target type must be a scalar");
-return GetSP();
-  }
+  if (!type.IsScalarType())
+return ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(),
+Status::FromErrorString("target type must be a scalar"));
 
-  if (!is_scalar && !is_enum && !is_pointer) {
-m_error =
-Status::FromErrorString("argument must be a scalar, enum, or pointer");
-return GetSP();
-  }
+  if (!is_scalar && !is_enum && !is_pointer)
+return ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(),
+Status::FromErrorString("argument must be a scalar, enum, or 
pointer"));
 
   lldb::TargetSP target = GetTargetSP();
   uint64_t type_byte_size = 0;
@@ -3215,16 +3215,15 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
 val_byte_size = temp.value();
 
   if (is_pointer) {
-if (!type.IsInteger() && !type.IsBoolean()) {
-  m_error =
-  Status::FromErrorString("target type must be an integer or boolean");
-  return GetSP();
-}
-if (!type.IsBoolean() && type_byte_size < val_byte_size) {
-  m_error = Status::FromErrorString(
-  "target type cannot be smaller than the pointer type");
-  return GetSP();
-}
+if (!type.IsInteger() && !type.IsBoolean())
+  return ValueObjectConstResult::Create(
+  exe_ctx.GetBestExecutionContextScope(),
+  Status::FromErrorString("target type must be an integer or 
boolean"));
+if (!type.IsBoolean() && type_byte_size < val_byte_size)
+  return ValueObjectConstResult::Create(
+  exe_ctx.GetBestExecutionContextScope(),
+  Status::FromErrorString(
+  "target type cannot be smaller than the pointer type"));
   }
 
   if (type.IsBoolean()) {
@@ -3236,12 +3235,12 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
   if (float_value_or_err)
 return ValueObject::CreateValueObjectFromBool(
 target, !float_value_or_err->isZero(), "result");
-  else {
-m_error = Status::FromErrorStringWithFormat(
-"cannot get value as APFloat: %s",
-llvm::toString(float_value_or_err.takeError()).c_str());
-return GetSP();
-  }
+  else
+return ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(),
+Status::FromErrorStringWithFormat(
+"cannot get value as APFloat: %s",
+llvm::toString(float_value_or_err.takeError()).c_str()));
 }
   }
 
@@ -3255,13 +3254,12 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
 int_value_or_err->extOrTrunc(type_byte_size * CHAR_BIT);
 return ValueObject::CreateValueObjectFromAPInt(target, ext, type,
"result");
-  } else {
-m_error = Status::FromErrorStringWithFormat(
-"cannot get value as APSInt: %s",
-llvm::toString(int_value_or_err.takeError()).c_str());
-;
-return GetSP();
-  }
+  } else
+return ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(),
+Status::FromErrorStringWithFormat(
+"cannot get value as APSInt: %s",
+llvm::toString(int_value_or_err.takeError()).c_str()));
 } else if (is_scalar && is_float) {
   llvm::APSInt integer(type_byte_size * CHAR_BIT, !type.IsSigned());
   bool is_exact;
@@ -3273,12 +3271,12 @@ lldb::ValueObjectSP 
ValueObject::Cas

[Lldb-commits] [lldb] [lldb] (Prepare to) speed up dwarf indexing (PR #118657)

2024-12-04 Thread Jonas Devlieghere via lldb-commits

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

Makes sense, LGTM.

If the amount of work here is so small, and the granularity was too fine for 
creating separate tasks, I'd argue that it's too fine for progress reporting as 
well. I think that's what you're saying too. There's probably multiple ways of 
dealing with that, so I'm looking forward to the PR that addresses that. 

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


[Lldb-commits] [lldb] d5ba143 - [lldb] Correct an issue when using Socket to listen on `localhost:0` on ipv4 and ipv6. (#118565)

2024-12-04 Thread via lldb-commits

Author: John Harrison
Date: 2024-12-04T08:47:18-08:00
New Revision: d5ba143a6d8e8726c900dbfc381dab0e7d8b6a65

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

LOG: [lldb] Correct an issue when using Socket to listen on `localhost:0` on 
ipv4 and ipv6.  (#118565)

On systems supporting ting ipv4 and ipv6 the second socket to initialize 
will not update the listening address correctly after the call to `bind`.

This results in the second address listed in
`Socket::GetListeningConnectionURI` to have port `:0`, which is
incorrect.

To fix this, correct which address is used to detect the port and update
the unit tests to cover this use case.

Additionally, I updated the SocketTest's to only parameterize tests that
can work on ipv4 or ipv6. This means tests like
`SocketTest::DecodeHostAndPort` are only run once, instead of twice
since they do not change behavior based on parameters.

I also included a new unit test to cover listening on `localhost:0`,
validating both sockets correctly list the updated port.

Added: 


Modified: 
lldb/source/Host/common/TCPSocket.cpp
lldb/unittests/Host/SocketTest.cpp

Removed: 




diff  --git a/lldb/source/Host/common/TCPSocket.cpp 
b/lldb/source/Host/common/TCPSocket.cpp
index d0055c3b6c44fb..d3282ab58b8185 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -216,11 +216,11 @@ Status TCPSocket::Listen(llvm::StringRef name, int 
backlog) {
 }
 
 if (host_port->port == 0) {
-  socklen_t sa_len = address.GetLength();
-  if (getsockname(fd, &address.sockaddr(), &sa_len) == 0)
-host_port->port = address.GetPort();
+  socklen_t sa_len = listen_address.GetLength();
+  if (getsockname(fd, &listen_address.sockaddr(), &sa_len) == 0)
+host_port->port = listen_address.GetPort();
 }
-m_listen_sockets[fd] = address;
+m_listen_sockets[fd] = listen_address;
   }
 
   if (m_listen_sockets.empty()) {

diff  --git a/lldb/unittests/Host/SocketTest.cpp 
b/lldb/unittests/Host/SocketTest.cpp
index a74352c19725d2..689ef4019c618c 100644
--- a/lldb/unittests/Host/SocketTest.cpp
+++ b/lldb/unittests/Host/SocketTest.cpp
@@ -35,7 +35,7 @@ class SocketTest : public 
testing::TestWithParam {
   }
 };
 
-TEST_P(SocketTest, DecodeHostAndPort) {
+TEST_F(SocketTest, DecodeHostAndPort) {
   EXPECT_THAT_EXPECTED(Socket::DecodeHostAndPort("localhost:1138"),
llvm::HasValue(Socket::HostAndPort{"localhost", 1138}));
 
@@ -63,9 +63,8 @@ TEST_P(SocketTest, DecodeHostAndPort) {
   EXPECT_THAT_EXPECTED(Socket::DecodeHostAndPort("*:65535"),
llvm::HasValue(Socket::HostAndPort{"*", 65535}));
 
-  EXPECT_THAT_EXPECTED(
-  Socket::DecodeHostAndPort("[::1]:12345"),
-  llvm::HasValue(Socket::HostAndPort{"::1", 12345}));
+  EXPECT_THAT_EXPECTED(Socket::DecodeHostAndPort("[::1]:12345"),
+   llvm::HasValue(Socket::HostAndPort{"::1", 12345}));
 
   EXPECT_THAT_EXPECTED(
   Socket::DecodeHostAndPort("[abcd:12fg:AF58::1]:12345"),
@@ -73,9 +72,10 @@ TEST_P(SocketTest, DecodeHostAndPort) {
 }
 
 #if LLDB_ENABLE_POSIX
-TEST_P(SocketTest, DomainListenConnectAccept) {
+TEST_F(SocketTest, DomainListenConnectAccept) {
   llvm::SmallString<64> Path;
-  std::error_code EC = 
llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path);
+  std::error_code EC =
+  llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path);
   ASSERT_FALSE(EC);
   llvm::sys::path::append(Path, "test");
 
@@ -88,7 +88,7 @@ TEST_P(SocketTest, DomainListenConnectAccept) {
   CreateDomainConnectedSockets(Path, &socket_a_up, &socket_b_up);
 }
 
-TEST_P(SocketTest, DomainListenGetListeningConnectionURI) {
+TEST_F(SocketTest, DomainListenGetListeningConnectionURI) {
   llvm::SmallString<64> Path;
   std::error_code EC =
   llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path);
@@ -110,7 +110,7 @@ TEST_P(SocketTest, DomainListenGetListeningConnectionURI) {
   testing::ElementsAre(llvm::formatv("unix-connect://{0}", Path).str()));
 }
 
-TEST_P(SocketTest, DomainMainLoopAccept) {
+TEST_F(SocketTest, DomainMainLoopAccept) {
   llvm::SmallString<64> Path;
   std::error_code EC =
   llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path);
@@ -270,6 +270,25 @@ TEST_P(SocketTest, TCPListen0GetListeningConnectionURI) {
.str()));
 }
 
+TEST_F(SocketTest, TCPListen0MultiListenerGetListeningConnectionURI) {
+  if (!HostSupportsIPv6() || !HostSupportsIPv4())
+return;
+
+  llvm::Expected> sock =
+  Socket::TcpListen("localhost:0", 5);
+  ASSERT_THAT_EXPECTED(sock, llvm::Succeeded());
+  ASSERT_TRUE(sock.get()->IsValid());
+
+  EXPECT_THAT(sock.get()->GetListening

[Lldb-commits] [lldb] [lldb] When using Socket to listen on `localhost:0` on systems supporting ting ipv4 and ipv6 the second socket to initialize will not update the listening address correctly after

2024-12-04 Thread John Harrison via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-04 Thread via lldb-commits

https://github.com/cmtice updated 
https://github.com/llvm/llvm-project/pull/117808

>From b8c64e227b8f9f82b420cc5c2f24fbd3f75f67f5 Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Tue, 26 Nov 2024 15:08:32 -0800
Subject: [PATCH 1/6] [lLDB] Fix crash in
 TypeSystemClang::GetIndexofChildMemberWithName.

LLDB can crash in TypeSystemClang::GetIndexOfChildMemberWithName, at a
point where it pushes an index onto the child_indexes vector, tries to call
itself recursively, then tries to pop the entry from child_indexes.
The problem is that the recursive call can clear child_indexes, so that
this code ends up trying to pop an already empty vector.  This change saves
the old vector before the push, then restores the saved vector rather than
trying to pop.
---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 1a77c7cf9161a0..16eca7700d9fff 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -6754,12 +6754,12 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
   llvm::StringRef field_name = field->getName();
   if (field_name.empty()) {
 CompilerType field_type = GetType(field->getType());
+std::vector save_indices = child_indexes;
 child_indexes.push_back(child_idx);
 if (field_type.GetIndexOfChildMemberWithName(
 name, omit_empty_base_classes, child_indexes))
   return child_indexes.size();
-child_indexes.pop_back();
-
+child_indexes = save_indices;
   } else if (field_name == name) {
 // We have to add on the number of base classes to this index!
 child_indexes.push_back(

>From 94e40c83dbeb2ef5384fe3177372dfd7e208552d Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Sun, 1 Dec 2024 12:29:27 -0800
Subject: [PATCH 2/6] Add test case.

---
 .../commands/frame/var/anon-struct/Makefile   |  3 +
 .../var/anon-struct/TestFrameVarAnonStruct.py | 63 +++
 .../commands/frame/var/anon-struct/main.cpp   | 20 ++
 3 files changed, 86 insertions(+)
 create mode 100644 lldb/test/API/commands/frame/var/anon-struct/Makefile
 create mode 100644 
lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py
 create mode 100644 lldb/test/API/commands/frame/var/anon-struct/main.cpp

diff --git a/lldb/test/API/commands/frame/var/anon-struct/Makefile 
b/lldb/test/API/commands/frame/var/anon-struct/Makefile
new file mode 100644
index 00..8b20bcb050
--- /dev/null
+++ b/lldb/test/API/commands/frame/var/anon-struct/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git 
a/lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py 
b/lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py
new file mode 100644
index 00..8ff26f137df972
--- /dev/null
+++ b/lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py
@@ -0,0 +1,63 @@
+"""
+Make sure the frame variable -g, -a, and -l flags work.
+"""
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+import os
+import shutil
+import time
+
+
+class TestFrameVarAnonStruct(TestBase):
+# If your test case doesn't stress debug info, then
+# set this to true.  That way it won't be run once for
+# each debug info format.
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_frame_var(self):
+self.build()
+self.do_test()
+
+def do_test(self):
+target = self.createTestTarget()
+
+# Now create a breakpoint in main.c at the source matching
+# "Set a breakpoint here"
+breakpoint = target.BreakpointCreateBySourceRegex(
+"Set a breakpoint here", lldb.SBFileSpec("main.cpp")
+)
+self.assertTrue(
+breakpoint and breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT
+)
+
+error = lldb.SBError()
+# This is the launch info.  If you want to launch with arguments or
+# environment variables, add them using SetArguments or
+# SetEnvironmentEntries
+
+launch_info = target.GetLaunchInfo()
+process = target.Launch(launch_info, error)
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# Did we hit our breakpoint?
+from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
+
+threads = get_threads_stopped_at_breakpoint(process, breakpoint)
+self.assertEqual(
+len(threads), 1, "There should be a thread stopped at our 
breakpoint"
+)
+
+# The hit count for the breakpoint should be 1.
+self.assertEqual(breakpoint.GetHitCount(), 1)
+
+  

[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-04 Thread via lldb-commits


@@ -0,0 +1,19 @@
+struct A {
+  struct {
+int x = 1;
+  };
+  int y = 2;

cmtice wrote:

No; leftover from other tests. Will remove it.

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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-04 Thread via lldb-commits

https://github.com/cmtice updated 
https://github.com/llvm/llvm-project/pull/117808

>From b8c64e227b8f9f82b420cc5c2f24fbd3f75f67f5 Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Tue, 26 Nov 2024 15:08:32 -0800
Subject: [PATCH 1/7] [lLDB] Fix crash in
 TypeSystemClang::GetIndexofChildMemberWithName.

LLDB can crash in TypeSystemClang::GetIndexOfChildMemberWithName, at a
point where it pushes an index onto the child_indexes vector, tries to call
itself recursively, then tries to pop the entry from child_indexes.
The problem is that the recursive call can clear child_indexes, so that
this code ends up trying to pop an already empty vector.  This change saves
the old vector before the push, then restores the saved vector rather than
trying to pop.
---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 1a77c7cf9161a0..16eca7700d9fff 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -6754,12 +6754,12 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
   llvm::StringRef field_name = field->getName();
   if (field_name.empty()) {
 CompilerType field_type = GetType(field->getType());
+std::vector save_indices = child_indexes;
 child_indexes.push_back(child_idx);
 if (field_type.GetIndexOfChildMemberWithName(
 name, omit_empty_base_classes, child_indexes))
   return child_indexes.size();
-child_indexes.pop_back();
-
+child_indexes = save_indices;
   } else if (field_name == name) {
 // We have to add on the number of base classes to this index!
 child_indexes.push_back(

>From 94e40c83dbeb2ef5384fe3177372dfd7e208552d Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Sun, 1 Dec 2024 12:29:27 -0800
Subject: [PATCH 2/7] Add test case.

---
 .../commands/frame/var/anon-struct/Makefile   |  3 +
 .../var/anon-struct/TestFrameVarAnonStruct.py | 63 +++
 .../commands/frame/var/anon-struct/main.cpp   | 20 ++
 3 files changed, 86 insertions(+)
 create mode 100644 lldb/test/API/commands/frame/var/anon-struct/Makefile
 create mode 100644 
lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py
 create mode 100644 lldb/test/API/commands/frame/var/anon-struct/main.cpp

diff --git a/lldb/test/API/commands/frame/var/anon-struct/Makefile 
b/lldb/test/API/commands/frame/var/anon-struct/Makefile
new file mode 100644
index 00..8b20bcb050
--- /dev/null
+++ b/lldb/test/API/commands/frame/var/anon-struct/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git 
a/lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py 
b/lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py
new file mode 100644
index 00..8ff26f137df972
--- /dev/null
+++ b/lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py
@@ -0,0 +1,63 @@
+"""
+Make sure the frame variable -g, -a, and -l flags work.
+"""
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+import os
+import shutil
+import time
+
+
+class TestFrameVarAnonStruct(TestBase):
+# If your test case doesn't stress debug info, then
+# set this to true.  That way it won't be run once for
+# each debug info format.
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_frame_var(self):
+self.build()
+self.do_test()
+
+def do_test(self):
+target = self.createTestTarget()
+
+# Now create a breakpoint in main.c at the source matching
+# "Set a breakpoint here"
+breakpoint = target.BreakpointCreateBySourceRegex(
+"Set a breakpoint here", lldb.SBFileSpec("main.cpp")
+)
+self.assertTrue(
+breakpoint and breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT
+)
+
+error = lldb.SBError()
+# This is the launch info.  If you want to launch with arguments or
+# environment variables, add them using SetArguments or
+# SetEnvironmentEntries
+
+launch_info = target.GetLaunchInfo()
+process = target.Launch(launch_info, error)
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# Did we hit our breakpoint?
+from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
+
+threads = get_threads_stopped_at_breakpoint(process, breakpoint)
+self.assertEqual(
+len(threads), 1, "There should be a thread stopped at our 
breakpoint"
+)
+
+# The hit count for the breakpoint should be 1.
+self.assertEqual(breakpoint.GetHitCount(), 1)
+
+  

[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-04 Thread via lldb-commits


@@ -0,0 +1,19 @@
+struct A {
+  struct {
+int x = 1;
+  };
+  int y = 2;
+} a;
+
+struct B {
+  // Anonymous struct inherits another struct.
+  struct : public A {
+int z = 3;
+  };
+  int w = 4;

cmtice wrote:

No; leftovers from previous testing. Will remove.

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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-04 Thread Felipe de Azevedo Piovezan via lldb-commits


@@ -6754,12 +6754,12 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
   llvm::StringRef field_name = field->getName();
   if (field_name.empty()) {
 CompilerType field_type = GetType(field->getType());
+std::vector save_indices = child_indexes;
 child_indexes.push_back(child_idx);
 if (field_type.GetIndexOfChildMemberWithName(
 name, omit_empty_base_classes, child_indexes))
   return child_indexes.size();
-child_indexes.pop_back();
-
+child_indexes = save_indices;

felipepiovezan wrote:

Whichever is the resolution for the discussion above, we should at the very 
least `child_index = std::move(save_indices)` here

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


[Lldb-commits] [lldb] [lldb] Fix the SocketTest failure on unsupported hosts (PR #118673)

2024-12-04 Thread John Harrison via lldb-commits

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

The test `SocketTest::TCPListen0MultiListenerGetListeningConnectionURI` is 
failing on hosts that do not map `localhost` to both an ipv4 and ipv6 address. 
For example this build https://lab.llvm.org/buildbot/#/builders/195/builds/1909.

To fix this, I added a helper to validate if the host has an /etc/hosts entry 
for both ipv4 and ipv6, otherwise we skip the test.

>From becab1c1b0a3a9237637909212f7ea7586b82321 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Wed, 4 Dec 2024 09:39:12 -0800
Subject: [PATCH] [lldb] Fix the
 SocketTest::TCPListen0MultiListenerGetListeningConnectionURI failure on
 unsupported hosts.

This failure https://lab.llvm.org/buildbot/#/builders/195/builds/1909 happened 
due to the host not having a `localhost` /etc/hosts entry for an ipv6 address.

To fix this, I added a helper to validate if the host has an /etc/hosts entry 
for both ipv4 and ipv6, otherwise we skip the test.
---
 lldb/unittests/Host/SocketTest.cpp |  2 +-
 .../Host/SocketTestUtilities.cpp   | 18 ++
 .../TestingSupport/Host/SocketTestUtilities.h  |  5 +
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/lldb/unittests/Host/SocketTest.cpp 
b/lldb/unittests/Host/SocketTest.cpp
index 689ef4019c618c..9cbf3e26b0883f 100644
--- a/lldb/unittests/Host/SocketTest.cpp
+++ b/lldb/unittests/Host/SocketTest.cpp
@@ -271,7 +271,7 @@ TEST_P(SocketTest, TCPListen0GetListeningConnectionURI) {
 }
 
 TEST_F(SocketTest, TCPListen0MultiListenerGetListeningConnectionURI) {
-  if (!HostSupportsIPv6() || !HostSupportsIPv4())
+  if (!HostSupportsLocalhostToIPv4() || !HostSupportsLocalhostToIPv6())
 return;
 
   llvm::Expected> sock =
diff --git a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp 
b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp
index eb5bda0fabc770..86349351b0c3a4 100644
--- a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp
+++ b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp
@@ -116,6 +116,24 @@ bool lldb_private::HostSupportsIPv6() {
   return CheckIPSupport("IPv6", "[::1]:0");
 }
 
+bool lldb_private::HostSupportsLocalhostToIPv4() {
+  if (!HostSupportsIPv4())
+return false;
+
+  auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, AF_INET,
+ SOCK_STREAM, IPPROTO_TCP);
+  return !addresses.empty();
+}
+
+bool lldb_private::HostSupportsLocalhostToIPv6() {
+  if (!HostSupportsIPv6())
+return false;
+
+  auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, 
AF_INET6,
+ SOCK_STREAM, IPPROTO_TCP);
+  return !addresses.empty();
+}
+
 llvm::Expected lldb_private::GetLocalhostIP() {
   if (HostSupportsIPv4())
 return "127.0.0.1";
diff --git a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h 
b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h
index efd17428ceefb6..e5bab163cf82eb 100644
--- a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h
+++ b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h
@@ -43,6 +43,11 @@ void CreateDomainConnectedSockets(llvm::StringRef path,
 bool HostSupportsIPv6();
 bool HostSupportsIPv4();
 
+/// Returns true if the name `localhost` maps to a loopback IPv4 address.
+bool HostSupportsLocalhostToIPv4();
+/// Returns true if the name `localhost` maps to a loopback IPv6 address.
+bool HostSupportsLocalhostToIPv6();
+
 /// Return an IP for localhost based on host support.
 ///
 /// This will return either "127.0.0.1" if IPv4 is detected, or "[::1]" if IPv6

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


[Lldb-commits] [lldb] ff59538 - [lldb-dap] Support finding the lldb-dap binary (#118547)

2024-12-04 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-12-04T09:43:49-08:00
New Revision: ff5953804ea5b430710b07f1dae395bfcf6d35d0

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

LOG: [lldb-dap] Support finding the lldb-dap binary (#118547)

Support finding the lldb-dap binary with `xcrun` on Darwin or in PATH on
all other platforms.

Unfortunately, this PR is larger than I would like because it removes
the `lldbDapOptions`. I believe these options are not necessary, and as
previously implemented, they caused a spurious warning with this change.
The problem was that the options were created before the custom factory.
By moving the creation logic into the factory, we make sure it's only
called after the factory has been registered. The upside is that this
simplifies the code and removes a level of indirection.

Added: 


Modified: 
lldb/tools/lldb-dap/package.json
lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
lldb/tools/lldb-dap/src-ts/extension.ts

Removed: 
lldb/tools/lldb-dap/src-ts/types.ts



diff  --git a/lldb/tools/lldb-dap/package.json 
b/lldb/tools/lldb-dap/package.json
index 5e9a7de9109ec8..6079edb5a2189a 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -1,7 +1,7 @@
 {
   "name": "lldb-dap",
   "displayName": "LLDB DAP",
-  "version": "0.2.6",
+  "version": "0.2.7",
   "publisher": "llvm-vs-code-extensions",
   "homepage": "https://lldb.llvm.org";,
   "description": "LLDB debugging from VSCode",

diff  --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts 
b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
index 2be21bfdf0dd69..55c2f3e9f7deb5 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -1,33 +1,99 @@
+import * as path from "path";
+import * as util from "util";
 import * as vscode from "vscode";
-import { LLDBDapOptions } from "./types";
+import * as child_process from "child_process";
+import * as fs from "node:fs/promises";
 
-/**
- * This class defines a factory used to find the lldb-dap binary to use
- * depending on the session configuration.
- */
-export class LLDBDapDescriptorFactory
-  implements vscode.DebugAdapterDescriptorFactory
-{
-  private lldbDapOptions: LLDBDapOptions;
-
-  constructor(lldbDapOptions: LLDBDapOptions) {
-this.lldbDapOptions = lldbDapOptions;
+export async function isExecutable(path: string): Promise {
+  try {
+await fs.access(path, fs.constants.X_OK);
+  } catch {
+return false;
   }
+  return true;
+}
 
-  static async isValidDebugAdapterPath(
-pathUri: vscode.Uri,
-  ): Promise {
+async function findWithXcrun(executable: string): Promise {
+  if (process.platform === "darwin") {
 try {
-  const fileStats = await vscode.workspace.fs.stat(pathUri);
-  if (!(fileStats.type & vscode.FileType.File)) {
-return false;
+  const exec = util.promisify(child_process.execFile);
+  let { stdout, stderr } = await exec("/usr/bin/xcrun", [
+"-find",
+executable,
+  ]);
+  if (stdout) {
+return stdout.toString().trimEnd();
   }
-} catch (err) {
-  return false;
+} catch (error) {}
+  }
+  return undefined;
+}
+
+async function findInPath(executable: string): Promise {
+  const env_path =
+process.platform === "win32" ? process.env["Path"] : process.env["PATH"];
+  if (!env_path) {
+return undefined;
+  }
+
+  const paths = env_path.split(path.delimiter);
+  for (const p of paths) {
+const exe_path = path.join(p, executable);
+if (await isExecutable(exe_path)) {
+  return exe_path;
 }
-return true;
+  }
+  return undefined;
+}
+
+async function findDAPExecutable(): Promise {
+  const executable = process.platform === "win32" ? "lldb-dap.exe" : 
"lldb-dap";
+
+  // Prefer lldb-dap from Xcode on Darwin.
+  const xcrun_dap = findWithXcrun(executable);
+  if (xcrun_dap) {
+return xcrun_dap;
+  }
+
+  // Find lldb-dap in the user's path.
+  const path_dap = findInPath(executable);
+  if (path_dap) {
+return path_dap;
   }
 
+  return undefined;
+}
+
+async function getDAPExecutable(
+  session: vscode.DebugSession,
+): Promise {
+  const config = vscode.workspace.getConfiguration(
+"lldb-dap",
+session.workspaceFolder,
+  );
+
+  // Prefer the explicitly specified path in the extension's configuration.
+  const configPath = config.get("executable-path");
+  if (configPath && configPath.length !== 0) {
+return configPath;
+  }
+
+  // Try finding the lldb-dap binary.
+  const foundPath = await findDAPExecutable();
+  if (foundPath) {
+return foundPath;
+  }
+
+  return undefined;
+}
+
+/**
+ * This class defines a factory used to find the lldb-dap binary to use
+ * depending on the session 

[Lldb-commits] [lldb] [lldb] Fix the SocketTest failure on unsupported hosts (PR #118673)

2024-12-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

The test `SocketTest::TCPListen0MultiListenerGetListeningConnectionURI` is 
failing on hosts that do not map `localhost` to both an ipv4 and ipv6 address. 
For example this build https://lab.llvm.org/buildbot/#/builders/195/builds/1909.

To fix this, I added a helper to validate if the host has an /etc/hosts entry 
for both ipv4 and ipv6, otherwise we skip the test.

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


3 Files Affected:

- (modified) lldb/unittests/Host/SocketTest.cpp (+1-1) 
- (modified) lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp (+18) 
- (modified) lldb/unittests/TestingSupport/Host/SocketTestUtilities.h (+5) 


``diff
diff --git a/lldb/unittests/Host/SocketTest.cpp 
b/lldb/unittests/Host/SocketTest.cpp
index 689ef4019c618c..9cbf3e26b0883f 100644
--- a/lldb/unittests/Host/SocketTest.cpp
+++ b/lldb/unittests/Host/SocketTest.cpp
@@ -271,7 +271,7 @@ TEST_P(SocketTest, TCPListen0GetListeningConnectionURI) {
 }
 
 TEST_F(SocketTest, TCPListen0MultiListenerGetListeningConnectionURI) {
-  if (!HostSupportsIPv6() || !HostSupportsIPv4())
+  if (!HostSupportsLocalhostToIPv4() || !HostSupportsLocalhostToIPv6())
 return;
 
   llvm::Expected> sock =
diff --git a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp 
b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp
index eb5bda0fabc770..86349351b0c3a4 100644
--- a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp
+++ b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp
@@ -116,6 +116,24 @@ bool lldb_private::HostSupportsIPv6() {
   return CheckIPSupport("IPv6", "[::1]:0");
 }
 
+bool lldb_private::HostSupportsLocalhostToIPv4() {
+  if (!HostSupportsIPv4())
+return false;
+
+  auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, AF_INET,
+ SOCK_STREAM, IPPROTO_TCP);
+  return !addresses.empty();
+}
+
+bool lldb_private::HostSupportsLocalhostToIPv6() {
+  if (!HostSupportsIPv6())
+return false;
+
+  auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, 
AF_INET6,
+ SOCK_STREAM, IPPROTO_TCP);
+  return !addresses.empty();
+}
+
 llvm::Expected lldb_private::GetLocalhostIP() {
   if (HostSupportsIPv4())
 return "127.0.0.1";
diff --git a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h 
b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h
index efd17428ceefb6..e5bab163cf82eb 100644
--- a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h
+++ b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h
@@ -43,6 +43,11 @@ void CreateDomainConnectedSockets(llvm::StringRef path,
 bool HostSupportsIPv6();
 bool HostSupportsIPv4();
 
+/// Returns true if the name `localhost` maps to a loopback IPv4 address.
+bool HostSupportsLocalhostToIPv4();
+/// Returns true if the name `localhost` maps to a loopback IPv6 address.
+bool HostSupportsLocalhostToIPv6();
+
 /// Return an IP for localhost based on host support.
 ///
 /// This will return either "127.0.0.1" if IPv4 is detected, or "[::1]" if IPv6

``




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


[Lldb-commits] [lldb] [lldb-dap] Support finding the lldb-dap binary (PR #118547)

2024-12-04 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-04 Thread via lldb-commits

https://github.com/cmtice updated 
https://github.com/llvm/llvm-project/pull/117808

>From b8c64e227b8f9f82b420cc5c2f24fbd3f75f67f5 Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Tue, 26 Nov 2024 15:08:32 -0800
Subject: [PATCH 1/8] [lLDB] Fix crash in
 TypeSystemClang::GetIndexofChildMemberWithName.

LLDB can crash in TypeSystemClang::GetIndexOfChildMemberWithName, at a
point where it pushes an index onto the child_indexes vector, tries to call
itself recursively, then tries to pop the entry from child_indexes.
The problem is that the recursive call can clear child_indexes, so that
this code ends up trying to pop an already empty vector.  This change saves
the old vector before the push, then restores the saved vector rather than
trying to pop.
---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 1a77c7cf9161a0..16eca7700d9fff 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -6754,12 +6754,12 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
   llvm::StringRef field_name = field->getName();
   if (field_name.empty()) {
 CompilerType field_type = GetType(field->getType());
+std::vector save_indices = child_indexes;
 child_indexes.push_back(child_idx);
 if (field_type.GetIndexOfChildMemberWithName(
 name, omit_empty_base_classes, child_indexes))
   return child_indexes.size();
-child_indexes.pop_back();
-
+child_indexes = save_indices;
   } else if (field_name == name) {
 // We have to add on the number of base classes to this index!
 child_indexes.push_back(

>From 94e40c83dbeb2ef5384fe3177372dfd7e208552d Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Sun, 1 Dec 2024 12:29:27 -0800
Subject: [PATCH 2/8] Add test case.

---
 .../commands/frame/var/anon-struct/Makefile   |  3 +
 .../var/anon-struct/TestFrameVarAnonStruct.py | 63 +++
 .../commands/frame/var/anon-struct/main.cpp   | 20 ++
 3 files changed, 86 insertions(+)
 create mode 100644 lldb/test/API/commands/frame/var/anon-struct/Makefile
 create mode 100644 
lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py
 create mode 100644 lldb/test/API/commands/frame/var/anon-struct/main.cpp

diff --git a/lldb/test/API/commands/frame/var/anon-struct/Makefile 
b/lldb/test/API/commands/frame/var/anon-struct/Makefile
new file mode 100644
index 00..8b20bcb050
--- /dev/null
+++ b/lldb/test/API/commands/frame/var/anon-struct/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git 
a/lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py 
b/lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py
new file mode 100644
index 00..8ff26f137df972
--- /dev/null
+++ b/lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py
@@ -0,0 +1,63 @@
+"""
+Make sure the frame variable -g, -a, and -l flags work.
+"""
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+import os
+import shutil
+import time
+
+
+class TestFrameVarAnonStruct(TestBase):
+# If your test case doesn't stress debug info, then
+# set this to true.  That way it won't be run once for
+# each debug info format.
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_frame_var(self):
+self.build()
+self.do_test()
+
+def do_test(self):
+target = self.createTestTarget()
+
+# Now create a breakpoint in main.c at the source matching
+# "Set a breakpoint here"
+breakpoint = target.BreakpointCreateBySourceRegex(
+"Set a breakpoint here", lldb.SBFileSpec("main.cpp")
+)
+self.assertTrue(
+breakpoint and breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT
+)
+
+error = lldb.SBError()
+# This is the launch info.  If you want to launch with arguments or
+# environment variables, add them using SetArguments or
+# SetEnvironmentEntries
+
+launch_info = target.GetLaunchInfo()
+process = target.Launch(launch_info, error)
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# Did we hit our breakpoint?
+from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
+
+threads = get_threads_stopped_at_breakpoint(process, breakpoint)
+self.assertEqual(
+len(threads), 1, "There should be a thread stopped at our 
breakpoint"
+)
+
+# The hit count for the breakpoint should be 1.
+self.assertEqual(breakpoint.GetHitCount(), 1)
+
+  

[Lldb-commits] [lldb] [lldb] When using Socket to listen on `localhost:0` on systems supporting ting ipv4 and ipv6 the second socket to initialize will not update the listening address correctly after

2024-12-04 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

It seems this patch break the test 
`lldb-unit::HostTests/SocketTest/TCPListen0MultiListenerGetListeningConnectionURI`
https://lab.llvm.org/buildbot/#/builders/195/builds/1909

https://github.com/llvm/llvm-project/pull/118565
___
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 links to LLVM issue tracked and pull requests (PR #118681)

2024-12-04 Thread Jonas Devlieghere via lldb-commits

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

Currently, the link to the issue tracker takes you to the Github source 
repository, rather than the Github issue tracker. This fixes the link and 
includes the lldb-dap label in both the issue and PR URL.

>From 61cf189ed3557833d223ef3700c4f465a8c77a2d Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 4 Dec 2024 10:19:06 -0800
Subject: [PATCH] [lldb-dap] Fix links to LLVM issue tracked and pull requests

Currently, the link to the issue tracker takes you to the Github source
repository, rather than the Github issue tracker. This fixes the link
and includes the lldb-dap label in both the issue and PR URL.
---
 lldb/tools/lldb-dap/README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/tools/lldb-dap/README.md b/lldb/tools/lldb-dap/README.md
index 8196dfdd5073c8..123869a033724f 100644
--- a/lldb/tools/lldb-dap/README.md
+++ b/lldb/tools/lldb-dap/README.md
@@ -324,8 +324,8 @@ API for handling a custom event from an extension.
 ## Contributing
 
 `lldb-dap` and `lldb` are developed under the umbrella of the [LLVM 
project](https://llvm.org/).
-The source code is [part of the LLVM 
repository](https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-dap) 
on Github.
-We use Github's [issue 
tracker](https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-dap) 
and patches can be submitted via [pull 
requests](https://github.com/llvm/llvm-project/pulls).
+The source code is part of the [LLVM 
repository](https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-dap) 
on Github.
+We use Github's [issue 
tracker](https://github.com/llvm/llvm-project/issues?q=label%3Alldb-dap) and 
patches can be submitted via [pull 
requests](https://github.com/llvm/llvm-project/pulls?q=label%3Alldb-dap).
 Furthermore, there is a [LLDB 
category](https://discourse.llvm.org/c/subprojects/lldb/8) on the LLVM 
discourse forum.
 
 For instructions on how to get started with development on lldb-dap, see the 
"[Contributing to lldb-dap](https://lldb.llvm.org/resources/lldbdap.html)"

___
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 links to LLVM issue tracked and pull requests (PR #118681)

2024-12-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Currently, the link to the issue tracker takes you to the Github source 
repository, rather than the Github issue tracker. This fixes the link and 
includes the lldb-dap label in both the issue and PR URL.

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


1 Files Affected:

- (modified) lldb/tools/lldb-dap/README.md (+2-2) 


``diff
diff --git a/lldb/tools/lldb-dap/README.md b/lldb/tools/lldb-dap/README.md
index 8196dfdd5073c8..123869a033724f 100644
--- a/lldb/tools/lldb-dap/README.md
+++ b/lldb/tools/lldb-dap/README.md
@@ -324,8 +324,8 @@ API for handling a custom event from an extension.
 ## Contributing
 
 `lldb-dap` and `lldb` are developed under the umbrella of the [LLVM 
project](https://llvm.org/).
-The source code is [part of the LLVM 
repository](https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-dap) 
on Github.
-We use Github's [issue 
tracker](https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-dap) 
and patches can be submitted via [pull 
requests](https://github.com/llvm/llvm-project/pulls).
+The source code is part of the [LLVM 
repository](https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-dap) 
on Github.
+We use Github's [issue 
tracker](https://github.com/llvm/llvm-project/issues?q=label%3Alldb-dap) and 
patches can be submitted via [pull 
requests](https://github.com/llvm/llvm-project/pulls?q=label%3Alldb-dap).
 Furthermore, there is a [LLDB 
category](https://discourse.llvm.org/c/subprojects/lldb/8) on the LLVM 
discourse forum.
 
 For instructions on how to get started with development on lldb-dap, see the 
"[Contributing to lldb-dap](https://lldb.llvm.org/resources/lldbdap.html)"

``




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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-04 Thread via lldb-commits

https://github.com/cmtice updated 
https://github.com/llvm/llvm-project/pull/117808

>From b8c64e227b8f9f82b420cc5c2f24fbd3f75f67f5 Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Tue, 26 Nov 2024 15:08:32 -0800
Subject: [PATCH 1/9] [lLDB] Fix crash in
 TypeSystemClang::GetIndexofChildMemberWithName.

LLDB can crash in TypeSystemClang::GetIndexOfChildMemberWithName, at a
point where it pushes an index onto the child_indexes vector, tries to call
itself recursively, then tries to pop the entry from child_indexes.
The problem is that the recursive call can clear child_indexes, so that
this code ends up trying to pop an already empty vector.  This change saves
the old vector before the push, then restores the saved vector rather than
trying to pop.
---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 1a77c7cf9161a0..16eca7700d9fff 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -6754,12 +6754,12 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
   llvm::StringRef field_name = field->getName();
   if (field_name.empty()) {
 CompilerType field_type = GetType(field->getType());
+std::vector save_indices = child_indexes;
 child_indexes.push_back(child_idx);
 if (field_type.GetIndexOfChildMemberWithName(
 name, omit_empty_base_classes, child_indexes))
   return child_indexes.size();
-child_indexes.pop_back();
-
+child_indexes = save_indices;
   } else if (field_name == name) {
 // We have to add on the number of base classes to this index!
 child_indexes.push_back(

>From 94e40c83dbeb2ef5384fe3177372dfd7e208552d Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Sun, 1 Dec 2024 12:29:27 -0800
Subject: [PATCH 2/9] Add test case.

---
 .../commands/frame/var/anon-struct/Makefile   |  3 +
 .../var/anon-struct/TestFrameVarAnonStruct.py | 63 +++
 .../commands/frame/var/anon-struct/main.cpp   | 20 ++
 3 files changed, 86 insertions(+)
 create mode 100644 lldb/test/API/commands/frame/var/anon-struct/Makefile
 create mode 100644 
lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py
 create mode 100644 lldb/test/API/commands/frame/var/anon-struct/main.cpp

diff --git a/lldb/test/API/commands/frame/var/anon-struct/Makefile 
b/lldb/test/API/commands/frame/var/anon-struct/Makefile
new file mode 100644
index 00..8b20bcb050
--- /dev/null
+++ b/lldb/test/API/commands/frame/var/anon-struct/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git 
a/lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py 
b/lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py
new file mode 100644
index 00..8ff26f137df972
--- /dev/null
+++ b/lldb/test/API/commands/frame/var/anon-struct/TestFrameVarAnonStruct.py
@@ -0,0 +1,63 @@
+"""
+Make sure the frame variable -g, -a, and -l flags work.
+"""
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+import os
+import shutil
+import time
+
+
+class TestFrameVarAnonStruct(TestBase):
+# If your test case doesn't stress debug info, then
+# set this to true.  That way it won't be run once for
+# each debug info format.
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_frame_var(self):
+self.build()
+self.do_test()
+
+def do_test(self):
+target = self.createTestTarget()
+
+# Now create a breakpoint in main.c at the source matching
+# "Set a breakpoint here"
+breakpoint = target.BreakpointCreateBySourceRegex(
+"Set a breakpoint here", lldb.SBFileSpec("main.cpp")
+)
+self.assertTrue(
+breakpoint and breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT
+)
+
+error = lldb.SBError()
+# This is the launch info.  If you want to launch with arguments or
+# environment variables, add them using SetArguments or
+# SetEnvironmentEntries
+
+launch_info = target.GetLaunchInfo()
+process = target.Launch(launch_info, error)
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# Did we hit our breakpoint?
+from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
+
+threads = get_threads_stopped_at_breakpoint(process, breakpoint)
+self.assertEqual(
+len(threads), 1, "There should be a thread stopped at our 
breakpoint"
+)
+
+# The hit count for the breakpoint should be 1.
+self.assertEqual(breakpoint.GetHitCount(), 1)
+
+  

[Lldb-commits] [lldb] [lldb][Process/Linux] Introduce LoongArch64 hw break/watchpoint support (PR #118043)

2024-12-04 Thread via lldb-commits

wangleiat wrote:

> We could move all this back into NativeRegisterContextLinux too but A: let's 
> take one step at a time and B: it may be that some architecture does not fit 
> the pattern that AArch64 and LoongArch do.
> 
> So in the interests of you getting this done and us having less churn, stick 
> to making a NativeRegisterContextDBReg class.
> 
> One of these days maybe we'll hoist it further up.

Thank you for your suggestion. I will divide it into two patches:

1. Extract the common parts into the `NativeRegisterContextDBReg` class to 
simplify `NativeRegisterContextDBReg_arm64`.
2. Based on the above, implement the hardware breakpoint and watchpoint 
functionality for `LoongArch`.


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