[Lldb-commits] [lldb] [lldb] Fix "exact match" debug_names type queries (PR #118465)

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


@@ -527,7 +527,7 @@ void DebugNamesDWARFIndex::GetTypesWithQuery(
   ConstString name = query.GetTypeBasename();
   std::vector query_context =
   query.GetContextRef();
-  if (query_context.size() <= 1)
+  if (query_context.size() <= 1 && !query.GetExactMatch())

Michael137 wrote:

Ah whoops, you're right I was looking at the wrong overload. 

https://github.com/llvm/llvm-project/pull/118465
___
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-03 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 "exact match" debug_names type queries (PR #118465)

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


@@ -527,7 +527,7 @@ void DebugNamesDWARFIndex::GetTypesWithQuery(
   ConstString name = query.GetTypeBasename();
   std::vector query_context =
   query.GetContextRef();
-  if (query_context.size() <= 1)
+  if (query_context.size() <= 1 && !query.GetExactMatch())

labath wrote:

I think you're looking at the wrong overload. This calls the variant taking a 
ConstString (line 461). That one doesn't take array so there's no first element 
to access.

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


[Lldb-commits] [lldb] [lldb][test] Add test categories for Linux and Darwin tests (PR #116194)

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

dzhidzhoev wrote:

Gentle ping.

https://github.com/llvm/llvm-project/pull/116194
___
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-03 Thread Michael Buch 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;

Michael137 wrote:

> So there could be several successful iterations, lengthening the vector, but 
> final failure. At the point of failure there could be some number of 
> no-longer-valid indexes that have been added to the vector, so clearing it is 
> the only option (other than saving it before the loop and restoring it when 
> the error condition is encountered...).
>
> And (to clarify a bit more), the reason that that is a problem is because at 
> line 6759 below, we make a recursive call, but if it fails we don't return an 
> error; instead we continue executing in this function (but now with a 
> child_indexes vector that would be incorrect if the recursive call hadn't 
> cleared it or restored it to its original state).

Right, but if we changed `GetIndexOfChildMemberWithName` to return an 
`Expected`, then we'd be able to handle the failure of the recursive call too. 
My thinking was that the case where Clang finds a path to a base-class but we 
then fail to compute the index to that element feels like a situation where we 
should bail out of this function. Although the counterpoint would be, what if 
Clang found paths to multiple base-classes, and only one of them failed. Then 
yes, we need the backtracking that you implement here. But looking current 
implementation, wouldn't we return a bogus result if Clang found multiple 
`CXXBasePaths` anyway? It would just add all the indices into `child_indexes` 
(it doesn't just pick "the first result" like the FIXME that Pavel points to 
suggests).

Correct me if I'm misunderstanding your points though!

I'm happy to go with your simple approach for now and clean up the function as 
a follow-up. It looks like there's a few things wrong with it. And the 
test-case you added here will be useful to drive that refactor.

I  think I prefer @labath's suggestion over mine too. That feels like the most 
robust option.

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-03 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] For a host socket, add a method to print the listening address. (PR #118330)

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


@@ -176,8 +191,9 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 
   if (host_port->hostname == "*")
 host_port->hostname = "0.0.0.0";
-  std::vector addresses = SocketAddress::GetAddressInfo(
-  host_port->hostname.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, 
IPPROTO_TCP);
+  std::vector addresses =

labath wrote:

Please revert formatting only changes (I see them in almost any file).

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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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


@@ -115,6 +121,15 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::string TCPSocket::GetListeningConnectionURI() const {

labath wrote:

Like I said in 
, I 
believe this should be a vector of strings (addresses). I guess that also means 
you have to change how you retrieve the address. I'd probably leave 
GetLocalIPAddress alone, and get the address directly from this function (if 
there's something reasonable that can be shared with the other function, you 
can put that into some sort of a helper.

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


[Lldb-commits] [lldb] 59bb9b9 - [lldb] Expose discontinuous functions through SBFunction::GetRanges (#117532)

2024-12-03 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-12-03T10:14:33+01:00
New Revision: 59bb9b915ef9137709313190395da56364b92db6

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

LOG: [lldb] Expose discontinuous functions through SBFunction::GetRanges 
(#117532)

SBFunction::GetEndAddress doesn't really make sense for discontinuous
functions, so I'm declaring it deprecated. GetStartAddress sort of makes
sense, if one uses it to find the functions entry point, so I'm keeping
that undeprecated.

I've made the test a Shell tests because these make it easier to create
discontinuous functions regardless of the host os and architecture. They
do make testing the python API harder, but I think I've managed to come
up with something not entirely unreasonable.

Added: 
lldb/test/Shell/ScriptInterpreter/Python/sb_function_ranges.s

Modified: 
lldb/include/lldb/API/SBAddressRangeList.h
lldb/include/lldb/API/SBFunction.h
lldb/include/lldb/Core/AddressRangeListImpl.h
lldb/include/lldb/Symbol/Function.h
lldb/source/API/SBFunction.cpp
lldb/source/Core/AddressRangeListImpl.cpp

Removed: 




diff  --git a/lldb/include/lldb/API/SBAddressRangeList.h 
b/lldb/include/lldb/API/SBAddressRangeList.h
index 5a4eeecf37dc96..41085b1edf8d7f 100644
--- a/lldb/include/lldb/API/SBAddressRangeList.h
+++ b/lldb/include/lldb/API/SBAddressRangeList.h
@@ -45,6 +45,7 @@ class LLDB_API SBAddressRangeList {
 private:
   friend class SBBlock;
   friend class SBProcess;
+  friend class SBFunction;
 
   lldb_private::AddressRangeListImpl &ref() const;
 

diff  --git a/lldb/include/lldb/API/SBFunction.h 
b/lldb/include/lldb/API/SBFunction.h
index df607fdc7ebf59..0a8aeeff1ea5ad 100644
--- a/lldb/include/lldb/API/SBFunction.h
+++ b/lldb/include/lldb/API/SBFunction.h
@@ -43,6 +43,8 @@ class LLDB_API SBFunction {
 
   lldb::SBAddress GetStartAddress();
 
+  LLDB_DEPRECATED_FIXME("Not compatible with discontinuous functions.",
+"GetRanges()")
   lldb::SBAddress GetEndAddress();
 
   lldb::SBAddressRangeList GetRanges();

diff  --git a/lldb/include/lldb/Core/AddressRangeListImpl.h 
b/lldb/include/lldb/Core/AddressRangeListImpl.h
index 6742e6ead87de0..6b88f9b1ac1795 100644
--- a/lldb/include/lldb/Core/AddressRangeListImpl.h
+++ b/lldb/include/lldb/Core/AddressRangeListImpl.h
@@ -24,9 +24,8 @@ class AddressRangeListImpl {
 public:
   AddressRangeListImpl();
 
-  AddressRangeListImpl(const AddressRangeListImpl &rhs) = default;
-
-  AddressRangeListImpl &operator=(const AddressRangeListImpl &rhs);
+  explicit AddressRangeListImpl(AddressRanges ranges)
+  : m_ranges(std::move(ranges)) {}
 
   size_t GetSize() const;
 

diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 70f51a846f8d96..855940a6415d72 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -444,8 +444,11 @@ class Function : public UserID, public SymbolContextScope {
 
   Function *CalculateSymbolContextFunction() override;
 
+  /// DEPRECATED: Use GetAddressRanges instead.
   const AddressRange &GetAddressRange() { return m_range; }
 
+  const AddressRanges &GetAddressRanges() const { return m_ranges; }
+
   lldb::LanguageType GetLanguage() const;
   /// Find the file and line number of the source location of the start of the
   /// function.  This will use the declaration if present and fall back on the

diff  --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index ac61220ec8736a..2ef62eea4d1993 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/lldb/source/API/SBFunction.cpp
@@ -10,6 +10,7 @@
 #include "lldb/API/SBAddressRange.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBStream.h"
+#include "lldb/Core/AddressRangeListImpl.h"
 #include "lldb/Core/Disassembler.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Symbol/CompileUnit.h"
@@ -153,10 +154,11 @@ SBAddress SBFunction::GetEndAddress() {
 
   SBAddress addr;
   if (m_opaque_ptr) {
-addr_t byte_size = m_opaque_ptr->GetAddressRange().GetByteSize();
-if (byte_size > 0) {
-  addr.SetAddress(m_opaque_ptr->GetAddressRange().GetBaseAddress());
-  addr->Slide(byte_size);
+llvm::ArrayRef ranges = m_opaque_ptr->GetAddressRanges();
+if (!ranges.empty()) {
+  // Return the end of the first range, use GetRanges to get all ranges.
+  addr.SetAddress(ranges.front().GetBaseAddress());
+  addr->Slide(ranges.front().GetByteSize());
 }
   }
   return addr;
@@ -166,11 +168,8 @@ lldb::SBAddressRangeList SBFunction::GetRanges() {
   LLDB_INSTRUMENT_VA(this);
 
   lldb::SBAddressRangeList ranges;
-  if (m_opaque_ptr) {
-lldb::SBAddressRange range;
-(*range.m_opaque_up) = m_opaque_ptr->GetAddressRange();
-ranges.Append(std::move(range));
-  }
+ 

[Lldb-commits] [lldb] [lldb] Expose discontinuous functions through SBFunction::GetRanges (PR #117532)

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

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


[Lldb-commits] [lldb] [lldb] Fix "exact match" debug_names type queries (PR #118465)

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

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

.. in the global namespace

The problem was the interaction of #116989 with an optimization in 
GetTypesWithQuery. The optimization was only correct for non-exact matches, but 
that didn't matter before this PR due to the "second layer of defense". After 
that was removed, the query started returning more types than it should.

>From 19f947f2a32e9edaceb05e7bbfbb101fe353362a Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 3 Dec 2024 11:34:58 +0100
Subject: [PATCH] [lldb] Fix "exact match" debug_names type queries

.. in the global namespace

The problem was the interaction of #116989 with an optimization in
GetTypesWithQuery. The optimization was only correct for non-exact matches, but
that didn't matter before this PR due to the "second layer of defense". After
that was removed, the query started returning more types than it should.
---
 .../Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 2 +-
 lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp  | 8 
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 6f2cb455ec00e1..c71c2dd47344a7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -527,7 +527,7 @@ void DebugNamesDWARFIndex::GetTypesWithQuery(
   ConstString name = query.GetTypeBasename();
   std::vector query_context =
   query.GetContextRef();
-  if (query_context.size() <= 1)
+  if (query_context.size() <= 1 && !query.GetExactMatch())
 return GetTypes(name, callback);
 
   llvm::SmallVector parent_contexts =
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp
index 2ed7b219d8da35..af49206608723a 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp
@@ -4,6 +4,8 @@
 // RUN: ld.lld %t.o -o %t
 // RUN: lldb-test symbols --name=foo --find=type %t | \
 // RUN:   FileCheck --check-prefix=NAME %s
+// RUN: lldb-test symbols --name=::foo --find=type %t | \
+// RUN:   FileCheck --check-prefix=EXACT %s
 // RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
 // RUN:   FileCheck --check-prefix=CONTEXT %s
 // RUN: lldb-test symbols --name=not_there --find=type %t | \
@@ -12,6 +14,8 @@
 // RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
 // RUN: lldb-test symbols --name=foo --find=type %t | \
 // RUN:   FileCheck --check-prefix=NAME %s
+// RUN: lldb-test symbols --name=::foo --find=type %t | \
+// RUN:   FileCheck --check-prefix=EXACT %s
 // RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
 // RUN:   FileCheck --check-prefix=CONTEXT %s
 // RUN: lldb-test symbols --name=not_there --find=type %t | \
@@ -22,6 +26,8 @@
 // RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
 // RUN: lldb-test symbols --name=foo --find=type %t | \
 // RUN:   FileCheck --check-prefix=NAME %s
+// RUN: lldb-test symbols --name=::foo --find=type %t | \
+// RUN:   FileCheck --check-prefix=EXACT %s
 // RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
 // RUN:   FileCheck --check-prefix=CONTEXT %s
 // RUN: lldb-test symbols --name=not_there --find=type %t | \
@@ -31,9 +37,11 @@
 
 // EMPTY: Found 0 types:
 // NAME: Found 4 types:
+// EXACT: Found 1 types:
 // CONTEXT: Found 1 types:
 struct foo { };
 // NAME-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-1]]
+// EXACT-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-2]]
 
 namespace bar {
 int context;

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


[Lldb-commits] [lldb] [lldb] Fix "exact match" debug_names type queries (PR #118465)

2024-12-03 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

.. in the global namespace

The problem was the interaction of #116989 with an optimization in 
GetTypesWithQuery. The optimization was only correct for non-exact matches, but 
that didn't matter before this PR due to the "second layer of defense". After 
that was removed, the query started returning more types than it should.

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


2 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
(+1-1) 
- (modified) lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp (+8) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 6f2cb455ec00e1..c71c2dd47344a7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -527,7 +527,7 @@ void DebugNamesDWARFIndex::GetTypesWithQuery(
   ConstString name = query.GetTypeBasename();
   std::vector query_context =
   query.GetContextRef();
-  if (query_context.size() <= 1)
+  if (query_context.size() <= 1 && !query.GetExactMatch())
 return GetTypes(name, callback);
 
   llvm::SmallVector parent_contexts =
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp
index 2ed7b219d8da35..af49206608723a 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp
@@ -4,6 +4,8 @@
 // RUN: ld.lld %t.o -o %t
 // RUN: lldb-test symbols --name=foo --find=type %t | \
 // RUN:   FileCheck --check-prefix=NAME %s
+// RUN: lldb-test symbols --name=::foo --find=type %t | \
+// RUN:   FileCheck --check-prefix=EXACT %s
 // RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
 // RUN:   FileCheck --check-prefix=CONTEXT %s
 // RUN: lldb-test symbols --name=not_there --find=type %t | \
@@ -12,6 +14,8 @@
 // RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
 // RUN: lldb-test symbols --name=foo --find=type %t | \
 // RUN:   FileCheck --check-prefix=NAME %s
+// RUN: lldb-test symbols --name=::foo --find=type %t | \
+// RUN:   FileCheck --check-prefix=EXACT %s
 // RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
 // RUN:   FileCheck --check-prefix=CONTEXT %s
 // RUN: lldb-test symbols --name=not_there --find=type %t | \
@@ -22,6 +26,8 @@
 // RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
 // RUN: lldb-test symbols --name=foo --find=type %t | \
 // RUN:   FileCheck --check-prefix=NAME %s
+// RUN: lldb-test symbols --name=::foo --find=type %t | \
+// RUN:   FileCheck --check-prefix=EXACT %s
 // RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
 // RUN:   FileCheck --check-prefix=CONTEXT %s
 // RUN: lldb-test symbols --name=not_there --find=type %t | \
@@ -31,9 +37,11 @@
 
 // EMPTY: Found 0 types:
 // NAME: Found 4 types:
+// EXACT: Found 1 types:
 // CONTEXT: Found 1 types:
 struct foo { };
 // NAME-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-1]]
+// EXACT-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-2]]
 
 namespace bar {
 int context;

``




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


[Lldb-commits] [lldb] [lldb] Expose discontinuous functions through SBFunction::GetRanges (PR #117532)

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

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

>From 03385da68038c3fd40fc085c8fb1914529116837 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 12 Nov 2024 11:30:39 +0100
Subject: [PATCH 1/2] [lldb] Expose discontinuous functions through
 SBFunction::GetRanges

SBFunction::GetEndAddress doesn't really make sense for discontinuous
functions, so I'm declaring it deprecated. GetStartAddress sort of makes
sense, if one uses it to find the functions entry point, so I'm keeping
that undeprecated.

I've made the test a Shell tests because these make it easier to create
discontinuous functions regardless of the host os and architecture. They
do make testing the python API harder, but I think I've managed to come
up with something not entirely unreasonable.
---
 lldb/include/lldb/API/SBAddressRangeList.h|   1 +
 lldb/include/lldb/API/SBFunction.h|   2 +
 lldb/include/lldb/Core/AddressRangeListImpl.h |   5 +-
 lldb/include/lldb/Symbol/Function.h   |   3 +
 lldb/source/API/SBFunction.cpp|  17 +-
 lldb/source/Core/AddressRangeListImpl.cpp |   8 -
 .../Python/sb_function_ranges.s   | 182 ++
 7 files changed, 198 insertions(+), 20 deletions(-)
 create mode 100644 
lldb/test/Shell/ScriptInterpreter/Python/sb_function_ranges.s

diff --git a/lldb/include/lldb/API/SBAddressRangeList.h 
b/lldb/include/lldb/API/SBAddressRangeList.h
index 5a4eeecf37dc96..41085b1edf8d7f 100644
--- a/lldb/include/lldb/API/SBAddressRangeList.h
+++ b/lldb/include/lldb/API/SBAddressRangeList.h
@@ -45,6 +45,7 @@ class LLDB_API SBAddressRangeList {
 private:
   friend class SBBlock;
   friend class SBProcess;
+  friend class SBFunction;
 
   lldb_private::AddressRangeListImpl &ref() const;
 
diff --git a/lldb/include/lldb/API/SBFunction.h 
b/lldb/include/lldb/API/SBFunction.h
index df607fdc7ebf59..0a8aeeff1ea5ad 100644
--- a/lldb/include/lldb/API/SBFunction.h
+++ b/lldb/include/lldb/API/SBFunction.h
@@ -43,6 +43,8 @@ class LLDB_API SBFunction {
 
   lldb::SBAddress GetStartAddress();
 
+  LLDB_DEPRECATED_FIXME("Not compatible with discontinuous functions.",
+"GetRanges()")
   lldb::SBAddress GetEndAddress();
 
   lldb::SBAddressRangeList GetRanges();
diff --git a/lldb/include/lldb/Core/AddressRangeListImpl.h 
b/lldb/include/lldb/Core/AddressRangeListImpl.h
index 6742e6ead87de0..6b88f9b1ac1795 100644
--- a/lldb/include/lldb/Core/AddressRangeListImpl.h
+++ b/lldb/include/lldb/Core/AddressRangeListImpl.h
@@ -24,9 +24,8 @@ class AddressRangeListImpl {
 public:
   AddressRangeListImpl();
 
-  AddressRangeListImpl(const AddressRangeListImpl &rhs) = default;
-
-  AddressRangeListImpl &operator=(const AddressRangeListImpl &rhs);
+  explicit AddressRangeListImpl(AddressRanges ranges)
+  : m_ranges(std::move(ranges)) {}
 
   size_t GetSize() const;
 
diff --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 70f51a846f8d96..11921398ac7651 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -444,8 +444,11 @@ class Function : public UserID, public SymbolContextScope {
 
   Function *CalculateSymbolContextFunction() override;
 
+  // DEPRECATED: Use GetAddressRanges instead.
   const AddressRange &GetAddressRange() { return m_range; }
 
+  const AddressRanges &GetAddressRanges() const { return m_ranges; }
+
   lldb::LanguageType GetLanguage() const;
   /// Find the file and line number of the source location of the start of the
   /// function.  This will use the declaration if present and fall back on the
diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index ac61220ec8736a..2ef62eea4d1993 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/lldb/source/API/SBFunction.cpp
@@ -10,6 +10,7 @@
 #include "lldb/API/SBAddressRange.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBStream.h"
+#include "lldb/Core/AddressRangeListImpl.h"
 #include "lldb/Core/Disassembler.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Symbol/CompileUnit.h"
@@ -153,10 +154,11 @@ SBAddress SBFunction::GetEndAddress() {
 
   SBAddress addr;
   if (m_opaque_ptr) {
-addr_t byte_size = m_opaque_ptr->GetAddressRange().GetByteSize();
-if (byte_size > 0) {
-  addr.SetAddress(m_opaque_ptr->GetAddressRange().GetBaseAddress());
-  addr->Slide(byte_size);
+llvm::ArrayRef ranges = m_opaque_ptr->GetAddressRanges();
+if (!ranges.empty()) {
+  // Return the end of the first range, use GetRanges to get all ranges.
+  addr.SetAddress(ranges.front().GetBaseAddress());
+  addr->Slide(ranges.front().GetByteSize());
 }
   }
   return addr;
@@ -166,11 +168,8 @@ lldb::SBAddressRangeList SBFunction::GetRanges() {
   LLDB_INSTRUMENT_VA(this);
 
   lldb::SBAddressRangeList ranges;
-  if (m_opaque_ptr) {
-lldb::SBAddressRange range;
-(*range.m_opaque_up) = m_opaque_ptr->GetAddressRange();
-ranges.Append(std::move(r

[Lldb-commits] [lldb] [lldb] Expose discontinuous functions through SBFunction::GetRanges (PR #117532)

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


@@ -444,8 +444,11 @@ class Function : public UserID, public SymbolContextScope {
 
   Function *CalculateSymbolContextFunction() override;
 
+  // DEPRECATED: Use GetAddressRanges instead.

labath wrote:

Sure.

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


[Lldb-commits] [lldb] [lldb] Expose discontinuous functions through SBFunction::GetRanges (PR #117532)

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


@@ -0,0 +1,182 @@
+# REQUIRES: x86

labath wrote:

The (only?) easy way would be to use a compiler to generate that, but I don't 
like the tradeoffs that come with that: the `-fbasic-block-sections` is not 
supported for all (or even most) targets. Most notably, it only supports ELF 
targets right now. This means that the test would come with a lot of other 
REQUIRES clauses -- that the developer might not be able do anything about 
(enabling the x86 target -- if it isn't already -- is much easier than trying 
to find a machine with a specific os/arch combination).

Using the compiler to generate the input also reduces our control over it, 
which means any assertion would have to be fairly loose to avoid the test 
breaking with compiler changes (we definitely couldn't assert the exact ranges, 
and even checking their count might too brittle).

https://github.com/llvm/llvm-project/pull/117532
___
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 DWARF index cache when index is partial. (PR #118390)

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


@@ -0,0 +1,62 @@
+// REQUIRES: lld
+
+// Test if we build a mixed binary where one .o file has a .debug_names and
+// another doesn't have one, that we save a full or partial index cache.
+// Previous versions of LLDB would have ManualDWARFIndex.cpp that would save 
out
+// an index cache to the same file regardless of wether the index cache was a
+// full DWARF manual index, or just the CUs and TUs that were missing from any
+// .debug_names tables. If the user had a .debug_names table and debugged once
+// with index caching enabled, then debugged again but set the setting to 
ignore
+// .debug_names ('settings set plugin.symbol-file.dwarf.ignore-file-indexes 1')
+// this could cause LLDB to load the index cache from the previous run which
+// was incomplete and it only contained the manually indexed DWARF from the run
+// where we used .debug_names, but it would now load it as if it were the
+// complete DWARF index.
+
+// Test that if we don't have .debug_names, that we save a full DWARF index.
+// RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -gdwarf-5 -DMAIN=1 -c %s 
-o %t.main.o
+// RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -gdwarf-5 -DMAIN=0 -c %s 
-o %t.foo.o
+// RUN: ld.lld %t.main.o %t.foo.o -o %t.nonames
+// RUN: llvm-dwp %t.main.dwo %t.foo.dwo -o %t.nonames.dwp
+// RUN: rm %t.main.dwo %t.foo.dwo
+// Run one time with the index cache enabled to populate the index cache. When
+// we populate the index cache we have to parse all of the DWARF debug info
+// and it is always available.
+// RUN: rm -rf %t.lldb-index-cache
+// RUN: %lldb \
+// RUN:   -O 'settings set symbols.enable-lldb-index-cache true' \
+// RUN:   -O 'settings set symbols.lldb-index-cache-path %t.lldb-index-cache' \
+// RUN:   -O 'settings set target.preload-symbols true' \
+// RUN:   %t.nonames -b
+
+// Make sure there is a file with "dwarf-index-full" in its filename
+// RUN: ls %t.lldb-index-cache | FileCheck %s -check-prefix=FULL
+// FULL: {{dwp-index-cache.cpp.tmp.nonames.*-dwarf-index-full-}}
+
+// Test that if we have one .o file with .debug_names and one without, that we
+// save a partial DWARF index.
+// RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -gdwarf-5 -DMAIN=1 -c %s 
-o %t.main.o -gpubnames
+// RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -gdwarf-5 -DMAIN=0 -c %s 
-o %t.foo.o
+// RUN: ld.lld %t.main.o %t.foo.o -o %t.somenames
+// RUN: llvm-dwp %t.main.dwo %t.foo.dwo -o %t.somenames.dwp
+// RUN: rm %t.main.dwo %t.foo.dwo

labath wrote:

ditto

https://github.com/llvm/llvm-project/pull/118390
___
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 DWARF index cache when index is partial. (PR #118390)

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


@@ -0,0 +1,62 @@
+// REQUIRES: lld
+
+// Test if we build a mixed binary where one .o file has a .debug_names and
+// another doesn't have one, that we save a full or partial index cache.
+// Previous versions of LLDB would have ManualDWARFIndex.cpp that would save 
out
+// an index cache to the same file regardless of wether the index cache was a
+// full DWARF manual index, or just the CUs and TUs that were missing from any
+// .debug_names tables. If the user had a .debug_names table and debugged once
+// with index caching enabled, then debugged again but set the setting to 
ignore
+// .debug_names ('settings set plugin.symbol-file.dwarf.ignore-file-indexes 1')
+// this could cause LLDB to load the index cache from the previous run which
+// was incomplete and it only contained the manually indexed DWARF from the run
+// where we used .debug_names, but it would now load it as if it were the
+// complete DWARF index.
+
+// Test that if we don't have .debug_names, that we save a full DWARF index.
+// RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -gdwarf-5 -DMAIN=1 -c %s 
-o %t.main.o
+// RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -gdwarf-5 -DMAIN=0 -c %s 
-o %t.foo.o
+// RUN: ld.lld %t.main.o %t.foo.o -o %t.nonames
+// RUN: llvm-dwp %t.main.dwo %t.foo.dwo -o %t.nonames.dwp
+// RUN: rm %t.main.dwo %t.foo.dwo

labath wrote:

Are these steps necessary. We should be able to build/save the index from dwo 
files alone, right?

https://github.com/llvm/llvm-project/pull/118390
___
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 DWARF index cache when index is partial. (PR #118390)

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

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


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


[Lldb-commits] [lldb] [lldb][NFC] Remove unused field Platform::m_remote_url (PR #118411)

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

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


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


[Lldb-commits] [lldb] ba14dac - [lldb] Use the function block as a source for function ranges (#117996)

2024-12-03 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-12-03T10:21:04+01:00
New Revision: ba14dac481564000339ba22ab867617590184f4c

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

LOG: [lldb] Use the function block as a source for function ranges (#117996)

This is a follow-up/reimplementation of #115730. While working on that
patch, I did not realize that the correct (discontinuous) set of ranges
is already stored in the block representing the whole function. The
catch -- ranges for this block are only set later, when parsing all of
the blocks of the function.

This patch changes that by populating the function block ranges eagerly
-- from within the Function constructor. This also necessitates a
corresponding change in all of the symbol files -- so that they stop
populating the ranges of that block. This allows us to avoid some
unnecessary work (not parsing the function DW_AT_ranges twice) and also
results in some simplification of the parsing code.

Added: 


Modified: 
lldb/include/lldb/Symbol/Function.h
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Symbol/Function.cpp
lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-function.s
lldb/test/Shell/SymbolFile/PDB/function-nested-block.test

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 855940a6415d72..51289f0f74ddfa 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -653,9 +653,6 @@ class Function : public UserID, public SymbolContextScope {
   /// All lexical blocks contained in this function.
   Block m_block;
 
-  /// List of address ranges belonging to the function.
-  AddressRanges m_ranges;
-
   /// The function address range that covers the widest range needed to contain
   /// all blocks. DEPRECATED: do not use this field in new code as the range 
may
   /// include addresses belonging to other functions.

diff  --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp 
b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
index df3bf157278daf..bc886259d6fa5f 100644
--- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -299,9 +299,7 @@ size_t SymbolFileBreakpad::ParseBlocksRecursive(Function 
&func) {
   // "INLINE 0 ...", the current level is 0 and its parent block is the
   // function block at index 0.
   std::vector blocks;
-  Block &block = func.GetBlock(false);
-  block.AddRange(Block::Range(0, func.GetAddressRange().GetByteSize()));
-  blocks.push_back(&block);
+  blocks.push_back(&func.GetBlock(false));
 
   size_t blocks_added = 0;
   addr_t func_base = func.GetAddressRange().GetBaseAddress().GetOffset();

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index fe711c56958c44..6f19b264eb3dda 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1305,121 +1305,76 @@ bool SymbolFileDWARF::ParseDebugMacros(CompileUnit 
&comp_unit) {
   return true;
 }
 
-size_t SymbolFileDWARF::ParseBlocksRecursive(
-lldb_private::CompileUnit &comp_unit, Block *parent_block,
-const DWARFDIE &orig_die, addr_t subprogram_low_pc, uint32_t depth) {
+size_t SymbolFileDWARF::ParseBlocksRecursive(CompileUnit &comp_unit,
+ Block *parent_block, DWARFDIE die,
+ addr_t subprogram_low_pc) {
   size_t blocks_added = 0;
-  DWARFDIE die = orig_die;
-  while (die) {
+  for (; die; die = die.GetSibling()) {
 dw_tag_t tag = die.Tag();
 
-switch (tag) {
-case DW_TAG_inlined_subroutine:
-case DW_TAG_subprogram:
-case DW_TAG_lexical_block: {
-  Block *block = nullptr;
-  if (tag == DW_TAG_subprogram) {
-// Skip any DW_TAG_subprogram DIEs that are inside of a normal or
-// inlined functions. These will be parsed on their own as separate
-// entities.
-
-if (depth > 0)
-  break;
+if (tag != DW_TAG_inlined_subroutine && tag != DW_TAG_lexical_block)
+  continue;
 
-block = parent_block;
-  } else {
-block = parent_block->CreateChild(die.GetID()).get();
-  }
-  DWARFRangeList ranges;
-  const char *name = nullptr;
-  const char *mangled_name = nullptr;
-
-  std::optional decl_file;
-  std::optional decl_li

[Lldb-commits] [lldb] [lldb] Use the function block as a source for function ranges (PR #117996)

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

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


[Lldb-commits] [lldb] 2526d5b - Revert "[lldb] Use the function block as a source for function ranges (#117996)"

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

Author: Pavel Labath
Date: 2024-12-03T10:27:31+01:00
New Revision: 2526d5b1689389da9b194b5ec2878cfb2f4aca93

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

LOG: Revert "[lldb] Use the function block as a source for function ranges 
(#117996)"

This reverts commit ba14dac481564000339ba22ab867617590184f4c. I guess
"has no conflicts" doesn't mean "it will build".

Added: 


Modified: 
lldb/include/lldb/Symbol/Function.h
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Symbol/Function.cpp
lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-function.s
lldb/test/Shell/SymbolFile/PDB/function-nested-block.test

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 51289f0f74ddfa..855940a6415d72 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -653,6 +653,9 @@ class Function : public UserID, public SymbolContextScope {
   /// All lexical blocks contained in this function.
   Block m_block;
 
+  /// List of address ranges belonging to the function.
+  AddressRanges m_ranges;
+
   /// The function address range that covers the widest range needed to contain
   /// all blocks. DEPRECATED: do not use this field in new code as the range 
may
   /// include addresses belonging to other functions.

diff  --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp 
b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
index bc886259d6fa5f..df3bf157278daf 100644
--- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -299,7 +299,9 @@ size_t SymbolFileBreakpad::ParseBlocksRecursive(Function 
&func) {
   // "INLINE 0 ...", the current level is 0 and its parent block is the
   // function block at index 0.
   std::vector blocks;
-  blocks.push_back(&func.GetBlock(false));
+  Block &block = func.GetBlock(false);
+  block.AddRange(Block::Range(0, func.GetAddressRange().GetByteSize()));
+  blocks.push_back(&block);
 
   size_t blocks_added = 0;
   addr_t func_base = func.GetAddressRange().GetBaseAddress().GetOffset();

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 6f19b264eb3dda..fe711c56958c44 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1305,76 +1305,121 @@ bool SymbolFileDWARF::ParseDebugMacros(CompileUnit 
&comp_unit) {
   return true;
 }
 
-size_t SymbolFileDWARF::ParseBlocksRecursive(CompileUnit &comp_unit,
- Block *parent_block, DWARFDIE die,
- addr_t subprogram_low_pc) {
+size_t SymbolFileDWARF::ParseBlocksRecursive(
+lldb_private::CompileUnit &comp_unit, Block *parent_block,
+const DWARFDIE &orig_die, addr_t subprogram_low_pc, uint32_t depth) {
   size_t blocks_added = 0;
-  for (; die; die = die.GetSibling()) {
+  DWARFDIE die = orig_die;
+  while (die) {
 dw_tag_t tag = die.Tag();
 
-if (tag != DW_TAG_inlined_subroutine && tag != DW_TAG_lexical_block)
-  continue;
+switch (tag) {
+case DW_TAG_inlined_subroutine:
+case DW_TAG_subprogram:
+case DW_TAG_lexical_block: {
+  Block *block = nullptr;
+  if (tag == DW_TAG_subprogram) {
+// Skip any DW_TAG_subprogram DIEs that are inside of a normal or
+// inlined functions. These will be parsed on their own as separate
+// entities.
 
-Block *block = parent_block->CreateChild(die.GetID()).get();
-DWARFRangeList ranges;
-const char *name = nullptr;
-const char *mangled_name = nullptr;
-
-std::optional decl_file;
-std::optional decl_line;
-std::optional decl_column;
-std::optional call_file;
-std::optional call_line;
-std::optional call_column;
-if (die.GetDIENamesAndRanges(name, mangled_name, ranges, decl_file,
- decl_line, decl_column, call_file, call_line,
- call_column, nullptr)) {
-  const size_t num_ranges = ranges.GetSize();
-  for (size_t i = 0; i < num_ranges; ++i) {
-const DWARFRangeList::Entry &range = ranges.GetEntryRef(i);
-const addr_t range_base = range.GetRangeBase();
-if (range_base >= subprogram_low_pc)
-  block->AddRange(Block::Range(range_base - subprogram_low_pc,
- 

[Lldb-commits] [lldb] [lldb] Use the function block as a source for function ranges (PR #117996)

2024-12-03 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-x86_64-debian-dylib` 
running on `gribozavr4` while building `lldb` at step 5 "build-unified-tree".

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


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

```
Step 5 (build-unified-tree) failure: build (failure)
...
57.552 [335/96/6617] Building CXX object 
tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/CompilerDecl.cpp.o
57.563 [334/96/6618] Building CXX object 
tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/CompilerDeclContext.cpp.o
57.578 [333/96/6619] Building CXX object 
tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/CompilerType.cpp.o
57.594 [332/96/6620] Building CXX object 
tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/SaveCoreOptions.cpp.o
57.609 [331/96/6621] Building CXX object 
tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/DWARFCallFrameInfo.cpp.o
57.758 [330/96/6622] Linking CXX executable bin/clangd-indexer
57.787 [329/96/6623] Building CXX object 
tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/DeclVendor.cpp.o
58.531 [328/96/6624] Linking CXX executable bin/clangd-fuzzer
58.659 [327/96/6625] Linking CXX executable bin/clangd
60.318 [326/96/6626] Building CXX object 
tools/lldb/source/Core/CMakeFiles/lldbCore.dir/FileLineResolver.cpp.o
FAILED: tools/lldb/source/Core/CMakeFiles/lldbCore.dir/FileLineResolver.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ 
-DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/source/Core 
-I/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source/Core 
-I/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/include 
-I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/include 
-I/b/1/llvm-x86_64-debian-dylib/build/include 
-I/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/include 
-I/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/../clang/include 
-I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/../clang/include 
-I/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source 
-I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/source -isystem 
/usr/include/libxml2 -fPIC -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -Wno-unknown-pragmas -Wno-strict-aliasing 
-Wno-vla-extension -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti 
-UNDEBUG -std=c++17 -MD -MT 
tools/lldb/source/Core/CMakeFiles/lldbCore.dir/FileLineResolver.cpp.o -MF 
tools/lldb/source/Core/CMakeFiles/lldbCore.dir/FileLineResolver.cpp.o.d -o 
tools/lldb/source/Core/CMakeFiles/lldbCore.dir/FileLineResolver.cpp.o -c 
/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source/Core/FileLineResolver.cpp
In file included from 
/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source/Core/FileLineResolver.cpp:11:
In file included from 
/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/include/lldb/Symbol/CompileUnit.h:15:
/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/include/lldb/Symbol/Function.h:450:58:
 error: use of undeclared identifier 'm_ranges'; did you mean 'm_range'?
  const AddressRanges &GetAddressRanges() const { return m_ranges; }
 ^~~~
 m_range
/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/include/lldb/Symbol/Function.h:659:16:
 note: 'm_range' declared here
  AddressRange m_range;
   ^
/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/include/lldb/Symbol/Function.h:450:58:
 error: no viable conversion from returned value of type 'const 
lldb_private::AddressRange' to function return type 'const 
lldb_private::AddressRanges'
  const AddressRanges &GetAddressRanges() const { return m_ranges; }
 ^~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:625:7:
 note: candidate inherited constructor not viable: no known conversion from 
'const lldb_private::AddressRange' to 
'initializer_list>::value_type>' (aka 
'initializer_list') for 1st argument
  vector(initializer_list __l,
  ^
/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/include/lldb/Core/AddressRange.h:256:50:
 note: constructor from base class 'vector>' inherited here
  using std::vector::vector;
 ^
/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/include/lldb/Core/AddressRange.h:254:7:

[Lldb-commits] [lldb] 9a4c5a5 - Revert "Re-apply [lldb] Do not use LC_FUNCTION_STARTS data to determine symbol size as symbols are created (#117079)"

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

Author: Michael Buch
Date: 2024-12-03T11:04:04Z
New Revision: 9a4c5a59d4ec0c582f56b221a64889c077f68376

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

LOG: Revert "Re-apply [lldb] Do not use LC_FUNCTION_STARTS data to determine 
symbol size as symbols are created (#117079)"

This reverts commit ba668eb99c5dc37d3c5cf2775079562460fd7619.

Below test started failing again on x86_64 macOS CI. We're unsure
if this patch is the exact cause, but since this patch has broken
this test before, we speculatively revert it to see if it was indeed
the root cause.
```
FAIL: lldb-shell :: Unwind/trap_frame_sym_ctx.test (1692 of 2162)
 TEST 'lldb-shell :: Unwind/trap_frame_sym_ctx.test' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 7: 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/bin/clang 
--target=specify-a-target-or-use-a-_host-substitution 
--target=x86_64-apple-darwin22.6.0 -isysroot 
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
 
-fmodules-cache-path=/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/lldb-test-build.noindex/module-cache-clang/lldb-shell
 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/Inputs/call-asm.c
 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/Inputs/trap_frame_sym_ctx.s
 -o 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/tools/lldb/test/Shell/Unwind/Output/trap_frame_sym_ctx.test.tmp
+ /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/bin/clang 
--target=specify-a-target-or-use-a-_host-substitution 
--target=x86_64-apple-darwin22.6.0 -isysroot 
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
 
-fmodules-cache-path=/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/lldb-test-build.noindex/module-cache-clang/lldb-shell
 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/Inputs/call-asm.c
 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/Inputs/trap_frame_sym_ctx.s
 -o 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/tools/lldb/test/Shell/Unwind/Output/trap_frame_sym_ctx.test.tmp
clang: warning: argument unused during compilation: 
'-fmodules-cache-path=/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/lldb-test-build.noindex/module-cache-clang/lldb-shell'
 [-Wunused-command-line-argument]
RUN: at line 8: 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/bin/lldb 
--no-lldbinit -S 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/tools/lldb/test/Shell/lit-lldb-init-quiet
 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/tools/lldb/test/Shell/Unwind/Output/trap_frame_sym_ctx.test.tmp
 -s 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test
 -o exit | 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/bin/FileCheck 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test
+ /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/bin/lldb 
--no-lldbinit -S 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/tools/lldb/test/Shell/lit-lldb-init-quiet
 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/tools/lldb/test/Shell/Unwind/Output/trap_frame_sym_ctx.test.tmp
 -s 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test
 -o exit
+ 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/lldb-build/bin/FileCheck 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test:21:10:
 error: CHECK: expected string not found in input
 ^
:26:64: note: scanning from here
 frame #1: 0x00013ee9 trap_frame_sym_ctx.test.tmp`tramp
   ^
:27:2: note: possible intended match here
 frame #2: 0x7ff7bfeff6c0
 ^

Input file: 
Check file: 
/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/Shell/Unwind/trap_frame_sym_ctx.test

-dump-input=help explains the following input dump.

Input was:
<<
.
.
.
   21:  0x13ed1 <+0>: pushq %rbp
   22:  0x13ed2 <+1>: movq %rsp, %rbp
   23: (lldb) thread backtrace -u
   24: * thread #1, queue = 'com.apple.main-thread', stop reason = 
breakpoint 1.1
   25:  * frame #0: 0x00010

[Lldb-commits] [lldb] [lldb] Fix "exact match" debug_names type queries (PR #118465)

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

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

LGTM, thanks for fixing!

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


[Lldb-commits] [lldb] 8c749ff - [lldb] Fix "exact match" debug_names type queries (#118465)

2024-12-03 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-12-03T15:18:59+01:00
New Revision: 8c749ff8aa787049cea4d4f7331493ee17565344

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

LOG: [lldb] Fix "exact match" debug_names type queries (#118465)

.. in the global namespace

The problem was the interaction of #116989 with an optimization in
GetTypesWithQuery. The optimization was only correct for non-exact
matches, but that didn't matter before this PR due to the "second layer
of defense". After that was removed, the query started returning more
types than it should.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 6f2cb455ec00e1..c71c2dd47344a7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -527,7 +527,7 @@ void DebugNamesDWARFIndex::GetTypesWithQuery(
   ConstString name = query.GetTypeBasename();
   std::vector query_context =
   query.GetContextRef();
-  if (query_context.size() <= 1)
+  if (query_context.size() <= 1 && !query.GetExactMatch())
 return GetTypes(name, callback);
 
   llvm::SmallVector parent_contexts =

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp
index 2ed7b219d8da35..af49206608723a 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp
@@ -4,6 +4,8 @@
 // RUN: ld.lld %t.o -o %t
 // RUN: lldb-test symbols --name=foo --find=type %t | \
 // RUN:   FileCheck --check-prefix=NAME %s
+// RUN: lldb-test symbols --name=::foo --find=type %t | \
+// RUN:   FileCheck --check-prefix=EXACT %s
 // RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
 // RUN:   FileCheck --check-prefix=CONTEXT %s
 // RUN: lldb-test symbols --name=not_there --find=type %t | \
@@ -12,6 +14,8 @@
 // RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
 // RUN: lldb-test symbols --name=foo --find=type %t | \
 // RUN:   FileCheck --check-prefix=NAME %s
+// RUN: lldb-test symbols --name=::foo --find=type %t | \
+// RUN:   FileCheck --check-prefix=EXACT %s
 // RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
 // RUN:   FileCheck --check-prefix=CONTEXT %s
 // RUN: lldb-test symbols --name=not_there --find=type %t | \
@@ -22,6 +26,8 @@
 // RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
 // RUN: lldb-test symbols --name=foo --find=type %t | \
 // RUN:   FileCheck --check-prefix=NAME %s
+// RUN: lldb-test symbols --name=::foo --find=type %t | \
+// RUN:   FileCheck --check-prefix=EXACT %s
 // RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
 // RUN:   FileCheck --check-prefix=CONTEXT %s
 // RUN: lldb-test symbols --name=not_there --find=type %t | \
@@ -31,9 +37,11 @@
 
 // EMPTY: Found 0 types:
 // NAME: Found 4 types:
+// EXACT: Found 1 types:
 // CONTEXT: Found 1 types:
 struct foo { };
 // NAME-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-1]]
+// EXACT-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-2]]
 
 namespace bar {
 int context;



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


[Lldb-commits] [lldb] [lldb] Fix "exact match" debug_names type queries (PR #118465)

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

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


[Lldb-commits] [lldb] [lldb/DWARF] Remove duplicate type filtering (PR #116989)

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

labath wrote:

I'm looking into this now.

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


[Lldb-commits] [lldb] 51b74bb - Reapply "[lldb] Use the function block as a source for function ranges (#117996)"

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

Author: Pavel Labath
Date: 2024-12-03T11:58:36+01:00
New Revision: 51b74bb9f6457cbe53776a2a35296189c5db52f3

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

LOG: Reapply "[lldb] Use the function block as a source for function ranges 
(#117996)"

This reverts commit 2526d5b1689389da9b194b5ec2878cfb2f4aca93, reapplying
ba14dac481564000339ba22ab867617590184f4c after fixing the conflict with
 #117532. The change is that Function::GetAddressRanges now recomputes
the returned value instead of returning the member. This means it now
returns a value instead of a reference type.

Added: 


Modified: 
lldb/include/lldb/Symbol/Function.h
lldb/source/API/SBFunction.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Symbol/Function.cpp
lldb/test/Shell/ScriptInterpreter/Python/sb_function_ranges.s
lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-function.s
lldb/test/Shell/SymbolFile/PDB/function-nested-block.test

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 855940a6415d72..e4118c1f9be867 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -447,7 +447,7 @@ class Function : public UserID, public SymbolContextScope {
   /// DEPRECATED: Use GetAddressRanges instead.
   const AddressRange &GetAddressRange() { return m_range; }
 
-  const AddressRanges &GetAddressRanges() const { return m_ranges; }
+  AddressRanges GetAddressRanges() { return m_block.GetRanges(); }
 
   lldb::LanguageType GetLanguage() const;
   /// Find the file and line number of the source location of the start of the
@@ -653,9 +653,6 @@ class Function : public UserID, public SymbolContextScope {
   /// All lexical blocks contained in this function.
   Block m_block;
 
-  /// List of address ranges belonging to the function.
-  AddressRanges m_ranges;
-
   /// The function address range that covers the widest range needed to contain
   /// all blocks. DEPRECATED: do not use this field in new code as the range 
may
   /// include addresses belonging to other functions.

diff  --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index 2ef62eea4d1993..3f6b4eea983187 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/lldb/source/API/SBFunction.cpp
@@ -154,7 +154,7 @@ SBAddress SBFunction::GetEndAddress() {
 
   SBAddress addr;
   if (m_opaque_ptr) {
-llvm::ArrayRef ranges = m_opaque_ptr->GetAddressRanges();
+AddressRanges ranges = m_opaque_ptr->GetAddressRanges();
 if (!ranges.empty()) {
   // Return the end of the first range, use GetRanges to get all ranges.
   addr.SetAddress(ranges.front().GetBaseAddress());

diff  --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp 
b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
index df3bf157278daf..bc886259d6fa5f 100644
--- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -299,9 +299,7 @@ size_t SymbolFileBreakpad::ParseBlocksRecursive(Function 
&func) {
   // "INLINE 0 ...", the current level is 0 and its parent block is the
   // function block at index 0.
   std::vector blocks;
-  Block &block = func.GetBlock(false);
-  block.AddRange(Block::Range(0, func.GetAddressRange().GetByteSize()));
-  blocks.push_back(&block);
+  blocks.push_back(&func.GetBlock(false));
 
   size_t blocks_added = 0;
   addr_t func_base = func.GetAddressRange().GetBaseAddress().GetOffset();

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index fe711c56958c44..6f19b264eb3dda 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1305,121 +1305,76 @@ bool SymbolFileDWARF::ParseDebugMacros(CompileUnit 
&comp_unit) {
   return true;
 }
 
-size_t SymbolFileDWARF::ParseBlocksRecursive(
-lldb_private::CompileUnit &comp_unit, Block *parent_block,
-const DWARFDIE &orig_die, addr_t subprogram_low_pc, uint32_t depth) {
+size_t SymbolFileDWARF::ParseBlocksRecursive(CompileUnit &comp_unit,
+ Block *parent_block, DWARFDIE die,
+ addr_t subprogram_low_pc) {
   size_t blocks_added = 0;
-  DWARFDIE die = orig_die;
-  while (die) {
+  for (; die; die = die.GetSibling()) {
 dw_tag_t tag = die.Tag();
 
-switch

[Lldb-commits] [lldb] [lldb] Fix "exact match" debug_names type queries (PR #118465)

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


@@ -527,7 +527,7 @@ void DebugNamesDWARFIndex::GetTypesWithQuery(
   ConstString name = query.GetTypeBasename();
   std::vector query_context =
   query.GetContextRef();
-  if (query_context.size() <= 1)
+  if (query_context.size() <= 1 && !query.GetExactMatch())

Michael137 wrote:

Nit (possibly for a separate PR if you prefer): could we change this to `== 1`? 
Would we ever get an empty context here? That feels like an invalid query. 
`GetTypes` already unconditionally accesses the zeroth element, which makes me 
think we're missing a check/assert for an empty context somewhere

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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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

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

>From c3226b620bc8f745b92b3aca7b189803a24db788 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 2 Dec 2024 08:29:01 -0800
Subject: [PATCH 1/3] [lldb] For a host socket, add a method to print the
 listening address.

This is most useful if you are listening on an address like 'localhost:0' and 
want to know the resolved ip + port of the socket listeniner.
---
 lldb/include/lldb/Host/Socket.h |  3 ++
 lldb/include/lldb/Host/common/TCPSocket.h   |  2 +
 lldb/include/lldb/Host/posix/DomainSocket.h |  2 +
 lldb/source/Host/common/TCPSocket.cpp   | 22 +++--
 lldb/source/Host/posix/DomainSocket.cpp | 17 ++-
 lldb/unittests/Host/SocketTest.cpp  | 51 ++---
 6 files changed, 86 insertions(+), 11 deletions(-)

diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h
index e98797b36c8a5d..c937e0c02ff19e 100644
--- a/lldb/include/lldb/Host/Socket.h
+++ b/lldb/include/lldb/Host/Socket.h
@@ -151,6 +151,9 @@ class Socket : public IOObject {
   // If this Socket is connected then return the URI used to connect.
   virtual std::string GetRemoteConnectionURI() const { return ""; };
 
+  // If the Socket is listening then return the URI for clients to connect.
+  virtual std::string GetListeningConnectionURI() const { return ""; }
+
 protected:
   Socket(SocketProtocol protocol, bool should_close);
 
diff --git a/lldb/include/lldb/Host/common/TCPSocket.h 
b/lldb/include/lldb/Host/common/TCPSocket.h
index ca36622691fe9a..ab6bf5ab97cae7 100644
--- a/lldb/include/lldb/Host/common/TCPSocket.h
+++ b/lldb/include/lldb/Host/common/TCPSocket.h
@@ -52,6 +52,8 @@ class TCPSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::string GetListeningConnectionURI() const override;
+
 private:
   TCPSocket(NativeSocket socket, const TCPSocket &listen_socket);
 
diff --git a/lldb/include/lldb/Host/posix/DomainSocket.h 
b/lldb/include/lldb/Host/posix/DomainSocket.h
index d4e0d43ee169c1..d79564cc76dafd 100644
--- a/lldb/include/lldb/Host/posix/DomainSocket.h
+++ b/lldb/include/lldb/Host/posix/DomainSocket.h
@@ -27,6 +27,8 @@ class DomainSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::string GetListeningConnectionURI() const override;
+
 protected:
   DomainSocket(SocketProtocol protocol);
 
diff --git a/lldb/source/Host/common/TCPSocket.cpp 
b/lldb/source/Host/common/TCPSocket.cpp
index 5d863954ee8868..b7bd62ff04855e 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -81,6 +81,12 @@ std::string TCPSocket::GetLocalIPAddress() const {
 socklen_t sock_addr_len = sock_addr.GetMaxLength();
 if (::getsockname(m_socket, sock_addr, &sock_addr_len) == 0)
   return sock_addr.GetIPAddress();
+  } else if (!m_listen_sockets.empty()) {
+SocketAddress sock_addr;
+socklen_t sock_addr_len = sock_addr.GetMaxLength();
+if (::getsockname(m_listen_sockets.begin()->first, sock_addr,
+  &sock_addr_len) == 0)
+  return sock_addr.GetIPAddress();
   }
   return "";
 }
@@ -115,6 +121,15 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::string TCPSocket::GetListeningConnectionURI() const {
+  if (!m_listen_sockets.empty()) {
+return std::string(llvm::formatv(
+"connection://[{0}]:{1}", GetLocalIPAddress(), GetLocalPortNumber()));
+  }
+
+  return "";
+}
+
 Status TCPSocket::CreateSocket(int domain) {
   Status error;
   if (IsValid())
@@ -176,8 +191,9 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 
   if (host_port->hostname == "*")
 host_port->hostname = "0.0.0.0";
-  std::vector addresses = SocketAddress::GetAddressInfo(
-  host_port->hostname.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, 
IPPROTO_TCP);
+  std::vector addresses =
+  SocketAddress::GetAddressInfo(host_port->hostname.c_str(), nullptr,
+AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
   for (SocketAddress &address : addresses) {
 int fd =
 Socket::CreateSocket(address.GetFamily(), kType, IPPROTO_TCP, error);
@@ -191,7 +207,7 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 }
 
 SocketAddress listen_address = address;
-if(!listen_address.IsLocalhost())
+if (!listen_address.IsLocalhost())
   listen_address.SetToAnyAddress(address.GetFamily(), host_port->port);
 else
   listen_address.SetPort(host_port->port);
diff --git a/lldb/source/Host/posix/DomainSocket.cpp 
b/lldb/source/Host/posix/DomainSocket.cpp
index 0451834630d33f..beec3c225ecc62 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -86,7 +86,8 @@ Status DomainSocket::Connect(llvm::StringRef name) {
   if (error.Fail())
 return error;
   if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),

[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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

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

>From c3226b620bc8f745b92b3aca7b189803a24db788 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 2 Dec 2024 08:29:01 -0800
Subject: [PATCH 1/4] [lldb] For a host socket, add a method to print the
 listening address.

This is most useful if you are listening on an address like 'localhost:0' and 
want to know the resolved ip + port of the socket listeniner.
---
 lldb/include/lldb/Host/Socket.h |  3 ++
 lldb/include/lldb/Host/common/TCPSocket.h   |  2 +
 lldb/include/lldb/Host/posix/DomainSocket.h |  2 +
 lldb/source/Host/common/TCPSocket.cpp   | 22 +++--
 lldb/source/Host/posix/DomainSocket.cpp | 17 ++-
 lldb/unittests/Host/SocketTest.cpp  | 51 ++---
 6 files changed, 86 insertions(+), 11 deletions(-)

diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h
index e98797b36c8a5d..c937e0c02ff19e 100644
--- a/lldb/include/lldb/Host/Socket.h
+++ b/lldb/include/lldb/Host/Socket.h
@@ -151,6 +151,9 @@ class Socket : public IOObject {
   // If this Socket is connected then return the URI used to connect.
   virtual std::string GetRemoteConnectionURI() const { return ""; };
 
+  // If the Socket is listening then return the URI for clients to connect.
+  virtual std::string GetListeningConnectionURI() const { return ""; }
+
 protected:
   Socket(SocketProtocol protocol, bool should_close);
 
diff --git a/lldb/include/lldb/Host/common/TCPSocket.h 
b/lldb/include/lldb/Host/common/TCPSocket.h
index ca36622691fe9a..ab6bf5ab97cae7 100644
--- a/lldb/include/lldb/Host/common/TCPSocket.h
+++ b/lldb/include/lldb/Host/common/TCPSocket.h
@@ -52,6 +52,8 @@ class TCPSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::string GetListeningConnectionURI() const override;
+
 private:
   TCPSocket(NativeSocket socket, const TCPSocket &listen_socket);
 
diff --git a/lldb/include/lldb/Host/posix/DomainSocket.h 
b/lldb/include/lldb/Host/posix/DomainSocket.h
index d4e0d43ee169c1..d79564cc76dafd 100644
--- a/lldb/include/lldb/Host/posix/DomainSocket.h
+++ b/lldb/include/lldb/Host/posix/DomainSocket.h
@@ -27,6 +27,8 @@ class DomainSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::string GetListeningConnectionURI() const override;
+
 protected:
   DomainSocket(SocketProtocol protocol);
 
diff --git a/lldb/source/Host/common/TCPSocket.cpp 
b/lldb/source/Host/common/TCPSocket.cpp
index 5d863954ee8868..b7bd62ff04855e 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -81,6 +81,12 @@ std::string TCPSocket::GetLocalIPAddress() const {
 socklen_t sock_addr_len = sock_addr.GetMaxLength();
 if (::getsockname(m_socket, sock_addr, &sock_addr_len) == 0)
   return sock_addr.GetIPAddress();
+  } else if (!m_listen_sockets.empty()) {
+SocketAddress sock_addr;
+socklen_t sock_addr_len = sock_addr.GetMaxLength();
+if (::getsockname(m_listen_sockets.begin()->first, sock_addr,
+  &sock_addr_len) == 0)
+  return sock_addr.GetIPAddress();
   }
   return "";
 }
@@ -115,6 +121,15 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::string TCPSocket::GetListeningConnectionURI() const {
+  if (!m_listen_sockets.empty()) {
+return std::string(llvm::formatv(
+"connection://[{0}]:{1}", GetLocalIPAddress(), GetLocalPortNumber()));
+  }
+
+  return "";
+}
+
 Status TCPSocket::CreateSocket(int domain) {
   Status error;
   if (IsValid())
@@ -176,8 +191,9 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 
   if (host_port->hostname == "*")
 host_port->hostname = "0.0.0.0";
-  std::vector addresses = SocketAddress::GetAddressInfo(
-  host_port->hostname.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, 
IPPROTO_TCP);
+  std::vector addresses =
+  SocketAddress::GetAddressInfo(host_port->hostname.c_str(), nullptr,
+AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
   for (SocketAddress &address : addresses) {
 int fd =
 Socket::CreateSocket(address.GetFamily(), kType, IPPROTO_TCP, error);
@@ -191,7 +207,7 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 }
 
 SocketAddress listen_address = address;
-if(!listen_address.IsLocalhost())
+if (!listen_address.IsLocalhost())
   listen_address.SetToAnyAddress(address.GetFamily(), host_port->port);
 else
   listen_address.SetPort(host_port->port);
diff --git a/lldb/source/Host/posix/DomainSocket.cpp 
b/lldb/source/Host/posix/DomainSocket.cpp
index 0451834630d33f..beec3c225ecc62 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -86,7 +86,8 @@ Status DomainSocket::Connect(llvm::StringRef name) {
   if (error.Fail())
 return error;
   if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),

[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

2024-12-03 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 071da9261b7e94c2d2d4e9d3d4eba1f29115e8ae 
0a512cb8e1883a37ef0dfe389de7c59cb1e51c03 --extensions h,cpp -- 
lldb/include/lldb/Host/Socket.h lldb/include/lldb/Host/common/TCPSocket.h 
lldb/include/lldb/Host/posix/DomainSocket.h 
lldb/source/Host/common/TCPSocket.cpp lldb/source/Host/posix/DomainSocket.cpp 
lldb/unittests/Host/SocketTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h
index faa27dca50..4585eac12e 100644
--- a/lldb/include/lldb/Host/Socket.h
+++ b/lldb/include/lldb/Host/Socket.h
@@ -153,7 +153,9 @@ public:
   virtual std::string GetRemoteConnectionURI() const { return ""; };
 
   // If the Socket is listening then return the URI for clients to connect.
-  virtual std::vector GetListeningConnectionURI() const { return 
{}; }
+  virtual std::vector GetListeningConnectionURI() const {
+return {};
+  }
 
 protected:
   Socket(SocketProtocol protocol, bool should_close);
diff --git a/lldb/unittests/Host/SocketTest.cpp 
b/lldb/unittests/Host/SocketTest.cpp
index 75e279fa32..712acfcfdc 100644
--- a/lldb/unittests/Host/SocketTest.cpp
+++ b/lldb/unittests/Host/SocketTest.cpp
@@ -299,7 +299,8 @@ TEST_P(SocketTest, UDPGetConnectURI) {
 #if LLDB_ENABLE_POSIX
 TEST_P(SocketTest, DomainGetConnectURI) {
   llvm::SmallString<64> domain_path;
-  std::error_code EC = 
llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", domain_path);
+  std::error_code EC = llvm::sys::fs::createUniqueDirectory(
+  "DomainListenConnectAccept", domain_path);
   ASSERT_FALSE(EC);
   llvm::sys::path::append(domain_path, "test");
 

``




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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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


@@ -115,6 +121,15 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::string TCPSocket::GetListeningConnectionURI() const {

ashgti wrote:

Since the listening sockets are a `std::map` it was very 
straightforward to adjust this without any new helpers.

https://github.com/llvm/llvm-project/pull/118330
___
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-03 Thread Jonas Devlieghere via lldb-commits

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


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-dap] Support finding the lldb-dap binary (PR #118547)

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


@@ -8,15 +11,7 @@ import { LLDBDapOptions } from "./types";
 export class LLDBDapDescriptorFactory
   implements vscode.DebugAdapterDescriptorFactory
 {
-  private lldbDapOptions: LLDBDapOptions;
-
-  constructor(lldbDapOptions: LLDBDapOptions) {
-this.lldbDapOptions = lldbDapOptions;
-  }
-
-  static async isValidDebugAdapterPath(
-pathUri: vscode.Uri,
-  ): Promise {
+  static async isValidFile(pathUri: vscode.Uri): Promise {

JDevlieghere wrote:

We're also calling this from `extension.ts`. I guess we could export the 
function but that doesn't seem much better than leaving it a static method?

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-dap] Support finding the lldb-dap binary (PR #118547)

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


@@ -28,6 +23,70 @@ export class LLDBDapDescriptorFactory
 return true;
   }
 
+  static async findDAPExecutable(): Promise {
+let executable = "lldb-dap";
+if (process.platform === "win32") {
+  executable = "lldb-dap.exe";
+}
+
+// Prefer lldb-dap from Xcode on Darwin.
+if (process.platform === "darwin") {
+  try {
+const exec = util.promisify(require("child_process").execFile);
+let { stdout, stderr } = await exec("/usr/bin/xcrun", [
+  "-find",
+  executable,
+]);
+if (stdout) {
+  return stdout.toString().trimEnd();
+}
+  } catch (error) {}
+}
+
+// Find lldb-dap in the user's path.
+let env_path =
+  process.env["PATH"] ||
+  (process.platform === "win32" ? process.env["Path"] : null);

walter-erquinigo wrote:

```suggestion
  process.platform === "win32" ? process.env["Path"] : process.env["PATH"]
```

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-dap] Support finding the lldb-dap binary (PR #118547)

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


@@ -28,6 +23,70 @@ export class LLDBDapDescriptorFactory
 return true;
   }
 
+  static async findDAPExecutable(): Promise {
+let executable = "lldb-dap";
+if (process.platform === "win32") {
+  executable = "lldb-dap.exe";
+}
+
+// Prefer lldb-dap from Xcode on Darwin.
+if (process.platform === "darwin") {
+  try {
+const exec = util.promisify(require("child_process").execFile);

walter-erquinigo wrote:

don't use require. Just import child process in the regular way, and then pass 
it to promisify. That way the typechecker will work correctly.

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-dap] Support finding the lldb-dap binary (PR #118547)

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


@@ -28,6 +23,70 @@ export class LLDBDapDescriptorFactory
 return true;
   }
 
+  static async findDAPExecutable(): Promise {

walter-erquinigo wrote:

This function is really not complex but a bit long. Can you split it into 
smaller chunks?

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-dap] Support finding the lldb-dap binary (PR #118547)

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

https://github.com/walter-erquinigo edited 
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-dap] Support finding the lldb-dap binary (PR #118547)

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

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

beautiful

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-03 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/5] [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/5] 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-03 Thread via lldb-commits


@@ -0,0 +1,19 @@
+int main(int argc, char** argv) {
+  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;
+A a;
+  } b;

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] [lldb] Update dwim-print to show expanded objc instances (PR #117500)

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


@@ -87,7 +87,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 
   DumpValueObjectOptions dump_options = m_varobj_options.GetAsDumpOptions(
   m_expr_options.m_verbosity, m_format_options.GetFormat());
-  dump_options.SetHideRootName(suppress_result);
+  dump_options.SetHideRootName(suppress_result)
+  .SetExpandPointerTypeFlags(lldb::eTypeIsObjC);

adrian-prantl wrote:

> Is this something we would want for `frame var`/`expr` too? In which case we 
> could just check for ObjC in `ValueObjectPrinter::ShouldPrintChildren` 
> directly instead of introducing this new API

Should/Could this perhaps be an (NSObject *) data formatter, doing this work, 
so it's applied consistently?

https://github.com/llvm/llvm-project/pull/117500
___
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-03 Thread John Harrison via lldb-commits

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

Super useful, especially on macOS with Xcode installed

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] 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-03 Thread Pavel Labath via lldb-commits

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

Good stuff. Thanks.

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] Add 'FindFirstSymbolWithNameAndType()' to ModuleList. (PR #117777)

2024-12-03 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

This would be easy to test if we expose this via the public API in `SBTarget`. 
We don't expose a FindFirstSymbolWithNameAndType, but we can expose maybe:
```
lldb::SBSymbol SBTarget::FindFirstSymbol(const char *name, lldb::SymbolType 
type = eSymbolTypeAny);
```
Since the target has a module list internally, this can use this new function 
and test it.

To test:
- create two binaries each with a code symbol and a data symbol with the same 
name by compiling with clang.
- Create a SBModule via `SBModule(const SBModuleSpec &module_spec);` for each 
binary
- create an empty SBTarget and call `bool SBTarget::AddModule(lldb::SBModule 
&module);` first with binary 1, and then binary 2, and call the API and sure 
you get the one from the binary 1 by checking the SBSymbol's SBAddress and 
getting the module and verifying it is the right one.
- do the same thing as above but add binary 2 first and then binary 1. Make 
sure you get the symbol from binary 2.

https://github.com/llvm/llvm-project/pull/11
___
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-03 Thread John Harrison via lldb-commits

https://github.com/ashgti edited 
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] Make SBMemoryRegionInfoList iterable with Python SWIG (PR #117358)

2024-12-03 Thread via lldb-commits

github-actions[bot] wrote:



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

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

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

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

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

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


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


[Lldb-commits] [lldb] 0ca8a59 - [lldb][NFC] Remove unused field Platform::m_remote_url (#118411)

2024-12-03 Thread via lldb-commits

Author: Alex Langford
Date: 2024-12-03T10:31:38-08:00
New Revision: 0ca8a593e5da5d00100db8f735b4c4babeb36eb8

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

LOG: [lldb][NFC] Remove unused field Platform::m_remote_url (#118411)

Related:
https://discourse.llvm.org/t/rfc-lldb-a-proposal-to-refactor-platform/82697

Added: 


Modified: 
lldb/include/lldb/Target/Platform.h

Removed: 




diff  --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index 920f80bc733174..f8a2cbf0d5d049 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -473,8 +473,6 @@ class Platform : public PluginInterface {
   LLVM_PRETTY_FUNCTION, GetName()));
   }
 
-  const std::string &GetRemoteURL() const { return m_remote_url; }
-
   bool IsHost() const {
 return m_is_host; // Is this the default host platform?
   }
@@ -977,7 +975,6 @@ class Platform : public PluginInterface {
   std::string m_sdk_build;
   FileSpec m_working_dir; // The working directory which is used when 
installing
   // modules that have no install path set
-  std::string m_remote_url;
   std::string m_hostname;
   llvm::VersionTuple m_os_version;
   ArchSpec



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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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


@@ -115,6 +115,18 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::vector TCPSocket::GetListeningConnectionURI() const {
+  if (m_listen_sockets.empty())
+return {};
+

ashgti wrote:

Applied suggestion

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


[Lldb-commits] [lldb] [lldb][NFC] Remove unused field Platform::m_remote_url (PR #118411)

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

https://github.com/bulbazord closed 
https://github.com/llvm/llvm-project/pull/118411
___
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-03 Thread John Harrison via lldb-commits


@@ -8,15 +11,7 @@ import { LLDBDapOptions } from "./types";
 export class LLDBDapDescriptorFactory
   implements vscode.DebugAdapterDescriptorFactory
 {
-  private lldbDapOptions: LLDBDapOptions;
-
-  constructor(lldbDapOptions: LLDBDapOptions) {
-this.lldbDapOptions = lldbDapOptions;
-  }
-
-  static async isValidDebugAdapterPath(
-pathUri: vscode.Uri,
-  ): Promise {
+  static async isValidFile(pathUri: vscode.Uri): Promise {

ashgti wrote:

I don't think this is doing anything specific for `LLDBDapDescriptorFactory` 
and a top level `isValidExe` or `isExecutable` is straight forward to reason vs 
`LLDBDapDescriptorFactory.isValidFile`.

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-03 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;

cmtice wrote:

Whether or not we return an Expected, the only way to make this code work 
(without major changes) is to save the vector before the recursive call and 
restore it in the case where the recursive call fails (and, with Expected, 
returns an llvm:Error).  If the recursive call is successful, we immediately 
return the  size of the vector (which was updated to contain the right values). 
But if the recursive call fails, then the code continues execution, looking for 
alternate paths, and assumes that the vector is in the same state it was before 
the recursive call was made.  Since the recursive call can update the vector 
before failing (and returning the error if we're using Expected), unless we 
restore it after the failure (and also consume the error), the following 
calculations may return an incorrect result (I saw this happen when I was 
testing your suggestion).

I would really prefer to NOT try to refactor and fix this entire function 
myself, so if you will accept my fix (once I fix the test case as requested) I 
would really appreciate 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][tests] Fix passing pthread library to a linker for some API tests (PR #118530)

2024-12-03 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vladislav Dzhidzhoev (dzhidzhoev)


Changes

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

Refactoring fix.

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


4 Files Affected:

- (modified) 
lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/Makefile
 (+2-1) 
- (modified) 
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/Makefile
 (+2-1) 
- (modified) lldb/test/API/functionalities/process_save_core_minidump/Makefile 
(+1-1) 
- (modified) lldb/test/API/tools/lldb-dap/threads/Makefile (+2-1) 


``diff
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

``




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] 3845624 - [lldb] For a host socket, add a method to print the listening address. (#118330)

2024-12-03 Thread via lldb-commits

Author: John Harrison
Date: 2024-12-03T11:11:32-08:00
New Revision: 384562495bae44be053c1bbd40c359ef4b82d803

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

LOG: [lldb] For a host socket, add a method to print the listening address. 
(#118330)

This is most useful if you are listening on an address like
'localhost:0' and want to know the resolved ip + port of the socket
listener.

Added: 


Modified: 
lldb/include/lldb/Host/Socket.h
lldb/include/lldb/Host/common/TCPSocket.h
lldb/include/lldb/Host/posix/DomainSocket.h
lldb/source/Host/common/TCPSocket.cpp
lldb/source/Host/posix/DomainSocket.cpp
lldb/unittests/Host/SocketTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h
index e98797b36c8a5d..4585eac12efb9e 100644
--- a/lldb/include/lldb/Host/Socket.h
+++ b/lldb/include/lldb/Host/Socket.h
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 
 #include "lldb/Host/MainLoopBase.h"
 #include "lldb/Utility/Timeout.h"
@@ -151,6 +152,11 @@ class Socket : public IOObject {
   // If this Socket is connected then return the URI used to connect.
   virtual std::string GetRemoteConnectionURI() const { return ""; };
 
+  // If the Socket is listening then return the URI for clients to connect.
+  virtual std::vector GetListeningConnectionURI() const {
+return {};
+  }
+
 protected:
   Socket(SocketProtocol protocol, bool should_close);
 

diff  --git a/lldb/include/lldb/Host/common/TCPSocket.h 
b/lldb/include/lldb/Host/common/TCPSocket.h
index ca36622691fe9a..cb950c0015ea6d 100644
--- a/lldb/include/lldb/Host/common/TCPSocket.h
+++ b/lldb/include/lldb/Host/common/TCPSocket.h
@@ -13,6 +13,8 @@
 #include "lldb/Host/Socket.h"
 #include "lldb/Host/SocketAddress.h"
 #include 
+#include 
+#include 
 
 namespace lldb_private {
 class TCPSocket : public Socket {
@@ -52,6 +54,8 @@ class TCPSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::vector GetListeningConnectionURI() const override;
+
 private:
   TCPSocket(NativeSocket socket, const TCPSocket &listen_socket);
 

diff  --git a/lldb/include/lldb/Host/posix/DomainSocket.h 
b/lldb/include/lldb/Host/posix/DomainSocket.h
index d4e0d43ee169c1..3dbe6206da2c5e 100644
--- a/lldb/include/lldb/Host/posix/DomainSocket.h
+++ b/lldb/include/lldb/Host/posix/DomainSocket.h
@@ -10,6 +10,8 @@
 #define LLDB_HOST_POSIX_DOMAINSOCKET_H
 
 #include "lldb/Host/Socket.h"
+#include 
+#include 
 
 namespace lldb_private {
 class DomainSocket : public Socket {
@@ -27,6 +29,8 @@ class DomainSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::vector GetListeningConnectionURI() const override;
+
 protected:
   DomainSocket(SocketProtocol protocol);
 

diff  --git a/lldb/source/Host/common/TCPSocket.cpp 
b/lldb/source/Host/common/TCPSocket.cpp
index 5d863954ee8868..d0055c3b6c44fb 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -115,6 +115,14 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::vector TCPSocket::GetListeningConnectionURI() const {
+  std::vector URIs;
+  for (const auto &[fd, addr] : m_listen_sockets)
+URIs.emplace_back(llvm::formatv("connection://[{0}]:{1}",
+addr.GetIPAddress(), addr.GetPort()));
+  return URIs;
+}
+
 Status TCPSocket::CreateSocket(int domain) {
   Status error;
   if (IsValid())

diff  --git a/lldb/source/Host/posix/DomainSocket.cpp 
b/lldb/source/Host/posix/DomainSocket.cpp
index 0451834630d33f..9a0b385d998bfc 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -175,3 +175,17 @@ std::string DomainSocket::GetRemoteConnectionURI() const {
   "{0}://{1}",
   GetNameOffset() == 0 ? "unix-connect" : "unix-abstract-connect", name);
 }
+
+std::vector DomainSocket::GetListeningConnectionURI() const {
+  if (m_socket == kInvalidSocketValue)
+return {};
+
+  struct sockaddr_un addr;
+  bzero(&addr, sizeof(struct sockaddr_un));
+  addr.sun_family = AF_UNIX;
+  socklen_t addr_len = sizeof(struct sockaddr_un);
+  if (::getsockname(m_socket, (struct sockaddr *)&addr, &addr_len) != 0)
+return {};
+
+  return {llvm::formatv("unix-connect://{0}", addr.sun_path)};
+}

diff  --git a/lldb/unittests/Host/SocketTest.cpp 
b/lldb/unittests/Host/SocketTest.cpp
index b20cfe54640285..a74352c19725d2 100644
--- a/lldb/unittests/Host/SocketTest.cpp
+++ b/lldb/unittests/Host/SocketTest.cpp
@@ -88,6 +88,28 @@ TEST_P(SocketTest, DomainListenConnectAccept) {
   CreateDomainConnectedSockets(Path, &socket_a_up, &socket_b_up);
 }
 
+TEST_P(SocketTest, DomainListenGetListeningConnectionURI) {
+  llvm::SmallString<64> Path;
+  std::er

[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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

https://github.com/ashgti closed 
https://github.com/llvm/llvm-project/pull/118330
___
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-03 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/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.

>From 984beaa4b26f97a925d8c3f3bc97a9e9b61511ec Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 3 Dec 2024 12:59:13 -0800
Subject: [PATCH] [lldb-dap] Support finding the lldb-dap binary

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.
---
 .../lldb-dap/src-ts/debug-adapter-factory.ts  | 117 +++---
 lldb/tools/lldb-dap/src-ts/extension.ts   |  76 ++--
 2 files changed, 112 insertions(+), 81 deletions(-)

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..d5616b2f8f6167 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -1,4 +1,7 @@
+import * as path from "path";
+import * as util from "util";
 import * as vscode from "vscode";
+
 import { LLDBDapOptions } from "./types";
 
 /**
@@ -8,15 +11,7 @@ import { LLDBDapOptions } from "./types";
 export class LLDBDapDescriptorFactory
   implements vscode.DebugAdapterDescriptorFactory
 {
-  private lldbDapOptions: LLDBDapOptions;
-
-  constructor(lldbDapOptions: LLDBDapOptions) {
-this.lldbDapOptions = lldbDapOptions;
-  }
-
-  static async isValidDebugAdapterPath(
-pathUri: vscode.Uri,
-  ): Promise {
+  static async isValidFile(pathUri: vscode.Uri): Promise {
 try {
   const fileStats = await vscode.workspace.fs.stat(pathUri);
   if (!(fileStats.type & vscode.FileType.File)) {
@@ -28,6 +23,70 @@ export class LLDBDapDescriptorFactory
 return true;
   }
 
+  static async findDAPExecutable(): Promise {
+let executable = "lldb-dap";
+if (process.platform === "win32") {
+  executable = "lldb-dap.exe";
+}
+
+// Prefer lldb-dap from Xcode on Darwin.
+if (process.platform === "darwin") {
+  try {
+const exec = util.promisify(require("child_process").execFile);
+let { stdout, stderr } = await exec("/usr/bin/xcrun", [
+  "-find",
+  executable,
+]);
+if (stdout) {
+  return stdout.toString().trimEnd();
+}
+  } catch (error) {}
+}
+
+// Find lldb-dap in the user's path.
+let env_path =
+  process.env["PATH"] ||
+  (process.platform === "win32" ? process.env["Path"] : null);
+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 LLDBDapDescriptorFactory.isValidFile(vscode.Uri.file(exe_path))
+  ) {
+return exe_path;
+  }
+}
+
+return undefined;
+  }
+
+  static async 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 LLDBDapDescriptorFactory.findDAPExecutable();
+if (foundPath) {
+  return foundPath;
+}
+
+return undefined;
+  }
+
   async createDebugAdapterDescriptor(
 session: vscode.DebugSession,
 executable: vscode.DebugAdapterExecutable | undefined,
@@ -36,14 +95,42 @@ export class LLDBDapDescriptorFactory
   "lldb-dap",
   session.workspaceFolder,
 );
-const customPath = config.get("executable-path");
-const path: string = customPath || executable!!.command;
 
-const fileUri = vscode.Uri.file(path);
-if (!(await LLDBDapDescriptorFactory.isValidDebugAdapterPath(fileUri))) {
-  LLDBDapDescriptorFacto

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

2024-12-03 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

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.

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


2 Files Affected:

- (modified) lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts (+102-15) 
- (modified) lldb/tools/lldb-dap/src-ts/extension.ts (+10-66) 


``diff
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..d5616b2f8f6167 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -1,4 +1,7 @@
+import * as path from "path";
+import * as util from "util";
 import * as vscode from "vscode";
+
 import { LLDBDapOptions } from "./types";
 
 /**
@@ -8,15 +11,7 @@ import { LLDBDapOptions } from "./types";
 export class LLDBDapDescriptorFactory
   implements vscode.DebugAdapterDescriptorFactory
 {
-  private lldbDapOptions: LLDBDapOptions;
-
-  constructor(lldbDapOptions: LLDBDapOptions) {
-this.lldbDapOptions = lldbDapOptions;
-  }
-
-  static async isValidDebugAdapterPath(
-pathUri: vscode.Uri,
-  ): Promise {
+  static async isValidFile(pathUri: vscode.Uri): Promise {
 try {
   const fileStats = await vscode.workspace.fs.stat(pathUri);
   if (!(fileStats.type & vscode.FileType.File)) {
@@ -28,6 +23,70 @@ export class LLDBDapDescriptorFactory
 return true;
   }
 
+  static async findDAPExecutable(): Promise {
+let executable = "lldb-dap";
+if (process.platform === "win32") {
+  executable = "lldb-dap.exe";
+}
+
+// Prefer lldb-dap from Xcode on Darwin.
+if (process.platform === "darwin") {
+  try {
+const exec = util.promisify(require("child_process").execFile);
+let { stdout, stderr } = await exec("/usr/bin/xcrun", [
+  "-find",
+  executable,
+]);
+if (stdout) {
+  return stdout.toString().trimEnd();
+}
+  } catch (error) {}
+}
+
+// Find lldb-dap in the user's path.
+let env_path =
+  process.env["PATH"] ||
+  (process.platform === "win32" ? process.env["Path"] : null);
+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 LLDBDapDescriptorFactory.isValidFile(vscode.Uri.file(exe_path))
+  ) {
+return exe_path;
+  }
+}
+
+return undefined;
+  }
+
+  static async 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 LLDBDapDescriptorFactory.findDAPExecutable();
+if (foundPath) {
+  return foundPath;
+}
+
+return undefined;
+  }
+
   async createDebugAdapterDescriptor(
 session: vscode.DebugSession,
 executable: vscode.DebugAdapterExecutable | undefined,
@@ -36,14 +95,42 @@ export class LLDBDapDescriptorFactory
   "lldb-dap",
   session.workspaceFolder,
 );
-const customPath = config.get("executable-path");
-const path: string = customPath || executable!!.command;
 
-const fileUri = vscode.Uri.file(path);
-if (!(await LLDBDapDescriptorFactory.isValidDebugAdapterPath(fileUri))) {
-  LLDBDapDescriptorFactory.showLLDBDapNotFoundMessage(fileUri.path);
+const log_path = config.get("log-path");
+let env: { [key: string]: string } = {};
+if (log_path) {
+  env["LLDBDAP_LOG"] = log_path;
+}
+const configEnvironment =
+  config.get<{ [key: string]: string }>("environment") || {};
+const dapPath = await LLDBDapDescriptorFactory.getDAPExecutable(session);
+const dbgOptions = {
+  env: {
+...executable?.options?.env,
+...configEnvironment,
+...env,
+  },
+};
+if (dapPath) {
+  const fileUri = vscode.Uri.file(dapPath);
+  if (!(await LLDBDapDescriptorFactory.isValidFile(fileUri))) {
+LLDBDapDescriptorFactory.showLLDBDapNotFoundMessage

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

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

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

>From 984beaa4b26f97a925d8c3f3bc97a9e9b61511ec Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 3 Dec 2024 12:59:13 -0800
Subject: [PATCH 1/3] [lldb-dap] Support finding the lldb-dap binary

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.
---
 .../lldb-dap/src-ts/debug-adapter-factory.ts  | 117 +++---
 lldb/tools/lldb-dap/src-ts/extension.ts   |  76 ++--
 2 files changed, 112 insertions(+), 81 deletions(-)

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..d5616b2f8f6167 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -1,4 +1,7 @@
+import * as path from "path";
+import * as util from "util";
 import * as vscode from "vscode";
+
 import { LLDBDapOptions } from "./types";
 
 /**
@@ -8,15 +11,7 @@ import { LLDBDapOptions } from "./types";
 export class LLDBDapDescriptorFactory
   implements vscode.DebugAdapterDescriptorFactory
 {
-  private lldbDapOptions: LLDBDapOptions;
-
-  constructor(lldbDapOptions: LLDBDapOptions) {
-this.lldbDapOptions = lldbDapOptions;
-  }
-
-  static async isValidDebugAdapterPath(
-pathUri: vscode.Uri,
-  ): Promise {
+  static async isValidFile(pathUri: vscode.Uri): Promise {
 try {
   const fileStats = await vscode.workspace.fs.stat(pathUri);
   if (!(fileStats.type & vscode.FileType.File)) {
@@ -28,6 +23,70 @@ export class LLDBDapDescriptorFactory
 return true;
   }
 
+  static async findDAPExecutable(): Promise {
+let executable = "lldb-dap";
+if (process.platform === "win32") {
+  executable = "lldb-dap.exe";
+}
+
+// Prefer lldb-dap from Xcode on Darwin.
+if (process.platform === "darwin") {
+  try {
+const exec = util.promisify(require("child_process").execFile);
+let { stdout, stderr } = await exec("/usr/bin/xcrun", [
+  "-find",
+  executable,
+]);
+if (stdout) {
+  return stdout.toString().trimEnd();
+}
+  } catch (error) {}
+}
+
+// Find lldb-dap in the user's path.
+let env_path =
+  process.env["PATH"] ||
+  (process.platform === "win32" ? process.env["Path"] : null);
+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 LLDBDapDescriptorFactory.isValidFile(vscode.Uri.file(exe_path))
+  ) {
+return exe_path;
+  }
+}
+
+return undefined;
+  }
+
+  static async 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 LLDBDapDescriptorFactory.findDAPExecutable();
+if (foundPath) {
+  return foundPath;
+}
+
+return undefined;
+  }
+
   async createDebugAdapterDescriptor(
 session: vscode.DebugSession,
 executable: vscode.DebugAdapterExecutable | undefined,
@@ -36,14 +95,42 @@ export class LLDBDapDescriptorFactory
   "lldb-dap",
   session.workspaceFolder,
 );
-const customPath = config.get("executable-path");
-const path: string = customPath || executable!!.command;
 
-const fileUri = vscode.Uri.file(path);
-if (!(await LLDBDapDescriptorFactory.isValidDebugAdapterPath(fileUri))) {
-  LLDBDapDescriptorFactory.showLLDBDapNotFoundMessage(fileUri.path);
+const log_path = config.get("log-path");
+let env: { [key: string]: string } = {};
+if (log_path) {
+  env["LLDBDAP_LOG"] = log_path;
+}
+const configEnvironment =
+  config.get<{ [key: string]: string }>("environment") || {};
+const dapPath = await LLDBDapDescriptorFactory.getDAPExecutable(session);
+const dbgOptions = {
+  env: {
+...executable?.options?.env,
+...configEnvironment,
+...env,
+  },
+};
+if (dapPath) {
+  const fileUri = vscode.Uri.file(d

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

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

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


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] Fix error returns in CastToBasicType and CastToEnumType in ValueObject. (PR #117401)

2024-12-03 Thread via lldb-commits

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

>From b6051edba2a1ecae144ead48712fb511c204131a Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Fri, 22 Nov 2024 15:33:42 -0800
Subject: [PATCH 1/3] [LLDB] Fix error returns in CastToBasicType and
 CastToEnumType in ValueObject.

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.
---
 lldb/source/ValueObject/ValueObject.cpp | 87 +++--
 1 file changed, 53 insertions(+), 34 deletions(-)

diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index 86172ad1b561f9..1093c4b665f4eb 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -3194,16 +3194,19 @@ 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();
+Status error = Status::FromErrorString("target type must be a scalar");
+return ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(), error.Clone());
   }
 
   if (!is_scalar && !is_enum && !is_pointer) {
-m_error =
+Status error =
 Status::FromErrorString("argument must be a scalar, enum, or pointer");
-return GetSP();
+return ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(), error.Clone());
   }
 
   lldb::TargetSP target = GetTargetSP();
@@ -3216,14 +3219,16 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
 
   if (is_pointer) {
 if (!type.IsInteger() && !type.IsBoolean()) {
-  m_error =
+  Status error =
   Status::FromErrorString("target type must be an integer or boolean");
-  return GetSP();
+  return ValueObjectConstResult::Create(
+  exe_ctx.GetBestExecutionContextScope(), error.Clone());
 }
 if (!type.IsBoolean() && type_byte_size < val_byte_size) {
-  m_error = Status::FromErrorString(
+  Status error = Status::FromErrorString(
   "target type cannot be smaller than the pointer type");
-  return GetSP();
+  return ValueObjectConstResult::Create(
+  exe_ctx.GetBestExecutionContextScope(), error.Clone());
 }
   }
 
@@ -3237,10 +3242,11 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
 return ValueObject::CreateValueObjectFromBool(
 target, !float_value_or_err->isZero(), "result");
   else {
-m_error = Status::FromErrorStringWithFormat(
+Status error = Status::FromErrorStringWithFormat(
 "cannot get value as APFloat: %s",
 llvm::toString(float_value_or_err.takeError()).c_str());
-return GetSP();
+return ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(), error.Clone());
   }
 }
   }
@@ -3256,11 +3262,12 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
 return ValueObject::CreateValueObjectFromAPInt(target, ext, type,
"result");
   } else {
-m_error = Status::FromErrorStringWithFormat(
+Status error = Status::FromErrorStringWithFormat(
 "cannot get value as APSInt: %s",
 llvm::toString(int_value_or_err.takeError()).c_str());
 ;
-return GetSP();
+return ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(), error.Clone());
   }
 } else if (is_scalar && is_float) {
   llvm::APSInt integer(type_byte_size * CHAR_BIT, !type.IsSigned());
@@ -3274,10 +3281,11 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
 // Casting floating point values that are out of bounds of the target
 // type is undefined behaviour.
 if (status & llvm::APFloatBase::opInvalidOp) {
-  m_error = Status::FromErrorStringWithFormat(
+  Status error = Status::FromErrorStringWithFormat(
   "invalid type cast detected: %s",
   llvm::toString(float_value_or_err.takeError()).c_str());
-  return GetSP();
+  return ValueObjectConstResult::Create(
+  exe_ctx.GetBestExecutionContextScope(), error.Clone());
 }
 return ValueObject::CreateValueObjectFromAPInt(target, integer, type,
"result");
@@ -3297,10 +3305,11 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
   

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

2024-12-03 Thread via lldb-commits


@@ -3194,16 +3194,19 @@ 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();
+Status error = Status::FromErrorString("target type must be a scalar");
+return ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(), error.Clone());

cmtice wrote:

Done.

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] 442ee78 - [lldb-dap] Fix Markdown tables in README.md

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

Author: Jonas Devlieghere
Date: 2024-12-03T20:59:02-08:00
New Revision: 442ee78cb414cd7101482bb677e62631e94e5480

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

LOG: [lldb-dap] Fix Markdown tables in README.md

The markdown tables in the README aren't getting rendered correctly on
the LLDB-DAP page in the Visual Studio arketplace [1]. This is a
somewhat speculative fix as the table itself appears to be correct. Even
if this change doesn't fix it, the new formatting significantly improves
the readability.

[1] 
https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.lldb-dap

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 42b5f501e32c65..8196dfdd5073c8 100644
--- a/lldb/tools/lldb-dap/README.md
+++ b/lldb/tools/lldb-dap/README.md
@@ -6,9 +6,9 @@ The extension requires the `lldb-dap` (formerly `lldb-vscode`) 
binary.
 This binary is not packaged with the VS Code extension.
 
 There are multiple ways to obtain this binary:
-* use the binary provided by your toolchain (for example `xcrun -f lldb-dap` 
on macOS) or contact your toolchain vendor to include it.
-* download one of the relase packages from the [LLVM release 
page](https://github.com/llvm/llvm-project/releases/). The 
`LLVM-19.1.0-{operating_system}.tar.xz` packages contain a prebuilt `lldb-dap` 
binary.
-* build it from source (see [LLDB's build 
instructions](https://lldb.llvm.org/resources/build.html))
+* Use the binary provided by your toolchain (for example `xcrun -f lldb-dap` 
on macOS) or contact your toolchain vendor to include it.
+* Download one of the relase packages from the [LLVM release 
page](https://github.com/llvm/llvm-project/releases/). The 
`LLVM-19.1.0-{operating_system}.tar.xz` packages contain a prebuilt `lldb-dap` 
binary.
+* Build it from source (see [LLDB's build 
instructions](https://lldb.llvm.org/resources/build.html)).
 
 By default, the VS Code extension will expect to find `lldb-dap` in your 
`PATH`.
 Alternatively, you can explictly specify the location of the `lldb-dap` binary 
using the `lldb-dap.executable-path` setting.
@@ -179,26 +179,26 @@ The default hostname being used `localhost`.
 For both launch and attach configurations, lldb-dap accepts the following 
`lldb-dap`
 specific key/value pairs:
 
-|parameter  |type|req | |
-|---||:--:|-|
-|**name**   |string|Y| A configuration name that will be displayed in 
the IDE.
-|**type**   |string|Y| Must be "lldb-dap".
-|**request**|string|Y| Must be "launch" or "attach".
-|**program**|string|Y| Path to the executable to launch.
-|**sourcePath** |string| | Specify a source path to remap \"./\" to allow 
full paths to be used when setting breakpoints in binaries that have relative 
source paths.
-|**sourceMap**  |[string[2]]| | Specify an array of path re-mappings. Each 
element in the array must be a two element array containing a source and 
destination pathname. Overrides sourcePath.
-|**debuggerRoot**   | string| |Specify a working directory to use when 
launching lldb-dap. If the debug information in your executable contains 
relative paths, this option can be used so that `lldb-dap` can find source 
files and object files that have relative paths.
-|**commandEscapePrefix** | string | | The escape prefix to use for executing 
regular LLDB commands in the Debug Console, instead of printing variables. 
Defaults to a backtick. If it's an empty string, then all expression in the 
Debug Console are treated as regular LLDB commands.
-|**customFrameFormat** | string | | If non-empty, stack frames will have 
descriptions generated based on the provided format. See 
https://lldb.llvm.org/use/formatting.html for an explanation on format strings 
for frames. If the format string contains errors, an error message will be 
displayed on the Debug Console and the default frame names will be used. This 
might come with a performance cost because debug information might need to be 
processed to generate the description.
-|**customThreadFormat** | string | | Same as `customFrameFormat`, but for 
threads instead of stack frames.
-|**displayExtendedBacktrace**|bool| | Enable language specific extended 
backtraces.
-|**enableAutoVariableSummaries**|bool| | Enable auto generated summaries for 
variables when no summaries exist for a given type. This feature can cause 
performance delays in large projects when viewing variables.
-|**enableSyntheticChildDebugging**|bool| | If a variable is displayed using a 
synthetic children, also display the actual contents of the variable at the end 
under a [raw] entry. This is useful when creating sythetic child plug-

[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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

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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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

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

>From c3226b620bc8f745b92b3aca7b189803a24db788 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 2 Dec 2024 08:29:01 -0800
Subject: [PATCH 1/5] [lldb] For a host socket, add a method to print the
 listening address.

This is most useful if you are listening on an address like 'localhost:0' and 
want to know the resolved ip + port of the socket listeniner.
---
 lldb/include/lldb/Host/Socket.h |  3 ++
 lldb/include/lldb/Host/common/TCPSocket.h   |  2 +
 lldb/include/lldb/Host/posix/DomainSocket.h |  2 +
 lldb/source/Host/common/TCPSocket.cpp   | 22 +++--
 lldb/source/Host/posix/DomainSocket.cpp | 17 ++-
 lldb/unittests/Host/SocketTest.cpp  | 51 ++---
 6 files changed, 86 insertions(+), 11 deletions(-)

diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h
index e98797b36c8a5d..c937e0c02ff19e 100644
--- a/lldb/include/lldb/Host/Socket.h
+++ b/lldb/include/lldb/Host/Socket.h
@@ -151,6 +151,9 @@ class Socket : public IOObject {
   // If this Socket is connected then return the URI used to connect.
   virtual std::string GetRemoteConnectionURI() const { return ""; };
 
+  // If the Socket is listening then return the URI for clients to connect.
+  virtual std::string GetListeningConnectionURI() const { return ""; }
+
 protected:
   Socket(SocketProtocol protocol, bool should_close);
 
diff --git a/lldb/include/lldb/Host/common/TCPSocket.h 
b/lldb/include/lldb/Host/common/TCPSocket.h
index ca36622691fe9a..ab6bf5ab97cae7 100644
--- a/lldb/include/lldb/Host/common/TCPSocket.h
+++ b/lldb/include/lldb/Host/common/TCPSocket.h
@@ -52,6 +52,8 @@ class TCPSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::string GetListeningConnectionURI() const override;
+
 private:
   TCPSocket(NativeSocket socket, const TCPSocket &listen_socket);
 
diff --git a/lldb/include/lldb/Host/posix/DomainSocket.h 
b/lldb/include/lldb/Host/posix/DomainSocket.h
index d4e0d43ee169c1..d79564cc76dafd 100644
--- a/lldb/include/lldb/Host/posix/DomainSocket.h
+++ b/lldb/include/lldb/Host/posix/DomainSocket.h
@@ -27,6 +27,8 @@ class DomainSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::string GetListeningConnectionURI() const override;
+
 protected:
   DomainSocket(SocketProtocol protocol);
 
diff --git a/lldb/source/Host/common/TCPSocket.cpp 
b/lldb/source/Host/common/TCPSocket.cpp
index 5d863954ee8868..b7bd62ff04855e 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -81,6 +81,12 @@ std::string TCPSocket::GetLocalIPAddress() const {
 socklen_t sock_addr_len = sock_addr.GetMaxLength();
 if (::getsockname(m_socket, sock_addr, &sock_addr_len) == 0)
   return sock_addr.GetIPAddress();
+  } else if (!m_listen_sockets.empty()) {
+SocketAddress sock_addr;
+socklen_t sock_addr_len = sock_addr.GetMaxLength();
+if (::getsockname(m_listen_sockets.begin()->first, sock_addr,
+  &sock_addr_len) == 0)
+  return sock_addr.GetIPAddress();
   }
   return "";
 }
@@ -115,6 +121,15 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::string TCPSocket::GetListeningConnectionURI() const {
+  if (!m_listen_sockets.empty()) {
+return std::string(llvm::formatv(
+"connection://[{0}]:{1}", GetLocalIPAddress(), GetLocalPortNumber()));
+  }
+
+  return "";
+}
+
 Status TCPSocket::CreateSocket(int domain) {
   Status error;
   if (IsValid())
@@ -176,8 +191,9 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 
   if (host_port->hostname == "*")
 host_port->hostname = "0.0.0.0";
-  std::vector addresses = SocketAddress::GetAddressInfo(
-  host_port->hostname.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, 
IPPROTO_TCP);
+  std::vector addresses =
+  SocketAddress::GetAddressInfo(host_port->hostname.c_str(), nullptr,
+AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
   for (SocketAddress &address : addresses) {
 int fd =
 Socket::CreateSocket(address.GetFamily(), kType, IPPROTO_TCP, error);
@@ -191,7 +207,7 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 }
 
 SocketAddress listen_address = address;
-if(!listen_address.IsLocalhost())
+if (!listen_address.IsLocalhost())
   listen_address.SetToAnyAddress(address.GetFamily(), host_port->port);
 else
   listen_address.SetPort(host_port->port);
diff --git a/lldb/source/Host/posix/DomainSocket.cpp 
b/lldb/source/Host/posix/DomainSocket.cpp
index 0451834630d33f..beec3c225ecc62 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -86,7 +86,8 @@ Status DomainSocket::Connect(llvm::StringRef name) {
   if (error.Fail())
 return error;
   if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),

[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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

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

Cool. Thanks.

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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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


@@ -88,6 +88,28 @@ TEST_P(SocketTest, DomainListenConnectAccept) {
   CreateDomainConnectedSockets(Path, &socket_a_up, &socket_b_up);
 }
 
+TEST_P(SocketTest, DomainListenGetListeningConnectionURI) {
+  llvm::SmallString<64> Path;
+  std::error_code EC =
+  llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path);
+  ASSERT_FALSE(EC);
+  llvm::sys::path::append(Path, "test");
+
+  // Skip the test if the $TMPDIR is too long to hold a domain socket.
+  if (Path.size() > 107u)
+return;
+
+  auto listen_socket_up = std::make_unique(
+  /*should_close=*/true);
+  Status error = listen_socket_up->Listen(Path, 5);
+  ASSERT_THAT_ERROR(error.ToError(), llvm::Succeeded());
+  ASSERT_TRUE(listen_socket_up->IsValid());
+
+  const auto &URIs = listen_socket_up->GetListeningConnectionURI();
+  ASSERT_EQ(URIs.size(), 1u);
+  ASSERT_EQ(URIs[0], llvm::formatv("unix-connect://{0}", Path).str());

labath wrote:

```suggestion
  ASSERT_THAT(URIs, testing::ElementsAre(llvm::formatv("unix-connect://{0}", 
Path).str()));
```

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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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


@@ -115,6 +115,18 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::vector TCPSocket::GetListeningConnectionURI() const {
+  if (m_listen_sockets.empty())
+return {};
+

labath wrote:

```suggestion
```

The common code handles this case just fine.

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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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


@@ -225,12 +247,29 @@ TEST_P(SocketTest, TCPListen0GetPort) {
   if (!HostSupportsIPv4())
 return;
   llvm::Expected> sock =
-  Socket::TcpListen("10.10.12.3:0", false);
+  Socket::TcpListen("10.10.12.3:0", 5);
   ASSERT_THAT_EXPECTED(sock, llvm::Succeeded());
   ASSERT_TRUE(sock.get()->IsValid());
   EXPECT_NE(sock.get()->GetLocalPortNumber(), 0);
 }
 
+TEST_P(SocketTest, TCPListen0GetListeningConnectionURI) {
+  if (!HostSupportsProtocol())
+return;
+
+  std::string addr = llvm::formatv("[{0}]:0", GetParam().localhost_ip).str();
+  llvm::Expected> sock = Socket::TcpListen(addr);
+  ASSERT_THAT_EXPECTED(sock, llvm::Succeeded());
+  ASSERT_TRUE(sock.get()->IsValid());
+
+  for (const auto &URI : sock.get()->GetListeningConnectionURI()) {
+EXPECT_EQ(URI,
+  llvm::formatv("connection://[{0}]:{1}", GetParam().localhost_ip,
+sock->get()->GetLocalPortNumber())
+  .str());
+  }
+}

labath wrote:

```suggestion
  EXPECT_THAT(sock.get()->GetListeningConnectionURI(), 
testing::ElementsAre(llvm::formatv("connection://[{0}]:{1}", 
GetParam().localhost_ip,
sock->get()->GetLocalPortNumber())
  .str()));
```

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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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


@@ -115,6 +115,18 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::vector TCPSocket::GetListeningConnectionURI() const {
+  if (m_listen_sockets.empty())
+return {};
+
+  std::vector URIs;
+  for (auto &s : m_listen_sockets)

labath wrote:

```suggestion
  for (const auto &[fd, addr] : m_listen_sockets)
```

(or any other variable names you like)

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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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


@@ -176,8 +191,9 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 
   if (host_port->hostname == "*")
 host_port->hostname = "0.0.0.0";
-  std::vector addresses = SocketAddress::GetAddressInfo(
-  host_port->hostname.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, 
IPPROTO_TCP);
+  std::vector addresses =

ashgti wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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

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

>From c3226b620bc8f745b92b3aca7b189803a24db788 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 2 Dec 2024 08:29:01 -0800
Subject: [PATCH 1/6] [lldb] For a host socket, add a method to print the
 listening address.

This is most useful if you are listening on an address like 'localhost:0' and 
want to know the resolved ip + port of the socket listeniner.
---
 lldb/include/lldb/Host/Socket.h |  3 ++
 lldb/include/lldb/Host/common/TCPSocket.h   |  2 +
 lldb/include/lldb/Host/posix/DomainSocket.h |  2 +
 lldb/source/Host/common/TCPSocket.cpp   | 22 +++--
 lldb/source/Host/posix/DomainSocket.cpp | 17 ++-
 lldb/unittests/Host/SocketTest.cpp  | 51 ++---
 6 files changed, 86 insertions(+), 11 deletions(-)

diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h
index e98797b36c8a5d..c937e0c02ff19e 100644
--- a/lldb/include/lldb/Host/Socket.h
+++ b/lldb/include/lldb/Host/Socket.h
@@ -151,6 +151,9 @@ class Socket : public IOObject {
   // If this Socket is connected then return the URI used to connect.
   virtual std::string GetRemoteConnectionURI() const { return ""; };
 
+  // If the Socket is listening then return the URI for clients to connect.
+  virtual std::string GetListeningConnectionURI() const { return ""; }
+
 protected:
   Socket(SocketProtocol protocol, bool should_close);
 
diff --git a/lldb/include/lldb/Host/common/TCPSocket.h 
b/lldb/include/lldb/Host/common/TCPSocket.h
index ca36622691fe9a..ab6bf5ab97cae7 100644
--- a/lldb/include/lldb/Host/common/TCPSocket.h
+++ b/lldb/include/lldb/Host/common/TCPSocket.h
@@ -52,6 +52,8 @@ class TCPSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::string GetListeningConnectionURI() const override;
+
 private:
   TCPSocket(NativeSocket socket, const TCPSocket &listen_socket);
 
diff --git a/lldb/include/lldb/Host/posix/DomainSocket.h 
b/lldb/include/lldb/Host/posix/DomainSocket.h
index d4e0d43ee169c1..d79564cc76dafd 100644
--- a/lldb/include/lldb/Host/posix/DomainSocket.h
+++ b/lldb/include/lldb/Host/posix/DomainSocket.h
@@ -27,6 +27,8 @@ class DomainSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::string GetListeningConnectionURI() const override;
+
 protected:
   DomainSocket(SocketProtocol protocol);
 
diff --git a/lldb/source/Host/common/TCPSocket.cpp 
b/lldb/source/Host/common/TCPSocket.cpp
index 5d863954ee8868..b7bd62ff04855e 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -81,6 +81,12 @@ std::string TCPSocket::GetLocalIPAddress() const {
 socklen_t sock_addr_len = sock_addr.GetMaxLength();
 if (::getsockname(m_socket, sock_addr, &sock_addr_len) == 0)
   return sock_addr.GetIPAddress();
+  } else if (!m_listen_sockets.empty()) {
+SocketAddress sock_addr;
+socklen_t sock_addr_len = sock_addr.GetMaxLength();
+if (::getsockname(m_listen_sockets.begin()->first, sock_addr,
+  &sock_addr_len) == 0)
+  return sock_addr.GetIPAddress();
   }
   return "";
 }
@@ -115,6 +121,15 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::string TCPSocket::GetListeningConnectionURI() const {
+  if (!m_listen_sockets.empty()) {
+return std::string(llvm::formatv(
+"connection://[{0}]:{1}", GetLocalIPAddress(), GetLocalPortNumber()));
+  }
+
+  return "";
+}
+
 Status TCPSocket::CreateSocket(int domain) {
   Status error;
   if (IsValid())
@@ -176,8 +191,9 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 
   if (host_port->hostname == "*")
 host_port->hostname = "0.0.0.0";
-  std::vector addresses = SocketAddress::GetAddressInfo(
-  host_port->hostname.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, 
IPPROTO_TCP);
+  std::vector addresses =
+  SocketAddress::GetAddressInfo(host_port->hostname.c_str(), nullptr,
+AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
   for (SocketAddress &address : addresses) {
 int fd =
 Socket::CreateSocket(address.GetFamily(), kType, IPPROTO_TCP, error);
@@ -191,7 +207,7 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 }
 
 SocketAddress listen_address = address;
-if(!listen_address.IsLocalhost())
+if (!listen_address.IsLocalhost())
   listen_address.SetToAnyAddress(address.GetFamily(), host_port->port);
 else
   listen_address.SetPort(host_port->port);
diff --git a/lldb/source/Host/posix/DomainSocket.cpp 
b/lldb/source/Host/posix/DomainSocket.cpp
index 0451834630d33f..beec3c225ecc62 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -86,7 +86,8 @@ Status DomainSocket::Connect(llvm::StringRef name) {
   if (error.Fail())
 return error;
   if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),

[Lldb-commits] [lldb] f44bee7 - [lldb] Fix the DWARF index cache when index is partial. (#118390)

2024-12-03 Thread via lldb-commits

Author: Greg Clayton
Date: 2024-12-03T10:09:40-08:00
New Revision: f44bee78c471df8f0a258c656a921a082d7e836a

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

LOG: [lldb] Fix the DWARF index cache when index is partial. (#118390)

The ManualDWARFIndex class can create a index cache if the LLDB index
cache is enabled. This used to save the index to the same file,
regardless of wether the cache was a full index (no .debug_names) or a
partial index (have .debug_names, but not all .o files were had
.debug_names). So we could end up saving an index cache that was
partial, and then later load that partial index as if it were a full
index if the user set the 'settings set
plugin.symbol-file.dwarf.ignore-file-indexes true'. This would cause us
to ignore the .debug_names section, and if the index cache was enabled,
we could end up loading the partial index as if it were a full DWARF
index.

This patch detects when the ManualDWARFIndex is being used with
.debug_names, and saves out a cache file with a suffix of "-full" or
"-partial" to avoid this issue.

Added: 
lldb/test/Shell/SymbolFile/DWARF/x86/dwp-index-cache.cpp

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 1220e6115a2a95..0be19ab29ef082 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -706,6 +706,11 @@ bool ManualDWARFIndex::Encode(DataEncoder &encoder) const {
   return true;
 }
 
+bool ManualDWARFIndex::IsPartial() const {
+  // If we have units or type units to skip, then this index is partial.
+  return !m_units_to_avoid.empty() || !m_type_sigs_to_avoid.empty();
+}
+
 std::string ManualDWARFIndex::GetCacheKey() {
   std::string key;
   llvm::raw_string_ostream strm(key);
@@ -713,9 +718,26 @@ std::string ManualDWARFIndex::GetCacheKey() {
   // module can have one object file as the main executable and might have
   // another object file in a separate symbol file, or we might have a .dwo 
file
   // that claims its module is the main executable.
+
+  // This class can be used to index all of the DWARF, or part of the DWARF
+  // when there is a .debug_names index where some compile or type units were
+  // built without .debug_names. So we need to know when we have a full manual
+  // DWARF index or a partial manual DWARF index and save them to 
diff erent
+  // cache files. Before this fix we might end up debugging a binary with
+  // .debug_names where some of the compile or type units weren't indexed, and
+  // find an issue with the .debug_names tables (bugs or being incomplete), and
+  // then we disable loading the .debug_names by setting a setting in LLDB by
+  // running "settings set plugin.symbol-file.dwarf.ignore-file-indexes 0" in
+  // another LLDB instance. The problem arose when there was an index cache 
from
+  // a previous run where .debug_names was enabled and it had saved a cache 
file
+  // that only covered the missing compile and type units from the 
.debug_names,
+  // and with the setting that disables the loading of the cache files we would
+  // load partial cache index cache. So we need to pick a unique cache suffix
+  // name that indicates if the cache is partial or full to avoid this problem.
+  llvm::StringRef dwarf_index_suffix(IsPartial() ? "partial-" : "full-");
   ObjectFile *objfile = m_dwarf->GetObjectFile();
   strm << objfile->GetModule()->GetCacheKey() << "-dwarf-index-"
-  << llvm::format_hex(objfile->GetCacheHash(), 10);
+   << dwarf_index_suffix << llvm::format_hex(objfile->GetCacheHash(), 10);
   return key;
 }
 

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
index d8c4a22ab21f7b..6a52c88a99220f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
@@ -168,6 +168,16 @@ class ManualDWARFIndex : public DWARFIndex {
 const lldb::LanguageType cu_language,
 IndexSet &set);
 
+  /// Return true if this manual DWARF index is covering only part of the 
DWARF.
+  ///
+  /// An instance of this class will be used to index all of the DWARF, but 
also
+  /// when we have .debug_names we will use one to index any compile or type
+  /// units that are not covered by the .debug_names table.
+  ///
+  /// \return
+  ///   True if this index is a partial index, false otherwise.
+  bool IsPartial() const;
+
   /// The DWARF file which we are indexing.
   SymbolF

[Lldb-commits] [lldb] [lldb] Fix the DWARF index cache when index is partial. (PR #118390)

2024-12-03 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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


@@ -88,6 +88,28 @@ TEST_P(SocketTest, DomainListenConnectAccept) {
   CreateDomainConnectedSockets(Path, &socket_a_up, &socket_b_up);
 }
 
+TEST_P(SocketTest, DomainListenGetListeningConnectionURI) {
+  llvm::SmallString<64> Path;
+  std::error_code EC =
+  llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path);
+  ASSERT_FALSE(EC);
+  llvm::sys::path::append(Path, "test");
+
+  // Skip the test if the $TMPDIR is too long to hold a domain socket.
+  if (Path.size() > 107u)
+return;
+
+  auto listen_socket_up = std::make_unique(
+  /*should_close=*/true);
+  Status error = listen_socket_up->Listen(Path, 5);
+  ASSERT_THAT_ERROR(error.ToError(), llvm::Succeeded());
+  ASSERT_TRUE(listen_socket_up->IsValid());
+
+  const auto &URIs = listen_socket_up->GetListeningConnectionURI();
+  ASSERT_EQ(URIs.size(), 1u);
+  ASSERT_EQ(URIs[0], llvm::formatv("unix-connect://{0}", Path).str());

ashgti wrote:

Applied suggestion

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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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


@@ -225,12 +247,29 @@ TEST_P(SocketTest, TCPListen0GetPort) {
   if (!HostSupportsIPv4())
 return;
   llvm::Expected> sock =
-  Socket::TcpListen("10.10.12.3:0", false);
+  Socket::TcpListen("10.10.12.3:0", 5);
   ASSERT_THAT_EXPECTED(sock, llvm::Succeeded());
   ASSERT_TRUE(sock.get()->IsValid());
   EXPECT_NE(sock.get()->GetLocalPortNumber(), 0);
 }
 
+TEST_P(SocketTest, TCPListen0GetListeningConnectionURI) {
+  if (!HostSupportsProtocol())
+return;
+
+  std::string addr = llvm::formatv("[{0}]:0", GetParam().localhost_ip).str();
+  llvm::Expected> sock = Socket::TcpListen(addr);
+  ASSERT_THAT_EXPECTED(sock, llvm::Succeeded());
+  ASSERT_TRUE(sock.get()->IsValid());
+
+  for (const auto &URI : sock.get()->GetListeningConnectionURI()) {
+EXPECT_EQ(URI,
+  llvm::formatv("connection://[{0}]:{1}", GetParam().localhost_ip,
+sock->get()->GetLocalPortNumber())
+  .str());
+  }
+}

ashgti wrote:

Applied suggestion

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


[Lldb-commits] [lldb] 2a1a024 - Make SBMemoryRegionInfoList iterable with Python SWIG (#117358)

2024-12-03 Thread via lldb-commits

Author: Luke Riddle
Date: 2024-12-03T10:29:12-08:00
New Revision: 2a1a02461a8d4ae9f560a4215fe85a1f085b4d82

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

LOG: Make SBMemoryRegionInfoList iterable with Python SWIG (#117358)

This PR fixes a simple SWIG issue with SBMemoryRegionInfoList not being
iterable out-of-the-box. This is mostly because of limitations to the
`lldb_iter` function, which doesn't allow for specifying arguments to
the size / iter functions passed.

Before:
```
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> for region in lldb.process.GetMemoryRegions():
...   print(region)
...
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/opt/llvm/stable/Toolchains/llvm-sand.xctoolchain/usr/lib/python3.10/site-packages/lldb/__init__.py",
 line 114, in lldb_iter
yield elem(i)
TypeError: SBMemoryRegionInfoList.GetMemoryRegionAtIndex() missing 1 required 
positional argument: 'region_info'
```

After:
```
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> for region in lldb.process.GetMemoryRegions():
...   print(region)
... 
[0x0020-0x002cf000 R--]
[0x002cf000-0x00597000 R-X]
[0x00597000-0x005ad000 R--]
[0x005ad000-0x005b1000 RW-]
[0x005b1000-0x00b68000 RW-]
[0x7fff7000-0x8fff7000 RW-]
[0x02008fff7000-0x10007fff8000 RW-]
[0x5030-0x5031 RW-]
[0x503e-0x503e0001 RW-]
[0x5040-0x5041 RW-]
[0x504e-0x504e0001 RW-]
[0x50d0-0x50d1 RW-]
[0x50de-0x50de0001 RW-]
[0x50e0-0x50e1 RW-]
[0x50ee-0x50ee0001 RW-]
[0x5110-0x5111 RW-]
[0x511e-0x511e0001 RW-]
[0x5130-0x5131 RW-]
...
```

Added: 


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

Removed: 




diff  --git a/lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i 
b/lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i
index 49d49110de7ff9..29c0179c0ffe3e 100644
--- a/lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i
+++ b/lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i
@@ -7,7 +7,12 @@
 
 def __iter__(self):
   '''Iterate over all the memory regions in a lldb.SBMemoryRegionInfoList 
object.'''
-  return lldb_iter(self, 'GetSize', 'GetMemoryRegionAtIndex')
+  import lldb
+  size = self.GetSize()
+  region = lldb.SBMemoryRegionInfo()
+  for i in range(size):
+self.GetMemoryRegionAtIndex(i, region)
+yield region
 %}
 #endif
 }

diff  --git a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py 
b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
index 04e807c5c6201d..1ef37d2ec98988 100644
--- a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
+++ b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
@@ -152,3 +152,16 @@ def test_find_in_memory_unaligned(self):
 )
 self.assertSuccess(error)
 self.assertEqual(addr, lldb.LLDB_INVALID_ADDRESS)
+
+def test_memory_info_list_iterable(self):
+"""Make sure the SBMemoryRegionInfoList is iterable"""
+self.assertTrue(self.process, PROCESS_IS_VALID)
+self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
+
+info_list = self.process.GetMemoryRegions()
+self.assertTrue(info_list.GetSize() > 0)
+try:
+for info in info_list:
+pass
+except Exception:
+self.fail("SBMemoryRegionInfoList is not iterable")



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


[Lldb-commits] [lldb] Make SBMemoryRegionInfoList iterable with Python SWIG (PR #117358)

2024-12-03 Thread Jacob Lalonde via lldb-commits

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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

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


@@ -115,6 +115,18 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::vector TCPSocket::GetListeningConnectionURI() const {
+  if (m_listen_sockets.empty())
+return {};
+
+  std::vector URIs;
+  for (auto &s : m_listen_sockets)

ashgti wrote:

Applied suggestion

https://github.com/llvm/llvm-project/pull/118330
___
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-03 Thread Jonas Devlieghere via lldb-commits

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

>From 984beaa4b26f97a925d8c3f3bc97a9e9b61511ec Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 3 Dec 2024 12:59:13 -0800
Subject: [PATCH 1/2] [lldb-dap] Support finding the lldb-dap binary

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.
---
 .../lldb-dap/src-ts/debug-adapter-factory.ts  | 117 +++---
 lldb/tools/lldb-dap/src-ts/extension.ts   |  76 ++--
 2 files changed, 112 insertions(+), 81 deletions(-)

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..d5616b2f8f6167 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -1,4 +1,7 @@
+import * as path from "path";
+import * as util from "util";
 import * as vscode from "vscode";
+
 import { LLDBDapOptions } from "./types";
 
 /**
@@ -8,15 +11,7 @@ import { LLDBDapOptions } from "./types";
 export class LLDBDapDescriptorFactory
   implements vscode.DebugAdapterDescriptorFactory
 {
-  private lldbDapOptions: LLDBDapOptions;
-
-  constructor(lldbDapOptions: LLDBDapOptions) {
-this.lldbDapOptions = lldbDapOptions;
-  }
-
-  static async isValidDebugAdapterPath(
-pathUri: vscode.Uri,
-  ): Promise {
+  static async isValidFile(pathUri: vscode.Uri): Promise {
 try {
   const fileStats = await vscode.workspace.fs.stat(pathUri);
   if (!(fileStats.type & vscode.FileType.File)) {
@@ -28,6 +23,70 @@ export class LLDBDapDescriptorFactory
 return true;
   }
 
+  static async findDAPExecutable(): Promise {
+let executable = "lldb-dap";
+if (process.platform === "win32") {
+  executable = "lldb-dap.exe";
+}
+
+// Prefer lldb-dap from Xcode on Darwin.
+if (process.platform === "darwin") {
+  try {
+const exec = util.promisify(require("child_process").execFile);
+let { stdout, stderr } = await exec("/usr/bin/xcrun", [
+  "-find",
+  executable,
+]);
+if (stdout) {
+  return stdout.toString().trimEnd();
+}
+  } catch (error) {}
+}
+
+// Find lldb-dap in the user's path.
+let env_path =
+  process.env["PATH"] ||
+  (process.platform === "win32" ? process.env["Path"] : null);
+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 LLDBDapDescriptorFactory.isValidFile(vscode.Uri.file(exe_path))
+  ) {
+return exe_path;
+  }
+}
+
+return undefined;
+  }
+
+  static async 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 LLDBDapDescriptorFactory.findDAPExecutable();
+if (foundPath) {
+  return foundPath;
+}
+
+return undefined;
+  }
+
   async createDebugAdapterDescriptor(
 session: vscode.DebugSession,
 executable: vscode.DebugAdapterExecutable | undefined,
@@ -36,14 +95,42 @@ export class LLDBDapDescriptorFactory
   "lldb-dap",
   session.workspaceFolder,
 );
-const customPath = config.get("executable-path");
-const path: string = customPath || executable!!.command;
 
-const fileUri = vscode.Uri.file(path);
-if (!(await LLDBDapDescriptorFactory.isValidDebugAdapterPath(fileUri))) {
-  LLDBDapDescriptorFactory.showLLDBDapNotFoundMessage(fileUri.path);
+const log_path = config.get("log-path");
+let env: { [key: string]: string } = {};
+if (log_path) {
+  env["LLDBDAP_LOG"] = log_path;
+}
+const configEnvironment =
+  config.get<{ [key: string]: string }>("environment") || {};
+const dapPath = await LLDBDapDescriptorFactory.getDAPExecutable(session);
+const dbgOptions = {
+  env: {
+...executable?.options?.env,
+...configEnvironment,
+...env,
+  },
+};
+if (dapPath) {
+  const fileUri = vscode.Uri.file(d

[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-03 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

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.

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


2 Files Affected:

- (modified) lldb/source/Host/common/TCPSocket.cpp (+4-4) 
- (modified) lldb/unittests/Host/SocketTest.cpp (+31-12) 


``diff
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()->GetListeningConnectionURI(),
+  testing::UnorderedElementsAre(
+  llvm::formatv("connection://[::1]:{0}",
+sock->get()->GetLocalPortNumber())
+  .str(),
+  llvm::formatv("connection://[127.0.0.1]:{0}",
+sock->get()->GetLocalPortNumber())
+  .str()));
+}
+
 TEST_P(SocketTest, TCPGetConnectURI) {
   std::uni

[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-03 Thread John Harrison via lldb-commits

https://github.com/ashgti ready_for_review 
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] 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-03 Thread John Harrison via lldb-commits

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

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.

>From d38d568653aca9cb90853cf64adc6bee69289a4e Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Tue, 3 Dec 2024 16:16:59 -0800
Subject: [PATCH] [lldb] When using Socket to listen on `localhost:0` on
 systems supporting 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.
---
 lldb/source/Host/common/TCPSocket.cpp |  8 ++---
 lldb/unittests/Host/SocketTest.cpp| 43 +++
 2 files changed, 35 insertions(+), 16 deletions(-)

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);
@@

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

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


@@ -28,6 +23,70 @@ export class LLDBDapDescriptorFactory
 return true;
   }
 
+  static async findDAPExecutable(): Promise {
+let executable = "lldb-dap";
+if (process.platform === "win32") {
+  executable = "lldb-dap.exe";
+}

walter-erquinigo wrote:

just use the ternary comparator

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-dap] Support finding the lldb-dap binary (PR #118547)

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


@@ -28,6 +23,70 @@ export class LLDBDapDescriptorFactory
 return true;
   }
 
+  static async findDAPExecutable(): Promise {
+let executable = "lldb-dap";
+if (process.platform === "win32") {
+  executable = "lldb-dap.exe";
+}
+
+// Prefer lldb-dap from Xcode on Darwin.
+if (process.platform === "darwin") {
+  try {
+const exec = util.promisify(require("child_process").execFile);

ashgti wrote:

Should this be moved to the top of the file? Its never modified after creation.

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-dap] Support finding the lldb-dap binary (PR #118547)

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


@@ -8,15 +11,7 @@ import { LLDBDapOptions } from "./types";
 export class LLDBDapDescriptorFactory
   implements vscode.DebugAdapterDescriptorFactory
 {
-  private lldbDapOptions: LLDBDapOptions;
-
-  constructor(lldbDapOptions: LLDBDapOptions) {
-this.lldbDapOptions = lldbDapOptions;
-  }
-
-  static async isValidDebugAdapterPath(
-pathUri: vscode.Uri,
-  ): Promise {
+  static async isValidFile(pathUri: vscode.Uri): Promise {
 try {

ashgti wrote:

We may want to validate that the file is executable. It looks like the VS Code 
FS API doesn't have that info but we could use the node FS instead, something 
like:
```
import { access, constants } from 'node:fs/promises';

try {
  await access('', constants.X_OK);
  console.log('can execute');
} catch {
  console.error('cannot execute');
} 
```

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-dap] Support finding the lldb-dap binary (PR #118547)

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


@@ -8,15 +11,7 @@ import { LLDBDapOptions } from "./types";
 export class LLDBDapDescriptorFactory
   implements vscode.DebugAdapterDescriptorFactory
 {
-  private lldbDapOptions: LLDBDapOptions;
-
-  constructor(lldbDapOptions: LLDBDapOptions) {
-this.lldbDapOptions = lldbDapOptions;
-  }
-
-  static async isValidDebugAdapterPath(
-pathUri: vscode.Uri,
-  ): Promise {
+  static async isValidFile(pathUri: vscode.Uri): Promise {

ashgti wrote:

Should this just be a function outside of the class?

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][tests] Fix passing pthread library to a linker for some API tests (PR #118530)

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

https://github.com/dzhidzhoev created 
https://github.com/llvm/llvm-project/pull/118530

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

Refactoring fix.

>From 540b07e0ff0b0ecd6745837456c81bb5b95f18ab Mon Sep 17 00:00:00 2001
From: Vladimir Vereschaka 
Date: Tue, 28 May 2024 21:40:10 -0700
Subject: [PATCH] [lldb][tests] Fix passing pthread library to a linker for
 some API tests.

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

Updated the following tests:

* 
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
---
 .../aarch64_sme_z_registers/za_dynamic_resize/Makefile | 3 ++-
 .../aarch64_sve_registers/rw_access_dynamic_resize/Makefile| 3 ++-
 .../API/functionalities/process_save_core_minidump/Makefile| 2 +-
 lldb/test/API/tools/lldb-dap/threads/Makefile  | 3 ++-
 4 files changed, 7 insertions(+), 4 deletions(-)

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] f715124 - [lldb-dap] Fix the vscode-uninstall command

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

Author: Jonas Devlieghere
Date: 2024-12-03T11:03:28-08:00
New Revision: f7151248579330df8ea68003f60b778149e0f262

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

LOG: [lldb-dap] Fix the vscode-uninstall command

The command was using the wrong publisher name ("llvm" rather than
"llvm-vs-code-extensions") resulting in the command complaining:

```
npm run vscode-uninstall

> lldb-dap@0.2.6 vscode-uninstall
> code --uninstall-extension llvm.lldb-dap

Extension 'llvm.lldb-dap' is not installed.
Make sure you use the full extension ID, including the publisher, e.g.: 
ms-dotnettools.csharp
```

Added: 


Modified: 
lldb/tools/lldb-dap/package.json

Removed: 




diff  --git a/lldb/tools/lldb-dap/package.json 
b/lldb/tools/lldb-dap/package.json
index 9155163c65ba5c..5e9a7de9109ec8 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -44,7 +44,7 @@
 "format": "npx prettier './src-ts/' --write",
 "package": "vsce package --out ./out/lldb-dap.vsix",
 "publish": "vsce publish",
-"vscode-uninstall": "code --uninstall-extension llvm.lldb-dap",
+"vscode-uninstall": "code --uninstall-extension 
llvm-vs-code-extensions.lldb-dap",
 "vscode-install": "code --install-extension ./out/lldb-dap.vsix"
   },
   "contributes": {
@@ -513,4 +513,4 @@
   }
 ]
   }
-}
\ No newline at end of file
+}



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