[Lldb-commits] [lldb] 9147569 - [lldb][test] Rename reverse-execution/TestReverseContinueNotSupported.py

2025-04-25 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2025-04-25T14:26:50+01:00
New Revision: 9147569c7fc996555af81916ce81a53ad7625d7d

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

LOG: [lldb][test] Rename reverse-execution/TestReverseContinueNotSupported.py

Otherwise `lldb-dotest` fails with:
```
Traceback (most recent call last):
  File "/Users/jonas/Git/llvm-worktrees/llvm-project/lldb/test/API/dotest.py", 
line 8, in 
lldbsuite.test.run_suite()
  File 
"/Users/jonas/Git/llvm-worktrees/llvm-project/lldb/packages/Python/lldbsuite/test/dotest.py",
 line 1063, in run_suite
visit("Test", dirpath, filenames)
  File 
"/Users/jonas/Git/llvm-worktrees/llvm-project/lldb/packages/Python/lldbsuite/test/dotest.py",
 line 701, in visit
raise Exception("Found multiple tests with the name %s" % name)
Exception: Found multiple tests with the name TestReverseContinueNotSupported.py
```

Added: 

lldb/test/API/functionalities/reverse-execution/TestReverseExecutionNotSupported.py

Modified: 


Removed: 

lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py



diff  --git 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
 
b/lldb/test/API/functionalities/reverse-execution/TestReverseExecutionNotSupported.py
similarity index 92%
rename from 
lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
rename to 
lldb/test/API/functionalities/reverse-execution/TestReverseExecutionNotSupported.py
index ae40cde322564..862b8b440303d 100644
--- 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
+++ 
b/lldb/test/API/functionalities/reverse-execution/TestReverseExecutionNotSupported.py
@@ -5,10 +5,10 @@
 from lldbsuite.test import lldbutil
 
 
-class TestReverseContinueNotSupported(TestBase):
+class TestReverseExecutionNotSupported(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
-def test_reverse_continue_not_supported(self):
+def test_reverse_execution_not_supported(self):
 self.build()
 exe = self.getBuildArtifact("a.out")
 target = self.dbg.CreateTarget(exe)



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


[Lldb-commits] [lldb] [llvm] [lldb] Add new per-language frame-format variables for formatting function names (PR #131836)

2025-04-25 Thread David Spickett via lldb-commits


@@ -319,3 +320,255 @@ TEST(MangledTest, NameIndexes_FindFunctionSymbols) {
   EXPECT_EQ(0, Count("undemangable", eFunctionNameTypeBase));
   EXPECT_EQ(0, Count("undemangable", eFunctionNameTypeMethod));
 }
+
+TEST(MangledTest, DemangledNameInfo_SetMangledResets) {
+  Mangled mangled;
+  EXPECT_EQ(mangled.GetDemangledInfo(), std::nullopt);
+
+  mangled.SetMangledName(ConstString("_Z3foov"));
+  ASSERT_TRUE(mangled);
+
+  auto info1 = mangled.GetDemangledInfo();
+  EXPECT_NE(info1, std::nullopt);
+  EXPECT_TRUE(info1->hasBasename());
+
+  mangled.SetMangledName(ConstString("_Z4funcv"));
+
+  // Should have re-calculated demangled-info since mangled name changed.
+  auto info2 = mangled.GetDemangledInfo();
+  ASSERT_NE(info2, std::nullopt);
+  EXPECT_TRUE(info2->hasBasename());
+
+  EXPECT_NE(info1.value(), info2.value());
+  EXPECT_EQ(mangled.GetDemangledName(), "func()");
+}
+
+TEST(MangledTest, DemangledNameInfo_SetDemangledResets) {
+  Mangled mangled("_Z3foov");
+  ASSERT_TRUE(mangled);
+
+  mangled.SetDemangledName(ConstString(""));
+
+  // Mangled name hasn't changed, so GetDemangledInfo causes re-demangling
+  // of previously set mangled name.
+  EXPECT_NE(mangled.GetDemangledInfo(), std::nullopt);
+  EXPECT_EQ(mangled.GetDemangledName(), "foo()");
+}
+
+TEST(MangledTest, DemangledNameInfo_Clear) {
+  Mangled mangled("_Z3foov");
+  ASSERT_TRUE(mangled);
+  EXPECT_NE(mangled.GetDemangledInfo(), std::nullopt);
+
+  mangled.Clear();
+
+  EXPECT_EQ(mangled.GetDemangledInfo(), std::nullopt);
+}
+
+TEST(MangledTest, DemangledNameInfo_SetValue) {
+  Mangled mangled("_Z4funcv");
+  ASSERT_TRUE(mangled);
+
+  auto demangled_func = mangled.GetDemangledInfo();
+
+  // SetValue(mangled) resets demangled-info
+  mangled.SetValue(ConstString("_Z3foov"));
+  auto demangled_foo = mangled.GetDemangledInfo();
+  EXPECT_NE(demangled_foo, std::nullopt);
+  EXPECT_NE(demangled_foo, demangled_func);
+
+  // SetValue(demangled) resets demangled-info
+  mangled.SetValue(ConstString("_Z4funcv"));
+  EXPECT_EQ(mangled.GetDemangledInfo(), demangled_func);
+
+  // SetValue(empty) resets demangled-info
+  mangled.SetValue(ConstString());
+  EXPECT_EQ(mangled.GetDemangledInfo(), std::nullopt);
+
+  // Demangling invalid mangled name will set demangled-info
+  // (without a valid basename).
+  mangled.SetValue(ConstString("_Zinvalid"));
+  ASSERT_NE(mangled.GetDemangledInfo(), std::nullopt);
+  EXPECT_FALSE(mangled.GetDemangledInfo()->hasBasename());
+}
+
+struct DemanglingPartsTestCase {
+  const char *mangled;
+  DemangledNameInfo expected_info;
+  std::string_view basename;
+  std::string_view scope;
+  std::string_view qualifiers;
+  bool valid_basename = true;
+};
+
+DemanglingPartsTestCase g_demangling_parts_test_cases[] = {

DavidSpickett wrote:

Some part/all of this lot is creating warnings compiling on Linux with clang 19:
```
$ ninja check-lldb
[244/267] Building CXX object 
tools/lldb/unit...MakeFiles/LLDBCoreTests.dir/MangledTest.cpp.o
/home/david.spickett/llvm-project/lldb/unittests/Core/MangledTest.cpp:416:8: 
warning: designated initializers are a C++20 extension [-Wc++20-designator]
  416 |  { .BasenameRange = {92, 98}, .ScopeRange = {36, 92}, 
.ArgumentsRange = { 108, 158 },
  |^
/home/david.spickett/llvm-project/lldb/unittests/Core/MangledTest.cpp:418:6: 
warning: mixture of designated and non-designated initializers in the same 
initializer list is a C99 extension [-Wc99-designator]
  418 |  .basename = "method",
  |  ^~~~
/home/david.spickett/llvm-project/lldb/unittests/Core/MangledTest.cpp:415:6: 
note: first non-designated initializer is here
  415 |{ 
"_ZNVKO3BarIN2ns3QuxIiEEE1CIPFi3FooIS_IiES6_EEE6methodIS6_EENS5_IT_SC_E5InnerIiEESD_SD_",
  |  
^~~~
/home/david.spickett/llvm-project/lldb/unittests/Core/MangledTest.cpp:423:8: 
warning: designated initializers are a C++20 extension [-Wc++20-designator]
  423 |  { .BasenameRange = {6, 13}, .ScopeRange = {6, 6}, .ArgumentsRange 
= { 20, 27 }, .QualifiersRange = {38, 38} },
<...>
```

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


[Lldb-commits] [lldb] [LLDB] Add unary operators Dereference and AddressOf to DIL (PR #134428)

2025-04-25 Thread Ilia Kuklin via lldb-commits

kuilpd wrote:

@labath 
Should I move the check for `void *` to `TypeSystemClang::GetDereferencedType` 
in the other PR?

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


[Lldb-commits] [lldb] [lldb] Make ValueObject::Dereference less aggressive (PR #137311)

2025-04-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

The function was always trying to dereference both the synthetic and 
non-synthetic view of the object. This is wrong as the caller should be able to 
determine which view of the object it wants to access, as is done e.g. for 
child member access.

This patch removes the nonsynthetic->synthetic fallback, which is the more 
surprising path, and fixes the callers to try both versions of the object (when 
appropriate). I also snuck in simplification of the member access code path 
because it was possible to use the same helper function for that, and I wanted 
to be sure I understand the logic correctly.

I've left the synthetic->nonsynthetic fallback in place. I think we may want 
to keep that one as we often have synthetic child providers for pointer types. 
They usually don't provide an explicit dereference operation but I think users 
would expect that a dereference operation on those objects would work. What we 
may want to do is to try the *synthetic* operation first in this case, so that 
the nonsynthetic case is really a fallback.

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


2 Files Affected:

- (modified) lldb/source/Target/StackFrame.cpp (+11-9) 
- (modified) lldb/source/ValueObject/ValueObject.cpp (+73-133) 


``diff
diff --git a/lldb/source/Target/StackFrame.cpp 
b/lldb/source/Target/StackFrame.cpp
index 0306f68169a98..634cc35337121 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -709,21 +709,17 @@ ValueObjectSP 
StackFrame::LegacyGetValueForVariableExpressionPath(
   // we have a synthetic dereference specified.
   if (!valobj_sp->IsPointerType() && valobj_sp->HasSyntheticValue()) {
 Status deref_error;
-if (valobj_sp->GetCompilerType().IsReferenceType()) {
-  valobj_sp = valobj_sp->GetSyntheticValue()->Dereference(deref_error);
-  if (!valobj_sp || deref_error.Fail()) {
-error = Status::FromErrorStringWithFormatv(
-"Failed to dereference reference type: {0}", deref_error);
-return ValueObjectSP();
-  }
+if (ValueObjectSP synth_deref_sp =
+valobj_sp->GetSyntheticValue()->Dereference(deref_error);
+synth_deref_sp && deref_error.Success()) {
+  valobj_sp = std::move(synth_deref_sp);
 }
-
-valobj_sp = valobj_sp->Dereference(deref_error);
 if (!valobj_sp || deref_error.Fail()) {
   error = Status::FromErrorStringWithFormatv(
   "Failed to dereference synthetic value: {0}", deref_error);
   return ValueObjectSP();
 }
+
 // Some synthetic plug-ins fail to set the error in Dereference
 if (!valobj_sp) {
   error =
@@ -1129,6 +1125,12 @@ ValueObjectSP 
StackFrame::LegacyGetValueForVariableExpressionPath(
   if (valobj_sp) {
 if (deref) {
   ValueObjectSP deref_valobj_sp(valobj_sp->Dereference(error));
+  if (!deref_valobj_sp && !no_synth_child) {
+if (ValueObjectSP synth_obj_sp = valobj_sp->GetSyntheticValue()) {
+  error.Clear();
+  deref_valobj_sp = synth_obj_sp->Dereference(error);
+}
+  }
   valobj_sp = deref_valobj_sp;
 } else if (address_of) {
   ValueObjectSP address_of_valobj_sp(valobj_sp->AddressOf(error));
diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index 8741cb7343166..aeee12a132630 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -2202,6 +2202,45 @@ void ValueObject::GetExpressionPath(Stream &s,
   }
 }
 
+// Return the alternate value (synthetic if the input object is non-synthetic
+// and otherwise) this is permitted by the expression path options.
+static ValueObjectSP GetAlternateValue(
+ValueObject &valobj,
+ValueObject::GetValueForExpressionPathOptions::SyntheticChildrenTraversal
+synth_traversal) {
+  using SynthTraversal =
+  
ValueObject::GetValueForExpressionPathOptions::SyntheticChildrenTraversal;
+
+  if (valobj.IsSynthetic()) {
+if (synth_traversal == SynthTraversal::FromSynthetic ||
+synth_traversal == SynthTraversal::Both)
+  return valobj.GetNonSyntheticValue();
+  } else {
+if (synth_traversal == SynthTraversal::ToSynthetic ||
+synth_traversal == SynthTraversal::Both)
+  return valobj.GetSyntheticValue();
+  }
+  return nullptr;
+}
+
+// Dereference the provided object or the alternate value, ir permitted by the
+// expression path options.
+static ValueObjectSP DereferenceValueOrAlternate(
+ValueObject &valobj,
+ValueObject::GetValueForExpressionPathOptions::SyntheticChildrenTraversal
+synth_traversal,
+Status &error) {
+  error.Clear();
+  ValueObjectSP result = valobj.Dereference(error);
+  if (!result || error.Fail()) {
+if (ValueObjectSP alt_obj = GetAlternateVa

[Lldb-commits] [lldb] [lldb] Make ValueObject::Dereference less aggressive (PR #137311)

2025-04-25 Thread Pavel Labath via lldb-commits

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

The function was always trying to dereference both the synthetic and 
non-synthetic view of the object. This is wrong as the caller should be able to 
determine which view of the object it wants to access, as is done e.g. for 
child member access.

This patch removes the nonsynthetic->synthetic fallback, which is the more 
surprising path, and fixes the callers to try both versions of the object (when 
appropriate). I also snuck in simplification of the member access code path 
because it was possible to use the same helper function for that, and I wanted 
to be sure I understand the logic correctly.

I've left the synthetic->nonsynthetic fallback in place. I think we may want to 
keep that one as we often have synthetic child providers for pointer types. 
They usually don't provide an explicit dereference operation but I think users 
would expect that a dereference operation on those objects would work. What we 
may want to do is to try the *synthetic* operation first in this case, so that 
the nonsynthetic case is really a fallback.

>From fc40cf1387e3ee825834e715cbe3b2742bfed3ce Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Fri, 25 Apr 2025 11:21:52 +0200
Subject: [PATCH] [lldb] Make ValueObject::Dereference less aggressive

The function was always trying to dereference both the synthetic
and non-synthetic view of the object. This is wrong as the caller should
be able to determine which view of the object it wants to access, as is
done e.g. for child member access.

This patch removes the nonsynthetic->synthetic fallback, which is the
more surprising path, and fixes the callers to try both versions of the
object (when appropriate). I also snuck in simplification of the member
access code path because it was possible to use the same helper function
for that, and I wanted to be sure I understand the logic correctly.

I've left the synthetic->nonsynthetic fallback in place. I think we may
want to keep that one as we often have synthetic child providers for
pointer types. They usually don't provide an explicit dereference
operation but I think users would expect that a dereference operation on
those objects would work. What we may want to do is to try the
*synthetic* operation first in this case, so that the nonsynthetic case
is really a fallback.
---
 lldb/source/Target/StackFrame.cpp   |  20 +--
 lldb/source/ValueObject/ValueObject.cpp | 206 +---
 2 files changed, 84 insertions(+), 142 deletions(-)

diff --git a/lldb/source/Target/StackFrame.cpp 
b/lldb/source/Target/StackFrame.cpp
index 0306f68169a98..634cc35337121 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -709,21 +709,17 @@ ValueObjectSP 
StackFrame::LegacyGetValueForVariableExpressionPath(
   // we have a synthetic dereference specified.
   if (!valobj_sp->IsPointerType() && valobj_sp->HasSyntheticValue()) {
 Status deref_error;
-if (valobj_sp->GetCompilerType().IsReferenceType()) {
-  valobj_sp = valobj_sp->GetSyntheticValue()->Dereference(deref_error);
-  if (!valobj_sp || deref_error.Fail()) {
-error = Status::FromErrorStringWithFormatv(
-"Failed to dereference reference type: {0}", deref_error);
-return ValueObjectSP();
-  }
+if (ValueObjectSP synth_deref_sp =
+valobj_sp->GetSyntheticValue()->Dereference(deref_error);
+synth_deref_sp && deref_error.Success()) {
+  valobj_sp = std::move(synth_deref_sp);
 }
-
-valobj_sp = valobj_sp->Dereference(deref_error);
 if (!valobj_sp || deref_error.Fail()) {
   error = Status::FromErrorStringWithFormatv(
   "Failed to dereference synthetic value: {0}", deref_error);
   return ValueObjectSP();
 }
+
 // Some synthetic plug-ins fail to set the error in Dereference
 if (!valobj_sp) {
   error =
@@ -1129,6 +1125,12 @@ ValueObjectSP 
StackFrame::LegacyGetValueForVariableExpressionPath(
   if (valobj_sp) {
 if (deref) {
   ValueObjectSP deref_valobj_sp(valobj_sp->Dereference(error));
+  if (!deref_valobj_sp && !no_synth_child) {
+if (ValueObjectSP synth_obj_sp = valobj_sp->GetSyntheticValue()) {
+  error.Clear();
+  deref_valobj_sp = synth_obj_sp->Dereference(error);
+}
+  }
   valobj_sp = deref_valobj_sp;
 } else if (address_of) {
   ValueObjectSP address_of_valobj_sp(valobj_sp->AddressOf(error));
diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index 8741cb7343166..aeee12a132630 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -2202,6 +2202,45 @@ void ValueObject::GetExpressionPath(Stream &s,
   }
 }
 
+// Return the alternate value (synthetic if the input object is non-synthetic
+// an

[Lldb-commits] [lldb] [lldb] Make ValueObject::Dereference less aggressive (PR #137311)

2025-04-25 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 HEAD~1 HEAD --extensions cpp -- 
lldb/source/Target/StackFrame.cpp lldb/source/ValueObject/ValueObject.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index aeee12a13..2ebd93782 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -2392,7 +2392,7 @@ ValueObjectSP ValueObject::GetValueForExpressionPath_Impl(
 // if no other separator just expand this last layer
 llvm::StringRef child_name = temp_expression;
 ValueObjectSP child_valobj_sp =
-root->GetChildMemberWithName(child_name);
+root->GetChildMemberWithName(child_name);
 if (!child_valobj_sp) {
   if (ValueObjectSP altroot = GetAlternateValue(
   *root, options.m_synthetic_children_traversal))

``




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


[Lldb-commits] [lldb] [llvm] [lldb] Add new per-language frame-format variables for formatting function names (PR #131836)

2025-04-25 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

Still failed

https://lab.llvm.org/buildbot/#/builders/195/builds/8109

https://lab.llvm.org/buildbot/#/builders/197/builds/4470

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


[Lldb-commits] [lldb] [lldb] Make ValueObject::Dereference less aggressive (PR #137311)

2025-04-25 Thread Pavel Labath via lldb-commits

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

>From a295fdb31c59050f9b6d9fc9ba4e0156a7e35c1b Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Fri, 25 Apr 2025 11:21:52 +0200
Subject: [PATCH] [lldb] Make ValueObject::Dereference less aggressive

The function was always trying to dereference both the synthetic
and non-synthetic view of the object. This is wrong as the caller should
be able to determine which view of the object it wants to access, as is
done e.g. for child member access.

This patch removes the nonsynthetic->synthetic fallback, which is the
more surprising path, and fixes the callers to try both versions of the
object (when appropriate). I also snuck in simplification of the member
access code path because it was possible to use the same helper function
for that, and I wanted to be sure I understand the logic correctly.

I've left the synthetic->nonsynthetic fallback in place. I think we may
want to keep that one as we often have synthetic child providers for
pointer types. They usually don't provide an explicit dereference
operation but I think users would expect that a dereference operation on
those objects would work. What we may want to do is to try the
*synthetic* operation first in this case, so that the nonsynthetic case
is really a fallback.
---
 lldb/source/Target/StackFrame.cpp   |  20 +--
 lldb/source/ValueObject/ValueObject.cpp | 204 +---
 2 files changed, 83 insertions(+), 141 deletions(-)

diff --git a/lldb/source/Target/StackFrame.cpp 
b/lldb/source/Target/StackFrame.cpp
index 0306f68169a98..634cc35337121 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -709,21 +709,17 @@ ValueObjectSP 
StackFrame::LegacyGetValueForVariableExpressionPath(
   // we have a synthetic dereference specified.
   if (!valobj_sp->IsPointerType() && valobj_sp->HasSyntheticValue()) {
 Status deref_error;
-if (valobj_sp->GetCompilerType().IsReferenceType()) {
-  valobj_sp = valobj_sp->GetSyntheticValue()->Dereference(deref_error);
-  if (!valobj_sp || deref_error.Fail()) {
-error = Status::FromErrorStringWithFormatv(
-"Failed to dereference reference type: {0}", deref_error);
-return ValueObjectSP();
-  }
+if (ValueObjectSP synth_deref_sp =
+valobj_sp->GetSyntheticValue()->Dereference(deref_error);
+synth_deref_sp && deref_error.Success()) {
+  valobj_sp = std::move(synth_deref_sp);
 }
-
-valobj_sp = valobj_sp->Dereference(deref_error);
 if (!valobj_sp || deref_error.Fail()) {
   error = Status::FromErrorStringWithFormatv(
   "Failed to dereference synthetic value: {0}", deref_error);
   return ValueObjectSP();
 }
+
 // Some synthetic plug-ins fail to set the error in Dereference
 if (!valobj_sp) {
   error =
@@ -1129,6 +1125,12 @@ ValueObjectSP 
StackFrame::LegacyGetValueForVariableExpressionPath(
   if (valobj_sp) {
 if (deref) {
   ValueObjectSP deref_valobj_sp(valobj_sp->Dereference(error));
+  if (!deref_valobj_sp && !no_synth_child) {
+if (ValueObjectSP synth_obj_sp = valobj_sp->GetSyntheticValue()) {
+  error.Clear();
+  deref_valobj_sp = synth_obj_sp->Dereference(error);
+}
+  }
   valobj_sp = deref_valobj_sp;
 } else if (address_of) {
   ValueObjectSP address_of_valobj_sp(valobj_sp->AddressOf(error));
diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index 8741cb7343166..2ebd937822720 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -2202,6 +2202,45 @@ void ValueObject::GetExpressionPath(Stream &s,
   }
 }
 
+// Return the alternate value (synthetic if the input object is non-synthetic
+// and otherwise) this is permitted by the expression path options.
+static ValueObjectSP GetAlternateValue(
+ValueObject &valobj,
+ValueObject::GetValueForExpressionPathOptions::SyntheticChildrenTraversal
+synth_traversal) {
+  using SynthTraversal =
+  
ValueObject::GetValueForExpressionPathOptions::SyntheticChildrenTraversal;
+
+  if (valobj.IsSynthetic()) {
+if (synth_traversal == SynthTraversal::FromSynthetic ||
+synth_traversal == SynthTraversal::Both)
+  return valobj.GetNonSyntheticValue();
+  } else {
+if (synth_traversal == SynthTraversal::ToSynthetic ||
+synth_traversal == SynthTraversal::Both)
+  return valobj.GetSyntheticValue();
+  }
+  return nullptr;
+}
+
+// Dereference the provided object or the alternate value, ir permitted by the
+// expression path options.
+static ValueObjectSP DereferenceValueOrAlternate(
+ValueObject &valobj,
+ValueObject::GetValueForExpressionPathOptions::SyntheticChildrenTraversal
+synth_traversal,
+Status &error) {
+  error.Cle

[Lldb-commits] [lldb] [lldb] Emit diagnostics as "important" output (PR #137280)

2025-04-25 Thread Ebuka Ezike via lldb-commits

da-viper wrote:

@labath this is what it looks like at the bottom right
 
![image](https://github.com/user-attachments/assets/750a38d0-7244-41ce-8140-1530d4eecece)


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


[Lldb-commits] [lldb] [lldb] Emit diagnostics as "important" output (PR #137280)

2025-04-25 Thread Pavel Labath via lldb-commits

labath wrote:

I see, so it's one of those popups that don't require interaction and disappear 
on their own after a while. I'm still somewhat worried, as these errors tend to 
be bursty.

Like, if there's something wrong with the debug info, we could get dozens (or 
more) of errors of the kind I just removed in #132395. I see they're currently 
being deduped, but the implementation is rather naive -- a hash of the error 
message, which won't help since a lot of these messages contain debug info 
offsets and stuff. However, I suppose we could improve this logic if that 
becomes a problem, so I guess I'd be fine with this.

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


[Lldb-commits] [lldb] [lldb] Highlight basenames in backtraces instead of the PC value (PR #137301)

2025-04-25 Thread Pavel Labath via lldb-commits

labath wrote:

I kinda like how the (highlighted) PC value creates a column. What would you 
say to highlighting both?

(I know I can change this locally if I want to, so this is really a question 
what's a better default => don't change this just because I said so)

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


[Lldb-commits] [lldb] [lldb] Emit diagnostics as "important" output (PR #137280)

2025-04-25 Thread Ebuka Ezike via lldb-commits

da-viper wrote:

this does not catch 
https://github.com/llvm/llvm-project/blob/d775b911c90e631f5cc332c07474f7121564e25b/lldb/tools/lldb-dap/DAP.cpp#L215-L219

for example if you add the initcommand of `breakpoint set --file=main.c 
--line=2 --command "bogus"` it is not sent to the important category 

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


[Lldb-commits] [lldb] [lldb] Emit diagnostics as "important" output (PR #137280)

2025-04-25 Thread Ebuka Ezike via lldb-commits

da-viper wrote:

Maybe we limit it to only Errors. 
as on linux if lldb is not built with lzma support it will spam warning 
messages like. 

```
warning: 45F7FBFE-9455-A458-4A50-347C4A5BC883/libsync.so No LZMA support found 
for reading .gnu_debugdata section
warning: 8E2F4272-9D82-2CEF-A46D-C69DF3FEC722/liblog.so No LZMA support found 
for reading .gnu_debugdata section
```

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


[Lldb-commits] [lldb] [lldb] Highlight basenames in backtraces instead of the PC value (PR #137301)

2025-04-25 Thread Michael Buch via lldb-commits

Michael137 wrote:

> I kinda like how the (highlighted) PC value creates a column. What would you 
> say to highlighting both?
> 
> (I know I can change this locally if I want to, so this is really a question 
> what's a better default => don't change this just because I said so)

This is what it would look like
https://github.com/user-attachments/assets/1d1d67e0-f00c-49a0-969e-270ee126e8fc";
 />

Maybe we could use a different color? Don't have strong opinions on this.

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


[Lldb-commits] [lldb] [lldb] Highlight basenames in backtraces instead of the PC value (PR #137301)

2025-04-25 Thread Michael Buch via lldb-commits

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

>From eac7bbaa47715c053c711ed6469f4dd9d3b55b4a Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 25 Apr 2025 10:25:51 +0100
Subject: [PATCH] [lldb] Highlight basenames in backtraces instead of PC value

---
 lldb/source/Core/CoreProperties.td| 4 ++--
 .../Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index f5d86b663de13..8c2ff934330b9 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -59,7 +59,7 @@ let Definition = "debugger" in {
 Desc<"The default disassembly format string to use when disassembling 
instruction sequences.">;
   def FrameFormat: Property<"frame-format", "FormatEntity">,
 Global,
-DefaultStringValue<"frame #${frame.index}: 
${ansi.fg.yellow}${frame.pc}${ansi.normal}{ 
${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset{
 at 
${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized}
 [opt]}{${frame.is-artificial} [artificial]}n">,
+DefaultStringValue<"frame #${frame.index}: ${frame.pc}{ 
${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset{
 at 
${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized}
 [opt]}{${frame.is-artificial} [artificial]}n">,
 Desc<"The default frame format string to use when displaying stack frame 
information for threads.">;
   def NotiftVoid: Property<"notify-void", "Boolean">,
 Global,
@@ -215,7 +215,7 @@ let Definition = "debugger" in {
 Desc<"If true, LLDB will automatically escape non-printable and escape 
characters when formatting strings.">;
   def FrameFormatUnique: Property<"frame-format-unique", "FormatEntity">,
 Global,
-DefaultStringValue<"frame #${frame.index}: 
${ansi.fg.yellow}${frame.pc}${ansi.normal}{ 
${module.file.basename}{`${function.name-without-args}{${frame.no-debug}${function.pc-offset{
 at 
${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized}
 [opt]}{${frame.is-artificial} [artificial]}n">,
+DefaultStringValue<"frame #${frame.index}: ${frame.pc}{ 
${module.file.basename}{`${function.name-without-args}{${frame.no-debug}${function.pc-offset{
 at 
${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized}
 [opt]}{${frame.is-artificial} [artificial]}n">,
 Desc<"The default frame format string to use when displaying stack frame 
information for threads from thread backtrace unique.">;
   def ShowAutosuggestion: Property<"show-autosuggestion", "Boolean">,
 Global,
diff --git 
a/lldb/source/Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td 
b/lldb/source/Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td
index 6ec87afe25758..348de256b154a 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td
+++ b/lldb/source/Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td
@@ -3,6 +3,6 @@ include "../../../../include/lldb/Core/PropertiesBase.td"
 let Definition = "language_cplusplus" in {
   def FunctionNameFormat: Property<"function-name-format", "FormatEntity">,
 Global,
-
DefaultStringValue<"${function.return-left}${function.scope}${function.basename}${function.template-arguments}${function.formatted-arguments}${function.return-right}${function.qualifiers}">,
+
DefaultStringValue<"${function.return-left}${function.scope}${ansi.fg.yellow}${function.basename}${ansi.normal}${function.template-arguments}${function.formatted-arguments}${function.return-right}${function.qualifiers}">,
 Desc<"C++ specific frame format string to use when displaying stack frame 
information for threads.">;
 }

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


[Lldb-commits] [lldb] [lldb] Highlight basenames in backtraces instead of the PC value (PR #137301)

2025-04-25 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

> > I kinda like how the (highlighted) PC value creates a column. What would 
> > you say to highlighting both?

> Maybe we could use a different color? Don't have strong opinions on this.

We could try a less aggressive color like the one used for the file names. I'm 
wondering if whoever came up with the current color scheme was trying to use a 
uniform color for all numbers. Even if so, that's not necessarily a property we 
need to preserve.

When discussing color changes, it might be best to show screenshots of a 
"default" gray-on-white and a black-on-white terminal (i.e., the "Basic" and 
"Pro" presets in Terminal.app) to get a better idea of what it will look like 
with a spectrum of widely-used color schemes.

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


[Lldb-commits] [lldb] [llvm] [lldb] Prefer `DW_AT_bit_size` over `DW_AT_byte_size` in `GetDIEBitSizeAndSign` (PR #137123)

2025-04-25 Thread Tom Tromey via lldb-commits

tromey wrote:

Thank you for the test case.  I sent a gdb fix: 
https://sourceware.org/pipermail/gdb-patches/2025-April/217513.html

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


[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

2025-04-25 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/129728

>From 21103adacdf9c08cee4065f8a6b90ff812fefbb3 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 4 Mar 2025 11:01:46 -0500
Subject: [PATCH 01/25] [LLDB][Telemetry] Collect telemetry from client when
 allowed.

This patch is slightly different from other impl in that we dispatch 
client-telemetry via a different helper method.
This is to make it easier for vendor to opt-out (simply by overriding the 
method to do nothing).
There is also a configuration option to disallow collecting client telemetry.
---
 lldb/include/lldb/API/SBDebugger.h|  3 +
 lldb/include/lldb/Core/Debugger.h |  5 ++
 lldb/include/lldb/Core/Telemetry.h| 89 +---
 lldb/source/API/SBDebugger.cpp| 11 +++
 lldb/source/Core/Debugger.cpp |  6 ++
 lldb/source/Core/Telemetry.cpp| 99 +++
 lldb/tools/lldb-dap/DAP.cpp   |  5 +-
 lldb/tools/lldb-dap/LLDBUtils.h   | 34 +
 lldb/unittests/Core/TelemetryTest.cpp |  2 +-
 9 files changed, 214 insertions(+), 40 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index e0819f1684f8b..28f92f2095951 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -249,6 +250,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void DispatchClientTelemetry(const lldb::SBStructuredData &data);
+
   // Return true if target is deleted from the target list of the debugger.
   bool DeleteTarget(lldb::SBTarget &target);
 
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ebc6147800e1..e40666d5ceec7 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -19,6 +19,8 @@
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/SourceManager.h"
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/StreamFile.h"
@@ -31,6 +33,7 @@
 #include "lldb/Utility/Diagnostics.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
+#include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-enumerations.h"
@@ -127,6 +130,8 @@ class Debugger : public 
std::enable_shared_from_this,
 
   void Clear();
 
+  void DispatchClientTelemetry(const lldb_private::StructuredDataImpl &entry);
+
   bool GetAsyncExecution();
 
   void SetAsyncExecution(bool async);
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 7d8716f1659b5..cad4a4a6c9048 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Telemetry/Telemetry.h"
+#include 
 #include 
 #include 
 #include 
@@ -28,6 +29,23 @@
 namespace lldb_private {
 namespace telemetry {
 
+struct LLDBConfig : public ::llvm::telemetry::Config {
+  // If true, we will collect full details about a debug command (eg., args and
+  // original command). Note: This may contain PII, hence can only be enabled 
by
+  // the vendor while creating the Manager.
+  const bool m_detailed_command_telemetry;
+  // If true, we will collect telemetry from LLDB's clients (eg., lldb-dap) via
+  // the SB interface. Must also be enabled by the vendor while creating the
+  // manager.
+  const bool m_enable_client_telemetry;
+
+  explicit LLDBConfig(bool enable_telemetry, bool detailed_command_telemetry,
+  bool enable_client_telemetry)
+  : ::llvm::telemetry::Config(enable_telemetry),
+m_detailed_command_telemetry(detailed_command_telemetry),
+m_enable_client_telemetry(enable_client_telemetry) {}
+};
+
 // We expect each (direct) subclass of LLDBTelemetryInfo to
 // have an LLDBEntryKind in the form 0b11
 // Specifically:
@@ -37,6 +55,7 @@ namespace telemetry {
 // must have their LLDBEntryKind in the similar form (ie., share common prefix)
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
   static const llvm::telemetry::KindType BaseInfo = 0b1100;
+  static const llvm::telemetry::KindType ClientInfo = 0b1110;
   static const llvm::telemetry::KindType DebuggerInfo = 0b11000100;
 };
 
@@ -86,6 +105,11 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+struct ClientInfo : public LLDBBaseTelemetryInfo {
+  std::string request_name;
+  std::optional error_msg;
+};
+
 /// The base Telemetry manager instance in LL

[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-25 Thread Ely Ronnen via lldb-commits

eronnen wrote:

@JDevlieghere any chance to merge?

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


[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

2025-04-25 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

Thanks all, for the feedback! I'll merge this EOD today, if there's no 
objection! :)


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


[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

2025-04-25 Thread Vy Nguyen via lldb-commits


@@ -156,6 +158,52 @@ uint32_t GetLLDBFrameID(uint64_t dap_frame_id);
 lldb::SBEnvironment
 GetEnvironmentFromArguments(const llvm::json::Object &arguments);
 
+/// Helper for sending telemetry to lldb server, if client-telemetry is 
enabled.
+#ifndef SWIG

oontvoo wrote:

Ah, ok. Removed it! Thanks

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


[Lldb-commits] [lldb] [lldb] Emit diagnostics as "important" output (PR #137280)

2025-04-25 Thread John Harrison via lldb-commits


@@ -117,6 +118,9 @@ static void EventThreadFunction(DAP &dap) {
   lldb::SBEvent event;
   lldb::SBListener listener = dap.debugger.GetListener();
   dap.broadcaster.AddListener(listener, eBroadcastBitStopEventThread);
+  dap.debugger.GetBroadcaster().AddListener(
+  listener, lldb::SBDebugger::eBroadcastBitError |

ashgti wrote:

Style nit, do these need `lldb::SBDebugger::` in front? I see them used below 
without the prefix.

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


[Lldb-commits] [lldb] [lldb] Emit diagnostics as "important" output (PR #137280)

2025-04-25 Thread John Harrison via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Highlight basenames in backtraces instead of the PC value (PR #137301)

2025-04-25 Thread Michael Buch via lldb-commits

Michael137 wrote:

Here's a version where the PC value is cyan (like the filename):
https://github.com/user-attachments/assets/d9e90fc7-9f06-4044-8500-2a6f5a4926d2";
 />

You still get the colored column, but it feels less difficult on the eyes than 
having both yellow

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


[Lldb-commits] [lldb] [lldb] Highlight basenames in backtraces (PR #137301)

2025-04-25 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Highlight basenames in backtraces (PR #137301)

2025-04-25 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Support riscv32 corefiles (PR #115408)

2025-04-25 Thread David Spickett via lldb-commits

DavidSpickett wrote:

You could adapt commands from 
https://github.com/llvm/llvm-project/tree/main/lldb/scripts/lldb-test-qemu, if 
you have an existing Ubuntu system of some other architecture.

https://lldb.llvm.org/resources/qemu-testing.html

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


[Lldb-commits] [lldb] [lldb] Rename reverse-continue/TestReverseContinueNotSupported.py (NFC) (PR #137262)

2025-04-25 Thread David Spickett via lldb-commits

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

Also noticed this trying to reproduce a failure on Windows with lldb-dotest.py, 
LGTM.

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


[Lldb-commits] [lldb] [llvm] [lldb] Add new per-language frame-format variables for formatting function names (PR #131836)

2025-04-25 Thread Michael Buch via lldb-commits

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

>From b3e1aa9ff4817af23d99a8b0b668c62149524181 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 7 Apr 2025 13:22:27 +0100
Subject: [PATCH 1/5] [lldb] Implement TrackingOutputBuffer to track demangled
 name information (#131836)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This patch implements a new `TrackingOutputBuffer` which tracks where the 
scope/basename/arguments begin and end in the demangled string.

The idea that a function name can be decomposed into . 
The assumption is that given the ranges of those three elements and the 
demangled name, LLDB will be able to to reconstruct the full demangled name. 
The tracking of those ranges is pretty simple. We don’t ever deal with nesting, 
so whenever we recurse into a template argument list or another function type, 
we just stop tracking any positions. Once we recursed out of those, and are 
back to printing the top-level function name, we continue tracking the 
positions.

We introduce a new structure `FunctionNameInfo` that holds all this information 
and is stored in the new `TrackingOutputBuffer` class.

Tests are in `ItaniumDemangleTest.cpp`.

https://github.com/llvm/llvm-project/pull/131836
---
 lldb/include/lldb/Core/DemangledNameInfo.h | 153 +++
 lldb/source/Core/CMakeLists.txt|   1 +
 lldb/source/Core/DemangledNameInfo.cpp | 213 +
 lldb/unittests/Core/MangledTest.cpp| 143 ++
 4 files changed, 510 insertions(+)
 create mode 100644 lldb/include/lldb/Core/DemangledNameInfo.h
 create mode 100644 lldb/source/Core/DemangledNameInfo.cpp

diff --git a/lldb/include/lldb/Core/DemangledNameInfo.h 
b/lldb/include/lldb/Core/DemangledNameInfo.h
new file mode 100644
index 0..51cd152bf79d8
--- /dev/null
+++ b/lldb/include/lldb/Core/DemangledNameInfo.h
@@ -0,0 +1,153 @@
+//===-- DemangledNameInfo.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_DEMANGLEDNAMEINFO_H
+#define LLDB_CORE_DEMANGLEDNAMEINFO_H
+
+#include "llvm/Demangle/ItaniumDemangle.h"
+#include "llvm/Demangle/Utility.h"
+
+#include 
+#include 
+
+namespace lldb_private {
+
+/// Stores information about where certain portions of a demangled
+/// function name begin and end.
+struct DemangledNameInfo {
+  /// A [start, end) pair for the function basename.
+  /// The basename is the name without scope qualifiers
+  /// and without template parameters. E.g.,
+  /// \code{.cpp}
+  ///void foo::bar::someFunc(int) const &&
+  ///^   ^
+  ///  startend
+  /// \endcode
+  std::pair BasenameRange;
+
+  /// A [start, end) pair for the function scope qualifiers.
+  /// E.g., for
+  /// \code{.cpp}
+  ///void foo::bar::qux(int) const &&
+  /// ^  ^
+  ///   start   end
+  /// \endcode
+  std::pair ScopeRange;
+
+  /// Indicates the [start, end) of the function argument lits.
+  /// E.g.,
+  /// \code{.cpp}
+  ///int (*getFunc(float, double))(int, int)
+  ///^  ^
+  ///  start   end
+  /// \endcode
+  std::pair ArgumentsRange;
+
+  /// Returns \c true if this object holds a valid basename range.
+  bool hasBasename() const {
+return BasenameRange.first != BasenameRange.second &&
+   BasenameRange.second > 0;
+  }
+
+  friend bool operator==(const DemangledNameInfo &lhs,
+ const DemangledNameInfo &rhs) {
+return std::tie(lhs.BasenameRange, lhs.ArgumentsRange, lhs.ScopeRange,
+lhs.QualifiersRange) ==
+   std::tie(rhs.BasenameRange, rhs.ArgumentsRange, rhs.ScopeRange,
+lhs.QualifiersRange);
+  }
+
+  friend bool operator!=(const DemangledNameInfo &lhs,
+ const DemangledNameInfo &rhs) {
+return !(lhs == rhs);
+  }
+};
+
+/// An OutputBuffer which keeps a record of where certain parts of a
+/// demangled name begin/end (e.g., basename, scope, argument list, etc.).
+/// The tracking occurs during printing of the Itanium demangle tree.
+///
+/// Usage:
+/// \code{.cpp}
+///
+/// Node *N = mangling_parser.parseType();
+///
+/// TrackingOutputBuffer buffer;
+/// N->printLeft(OB);
+///
+/// assert (buffer.NameInfo.hasBasename());
+///
+/// \endcode
+struct TrackingOutputBuffer : public llvm::itanium_demangle::OutputBuffer {
+  using OutputBuffer::OutputBuffer;
+
+  /// Holds information about the demangled name that is
+  /// being printed into this buffer.
+  DemangledNameInfo NameInfo;
+
+  void printLeft(const l

[Lldb-commits] [lldb] [lldb] Add InstructionARM64 to lldb-server (PR #137267)

2025-04-25 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> The instruction emulation plugins are used to implement software 
> single-stepping on architectures without (reliably present) hardware support. 
> AFAIK aarch64 is not one of those.

I think it's also used in unwinding for some basic prologue/epilogue 
instructions, but I think that would happen in the client lldb not the server.

Also if this code is not in lldb-server now, I don't see a reason to add it 
unless it's solving a real prolem.

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


[Lldb-commits] [lldb] [lldb] Add InstructionARM64 to lldb-server (PR #137267)

2025-04-25 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

Ok, thanks. 
Then I will close this PR.

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


[Lldb-commits] [lldb] [lldb] Add InstructionARM64 to lldb-server (PR #137267)

2025-04-25 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

2025-04-25 Thread Pavel Labath via lldb-commits


@@ -156,6 +158,52 @@ uint32_t GetLLDBFrameID(uint64_t dap_frame_id);
 lldb::SBEnvironment
 GetEnvironmentFromArguments(const llvm::json::Object &arguments);
 
+/// Helper for sending telemetry to lldb server, if client-telemetry is 
enabled.
+#ifndef SWIG

labath wrote:

You don't need this. The SWIG macro is only defined while swig is parsing the 
headers, never during actual compilation.

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


[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

2025-04-25 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] a267225 - [lldb][Mangled] Retrieve and cache demangled name info (#131836)

2025-04-25 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2025-04-25T10:04:27+01:00
New Revision: a2672250be871bdac18c1a955265a98704434218

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

LOG: [lldb][Mangled] Retrieve and cache demangled name info (#131836)

Uses the `TrackingOutputBuffer` to populate the new member 
`Mangled::m_demangled_info`.

`m_demangled_info` is lazily popluated by `GetDemangledInfo`. To ensure 
`m_demangled` and `m_demangled_info` are in-sync we clear `m_demangled_info` 
anytime `m_demangled` is set/cleared.

https://github.com/llvm/llvm-project/pull/131836

Added: 


Modified: 
lldb/include/lldb/Core/DemangledNameInfo.h
lldb/include/lldb/Core/Mangled.h
lldb/source/Core/DemangledNameInfo.cpp
lldb/source/Core/Mangled.cpp
lldb/unittests/Core/MangledTest.cpp
llvm/include/llvm/Demangle/Demangle.h
llvm/lib/Demangle/ItaniumDemangle.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/DemangledNameInfo.h 
b/lldb/include/lldb/Core/DemangledNameInfo.h
index 51cd152bf79d8..3926b45a96f3e 100644
--- a/lldb/include/lldb/Core/DemangledNameInfo.h
+++ b/lldb/include/lldb/Core/DemangledNameInfo.h
@@ -48,9 +48,20 @@ struct DemangledNameInfo {
   /// \endcode
   std::pair ArgumentsRange;
 
+  /// Indicates the [start, end) of the function qualifiers
+  /// (e.g., CV-qualifiers, reference qualifiers, requires clauses).
+  ///
+  /// E.g.,
+  /// \code{.cpp}
+  ///void foo::bar::qux(int) const &&
+  ///   ^^
+  /// start end
+  /// \endcode
+  std::pair QualifiersRange;
+
   /// Returns \c true if this object holds a valid basename range.
   bool hasBasename() const {
-return BasenameRange.first != BasenameRange.second &&
+return BasenameRange.second > BasenameRange.first &&
BasenameRange.second > 0;
   }
 
@@ -139,6 +150,8 @@ struct TrackingOutputBuffer : public 
llvm::itanium_demangle::OutputBuffer {
   void finalizeArgumentEnd();
   void finalizeStart();
   void finalizeEnd();
+  void finalizeQualifiersStart();
+  void finalizeQualifiersEnd();
 
   /// Helper used in the finalize APIs.
   bool canFinalize() const;

diff  --git a/lldb/include/lldb/Core/Mangled.h 
b/lldb/include/lldb/Core/Mangled.h
index 1dca1f0e2b139..eb9a58c568896 100644
--- a/lldb/include/lldb/Core/Mangled.h
+++ b/lldb/include/lldb/Core/Mangled.h
@@ -9,10 +9,11 @@
 #ifndef LLDB_CORE_MANGLED_H
 #define LLDB_CORE_MANGLED_H
 
+#include "lldb/Core/DemangledNameInfo.h"
+#include "lldb/Utility/ConstString.h"
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
-#include "lldb/Utility/ConstString.h"
 #include "llvm/ADT/StringRef.h"
 
 #include 
@@ -134,9 +135,15 @@ class Mangled {
   /// A const reference to the display demangled name string object.
   ConstString GetDisplayDemangledName() const;
 
-  void SetDemangledName(ConstString name) { m_demangled = name; }
+  void SetDemangledName(ConstString name) {
+m_demangled = name;
+m_demangled_info.reset();
+  }
 
-  void SetMangledName(ConstString name) { m_mangled = name; }
+  void SetMangledName(ConstString name) {
+m_mangled = name;
+m_demangled_info.reset();
+  }
 
   /// Mangled name get accessor.
   ///
@@ -277,6 +284,9 @@ class Mangled {
   ///   table offsets in the cache data.
   void Encode(DataEncoder &encoder, ConstStringTable &strtab) const;
 
+  /// Retrieve \c DemangledNameInfo of the demangled name held by this object.
+  const std::optional &GetDemangledInfo() const;
+
 private:
   /// If \c force is \c false, this function will re-use the previously
   /// demangled name (if any). If \c force is \c true (or the mangled name
@@ -290,6 +300,10 @@ class Mangled {
   /// Mutable so we can get it on demand with
   /// a const version of this object.
   mutable ConstString m_demangled;
+
+  /// If available, holds information about where in \c m_demangled certain
+  /// parts of the name (e.g., basename, arguments, etc.) begin and end.
+  mutable std::optional m_demangled_info = std::nullopt;
 };
 
 Stream &operator<<(Stream &s, const Mangled &obj);

diff  --git a/lldb/source/Core/DemangledNameInfo.cpp 
b/lldb/source/Core/DemangledNameInfo.cpp
index 89757032409c2..54a06edc5ec1d 100644
--- a/lldb/source/Core/DemangledNameInfo.cpp
+++ b/lldb/source/Core/DemangledNameInfo.cpp
@@ -66,6 +66,20 @@ void TrackingOutputBuffer::finalizeArgumentEnd() {
   NameInfo.ArgumentsRange.second = getCurrentPosition();
 }
 
+void TrackingOutputBuffer::finalizeQualifiersStart() {
+  if (!canFinalize())
+return;
+
+  NameInfo.QualifiersRange.first = getCurrentPosition();
+}
+
+void TrackingOutputBuffer::finalizeQualifiersEnd() {
+  if (!canFinalize())
+return;
+
+  NameInfo.QualifiersRange.second 

[Lldb-commits] [lldb] 8b91b44 - [lldb][Format] Introduce new frame-format variables for function parts (#131836)

2025-04-25 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2025-04-25T10:04:27+01:00
New Revision: 8b91b44a3be680788f914af72f38f90d35925c23

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

LOG: [lldb][Format] Introduce new frame-format variables for function parts 
(#131836)

Adds new frame-format variables and implements them in the CPlusPlusLanguage 
plugin.

We use the `DemangledNameInfo` type to retrieve the necessary part of the 
demangled name.

https://github.com/llvm/llvm-project/pull/131836

Added: 
lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test
lldb/test/Shell/Settings/TestFrameFormatFunctionBasenameObjC.test
lldb/test/Shell/Settings/TestFrameFormatFunctionFormattedArguments.test
lldb/test/Shell/Settings/TestFrameFormatFunctionFormattedArgumentsObjC.test
lldb/test/Shell/Settings/TestFrameFormatFunctionQualifiers.test
lldb/test/Shell/Settings/TestFrameFormatFunctionQualifiersObjC.test
lldb/test/Shell/Settings/TestFrameFormatFunctionReturn.test
lldb/test/Shell/Settings/TestFrameFormatFunctionReturnObjC.test
lldb/test/Shell/Settings/TestFrameFormatFunctionScope.test
lldb/test/Shell/Settings/TestFrameFormatFunctionScopeObjC.test
lldb/test/Shell/Settings/TestFrameFormatFunctionTemplateArguments.test
lldb/test/Shell/Settings/TestFrameFormatFunctionTemplateArgumentsObjC.test

Modified: 
lldb/include/lldb/Core/FormatEntity.h
lldb/include/lldb/Symbol/SymbolContext.h
lldb/include/lldb/Target/Language.h
lldb/source/Core/FormatEntity.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
lldb/source/Symbol/SymbolContext.cpp
lldb/test/Shell/Settings/TestFrameFormatName.test

Removed: 




diff  --git a/lldb/include/lldb/Core/FormatEntity.h 
b/lldb/include/lldb/Core/FormatEntity.h
index f6c3bd981e03a..31a08b3e4add0 100644
--- a/lldb/include/lldb/Core/FormatEntity.h
+++ b/lldb/include/lldb/Core/FormatEntity.h
@@ -88,6 +88,13 @@ struct Entry {
 FunctionNameWithArgs,
 FunctionNameNoArgs,
 FunctionMangledName,
+FunctionScope,
+FunctionBasename,
+FunctionTemplateArguments,
+FunctionFormattedArguments,
+FunctionReturnLeft,
+FunctionReturnRight,
+FunctionQualifiers,
 FunctionAddrOffset,
 FunctionAddrOffsetConcrete,
 FunctionLineOffset,

diff  --git a/lldb/include/lldb/Symbol/SymbolContext.h 
b/lldb/include/lldb/Symbol/SymbolContext.h
index 4f8405f1f0db5..af2f694e554de 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -311,8 +311,7 @@ class SymbolContext {
   /// mangling preference. If this object represents an inlined function,
   /// returns the name of the inlined function. Returns nullptr if no function
   /// name could be determined.
-  const char *GetPossiblyInlinedFunctionName(
-  Mangled::NamePreference mangling_preference) const;
+  Mangled GetPossiblyInlinedFunctionName() const;
 
   // Member variables
   lldb::TargetSP target_sp; ///< The Target for a given query

diff  --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index fa856843871e3..94ace6433df2f 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -15,6 +15,7 @@
 #include 
 #include 
 
+#include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/Highlighter.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
@@ -371,6 +372,13 @@ class Language : public PluginInterface {
   FunctionNameRepresentation 
representation,
   Stream &s);
 
+  virtual bool HandleFrameFormatVariable(const SymbolContext &sc,
+ const ExecutionContext *exe_ctx,
+ FormatEntity::Entry::Type type,
+ Stream &s) {
+return false;
+  }
+
   virtual ConstString
   GetDemangledFunctionNameWithoutArguments(Mangled mangled) const {
 if (ConstString demangled = mangled.GetDemangledName())

diff  --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 874478340003c..eafc8c932208c 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -122,7 +122,15 @@ constexpr Definition g_function_child_entries[] = {
 Definition("pc-offset", EntryType::FunctionPCOffset),
 Definition("initial-function", EntryType::FunctionInitial),
 Definition("changed", EntryType::FunctionChanged),
-Definition("is-optimized", EntryType::FunctionIsOptimized)};
+Definition("is-optimized", EntryType::FunctionIsOptimized),
+Definition("scope", EntryType::FunctionSc

[Lldb-commits] [lldb] d555b9f - [lldb][CPlusPlus] Add plugin.cplusplus.display.function-name-format setting (#131836)

2025-04-25 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2025-04-25T10:04:27+01:00
New Revision: d555b9f9a01705097edf2434cf897e351095e5c9

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

LOG: [lldb][CPlusPlus] Add plugin.cplusplus.display.function-name-format 
setting (#131836)

Adds the new `plugin.cplusplus.display.function-name-format` setting and makes 
the `${function.name-with-args}` query it for formatting the function name.

One caveat is that the setting can't itself be set to 
`${function.name-with-args}` because that would cause infinite recursion and 
blow the stack. I added an XFAILed test-case for it and will address it in a 
follow-up patch.

https://github.com/llvm/llvm-project/pull/131836

Added: 
lldb/source/Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td
lldb/test/Shell/Settings/TestCxxFrameFormat.test
lldb/test/Shell/Settings/TestCxxFrameFormatMixedLanguages.test
lldb/test/Shell/Settings/TestCxxFrameFormatObjC.test
lldb/test/Shell/Settings/TestCxxFrameFormatPartialFailure.test
lldb/test/Shell/Settings/TestCxxFrameFormatRecursive.test

Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/include/lldb/Target/Language.h
lldb/source/Core/FormatEntity.cpp
lldb/source/Core/PluginManager.cpp
lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index a6dab045adf27..d73dd71d833f3 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -141,8 +141,10 @@ class PluginManager {
   GetOperatingSystemCreateCallbackForPluginName(llvm::StringRef name);
 
   // Language
-  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
- LanguageCreateInstance create_callback);
+  static bool
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
+ LanguageCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
 
   static bool UnregisterPlugin(LanguageCreateInstance create_callback);
 
@@ -613,6 +615,14 @@ class PluginManager {
   static bool CreateSettingForStructuredDataPlugin(
   Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
   llvm::StringRef description, bool is_global_property);
+
+  static lldb::OptionValuePropertiesSP
+  GetSettingForCPlusPlusLanguagePlugin(Debugger &debugger,
+   llvm::StringRef setting_name);
+
+  static bool CreateSettingForCPlusPlusLanguagePlugin(
+  Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+  llvm::StringRef description, bool is_global_property);
 };
 
 } // namespace lldb_private

diff  --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 94ace6433df2f..d62871bd7ed70 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -495,6 +495,10 @@ class Language : public PluginInterface {
   /// Python uses \b except. Defaults to \b catch.
   virtual llvm::StringRef GetCatchKeyword() const { return "catch"; }
 
+  virtual const FormatEntity::Entry *GetFunctionNameFormat() const {
+return nullptr;
+  }
+
 protected:
   // Classes that inherit from Language can see and modify these
 

diff  --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index eafc8c932208c..e352d07fe487d 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -1237,6 +1237,35 @@ static bool HandleFunctionNameWithArgs(Stream &s,
   return true;
 }
 
+static bool FormatFunctionNameForLanguage(Stream &s,
+  const ExecutionContext *exe_ctx,
+  const SymbolContext *sc) {
+  assert(sc);
+
+  Language *language_plugin = nullptr;
+  if (sc->function)
+language_plugin = Language::FindPlugin(sc->function->GetLanguage());
+  else if (sc->symbol)
+language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());
+
+  if (!language_plugin)
+return false;
+
+  const auto *format = language_plugin->GetFunctionNameFormat();
+  if (!format)
+return false;
+
+  StreamString name_stream;
+  const bool success =
+  FormatEntity::Format(*format, name_stream, sc, exe_ctx, /*addr=*/nullptr,
+   /*valobj=*/nullptr, /*function_changed=*/false,
+   /*initial_function=*/false);
+  if (success)
+s << name_stream.GetString();
+
+  return success;
+}
+
 bool FormatEntity::FormatStringRef(const llv

[Lldb-commits] [lldb] 9c830ce - [lldb] Implement TrackingOutputBuffer to track demangled name information (#131836)

2025-04-25 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2025-04-25T10:04:27+01:00
New Revision: 9c830cef3d7c2f1adfadcc0026a73ba2cdbeef05

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

LOG: [lldb] Implement TrackingOutputBuffer to track demangled name information 
(#131836)

This patch implements a new `TrackingOutputBuffer` which tracks where the 
scope/basename/arguments begin and end in the demangled string.

The idea that a function name can be decomposed into . 
The assumption is that given the ranges of those three elements and the 
demangled name, LLDB will be able to to reconstruct the full demangled name. 
The tracking of those ranges is pretty simple. We don’t ever deal with nesting, 
so whenever we recurse into a template argument list or another function type, 
we just stop tracking any positions. Once we recursed out of those, and are 
back to printing the top-level function name, we continue tracking the 
positions.

We introduce a new structure `FunctionNameInfo` that holds all this information 
and is stored in the new `TrackingOutputBuffer` class.

Tests are in `ItaniumDemangleTest.cpp`.

https://github.com/llvm/llvm-project/pull/131836

Added: 
lldb/include/lldb/Core/DemangledNameInfo.h
lldb/source/Core/DemangledNameInfo.cpp

Modified: 
lldb/source/Core/CMakeLists.txt
lldb/unittests/Core/MangledTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/DemangledNameInfo.h 
b/lldb/include/lldb/Core/DemangledNameInfo.h
new file mode 100644
index 0..51cd152bf79d8
--- /dev/null
+++ b/lldb/include/lldb/Core/DemangledNameInfo.h
@@ -0,0 +1,153 @@
+//===-- DemangledNameInfo.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_DEMANGLEDNAMEINFO_H
+#define LLDB_CORE_DEMANGLEDNAMEINFO_H
+
+#include "llvm/Demangle/ItaniumDemangle.h"
+#include "llvm/Demangle/Utility.h"
+
+#include 
+#include 
+
+namespace lldb_private {
+
+/// Stores information about where certain portions of a demangled
+/// function name begin and end.
+struct DemangledNameInfo {
+  /// A [start, end) pair for the function basename.
+  /// The basename is the name without scope qualifiers
+  /// and without template parameters. E.g.,
+  /// \code{.cpp}
+  ///void foo::bar::someFunc(int) const &&
+  ///^   ^
+  ///  startend
+  /// \endcode
+  std::pair BasenameRange;
+
+  /// A [start, end) pair for the function scope qualifiers.
+  /// E.g., for
+  /// \code{.cpp}
+  ///void foo::bar::qux(int) const &&
+  /// ^  ^
+  ///   start   end
+  /// \endcode
+  std::pair ScopeRange;
+
+  /// Indicates the [start, end) of the function argument lits.
+  /// E.g.,
+  /// \code{.cpp}
+  ///int (*getFunc(float, double))(int, int)
+  ///^  ^
+  ///  start   end
+  /// \endcode
+  std::pair ArgumentsRange;
+
+  /// Returns \c true if this object holds a valid basename range.
+  bool hasBasename() const {
+return BasenameRange.first != BasenameRange.second &&
+   BasenameRange.second > 0;
+  }
+
+  friend bool operator==(const DemangledNameInfo &lhs,
+ const DemangledNameInfo &rhs) {
+return std::tie(lhs.BasenameRange, lhs.ArgumentsRange, lhs.ScopeRange,
+lhs.QualifiersRange) ==
+   std::tie(rhs.BasenameRange, rhs.ArgumentsRange, rhs.ScopeRange,
+lhs.QualifiersRange);
+  }
+
+  friend bool operator!=(const DemangledNameInfo &lhs,
+ const DemangledNameInfo &rhs) {
+return !(lhs == rhs);
+  }
+};
+
+/// An OutputBuffer which keeps a record of where certain parts of a
+/// demangled name begin/end (e.g., basename, scope, argument list, etc.).
+/// The tracking occurs during printing of the Itanium demangle tree.
+///
+/// Usage:
+/// \code{.cpp}
+///
+/// Node *N = mangling_parser.parseType();
+///
+/// TrackingOutputBuffer buffer;
+/// N->printLeft(OB);
+///
+/// assert (buffer.NameInfo.hasBasename());
+///
+/// \endcode
+struct TrackingOutputBuffer : public llvm::itanium_demangle::OutputBuffer {
+  using OutputBuffer::OutputBuffer;
+
+  /// Holds information about the demangled name that is
+  /// being printed into this buffer.
+  DemangledNameInfo NameInfo;
+
+  void printLeft(const llvm::itanium_demangle::Node &N) override;
+  void printRight(const llvm::itanium_demangle::Node &N) override;
+
+private:
+  void printLeftImpl(const llvm::i

[Lldb-commits] [lldb] f220ea2 - [lldb][Mangled] Add API to force re-demangling a Mangled object (#131836)

2025-04-25 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2025-04-25T10:04:27+01:00
New Revision: f220ea2947b9c8b1e33db65b008086d47fa72af3

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

LOG: [lldb][Mangled] Add API to force re-demangling a Mangled object (#131836)

Add version of GetDemangledName that will force re-demangling. This is required 
because LLDB will SetDemangledName without going through the demangler. So we 
need a way to force demangling to set the m_demangled_info member when we need 
it.

https://github.com/llvm/llvm-project/pull/131836

Added: 


Modified: 
lldb/include/lldb/Core/Mangled.h
lldb/source/Core/Mangled.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Mangled.h 
b/lldb/include/lldb/Core/Mangled.h
index 7db63eeeb6ee0..1dca1f0e2b139 100644
--- a/lldb/include/lldb/Core/Mangled.h
+++ b/lldb/include/lldb/Core/Mangled.h
@@ -278,6 +278,12 @@ class Mangled {
   void Encode(DataEncoder &encoder, ConstStringTable &strtab) const;
 
 private:
+  /// If \c force is \c false, this function will re-use the previously
+  /// demangled name (if any). If \c force is \c true (or the mangled name
+  /// on this object was not previously demangled), demangle and cache the
+  /// name.
+  ConstString GetDemangledNameImpl(bool force) const;
+
   /// The mangled version of the name.
   ConstString m_mangled;
 

diff  --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index 56836a6e5663e..b69be163ca233 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -265,19 +265,24 @@ bool Mangled::GetRichManglingInfo(RichManglingContext 
&context,
   llvm_unreachable("Fully covered switch above!");
 }
 
+ConstString Mangled::GetDemangledName() const {
+  return GetDemangledNameImpl(/*force=*/false);
+}
+
 // Generate the demangled name on demand using this accessor. Code in this
 // class will need to use this accessor if it wishes to decode the demangled
 // name. The result is cached and will be kept until a new string value is
 // supplied to this object, or until the end of the object's lifetime.
-ConstString Mangled::GetDemangledName() const {
+ConstString Mangled::GetDemangledNameImpl(bool force) const {
   if (!m_mangled)
 return m_demangled;
 
   // Re-use previously demangled names.
-  if (!m_demangled.IsNull())
+  if (!force && !m_demangled.IsNull())
 return m_demangled;
 
-  if (m_mangled.GetMangledCounterpart(m_demangled) && !m_demangled.IsNull())
+  if (!force && m_mangled.GetMangledCounterpart(m_demangled) &&
+  !m_demangled.IsNull())
 return m_demangled;
 
   // We didn't already mangle this name, demangle it and if all goes well



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


[Lldb-commits] [lldb] 5a64510 - [lldb] Remove redundant DemangledNameInfo::operator==

2025-04-25 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2025-04-25T10:18:33+01:00
New Revision: 5a645109c3a965dcaab08e3485f2fa505e44cde3

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

LOG: [lldb] Remove redundant DemangledNameInfo::operator==

This wasn't defined correctly and was unused. And it was causing a CI
build failure:
```
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/include/lldb/Core/DemangledNameInfo.h:
 In function ‘bool lldb_private::operator==(const 
lldb_private::DemangledNameInfo&, const lldb_private::DemangledNameInfo&)’:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/include/lldb/Core/DemangledNameInfo.h:60:25:
 error: ‘const struct lldb_private::DemangledNameInfo’ has no member named 
‘QualifiersRange’
   60 | lhs.QualifiersRange) ==
  | ^~~
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/include/lldb/Core/DemangledNameInfo.h:62:25:
 error: ‘const struct lldb_private::DemangledNameInfo’ has no member named 
‘QualifiersRange’
   62 | lhs.QualifiersRange);
  | ^~~
111.469 [1284/7/3896] Building CXX object 
tools/lldb/source/Expression/CMakeFiles/lldbExpression.dir/ObjectFileJIT.cpp.o
111.470 [1284/6/3897] Building CXX object 
tools/lldb/source/Expression/CMakeFiles/lldbExpression.dir/Materializer.cpp.o
111.492 [1284/5/3898] Building CXX object 
tools/lldb/source/Expression/CMakeFiles/lldbExpression.dir/REPL.cpp.o
111.496 [1284/4/3899] Building CXX object 
tools/lldb/source/Expression/CMakeFiles/lldbExpression.dir/UserExpression.cpp.o
111.695 [1284/3/3900] Building CXX object 
tools/lldb/source/Commands/CMakeFiles/lldbCommands.dir/CommandObjectTarget.cpp.o
112.944 [1284/2/3901] Linking CXX shared library lib/libclang.so.21.0.0git
113.098 [1284/1/3902] Linking CXX shared library lib/libclang-cpp.so.21.0git
```

Added: 


Modified: 
lldb/include/lldb/Core/DemangledNameInfo.h

Removed: 




diff  --git a/lldb/include/lldb/Core/DemangledNameInfo.h 
b/lldb/include/lldb/Core/DemangledNameInfo.h
index 3926b45a96f3e..11d3bb58871b8 100644
--- a/lldb/include/lldb/Core/DemangledNameInfo.h
+++ b/lldb/include/lldb/Core/DemangledNameInfo.h
@@ -64,19 +64,6 @@ struct DemangledNameInfo {
 return BasenameRange.second > BasenameRange.first &&
BasenameRange.second > 0;
   }
-
-  friend bool operator==(const DemangledNameInfo &lhs,
- const DemangledNameInfo &rhs) {
-return std::tie(lhs.BasenameRange, lhs.ArgumentsRange, lhs.ScopeRange,
-lhs.QualifiersRange) ==
-   std::tie(rhs.BasenameRange, rhs.ArgumentsRange, rhs.ScopeRange,
-lhs.QualifiersRange);
-  }
-
-  friend bool operator!=(const DemangledNameInfo &lhs,
- const DemangledNameInfo &rhs) {
-return !(lhs == rhs);
-  }
 };
 
 /// An OutputBuffer which keeps a record of where certain parts of a



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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-25 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> @JDevlieghere any chance to merge?

There's a conflict in `StackTraceRequestHandler.cpp`, let me know once you've 
resolved that and I'm happy to go ahead and merge this. 

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


[Lldb-commits] [lldb] 480f1a4 - [lldb-dap] fix wrong assembly line number x64 (#136486)

2025-04-25 Thread via lldb-commits

Author: Ely Ronnen
Date: 2025-04-25T09:34:17-07:00
New Revision: 480f1a4980de4d1a3691329bbe0b5b9e4321a3f3

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

LOG: [lldb-dap] fix wrong assembly line number x64 (#136486)

Fix wrong assembly line number calculation that assumes the instruction
size is `GetAddressByteSize() / 2`

Fixes #136495

Added: 
lldb/test/API/tools/lldb-dap/stackTrace-x86/Makefile
lldb/test/API/tools/lldb-dap/stackTrace-x86/TestDAP_source_x86.py
lldb/test/API/tools/lldb-dap/stackTrace-x86/main.c

Modified: 
lldb/tools/lldb-dap/JSONUtils.cpp

Removed: 




diff  --git a/lldb/test/API/tools/lldb-dap/stackTrace-x86/Makefile 
b/lldb/test/API/tools/lldb-dap/stackTrace-x86/Makefile
new file mode 100644
index 0..10495940055b6
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/stackTrace-x86/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules

diff  --git a/lldb/test/API/tools/lldb-dap/stackTrace-x86/TestDAP_source_x86.py 
b/lldb/test/API/tools/lldb-dap/stackTrace-x86/TestDAP_source_x86.py
new file mode 100644
index 0..6239e1af53ecd
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/stackTrace-x86/TestDAP_source_x86.py
@@ -0,0 +1,65 @@
+"""
+Test lldb-dap stack trace containing x86 assembly
+"""
+
+import lldbdap_testcase
+from lldbsuite.test import lldbplatformutil
+from lldbsuite.test.decorators import skipUnlessArch, skipUnlessPlatform
+from lldbsuite.test.lldbtest import line_number
+
+
+class TestDAP_stacktrace_x86(lldbdap_testcase.DAPTestCaseBase):
+@skipUnlessArch("x86_64")
+@skipUnlessPlatform(["linux"] + lldbplatformutil.getDarwinOSTriples())
+def test_stacktrace_x86(self):
+"""
+Tests that lldb-dap steps through correctly and the source lines are 
correct in x86 assembly.
+"""
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(
+program,
+initCommands=[
+"settings set target.process.thread.step-in-avoid-nodebug 
false"
+],
+)
+
+source = "main.c"
+breakpoint_ids = self.set_source_breakpoints(
+source,
+[line_number(source, "// Break here")],
+)
+self.continue_to_breakpoints(breakpoint_ids)
+self.stepIn()
+
+frame = self.get_stackFrames()[0]
+self.assertEqual(
+frame["name"],
+"no_branch_func",
+"verify we are in the no_branch_func function",
+)
+
+self.assertEqual(frame["line"], 1, "verify we are at the start of the 
function")
+minimum_assembly_lines = (
+line_number(source, "Assembly end")
+- line_number(source, "Assembly start")
++ 1
+)
+self.assertLessEqual(
+10,
+minimum_assembly_lines,
+"verify we have a reasonable number of assembly lines",
+)
+
+for i in range(2, minimum_assembly_lines):
+self.stepIn()
+frame = self.get_stackFrames()[0]
+self.assertEqual(
+frame["name"],
+"no_branch_func",
+"verify we are still in the no_branch_func function",
+)
+self.assertEqual(
+frame["line"],
+i,
+f"step in should advance a single line in the function to {i}",
+)

diff  --git a/lldb/test/API/tools/lldb-dap/stackTrace-x86/main.c 
b/lldb/test/API/tools/lldb-dap/stackTrace-x86/main.c
new file mode 100644
index 0..52ee3132d0df0
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/stackTrace-x86/main.c
@@ -0,0 +1,29 @@
+#include 
+
+__attribute__((nodebug)) int no_branch_func(void) {
+  int result = 0;
+
+  __asm__ __volatile__("movl $0, %%eax;" // Assembly start
+   "incl %%eax;"
+   "incl %%eax;"
+   "incl %%eax;"
+   "incl %%eax;"
+   "incl %%eax;"
+   "incl %%eax;"
+   "incl %%eax;"
+   "incl %%eax;"
+   "incl %%eax;"
+   "incl %%eax;"
+   "movl %%eax, %0;" // Assembly end
+   : "=r"(result)
+   :
+   : "%eax");
+
+  return result;
+}
+
+int main(void) {
+  int result = no_branch_func(); // Break here
+  printf("Result: %d\n", result);
+  return 0;
+}

diff  --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index 621492a882bca..4b8e43cf23960 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -19,6 +19,7 @@
 #include "lldb/API/SBFileSpec.h"

[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

2025-04-25 Thread Emre Kultursay via lldb-commits


@@ -182,3 +191,20 @@ std::vector 
DomainSocket::GetListeningConnectionURI() const {
 
   return {llvm::formatv("unix-connect://{0}", addr.sun_path)};
 }
+
+llvm::Expected>
+DomainSocket::FromBoundNativeSocket(NativeSocket sockfd, bool should_close) {
+#ifdef __linux__
+  // Check if fd represents domain socket or abstract socket.
+  struct sockaddr_un addr;
+  socklen_t addr_len = sizeof(addr);
+  if (getsockname(sockfd, (struct sockaddr *)&addr, &addr_len) == -1)
+return llvm::createStringError("not a socket or error occurred");
+  if (addr.sun_family != AF_UNIX)
+return llvm::createStringError("Bad socket type");

emrekultursay wrote:

Done.

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

2025-04-25 Thread Emre Kultursay via lldb-commits

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

2025-04-25 Thread Emre Kultursay via lldb-commits


@@ -339,6 +342,48 @@ TEST_F(SocketTest, DomainGetConnectURI) {
 }
 #endif
 
+#if LLDB_ENABLE_POSIX

emrekultursay wrote:

Done.

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

2025-04-25 Thread Emre Kultursay via lldb-commits


@@ -339,6 +342,48 @@ TEST_F(SocketTest, DomainGetConnectURI) {
 }
 #endif
 
+#if LLDB_ENABLE_POSIX
+TEST_F(SocketTest, DomainSocketFromBoundNativeSocket) {
+  // Generate a name for the domain socket.
+  llvm::SmallString<64> name;
+  std::error_code EC = llvm::sys::fs::createUniqueDirectory(
+  "DomainSocketFromBoundNativeSocket", name);
+  ASSERT_FALSE(EC);
+  llvm::sys::path::append(name, "test");
+
+  DomainSocket socket(true);
+  Status error = socket.Listen(name, /*backlog=*/10);
+  ASSERT_FALSE(error.ToError());
+  NativeSocket native_socket = socket.GetNativeSocket();
+
+  llvm::Expected> sock =
+  DomainSocket::FromBoundNativeSocket(native_socket, 
/*should_close=*/true);
+  ASSERT_THAT_EXPECTED(sock, llvm::Succeeded());
+  ASSERT_EQ(Socket::ProtocolUnixDomain, sock->get()->GetSocketProtocol());
+}
+#endif
+
+#if __linux__
+TEST_F(SocketTest, AbstractSocketFromBoundNativeSocket) {
+  // Generate a name for the abstract socket.
+  llvm::SmallString<64> name;
+  std::error_code EC = llvm::sys::fs::createUniqueDirectory(
+  "AbstractSocketFromBoundNativeSocket", name);
+  ASSERT_FALSE(EC);
+  llvm::sys::path::append(name, "test");
+
+  AbstractSocket socket;
+  Status error = socket.Listen(name, /*backlog=*/10);
+  ASSERT_FALSE(error.ToError());
+  NativeSocket native_socket = socket.GetNativeSocket();
+
+  llvm::Expected> sock =
+  DomainSocket::FromBoundNativeSocket(native_socket, 
/*should_close=*/true);

emrekultursay wrote:

Done.

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

2025-04-25 Thread Emre Kultursay via lldb-commits


@@ -339,6 +342,48 @@ TEST_F(SocketTest, DomainGetConnectURI) {
 }
 #endif
 
+#if LLDB_ENABLE_POSIX
+TEST_F(SocketTest, DomainSocketFromBoundNativeSocket) {
+  // Generate a name for the domain socket.
+  llvm::SmallString<64> name;
+  std::error_code EC = llvm::sys::fs::createUniqueDirectory(
+  "DomainSocketFromBoundNativeSocket", name);
+  ASSERT_FALSE(EC);
+  llvm::sys::path::append(name, "test");
+
+  DomainSocket socket(true);
+  Status error = socket.Listen(name, /*backlog=*/10);
+  ASSERT_FALSE(error.ToError());

emrekultursay wrote:

Thanks! Done.


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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

2025-04-25 Thread Emre Kultursay via lldb-commits

https://github.com/emrekultursay commented:

Thanks. PTAL. 

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

2025-04-25 Thread Emre Kultursay via lldb-commits


@@ -339,6 +342,48 @@ TEST_F(SocketTest, DomainGetConnectURI) {
 }
 #endif
 
+#if LLDB_ENABLE_POSIX
+TEST_F(SocketTest, DomainSocketFromBoundNativeSocket) {
+  // Generate a name for the domain socket.
+  llvm::SmallString<64> name;
+  std::error_code EC = llvm::sys::fs::createUniqueDirectory(
+  "DomainSocketFromBoundNativeSocket", name);
+  ASSERT_FALSE(EC);
+  llvm::sys::path::append(name, "test");
+
+  DomainSocket socket(true);
+  Status error = socket.Listen(name, /*backlog=*/10);
+  ASSERT_FALSE(error.ToError());
+  NativeSocket native_socket = socket.GetNativeSocket();
+
+  llvm::Expected> sock =
+  DomainSocket::FromBoundNativeSocket(native_socket, 
/*should_close=*/true);
+  ASSERT_THAT_EXPECTED(sock, llvm::Succeeded());
+  ASSERT_EQ(Socket::ProtocolUnixDomain, sock->get()->GetSocketProtocol());
+}
+#endif
+
+#if __linux__
+TEST_F(SocketTest, AbstractSocketFromBoundNativeSocket) {
+  // Generate a name for the abstract socket.
+  llvm::SmallString<64> name;
+  std::error_code EC = llvm::sys::fs::createUniqueDirectory(
+  "AbstractSocketFromBoundNativeSocket", name);

emrekultursay wrote:

Done.

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap 'launch' request to use typed RequestHandler<>. (PR #133624)

2025-04-25 Thread John Harrison via lldb-commits


@@ -37,14 +39,12 @@ MakeArgv(const llvm::ArrayRef &strs) {
   return argv;
 }
 
-static uint32_t SetLaunchFlag(uint32_t flags, const llvm::json::Object *obj,
-  llvm::StringRef key, lldb::LaunchFlags mask) {
-  if (const auto opt_value = GetBoolean(obj, key)) {
-if (*opt_value)
-  flags |= mask;
-else
-  flags &= ~mask;
-  }
+static uint32_t SetLaunchFlag(uint32_t flags, bool flag,
+  lldb::LaunchFlags mask) {
+  if (flag)
+flags |= mask;
+  else
+flags &= ~mask;

ashgti wrote:

Technically, whatever lldb-dap does is the source of through here. I think the 
package.json description is actually out of date for a few fields. I'll send a 
PR to fix those.

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


[Lldb-commits] [lldb] [lldb] Emit diagnostics as "important" output (PR #137280)

2025-04-25 Thread Jonas Devlieghere via lldb-commits

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

>From 93f3b75bab631deeeccb4d90491ce482d9adb825 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 24 Apr 2025 17:59:29 -0700
Subject: [PATCH 1/3] [lldb] Emit diagnostics as "important" output

Handle diagnostics events from the debugger (i.e. asynchronous errors
and warnings) in the lldb-dap event handler and emit them as "important"
output.
---
 .../test/tools/lldb-dap/lldbdap_testcase.py   | 13 --
 .../tools/lldb-dap/console/TestDAP_console.py | 17 +
 .../API/tools/lldb-dap/console/minidump.yaml  | 24 +++
 lldb/tools/lldb-dap/DAP.cpp   |  3 +++
 lldb/tools/lldb-dap/DAP.h |  2 +-
 .../Handler/InitializeRequestHandler.cpp  | 13 ++
 lldb/tools/lldb-dap/LLDBUtils.cpp | 15 
 lldb/tools/lldb-dap/LLDBUtils.h   |  3 +++
 8 files changed, 87 insertions(+), 3 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/console/minidump.yaml

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 2671d65031203..87ab0caabe455 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -217,16 +217,25 @@ def get_stdout(self, timeout=0.0):
 def get_console(self, timeout=0.0):
 return self.dap_server.get_output("console", timeout=timeout)
 
+def get_important(self, timeout=0.0):
+return self.dap_server.get_output("important", timeout=timeout)
+
+def collect_stdout(self, timeout_secs, pattern=None):
+return self.dap_server.collect_output(
+"stdout", timeout_secs=timeout_secs, pattern=pattern
+)
+
 def collect_console(self, timeout_secs, pattern=None):
 return self.dap_server.collect_output(
 "console", timeout_secs=timeout_secs, pattern=pattern
 )
 
-def collect_stdout(self, timeout_secs, pattern=None):
+def collect_important(self, timeout_secs, pattern=None):
 return self.dap_server.collect_output(
-"stdout", timeout_secs=timeout_secs, pattern=pattern
+"important", timeout_secs=timeout_secs, pattern=pattern
 )
 
+
 def get_local_as_int(self, name, threadId=None):
 value = self.dap_server.get_local_variable_value(name, 
threadId=threadId)
 # 'value' may have the variable value and summary.
diff --git a/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py 
b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
index 8bbab8d0991de..b07c4f871d73b 100644
--- a/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
+++ b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
@@ -164,3 +164,20 @@ def test_exit_status_message_ok(self):
 console_output,
 "Exit status does not contain message 'exited with status'",
 )
+
+def test_diagnositcs(self):
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+
+core = self.getBuildArtifact("minidump.core")
+self.yaml2obj("minidump.yaml", core)
+self.dap_server.request_evaluate(
+f"target create --core  {core}", context="repl"
+)
+
+output = self.get_important()
+self.assertIn(
+"warning: unable to retrieve process ID from minidump file",
+output,
+"diagnostic found in important output",
+)
diff --git a/lldb/test/API/tools/lldb-dap/console/minidump.yaml 
b/lldb/test/API/tools/lldb-dap/console/minidump.yaml
new file mode 100644
index 0..42f0a23702950
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/console/minidump.yaml
@@ -0,0 +1,24 @@
+--- !minidump
+Streams:
+  - Type:ThreadList
+Threads:
+  - Thread Id:   0x3E81
+Context: 
0B001000330006020100100010A234EBFC7F10A234EBFC7FF09C34EBFC7FC0A91ABCE97FA0163FBCE97F4602921C400030A434EBFC7FC61D40007F03801F0000FF002525252525252525252525252525252500

[Lldb-commits] [lldb] [lldb] Emit diagnostics as "important" output (PR #137280)

2025-04-25 Thread Jonas Devlieghere via lldb-commits

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

>From 93f3b75bab631deeeccb4d90491ce482d9adb825 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 24 Apr 2025 17:59:29 -0700
Subject: [PATCH 1/4] [lldb] Emit diagnostics as "important" output

Handle diagnostics events from the debugger (i.e. asynchronous errors
and warnings) in the lldb-dap event handler and emit them as "important"
output.
---
 .../test/tools/lldb-dap/lldbdap_testcase.py   | 13 --
 .../tools/lldb-dap/console/TestDAP_console.py | 17 +
 .../API/tools/lldb-dap/console/minidump.yaml  | 24 +++
 lldb/tools/lldb-dap/DAP.cpp   |  3 +++
 lldb/tools/lldb-dap/DAP.h |  2 +-
 .../Handler/InitializeRequestHandler.cpp  | 13 ++
 lldb/tools/lldb-dap/LLDBUtils.cpp | 15 
 lldb/tools/lldb-dap/LLDBUtils.h   |  3 +++
 8 files changed, 87 insertions(+), 3 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/console/minidump.yaml

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 2671d65031203..87ab0caabe455 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -217,16 +217,25 @@ def get_stdout(self, timeout=0.0):
 def get_console(self, timeout=0.0):
 return self.dap_server.get_output("console", timeout=timeout)
 
+def get_important(self, timeout=0.0):
+return self.dap_server.get_output("important", timeout=timeout)
+
+def collect_stdout(self, timeout_secs, pattern=None):
+return self.dap_server.collect_output(
+"stdout", timeout_secs=timeout_secs, pattern=pattern
+)
+
 def collect_console(self, timeout_secs, pattern=None):
 return self.dap_server.collect_output(
 "console", timeout_secs=timeout_secs, pattern=pattern
 )
 
-def collect_stdout(self, timeout_secs, pattern=None):
+def collect_important(self, timeout_secs, pattern=None):
 return self.dap_server.collect_output(
-"stdout", timeout_secs=timeout_secs, pattern=pattern
+"important", timeout_secs=timeout_secs, pattern=pattern
 )
 
+
 def get_local_as_int(self, name, threadId=None):
 value = self.dap_server.get_local_variable_value(name, 
threadId=threadId)
 # 'value' may have the variable value and summary.
diff --git a/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py 
b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
index 8bbab8d0991de..b07c4f871d73b 100644
--- a/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
+++ b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
@@ -164,3 +164,20 @@ def test_exit_status_message_ok(self):
 console_output,
 "Exit status does not contain message 'exited with status'",
 )
+
+def test_diagnositcs(self):
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+
+core = self.getBuildArtifact("minidump.core")
+self.yaml2obj("minidump.yaml", core)
+self.dap_server.request_evaluate(
+f"target create --core  {core}", context="repl"
+)
+
+output = self.get_important()
+self.assertIn(
+"warning: unable to retrieve process ID from minidump file",
+output,
+"diagnostic found in important output",
+)
diff --git a/lldb/test/API/tools/lldb-dap/console/minidump.yaml 
b/lldb/test/API/tools/lldb-dap/console/minidump.yaml
new file mode 100644
index 0..42f0a23702950
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/console/minidump.yaml
@@ -0,0 +1,24 @@
+--- !minidump
+Streams:
+  - Type:ThreadList
+Threads:
+  - Thread Id:   0x3E81
+Context: 
0B001000330006020100100010A234EBFC7F10A234EBFC7FF09C34EBFC7FC0A91ABCE97FA0163FBCE97F4602921C400030A434EBFC7FC61D40007F03801F0000FF002525252525252525252525252525252500

[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap 'launch' request to use typed RequestHandler<>. (PR #133624)

2025-04-25 Thread John Harrison via lldb-commits


@@ -37,14 +39,12 @@ MakeArgv(const llvm::ArrayRef &strs) {
   return argv;
 }
 
-static uint32_t SetLaunchFlag(uint32_t flags, const llvm::json::Object *obj,
-  llvm::StringRef key, lldb::LaunchFlags mask) {
-  if (const auto opt_value = GetBoolean(obj, key)) {
-if (*opt_value)
-  flags |= mask;
-else
-  flags &= ~mask;
-  }
+static uint32_t SetLaunchFlag(uint32_t flags, bool flag,
+  lldb::LaunchFlags mask) {
+  if (flag)
+flags |= mask;
+  else
+flags &= ~mask;

ashgti wrote:

For the launch.json, we're the ones defining the fields and their defaults, 
defined in the package.json 
https://github.com/llvm/llvm-project/blob/5dc2d668e68613e8898c5c42960d792129453e9d/lldb/tools/lldb-dap/package.json#L226-L250
 

The defaults I'm specifying in the `LaunchRequestArguments` are setup to match 
those defaults as well. We can change the defaults, since this part is defined 
by the lldb-dap itself.

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


[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Hide the `TargetOptions` pointer from `CompilerInvocation` (PR #106271)

2025-04-25 Thread Jan Svoboda via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap 'launch' request to use typed RequestHandler<>. (PR #133624)

2025-04-25 Thread Jonas Devlieghere via lldb-commits


@@ -37,14 +39,12 @@ MakeArgv(const llvm::ArrayRef &strs) {
   return argv;
 }
 
-static uint32_t SetLaunchFlag(uint32_t flags, const llvm::json::Object *obj,
-  llvm::StringRef key, lldb::LaunchFlags mask) {
-  if (const auto opt_value = GetBoolean(obj, key)) {
-if (*opt_value)
-  flags |= mask;
-else
-  flags &= ~mask;
-  }
+static uint32_t SetLaunchFlag(uint32_t flags, bool flag,
+  lldb::LaunchFlags mask) {
+  if (flag)
+flags |= mask;
+  else
+flags &= ~mask;

JDevlieghere wrote:

That's the part I was missing, thanks for clarifying. I can't say I'm 
particularly happy about having to manually keep things in sync, but it does 
remove the need for the additional complexity that the optionals introduce. 

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap 'launch' request to use typed RequestHandler<>. (PR #133624)

2025-04-25 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] 51dc0cc - [lldb-dap] Handle stack frames without a module (#136777)

2025-04-25 Thread via lldb-commits

Author: Ely Ronnen
Date: 2025-04-25T09:30:09-07:00
New Revision: 51dc0cc7a43a4aef98a62bae93e758083f92b6f4

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

LOG: [lldb-dap] Handle stack frames without a module (#136777)

* Fix error in lldb-dap when the stack trace contains a frame without a
module by simply showing the first 32 assembly instructions after the PC.
* Adds a test with a simple example that triggers this case.

Added: 
lldb/test/API/tools/lldb-dap/stackTraceMissingModule/Makefile

lldb/test/API/tools/lldb-dap/stackTraceMissingModule/TestDAP_stackTraceMissingModule.py
lldb/test/API/tools/lldb-dap/stackTraceMissingModule/main.c

Modified: 
lldb/tools/lldb-dap/Handler/SourceRequestHandler.cpp
lldb/tools/lldb-dap/JSONUtils.cpp

Removed: 




diff  --git a/lldb/test/API/tools/lldb-dap/stackTraceMissingModule/Makefile 
b/lldb/test/API/tools/lldb-dap/stackTraceMissingModule/Makefile
new file mode 100644
index 0..c9319d6e6888a
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/stackTraceMissingModule/Makefile
@@ -0,0 +1,2 @@
+C_SOURCES := main.c
+include Makefile.rules

diff  --git 
a/lldb/test/API/tools/lldb-dap/stackTraceMissingModule/TestDAP_stackTraceMissingModule.py
 
b/lldb/test/API/tools/lldb-dap/stackTraceMissingModule/TestDAP_stackTraceMissingModule.py
new file mode 100644
index 0..1eb00f9935a22
--- /dev/null
+++ 
b/lldb/test/API/tools/lldb-dap/stackTraceMissingModule/TestDAP_stackTraceMissingModule.py
@@ -0,0 +1,54 @@
+"""
+Test lldb-dap stack trace when module is missing
+"""
+
+from lldbsuite.test.decorators import skipUnlessPlatform
+from lldbsuite.test.lldbtest import line_number
+import lldbdap_testcase
+import re
+
+
+class TestDAP_stackTraceMissingModule(lldbdap_testcase.DAPTestCaseBase):
+@skipUnlessPlatform(["linux"])
+def test_missingModule(self):
+"""
+Test that the stack frame without a module still has assembly source.
+"""
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program, commandEscapePrefix="")
+
+source = "main.c"
+self.set_source_breakpoints(
+source,
+[line_number(source, "// Break here")],
+)
+self.continue_to_next_stop()
+
+# Evaluate expr -- func
+expr_result = self.dap_server.request_evaluate(
+expression="expr -f pointer -- func",
+context="repl",
+)
+
+expr_result_address = re.search(
+r"0x[0-9a-fA-F]+", expr_result["body"]["result"]
+)
+self.assertIsNotNone(
+expr_result_address, "Failed to get address of dynamic allocated 
func"
+)
+func_address = expr_result_address.group(0)
+
+self.dap_server.request_evaluate(
+expression=f"breakpoint set --address {func_address}",
+context="repl",
+)
+
+self.continue_to_next_stop()
+
+frame_without_module = self.get_stackFrames()[0]
+
+self.assertIn("line", frame_without_module, "Line number missing.")
+self.assertIn("column", frame_without_module, "Column number missing.")
+self.assertIn("source", frame_without_module, "Source location 
missing.")
+source = frame_without_module["source"]
+self.assertIn("sourceReference", source, "Source reference missing.")

diff  --git a/lldb/test/API/tools/lldb-dap/stackTraceMissingModule/main.c 
b/lldb/test/API/tools/lldb-dap/stackTraceMissingModule/main.c
new file mode 100644
index 0..d706231fbd5c2
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/stackTraceMissingModule/main.c
@@ -0,0 +1,37 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+extern uint8_t __start_target_section[];
+extern uint8_t __stop_target_section[];
+
+__attribute__((used, section("target_section"))) int target_function(void) {
+  return 42;
+}
+
+typedef int (*target_function_t)(void);
+
+int main(void) {
+  size_t target_function_size = __stop_target_section - __start_target_section;
+  size_t page_size = sysconf(_SC_PAGESIZE);
+  size_t page_aligned_size =
+  (target_function_size + page_size - 1) & ~(page_size - 1);
+
+  void *executable_memory =
+  mmap(NULL, page_aligned_size, PROT_READ | PROT_WRITE | PROT_EXEC,
+   MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+  if (executable_memory == MAP_FAILED) {
+perror("mmap");
+return 1;
+  }
+
+  memcpy(executable_memory, __start_target_section, target_function_size);
+
+  target_function_t func = (target_function_t)executable_memory;
+  int result = func(); // Break here
+  printf("Result from target function: %d\n", result);
+
+  return 0;
+}

diff  --git a/lldb/tools/lldb-dap/Handler/SourceRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/S

[Lldb-commits] [lldb] [lldb] Fix error that lead Windows to think it could reverse execute (PR #137351)

2025-04-25 Thread Jonas Devlieghere via lldb-commits


@@ -239,15 +239,15 @@ ProcessWindows::DoAttachToProcessWithID(lldb::pid_t pid,
 Status ProcessWindows::DoResume(RunDirection direction) {
   Log *log = GetLog(WindowsLog::Process);
   llvm::sys::ScopedLock lock(m_mutex);
-  Status error;
 
   if (direction == RunDirection::eRunReverse) {
-error.FromErrorStringWithFormatv(
+return Status::FromErrorStringWithFormatv(
 "error: {0} does not support reverse execution of processes",

JDevlieghere wrote:

Nit: error's shouldn't be fixed with `error:`

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Respect x86 disassembly flavor setting (PR #134722)

2025-04-25 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Migrating the 'stepOut' request to use typed RequestHandler. (PR #137362)

2025-04-25 Thread Jonas Devlieghere via lldb-commits

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

This looks pretty straightforward. LGTM.

https://github.com/llvm/llvm-project/pull/137362
___
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 that lead Windows to think it could reverse execute (PR #137351)

2025-04-25 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Highlight basenames in backtraces instead of the PC value (PR #137301)

2025-04-25 Thread Michael Buch via lldb-commits

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

>From eac7bbaa47715c053c711ed6469f4dd9d3b55b4a Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 25 Apr 2025 10:25:51 +0100
Subject: [PATCH 1/2] [lldb] Highlight basenames in backtraces instead of PC
 value

---
 lldb/source/Core/CoreProperties.td| 4 ++--
 .../Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index f5d86b663de13..8c2ff934330b9 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -59,7 +59,7 @@ let Definition = "debugger" in {
 Desc<"The default disassembly format string to use when disassembling 
instruction sequences.">;
   def FrameFormat: Property<"frame-format", "FormatEntity">,
 Global,
-DefaultStringValue<"frame #${frame.index}: 
${ansi.fg.yellow}${frame.pc}${ansi.normal}{ 
${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset{
 at 
${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized}
 [opt]}{${frame.is-artificial} [artificial]}n">,
+DefaultStringValue<"frame #${frame.index}: ${frame.pc}{ 
${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset{
 at 
${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized}
 [opt]}{${frame.is-artificial} [artificial]}n">,
 Desc<"The default frame format string to use when displaying stack frame 
information for threads.">;
   def NotiftVoid: Property<"notify-void", "Boolean">,
 Global,
@@ -215,7 +215,7 @@ let Definition = "debugger" in {
 Desc<"If true, LLDB will automatically escape non-printable and escape 
characters when formatting strings.">;
   def FrameFormatUnique: Property<"frame-format-unique", "FormatEntity">,
 Global,
-DefaultStringValue<"frame #${frame.index}: 
${ansi.fg.yellow}${frame.pc}${ansi.normal}{ 
${module.file.basename}{`${function.name-without-args}{${frame.no-debug}${function.pc-offset{
 at 
${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized}
 [opt]}{${frame.is-artificial} [artificial]}n">,
+DefaultStringValue<"frame #${frame.index}: ${frame.pc}{ 
${module.file.basename}{`${function.name-without-args}{${frame.no-debug}${function.pc-offset{
 at 
${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized}
 [opt]}{${frame.is-artificial} [artificial]}n">,
 Desc<"The default frame format string to use when displaying stack frame 
information for threads from thread backtrace unique.">;
   def ShowAutosuggestion: Property<"show-autosuggestion", "Boolean">,
 Global,
diff --git 
a/lldb/source/Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td 
b/lldb/source/Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td
index 6ec87afe25758..348de256b154a 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td
+++ b/lldb/source/Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td
@@ -3,6 +3,6 @@ include "../../../../include/lldb/Core/PropertiesBase.td"
 let Definition = "language_cplusplus" in {
   def FunctionNameFormat: Property<"function-name-format", "FormatEntity">,
 Global,
-
DefaultStringValue<"${function.return-left}${function.scope}${function.basename}${function.template-arguments}${function.formatted-arguments}${function.return-right}${function.qualifiers}">,
+
DefaultStringValue<"${function.return-left}${function.scope}${ansi.fg.yellow}${function.basename}${ansi.normal}${function.template-arguments}${function.formatted-arguments}${function.return-right}${function.qualifiers}">,
 Desc<"C++ specific frame format string to use when displaying stack frame 
information for threads.">;
 }

>From 3a36ee7dbdb6144b8dc875ac61486c88abd236f9 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 25 Apr 2025 16:46:43 +0100
Subject: [PATCH 2/2] fixup! make PC value cyan

---
 lldb/source/Core/CoreProperties.td | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 8c2ff934330b9..b389e5ba7bbde 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -59,7 +59,7 @@ let Definition = "debugger" in {
 Desc<"The default disassembly format string to use when disassembling 
instruction sequences.">;
   def FrameFormat: Property<"frame-format", "FormatEntity

[Lldb-commits] [lldb] [lldb][lldb-dap] Respect x86 disassembly flavor setting (PR #134722)

2025-04-25 Thread Jonas Devlieghere via lldb-commits


@@ -190,6 +190,7 @@ void 
CommandObjectDisassemble::CommandOptions::OptionParsingStarting(
 // architecture.  For now GetDisassemblyFlavor is really only valid for x86
 // (and for the llvm assembler plugin, but I'm papering over that since 
that
 // is the only disassembler plugin we have...
+// this logic is also duplicated in `Handler/DisassembleRequestHandler`

JDevlieghere wrote:

```suggestion
// This logic is duplicated in `Handler/DisassembleRequestHandler`.
```

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


[Lldb-commits] [lldb] Add symbol locator time for each module in statistics (PR #134563)

2025-04-25 Thread Kazu Hirata via lldb-commits

kazutakahirata wrote:

@GeorgeHuyubo I've reverted this PR.  I'm happy to try your revised patch.  
Thanks!

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


[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-04-25 Thread David Peixotto via lldb-commits


@@ -174,12 +174,21 @@ struct StatisticsOptions {
 return !GetSummaryOnly();
   }
 
+  void SetIncludePlugins(bool value) { m_include_plugins = value; }
+  bool GetIncludePlugins() const {
+if (m_include_plugins.has_value())
+  return m_include_plugins.value();
+// Default to true in both default mode and summary mode.

dmpots wrote:

Should we include plugin info in the stats by default?

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


[Lldb-commits] [lldb] [lldb-dap] Fix formatting chrono::seconds warning. (PR #137371)

2025-04-25 Thread John Harrison via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Mitigate a build error on Windows. (PR #137388)

2025-04-25 Thread John Harrison via lldb-commits

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

When building with MSVC 2019 using `std::future` causes a compile 
time build error.

```
C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\future(196): error 
C2248: 'llvm::Error::Error': cannot access protected member declared in class 
'llvm::Error'

C:\work\main\llvm-project\llvm\include\llvm/Support/Error.h(181): note: see 
declaration of 'llvm::Error::Error'

C:\work\main\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(20):
 note: see declaration of 'llvm::Error'

C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\future(193): note: 
while compiling class template member function 
'std::_Associated_state<_Ty>::_Associated_state(std::_Deleter_base<_Ty> *)'

with

[

_Ty=llvm::Error

]

C:\work\main\llvm-project\lldb\tools\lldb-dap\DAP.cpp(854): note: see reference 
to class template instantiation 'std::future' being compiled
```

To work around this, swapping to a lldb::SBError for now.

>From 8f1e049869fd655f906343326e7375721c49bb58 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Fri, 25 Apr 2025 12:48:26 -0700
Subject: [PATCH] [lldb-dap] Mitigate a build error on Windows.

When building with MSVC 2019 using `std::future` causes a compile 
time build error.

```
C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\future(196): error 
C2248: 'llvm::Error::Error': cannot access protected member declared in class 
'llvm::Error'

C:\work\main\llvm-project\llvm\include\llvm/Support/Error.h(181): note: see 
declaration of 'llvm::Error::Error'

C:\work\main\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(20):
 note: see declaration of 'llvm::Error'

C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\future(193): note: 
while compiling class template member function 
'std::_Associated_state<_Ty>::_Associated_state(std::_Deleter_base<_Ty> *)'

with

[

_Ty=llvm::Error

]

C:\work\main\llvm-project\lldb\tools\lldb-dap\DAP.cpp(854): note: see reference 
to class template instantiation 'std::future' being compiled
```

To work around this, swapping to a lldb::SBError for now.
---
 lldb/tools/lldb-dap/DAP.cpp | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 185b475cfcad6..1813d8f853cda 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -844,8 +844,10 @@ static std::optional getArgumentsIfRequest(const 
Message &pm,
 }
 
 llvm::Error DAP::Loop() {
-  std::future queue_reader =
-  std::async(std::launch::async, [&]() -> llvm::Error {
+  // Can't use \a std::future because it doesn't compile on
+  // Windows.
+  std::future queue_reader =
+  std::async(std::launch::async, [&]() -> lldb::SBError {
 llvm::set_thread_name(transport.GetClientName() + 
".transport_handler");
 auto cleanup = llvm::make_scope_exit([&]() {
   // Ensure we're marked as disconnecting when the reader exits.
@@ -867,8 +869,11 @@ llvm::Error DAP::Loop() {
 continue;
   }
 
-  if (llvm::Error err = next.takeError())
-return err;
+  if (llvm::Error err = next.takeError()) {
+lldb::SBError errWrapper;
+errWrapper.SetErrorString(llvm::toString(std::move(err)).c_str());
+return errWrapper;
+  }
 
   if (const protocol::Request *req =
   std::get_if(&*next);
@@ -906,7 +911,7 @@ llvm::Error DAP::Loop() {
   m_queue_cv.notify_one();
 }
 
-return llvm::Error::success();
+return lldb::SBError();
   });
 
   auto cleanup = llvm::make_scope_exit([&]() {
@@ -930,7 +935,7 @@ llvm::Error DAP::Loop() {
  "unhandled packet");
   }
 
-  return queue_reader.get();
+  return ToError(queue_reader.get());
 }
 
 lldb::SBError DAP::WaitForProcessToStop(std::chrono::seconds seconds) {

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


[Lldb-commits] [lldb] [lldb-dap] Mitigate a build error on Windows. (PR #137388)

2025-04-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

When building with MSVC 2019 using `std::future` causes a 
compile time build error.

```
C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\future(196): error 
C2248: 'llvm::Error::Error': cannot access protected member declared in class 
'llvm::Error'

C:\work\main\llvm-project\llvm\include\llvm/Support/Error.h(181): note: see 
declaration of 'llvm::Error::Error'

C:\work\main\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(20):
 note: see declaration of 'llvm::Error'

C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\future(193): note: 
while compiling class template member function 
'std::_Associated_state<_Ty>::_Associated_state(std::_Deleter_base<_Ty>
 *)'

with

[

_Ty=llvm::Error

]

C:\work\main\llvm-project\lldb\tools\lldb-dap\DAP.cpp(854): note: see reference 
to class template instantiation 'std::future' being compiled
```

To work around this, swapping to a lldb::SBError for now.

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


1 Files Affected:

- (modified) lldb/tools/lldb-dap/DAP.cpp (+11-6) 


``diff
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 185b475cfcad6..1813d8f853cda 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -844,8 +844,10 @@ static std::optional getArgumentsIfRequest(const 
Message &pm,
 }
 
 llvm::Error DAP::Loop() {
-  std::future queue_reader =
-  std::async(std::launch::async, [&]() -> llvm::Error {
+  // Can't use \a std::future because it doesn't compile on
+  // Windows.
+  std::future queue_reader =
+  std::async(std::launch::async, [&]() -> lldb::SBError {
 llvm::set_thread_name(transport.GetClientName() + 
".transport_handler");
 auto cleanup = llvm::make_scope_exit([&]() {
   // Ensure we're marked as disconnecting when the reader exits.
@@ -867,8 +869,11 @@ llvm::Error DAP::Loop() {
 continue;
   }
 
-  if (llvm::Error err = next.takeError())
-return err;
+  if (llvm::Error err = next.takeError()) {
+lldb::SBError errWrapper;
+errWrapper.SetErrorString(llvm::toString(std::move(err)).c_str());
+return errWrapper;
+  }
 
   if (const protocol::Request *req =
   std::get_if(&*next);
@@ -906,7 +911,7 @@ llvm::Error DAP::Loop() {
   m_queue_cv.notify_one();
 }
 
-return llvm::Error::success();
+return lldb::SBError();
   });
 
   auto cleanup = llvm::make_scope_exit([&]() {
@@ -930,7 +935,7 @@ llvm::Error DAP::Loop() {
  "unhandled packet");
   }
 
-  return queue_reader.get();
+  return ToError(queue_reader.get());
 }
 
 lldb::SBError DAP::WaitForProcessToStop(std::chrono::seconds seconds) {

``




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


[Lldb-commits] [lldb] Add symbol locator time for each module in statistics (PR #137379)

2025-04-25 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/137379

>From 2c2de66f4ea47716452c2deafbef6e2bfa7113fa Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Tue, 22 Apr 2025 19:37:05 -0700
Subject: [PATCH] Add symbol locator time for each module in statistics

---
 lldb/include/lldb/Core/Module.h   |  6 +
 lldb/include/lldb/Core/PluginManager.h|  7 --
 lldb/include/lldb/Target/Statistics.h | 21 
 lldb/source/Core/DynamicLoader.cpp| 11 ++--
 lldb/source/Core/ModuleList.cpp   |  8 +++---
 lldb/source/Core/PluginManager.cpp| 25 ++-
 .../Platform/MacOSX/PlatformDarwinKernel.cpp  |  4 +--
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  | 11 +---
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 10 +---
 .../SymbolVendor/ELF/SymbolVendorELF.cpp  |  9 +++
 .../MacOSX/SymbolVendorMacOSX.cpp |  5 ++--
 .../PECOFF/SymbolVendorPECOFF.cpp |  4 +--
 .../SymbolVendor/wasm/SymbolVendorWasm.cpp|  4 +--
 lldb/source/Target/Statistics.cpp | 18 +
 .../Commands/command-statistics-dump.test |  1 -
 .../unittests/Symbol/LocateSymbolFileTest.cpp |  6 +++--
 16 files changed, 114 insertions(+), 36 deletions(-)

diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 1ad67d6747850..8bb55c95773bc 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -885,6 +885,10 @@ class Module : public std::enable_shared_from_this,
   /// ElapsedTime RAII object.
   StatsDuration &GetSymtabIndexTime() { return m_symtab_index_time; }
 
+  StatisticsMap &GetSymbolLocatorStatistics() {
+return m_symbol_locator_duration_map;
+  }
+
   void ResetStatistics();
 
   /// \class LookupInfo Module.h "lldb/Core/Module.h"
@@ -1064,6 +1068,8 @@ class Module : public 
std::enable_shared_from_this,
   /// time for the symbol tables can be aggregated here.
   StatsDuration m_symtab_index_time;
 
+  StatisticsMap m_symbol_locator_duration_map;
+
   /// A set of hashes of all warnings and errors, to avoid reporting them
   /// multiple times to the same Debugger.
   llvm::DenseMap>
diff --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index d73dd71d833f3..e2f709ecd2ff7 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -12,6 +12,7 @@
 #include "lldb/Core/Architecture.h"
 #include "lldb/Interpreter/Interfaces/ScriptedInterfaceUsages.h"
 #include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Target/Statistics.h"
 #include "lldb/Utility/CompletionRequest.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
@@ -379,11 +380,13 @@ class PluginManager {
   static SymbolLocatorCreateInstance
   GetSymbolLocatorCreateCallbackAtIndex(uint32_t idx);
 
-  static ModuleSpec LocateExecutableObjectFile(const ModuleSpec &module_spec);
+  static ModuleSpec LocateExecutableObjectFile(const ModuleSpec &module_spec,
+   StatisticsMap &map);
 
   static FileSpec
   LocateExecutableSymbolFile(const ModuleSpec &module_spec,
- const FileSpecList &default_search_paths);
+ const FileSpecList &default_search_paths,
+ StatisticsMap &map);
 
   static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec,
   Status &error,
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index 565f1b4351bdd..9ac32172e8002 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -90,6 +90,26 @@ class ElapsedTime {
   }
 };
 
+/// A class to count time for plugins
+class StatisticsMap {
+public:
+  void add(llvm::StringRef key, double value) {
+if (key.empty())
+  return;
+auto it = map.find(key);
+if (it == map.end())
+  map.try_emplace(key, value);
+else
+  it->second += value;
+  }
+  void merge(StatisticsMap map_to_merge) {
+for (const auto &entry : map_to_merge.map) {
+  add(entry.first(), entry.second);
+}
+  }
+  llvm::StringMap map;
+};
+
 /// A class to count success/fail statistics.
 struct StatsSuccessFail {
   StatsSuccessFail(llvm::StringRef n) : name(n.str()) {}
@@ -118,6 +138,7 @@ struct ModuleStats {
   // track down all of the stats that contribute to this module.
   std::vector symfile_modules;
   llvm::StringMap type_system_stats;
+  StatisticsMap symbol_locator_time;
   double symtab_parse_time = 0.0;
   double symtab_index_time = 0.0;
   uint32_t symtab_symbol_count = 0;
diff --git a/lldb/source/Core/DynamicLoader.cpp 
b/lldb/source/Core/DynamicLoader.cpp
index 76c71d2a49a48..291e6b73a2c39 100644
--- a/lldb/source/Core/DynamicLoader.cpp
+++ b/lldb/source/Core/DynamicLoader.cpp
@@ -243,15 +243,22 @@ ModuleSP DynamicLoader::LoadBi

[Lldb-commits] [lldb] Add symbol locator time for each module in statistics (PR #137379)

2025-04-25 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Emit diagnostics as "important" output (PR #137280)

2025-04-25 Thread Jonas Devlieghere via lldb-commits


@@ -164,3 +164,20 @@ def test_exit_status_message_ok(self):
 console_output,
 "Exit status does not contain message 'exited with status'",
 )
+
+def test_diagnositcs(self):
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+
+core = self.getBuildArtifact("minidump.core")

JDevlieghere wrote:

This works on all platforms (you can load an Linux ELF core on macOS and vice 
versa). We use the same technique in `TestDiagnosticReporting`. 

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


[Lldb-commits] [lldb] [lldb-dap] fix wrong assembly line number x64 (PR #136486)

2025-04-25 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere closed 
https://github.com/llvm/llvm-project/pull/136486
___
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 that lead Windows to think it could reverse execute (PR #137351)

2025-04-25 Thread David Spickett via lldb-commits


@@ -239,15 +239,15 @@ ProcessWindows::DoAttachToProcessWithID(lldb::pid_t pid,
 Status ProcessWindows::DoResume(RunDirection direction) {
   Log *log = GetLog(WindowsLog::Process);
   llvm::sys::ScopedLock lock(m_mutex);
-  Status error;
 
   if (direction == RunDirection::eRunReverse) {
-error.FromErrorStringWithFormatv(
+return Status::FromErrorStringWithFormatv(
 "error: {0} does not support reverse execution of processes",

DavidSpickett wrote:

There are a few of these, I'll fix them all in a follow up.

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


[Lldb-commits] [lldb] [lldb-dap] fix wrong assembly line number x64 (PR #136486)

2025-04-25 Thread via lldb-commits

github-actions[bot] wrote:



@eronnen 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/136486
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-dap] Respect x86 disassembly flavor setting (PR #134722)

2025-04-25 Thread Jonas Devlieghere via lldb-commits


@@ -116,7 +116,25 @@ void DisassembleRequestHandler::operator()(
 
   const auto inst_count =
   GetInteger(arguments, "instructionCount").value_or(0);
-  lldb::SBInstructionList insts = dap.target.ReadInstructions(addr, 
inst_count);
+
+  std::string flavor_string{};
+  const auto target_triple = llvm::StringRef(dap.target.GetTriple());
+  // this handles both 32 and 64bit x86 architecture.
+  // this logic is also duplicated in
+  // `CommandObjectDisassemble::CommandOptions::OptionParsingStarting`

JDevlieghere wrote:

```suggestion
  // This handles both 32 and 64bit x86 architecture. The logic is duplicated in
  // `CommandObjectDisassemble::CommandOptions::OptionParsingStarting`
```

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Respect x86 disassembly flavor setting (PR #134722)

2025-04-25 Thread Jonas Devlieghere via lldb-commits


@@ -116,7 +116,25 @@ void DisassembleRequestHandler::operator()(
 
   const auto inst_count =
   GetInteger(arguments, "instructionCount").value_or(0);
-  lldb::SBInstructionList insts = dap.target.ReadInstructions(addr, 
inst_count);
+
+  std::string flavor_string{};

JDevlieghere wrote:

```suggestion
  std::string flavor_string;
```

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


[Lldb-commits] [lldb] [lldb] Emit diagnostics as "important" output (PR #137280)

2025-04-25 Thread Jonas Devlieghere via lldb-commits


@@ -117,6 +118,9 @@ static void EventThreadFunction(DAP &dap) {
   lldb::SBEvent event;
   lldb::SBListener listener = dap.debugger.GetListener();
   dap.broadcaster.AddListener(listener, eBroadcastBitStopEventThread);
+  dap.debugger.GetBroadcaster().AddListener(
+  listener, lldb::SBDebugger::eBroadcastBitError |

JDevlieghere wrote:

The enum exists both in SBDebugger (for API compatibility) as well as in 
`lldb-enumerations.h`. We should definitely be consistent, so let's go with the 
latter.

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Respect x86 disassembly flavor setting (PR #134722)

2025-04-25 Thread Ebuka Ezike via lldb-commits

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

>From ababee38bf0dae6c12e09225bf84ec2bf03e7982 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Mon, 7 Apr 2025 20:43:30 +0100
Subject: [PATCH 1/4] [lldb][lldb-dap] Respect x86 disassembly flavor setting

Ensure the disassembly respects the "target.x86-disassembly-flavor" setting for 
x86 and x86_64 targets.

Depends on #134626
---
 .../Handler/DisassembleRequestHandler.cpp   | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index f0cb7be70210d..0fd9390623046 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -116,7 +116,22 @@ void DisassembleRequestHandler::operator()(
 
   const auto inst_count =
   GetInteger(arguments, "instructionCount").value_or(0);
-  lldb::SBInstructionList insts = dap.target.ReadInstructions(addr, 
inst_count);
+
+  std::string flavor_string{};
+  const auto target_triple = llvm::StringRef(dap.target.GetTriple());
+  if (target_triple.starts_with("x86_64") || target_triple.starts_with("x86")) 
{
+const lldb::SBStructuredData flavor =
+dap.debugger.GetSetting("target.x86-disassembly-flavor");
+
+const size_t str_length = flavor.GetStringValue(nullptr, 0);
+if (str_length != 0) {
+  flavor_string.resize(str_length + 1);
+  flavor.GetStringValue(flavor_string.data(), flavor_string.length());
+}
+  }
+
+  lldb::SBInstructionList insts =
+  dap.target.ReadInstructions(addr, inst_count, flavor_string.c_str());
 
   if (!insts.IsValid()) {
 response["success"] = false;

>From c69872d867a6e0dc50784c8c69c75c9d5535b67b Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Wed, 16 Apr 2025 20:50:11 +0100
Subject: [PATCH 2/4] [lldb][lldb-dap] add review changes

Signed-off-by: Ebuka Ezike 
---
 lldb/source/Commands/CommandObjectDisassemble.cpp | 1 +
 lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp | 5 -
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp 
b/lldb/source/Commands/CommandObjectDisassemble.cpp
index 70e687e19ac6d..fa9311ad9624e 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -190,6 +190,7 @@ void 
CommandObjectDisassemble::CommandOptions::OptionParsingStarting(
 // architecture.  For now GetDisassemblyFlavor is really only valid for x86
 // (and for the llvm assembler plugin, but I'm papering over that since 
that
 // is the only disassembler plugin we have...
+// this logic is also duplicated in `Handler/DisassembleRequestHandler`
 if (target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86 ||
 target->GetArchitecture().GetTriple().getArch() ==
 llvm::Triple::x86_64) {
diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index 0fd9390623046..7489c63a61afe 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -119,7 +119,10 @@ void DisassembleRequestHandler::operator()(
 
   std::string flavor_string{};
   const auto target_triple = llvm::StringRef(dap.target.GetTriple());
-  if (target_triple.starts_with("x86_64") || target_triple.starts_with("x86")) 
{
+  // this handles both 32 and 64bit x86 architecture.
+  // this logic is also duplicated in
+  // `CommandObjectDisassemble::CommandOptions::OptionParsingStarting`
+  if (target_triple.starts_with("x86")) {
 const lldb::SBStructuredData flavor =
 dap.debugger.GetSetting("target.x86-disassembly-flavor");
 

>From d8ea6305ccfa6adaf5b55bc4e48edcd4031678a4 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Fri, 25 Apr 2025 17:38:01 +0100
Subject: [PATCH 3/4] Update
 lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp

Co-authored-by: Jonas Devlieghere 
---
 lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index 7489c63a61afe..3a292728e42f1 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -117,7 +117,7 @@ void DisassembleRequestHandler::operator()(
   const auto inst_count =
   GetInteger(arguments, "instructionCount").value_or(0);
 
-  std::string flavor_string{};
+  std::string flavor_string;
   const auto target_triple = llvm::StringRef(dap.target.GetTriple());
   // this handles both 32 and 64bit x86 architecture.
   // this logic is also duplicated in

>From ebbf286ad020911a2e7d2ada645f328d6e10

[Lldb-commits] [lldb] [lldb][lldb-dap] Respect x86 disassembly flavor setting (PR #134722)

2025-04-25 Thread Ebuka Ezike via lldb-commits

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

>From ababee38bf0dae6c12e09225bf84ec2bf03e7982 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Mon, 7 Apr 2025 20:43:30 +0100
Subject: [PATCH 1/3] [lldb][lldb-dap] Respect x86 disassembly flavor setting

Ensure the disassembly respects the "target.x86-disassembly-flavor" setting for 
x86 and x86_64 targets.

Depends on #134626
---
 .../Handler/DisassembleRequestHandler.cpp   | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index f0cb7be70210d..0fd9390623046 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -116,7 +116,22 @@ void DisassembleRequestHandler::operator()(
 
   const auto inst_count =
   GetInteger(arguments, "instructionCount").value_or(0);
-  lldb::SBInstructionList insts = dap.target.ReadInstructions(addr, 
inst_count);
+
+  std::string flavor_string{};
+  const auto target_triple = llvm::StringRef(dap.target.GetTriple());
+  if (target_triple.starts_with("x86_64") || target_triple.starts_with("x86")) 
{
+const lldb::SBStructuredData flavor =
+dap.debugger.GetSetting("target.x86-disassembly-flavor");
+
+const size_t str_length = flavor.GetStringValue(nullptr, 0);
+if (str_length != 0) {
+  flavor_string.resize(str_length + 1);
+  flavor.GetStringValue(flavor_string.data(), flavor_string.length());
+}
+  }
+
+  lldb::SBInstructionList insts =
+  dap.target.ReadInstructions(addr, inst_count, flavor_string.c_str());
 
   if (!insts.IsValid()) {
 response["success"] = false;

>From c69872d867a6e0dc50784c8c69c75c9d5535b67b Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Wed, 16 Apr 2025 20:50:11 +0100
Subject: [PATCH 2/3] [lldb][lldb-dap] add review changes

Signed-off-by: Ebuka Ezike 
---
 lldb/source/Commands/CommandObjectDisassemble.cpp | 1 +
 lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp | 5 -
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp 
b/lldb/source/Commands/CommandObjectDisassemble.cpp
index 70e687e19ac6d..fa9311ad9624e 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -190,6 +190,7 @@ void 
CommandObjectDisassemble::CommandOptions::OptionParsingStarting(
 // architecture.  For now GetDisassemblyFlavor is really only valid for x86
 // (and for the llvm assembler plugin, but I'm papering over that since 
that
 // is the only disassembler plugin we have...
+// this logic is also duplicated in `Handler/DisassembleRequestHandler`
 if (target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86 ||
 target->GetArchitecture().GetTriple().getArch() ==
 llvm::Triple::x86_64) {
diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index 0fd9390623046..7489c63a61afe 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -119,7 +119,10 @@ void DisassembleRequestHandler::operator()(
 
   std::string flavor_string{};
   const auto target_triple = llvm::StringRef(dap.target.GetTriple());
-  if (target_triple.starts_with("x86_64") || target_triple.starts_with("x86")) 
{
+  // this handles both 32 and 64bit x86 architecture.
+  // this logic is also duplicated in
+  // `CommandObjectDisassemble::CommandOptions::OptionParsingStarting`
+  if (target_triple.starts_with("x86")) {
 const lldb::SBStructuredData flavor =
 dap.debugger.GetSetting("target.x86-disassembly-flavor");
 

>From d8ea6305ccfa6adaf5b55bc4e48edcd4031678a4 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Fri, 25 Apr 2025 17:38:01 +0100
Subject: [PATCH 3/3] Update
 lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp

Co-authored-by: Jonas Devlieghere 
---
 lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index 7489c63a61afe..3a292728e42f1 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -117,7 +117,7 @@ void DisassembleRequestHandler::operator()(
   const auto inst_count =
   GetInteger(arguments, "instructionCount").value_or(0);
 
-  std::string flavor_string{};
+  std::string flavor_string;
   const auto target_triple = llvm::StringRef(dap.target.GetTriple());
   // this handles both 32 and 64bit x86 architecture.
   // this logic is also duplicated in

__

[Lldb-commits] [lldb] 332e181 - [lldb] Fix error that lead Windows to think it could reverse execute (#137351)

2025-04-25 Thread via lldb-commits

Author: David Spickett
Date: 2025-04-25T18:04:08+01:00
New Revision: 332e1817667827c242422e91c4de1b27fb573a0b

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

LOG: [lldb] Fix error that lead Windows to think it could reverse execute 
(#137351)

The new test added in https://github.com/llvm/llvm-project/pull/132783
was failing on Windows because it created a new error to say it did not
support the feature, but then returned the existing, default constructed
error. Which was a success value.

This also changes the GDBRemote error message to the same phrasing used
in all the other places so we don't have to special case any platform.

Added: 


Modified: 
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

lldb/test/API/commands/process/reverse-continue/TestReverseContinueNotSupported.py

Removed: 




diff  --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
index 9196ac2702c85..331139d029f50 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -239,15 +239,15 @@ ProcessWindows::DoAttachToProcessWithID(lldb::pid_t pid,
 Status ProcessWindows::DoResume(RunDirection direction) {
   Log *log = GetLog(WindowsLog::Process);
   llvm::sys::ScopedLock lock(m_mutex);
-  Status error;
 
   if (direction == RunDirection::eRunReverse) {
-error.FromErrorStringWithFormatv(
+return Status::FromErrorStringWithFormatv(
 "error: {0} does not support reverse execution of processes",
 GetPluginName());
-return error;
   }
 
+  Status error;
+
   StateType private_state = GetPrivateState();
   if (private_state == eStateStopped || private_state == eStateCrashed) {
 LLDB_LOG(log, "process {0} is in state {1}.  Resuming...",

diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index b616e99be83b2..f924d1194e8a1 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1410,7 +1410,7 @@ Status ProcessGDBRemote::DoResume(RunDirection direction) 
{
   LLDB_LOGF(log, "ProcessGDBRemote::DoResume: target does not "
  "support reverse-continue");
   return Status::FromErrorString(
-  "target does not support reverse-continue");
+  "target does not support reverse execution of processes");
 }
 
 if (num_continue_C_tids > 0) {

diff  --git 
a/lldb/test/API/commands/process/reverse-continue/TestReverseContinueNotSupported.py
 
b/lldb/test/API/commands/process/reverse-continue/TestReverseContinueNotSupported.py
index 54d757dc4b98b..167d5827bff55 100644
--- 
a/lldb/test/API/commands/process/reverse-continue/TestReverseContinueNotSupported.py
+++ 
b/lldb/test/API/commands/process/reverse-continue/TestReverseContinueNotSupported.py
@@ -11,7 +11,6 @@
 
 
 class TestReverseContinueNotSupported(TestBase):
-@skipIfWindows
 def test_reverse_continue_not_supported(self):
 target = self.connect()
 
@@ -26,7 +25,9 @@ def test_reverse_continue_not_supported(self):
 self.expect(
 "process continue --reverse",
 error=True,
-substrs=["target does not support reverse-continue"],
+# This error is " does not support...". The plugin 
name changes
+# between platforms.
+substrs=["does not support reverse execution of processes"],
 )
 
 def test_reverse_continue_forward_and_reverse(self):



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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

2025-04-25 Thread Emre Kultursay via lldb-commits

https://github.com/emrekultursay updated 
https://github.com/llvm/llvm-project/pull/136466

>From b6c46b7a28a807b507f06d748ed93f20d26fdfcc Mon Sep 17 00:00:00 2001
From: Emre Kultursay 
Date: Sun, 20 Apr 2025 01:11:31 +
Subject: [PATCH 1/5] Fix connecting via abstract socket

Commit 82ee31f and Commit 2e893124 added socket sharing, but only for
unix domain sockets. That broke Android, which uses unix-abstract
sockets.
---
 lldb/include/lldb/Host/linux/AbstractSocket.h |  1 +
 lldb/include/lldb/Host/posix/DomainSocket.h   |  1 +
 lldb/source/Host/linux/AbstractSocket.cpp |  3 ++
 lldb/source/Host/posix/DomainSocket.cpp   |  6 +++
 lldb/tools/lldb-server/lldb-platform.cpp  | 40 +--
 5 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/lldb/include/lldb/Host/linux/AbstractSocket.h 
b/lldb/include/lldb/Host/linux/AbstractSocket.h
index accfd01457a5e..c6a0e2f8af63b 100644
--- a/lldb/include/lldb/Host/linux/AbstractSocket.h
+++ b/lldb/include/lldb/Host/linux/AbstractSocket.h
@@ -15,6 +15,7 @@ namespace lldb_private {
 class AbstractSocket : public DomainSocket {
 public:
   AbstractSocket();
+  AbstractSocket(NativeSocket socket, bool should_close);
 
 protected:
   size_t GetNameOffset() const override;
diff --git a/lldb/include/lldb/Host/posix/DomainSocket.h 
b/lldb/include/lldb/Host/posix/DomainSocket.h
index 3dbe6206da2c5..562c011ee73e6 100644
--- a/lldb/include/lldb/Host/posix/DomainSocket.h
+++ b/lldb/include/lldb/Host/posix/DomainSocket.h
@@ -33,6 +33,7 @@ class DomainSocket : public Socket {
 
 protected:
   DomainSocket(SocketProtocol protocol);
+  DomainSocket(SocketProtocol protocol, NativeSocket socket, bool 
should_close);
 
   virtual size_t GetNameOffset() const;
   virtual void DeleteSocketFile(llvm::StringRef name);
diff --git a/lldb/source/Host/linux/AbstractSocket.cpp 
b/lldb/source/Host/linux/AbstractSocket.cpp
index 8393a80e86e72..681aa2d1ebc72 100644
--- a/lldb/source/Host/linux/AbstractSocket.cpp
+++ b/lldb/source/Host/linux/AbstractSocket.cpp
@@ -15,6 +15,9 @@ using namespace lldb_private;
 
 AbstractSocket::AbstractSocket() : DomainSocket(ProtocolUnixAbstract) {}
 
+AbstractSocket::AbstractSocket(NativeSocket socket, bool should_close)
+: DomainSocket(ProtocolUnixAbstract, socket, should_close) {}
+
 size_t AbstractSocket::GetNameOffset() const { return 1; }
 
 void AbstractSocket::DeleteSocketFile(llvm::StringRef name) {}
diff --git a/lldb/source/Host/posix/DomainSocket.cpp 
b/lldb/source/Host/posix/DomainSocket.cpp
index 6c490cdda47ed..9b1e4f71bba2a 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -67,6 +67,12 @@ DomainSocket::DomainSocket(NativeSocket socket,
   m_socket = socket;
 }
 
+DomainSocket::DomainSocket(SocketProtocol protocol, NativeSocket socket,
+   bool should_close)
+: Socket(protocol, should_close) {
+  m_socket = socket;
+}
+
 Status DomainSocket::Connect(llvm::StringRef name) {
   sockaddr_un saddr_un;
   socklen_t saddr_un_len;
diff --git a/lldb/tools/lldb-server/lldb-platform.cpp 
b/lldb/tools/lldb-server/lldb-platform.cpp
index 23d36ffb4cb66..59a83c28b0212 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -39,11 +39,19 @@
 #if LLDB_ENABLE_POSIX
 #include "lldb/Host/posix/DomainSocket.h"
 #endif
+#ifdef __linux__
+#include "lldb/Host/linux/AbstractSocket.h"
+#endif
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/UriParser.h"
 
+#if LLDB_ENABLE_POSIX
+#include 
+#include 
+#endif
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::lldb_server;
@@ -455,14 +463,28 @@ int main_platform(int argc, char *argv[]) {
   lldb_private::Args inferior_arguments;
   inferior_arguments.SetArguments(argc, const_cast(argv));
 
+  Log *log = GetLog(LLDBLog::Platform);
   Socket::SocketProtocol protocol = Socket::ProtocolUnixDomain;
 
   if (fd != SharedSocket::kInvalidFD) {
 // Child process will handle the connection and exit.
-if (gdbserver_port)
+if (gdbserver_port) {
   protocol = Socket::ProtocolTcp;
+} else {
+#ifdef LLDB_ENABLE_POSIX
+  // Check if fd represents domain socket or abstract socket.
+  struct sockaddr_un addr;
+  socklen_t addr_len = sizeof(addr);
+  if (getsockname(fd, (struct sockaddr *)&addr, &addr_len) == -1) {
+LLDB_LOGF(log, "lldb-platform child: not a socket or error occurred");
+return socket_error;
+  }
 
-Log *log = GetLog(LLDBLog::Platform);
+  if (addr.sun_family == AF_UNIX && addr.sun_path[0] == '\0') {
+protocol = Socket::ProtocolUnixAbstract;
+  }
+#endif
+}
 
 NativeSocket sockfd;
 error = SharedSocket::GetNativeSocket(fd, sockfd);
@@ -473,17 +495,27 @@ int main_platform(int argc, char *argv[]) {
 
 GDBRemoteCommunicationServerPlatform platform(protocol, gdbserver_

[Lldb-commits] [lldb] [lldb-dap] Fix TestDap_attach.py flakiness (PR #137278)

2025-04-25 Thread David Peixotto via lldb-commits


@@ -374,6 +374,12 @@ def wait_for_event(self, filter=None, timeout=None):
 )
 return None
 
+def wait_for_process_and_initialized(self, timeout=None):

dmpots wrote:

You are taking `timeout` as a parameter here, but not passing it down to 
`wait_for_event`.

I wonder if it would be useful to have a more general function to wait for any 
set of events. Something like
```
# Wait for the set of events in `events`. 
# Return the events not hit for before the timeout expired
def wait_for_events(self, events, timeout=None):
events = events[:] # Should we make a copy to not modify the input?
while events:
event = self.wait_for_event(filter=events, timeout=timeout)
events.remove(event["event"])
return events
```

Then we can call it like
```
   self.wait_for_events(["process", "initialized"])
```

What do you think?

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


[Lldb-commits] [lldb] [lldb] Emit diagnostics as "important" output (PR #137280)

2025-04-25 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> I also think this LZMA message is important enough to see -- but once, not 
> once for each module. So I can imagine a setup where the first of these 
> messages would cause a popup and the rest would be squirrelled away somewhere 
> -- but for that we'd need a better mechanism to track these.

The methods to emit diagnostics (`ReportError`, `ReportWarning`) already take 
an optional `std::once_flag`. We have a somewhat similar way of making these 
errors and warnings very visible in Xcode, so making sure they're not too 
spammy is something we also care about. I remember several patches (maybe some 
on the Swift fork) to improve this. In other words, if this needs improving, 
let's do it at the source. 

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


[Lldb-commits] [lldb] [lldb-dap] Fix broken tests with commanEscapePrefix="" (PR #137384)

2025-04-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ely Ronnen (eronnen)


Changes

* Fix broken tests that use commanEscapePrefix="",  in my case 
`TestDAP_stackTraceMissingModule.test_missingModule`

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


1 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
(+1-1) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 0f8a84461c9e7..40bdcf99e5b09 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -860,7 +860,7 @@ def request_launch(
 args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
 args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
 args_dict["displayExtendedBacktrace"] = displayExtendedBacktrace
-if commandEscapePrefix:
+if commandEscapePrefix is not None:
 args_dict["commandEscapePrefix"] = commandEscapePrefix
 command_dict = {"command": "launch", "type": "request", "arguments": 
args_dict}
 response = self.send_recv(command_dict)

``




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


[Lldb-commits] [lldb] [lldb-dap] Fix broken tests with commanEscapePrefix="" (PR #137384)

2025-04-25 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen created 
https://github.com/llvm/llvm-project/pull/137384

* Fix broken tests that use commanEscapePrefix="",  in my case 
`TestDAP_stackTraceMissingModule.test_missingModule`

>From c496d0ec97db4a1bcb4717afb7427648e0c371ec Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Fri, 25 Apr 2025 21:23:19 +0200
Subject: [PATCH] [lldb-dap] fix broken tests with commanEscapePrefix=""

---
 .../packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 0f8a84461c9e7..40bdcf99e5b09 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -860,7 +860,7 @@ def request_launch(
 args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
 args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
 args_dict["displayExtendedBacktrace"] = displayExtendedBacktrace
-if commandEscapePrefix:
+if commandEscapePrefix is not None:
 args_dict["commandEscapePrefix"] = commandEscapePrefix
 command_dict = {"command": "launch", "type": "request", "arguments": 
args_dict}
 response = self.send_recv(command_dict)

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


[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

2025-04-25 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen updated 
https://github.com/llvm/llvm-project/pull/136494

>From caf6db4c4ef8caea027bb7909a723bf24ff881ad Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 20 Apr 2025 17:07:09 +0200
Subject: [PATCH] fallback to assembly when source code is not available

fix TestDAP_coreFile.py with source maps

use stop-disassembly-display setting to determine when to show disassembly

* Use GetSetting instead of Handle command

* Implement OptionValueEnumeration::ToJSON

export StopDisassemblyType enum

fix comment

cleaner stackTraceDisassemblyDisplay tests

remove include in main.c in test
---
 lldb/include/lldb/Core/Debugger.h |  10 +-
 lldb/include/lldb/lldb-enumerations.h |   8 +
 lldb/source/Core/CoreProperties.td|  12 +-
 lldb/source/Core/Debugger.cpp |  14 +-
 lldb/source/Target/StackFrame.cpp |  11 +-
 .../stackTraceDisassemblyDisplay/Makefile |   3 +
 .../TestDAP_stackTraceDisassemblyDisplay.py   | 161 ++
 .../stackTraceDisassemblyDisplay/main.c   |   6 +
 .../Handler/StackTraceRequestHandler.cpp  |   7 +-
 lldb/tools/lldb-dap/JSONUtils.cpp |  35 +++-
 lldb/tools/lldb-dap/JSONUtils.h   |  22 ++-
 lldb/tools/lldb-dap/LLDBUtils.cpp |  27 +++
 lldb/tools/lldb-dap/LLDBUtils.h   |   9 +
 13 files changed, 288 insertions(+), 37 deletions(-)
 create mode 100644 
lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py
 create mode 100644 
lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/main.c

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index c2e7d6f1d64b7..0595125b1813d 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -232,14 +232,6 @@ class Debugger : public 
std::enable_shared_from_this,
 
   void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
 
-  // Properties Functions
-  enum StopDisassemblyType {
-eStopDisassemblyTypeNever = 0,
-eStopDisassemblyTypeNoDebugInfo,
-eStopDisassemblyTypeNoSource,
-eStopDisassemblyTypeAlways
-  };
-
   Status SetPropertyValue(const ExecutionContext *exe_ctx,
   VarSetOperationType op, llvm::StringRef 
property_path,
   llvm::StringRef value) override;
@@ -336,7 +328,7 @@ class Debugger : public 
std::enable_shared_from_this,
 
   uint64_t GetStopSourceLineCount(bool before) const;
 
-  StopDisassemblyType GetStopDisassemblyDisplay() const;
+  lldb::StopDisassemblyType GetStopDisassemblyDisplay() const;
 
   uint64_t GetDisassemblyLineCount() const;
 
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 8e962428260f8..6d10cc8bcffcb 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1383,6 +1383,14 @@ enum CommandReturnObjectCallbackResult {
   eCommandReturnObjectPrintCallbackHandled = 1,
 };
 
+/// Used to determine when to show disassembly.
+enum StopDisassemblyType {
+  eStopDisassemblyTypeNever = 0,
+  eStopDisassemblyTypeNoDebugInfo,
+  eStopDisassemblyTypeNoSource,
+  eStopDisassemblyTypeAlways
+};
+
 } // namespace lldb
 
 #endif // LLDB_LLDB_ENUMERATIONS_H
diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index f5d86b663de13..a1a4e994c3b9c 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -91,11 +91,13 @@ let Definition = "debugger" in {
 Global,
 DefaultUnsignedValue<4>,
 Desc<"The number of disassembly lines to show when displaying a stopped 
context.">;
-  def StopDisassemblyDisplay: Property<"stop-disassembly-display", "Enum">,
-Global,
-DefaultEnumValue<"Debugger::eStopDisassemblyTypeNoDebugInfo">,
-EnumValues<"OptionEnumValues(g_show_disassembly_enum_values)">,
-Desc<"Control when to display disassembly when displaying a stopped 
context.">;
+  def StopDisassemblyDisplay
+  : Property<"stop-disassembly-display", "Enum">,
+Global,
+DefaultEnumValue<"eStopDisassemblyTypeNoDebugInfo">,
+EnumValues<"OptionEnumValues(g_show_disassembly_enum_values)">,
+Desc<"Control when to display disassembly when displaying a stopped "
+ "context.">;
   def StopDisassemblyMaxSize: Property<"stop-disassembly-max-size", "UInt64">,
 Global,
 DefaultUnsignedValue<32000>,
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index cd8726eeba632..1a0723a2f3b3f 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -112,24 +112,24 @@ static llvm::DefaultThreadPool *g_thread_pool = nullptr;
 
 static constexpr OptionEnumValueElement g_show_disassembly_enum_values[] = {
 {
-Debugger::eStopDisassemblyTypeNever,
+ll

[Lldb-commits] [lldb] [lldb][docs] Update instructions to build standalone (PR #137383)

2025-04-25 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/137383

The instructions to build LLDB standalone contain a CMake configure step to 
build LLVM standalone. This configure step needs to also have the CMake build 
type in order to work.

>From c12f01f83d6849023635fd9c618eeb5159dc2252 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Fri, 25 Apr 2025 11:57:30 -0700
Subject: [PATCH] [lldb][docs] Update instructions to build standalone

The instructions to build LLDB standalone contain a CMake configure step
to build LLVM standalone. This configure step needs to also have the
CMake build type in order to work.
---
 lldb/docs/resources/build.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index e59dcc1972418..53ad078ad437e 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -210,6 +210,7 @@ Clang. Then we build the ``ALL`` target with ninja:
 ::
 
   $ cmake -B /path/to/llvm-build -G Ninja \
+  -DCMAKE_BUILD_TYPE=[] \
   -DLLVM_ENABLE_PROJECTS=clang \
   [] /path/to/llvm-project/llvm
   $ ninja

___
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 the Module Event (PR #137380)

2025-04-25 Thread Jonas Devlieghere via lldb-commits

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

>From 681beb0f851d20896456b53c51b8ee84382a1254 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 25 Apr 2025 10:40:45 -0700
Subject: [PATCH 1/2] [lldb-dap] Support the Module Event

The module event indicates that some information about a module has
changed. The event is supported by the Emacs and Visual Studio DAP
clients. This PR adds support for emitting the event from lldb-dap.

Fixes #137058
---
 .../test/tools/lldb-dap/dap_server.py |  6 +
 .../tools/lldb-dap/module/TestDAP_module.py   | 11 +
 lldb/tools/lldb-dap/DAP.cpp   |  4 +++-
 .../Handler/InitializeRequestHandler.cpp  | 24 +++
 4 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 0f8a84461c9e7..5c43c91734b43 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -135,6 +135,7 @@ def __init__(self, recv, send, init_commands, 
log_file=None):
 self.breakpoint_events = []
 self.progress_events = []
 self.reverse_requests = []
+self.module_events = []
 self.sequence = 1
 self.threads = None
 self.recv_thread.start()
@@ -255,6 +256,11 @@ def handle_recv_packet(self, packet):
 # and 'progressEnd' events. Keep these around in case test
 # cases want to verify them.
 self.progress_events.append(packet)
+elif event == "module":
+# Module events indicate that some information about a module 
has changed.
+self.module_events.append(packet)
+# no need to add 'module' event packets to our packets list
+return keepGoing
 
 elif packet_type == "response":
 if packet["command"] == "disconnect":
diff --git a/lldb/test/API/tools/lldb-dap/module/TestDAP_module.py 
b/lldb/test/API/tools/lldb-dap/module/TestDAP_module.py
index a4e0f04d450d9..e839d46e1d114 100644
--- a/lldb/test/API/tools/lldb-dap/module/TestDAP_module.py
+++ b/lldb/test/API/tools/lldb-dap/module/TestDAP_module.py
@@ -57,6 +57,17 @@ def checkSymbolsLoadedWithSize():
 self.assertEqual(program, program_module["path"])
 self.assertIn("addressRange", program_module)
 
+# Collect all the module names we saw as events.
+module_event_names = set()
+for module_event in self.dap_server.module_events:
+module_event_names.add(module_event["body"]["module"]["name"])
+self.assertNotEqual(len(module_event_names), 0)
+
+# Make sure we got an event for every active module.
+for module in active_modules:
+# assertIn doesn't work with set.
+self.assertTrue(module in module_event_names)
+
 @skipIfWindows
 def test_modules(self):
 """
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index f8dbc4c1398e6..f866886c33014 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -692,7 +692,9 @@ void DAP::SetTarget(const lldb::SBTarget target) {
 lldb::SBListener listener = this->debugger.GetListener();
 listener.StartListeningForEvents(
 this->target.GetBroadcaster(),
-lldb::SBTarget::eBroadcastBitBreakpointChanged);
+lldb::SBTarget::eBroadcastBitBreakpointChanged |
+lldb::SBTarget::eBroadcastBitModulesLoaded |
+lldb::SBTarget::eBroadcastBitModulesUnloaded);
 listener.StartListeningForEvents(this->broadcaster,
  eBroadcastBitStopEventThread);
   }
diff --git a/lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp
index 7d8ac676ba935..f98c4d743b2d8 100644
--- a/lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp
@@ -15,6 +15,8 @@
 #include "lldb/API/SBEvent.h"
 #include "lldb/API/SBListener.h"
 #include "lldb/API/SBStream.h"
+#include "lldb/API/SBTarget.h"
+#include 
 
 using namespace lldb;
 using namespace lldb_dap::protocol;
@@ -193,6 +195,28 @@ static void EventThreadFunction(DAP &dap) {
(event_mask & lldb::SBProcess::eBroadcastBitSTDERR)) {
   SendStdOutStdErr(dap, process);
 }
+  } else if (lldb::SBTarget::EventIsTargetEvent(event)) {
+if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded ||
+event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded) {
+  const llvm::StringRef reason =
+  event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded
+  ? "new"
+  : "removed";
+  const uint32_t num_modules = SBTarget::GetNumModul

[Lldb-commits] [lldb] Add symbol locator time for each module in statistics (PR #137379)

2025-04-25 Thread via lldb-commits

GeorgeHuyubo wrote:

> I've locally applied your change on the top of tree, but I still get:
> 
> ```
> lldb/source/Target/Statistics.cpp:75:39: error: use of undeclared identifier 
> 'num_symbols_loaded'
>   module.try_emplace("symbolsLoaded", num_symbols_loaded);
>   ^
> 1 error generated.
> ```
> 
> Would you mind looking into this? Thanks!

should be fixed now

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


[Lldb-commits] [lldb] [lldb] Make ValueObject::Dereference less aggressive (PR #137311)

2025-04-25 Thread Ilia Kuklin via lldb-commits

https://github.com/kuilpd edited 
https://github.com/llvm/llvm-project/pull/137311
___
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 that lead Windows to think it could reverse execute (PR #137351)

2025-04-25 Thread Robert O'Callahan via lldb-commits

rocallahan wrote:

Thanks!!!

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


[Lldb-commits] [lldb] [llvm] [lldb] Add new per-language frame-format variables for formatting function names (PR #131836)

2025-04-25 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

https://lab.llvm.org/buildbot/#/builders/141 is also broken.

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


[Lldb-commits] [lldb] 488eeb3 - Fix connecting via abstract socket (#136466)

2025-04-25 Thread via lldb-commits

Author: Emre Kultursay
Date: 2025-04-25T14:11:19-07:00
New Revision: 488eeb3ae508221f8e476bbc9d2e9f014542862e

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

LOG: Fix connecting via abstract socket (#136466)

Commit 82ee31f and Commit 2e893124 added socket sharing, but only for
unix domain sockets. That broke Android, which uses unix-abstract
sockets.

Added: 


Modified: 
lldb/include/lldb/Host/linux/AbstractSocket.h
lldb/include/lldb/Host/posix/DomainSocket.h
lldb/source/Host/linux/AbstractSocket.cpp
lldb/source/Host/posix/DomainSocket.cpp
lldb/tools/lldb-server/lldb-platform.cpp
lldb/unittests/Host/SocketTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/linux/AbstractSocket.h 
b/lldb/include/lldb/Host/linux/AbstractSocket.h
index accfd01457a5e..c6a0e2f8af63b 100644
--- a/lldb/include/lldb/Host/linux/AbstractSocket.h
+++ b/lldb/include/lldb/Host/linux/AbstractSocket.h
@@ -15,6 +15,7 @@ namespace lldb_private {
 class AbstractSocket : public DomainSocket {
 public:
   AbstractSocket();
+  AbstractSocket(NativeSocket socket, bool should_close);
 
 protected:
   size_t GetNameOffset() const override;

diff  --git a/lldb/include/lldb/Host/posix/DomainSocket.h 
b/lldb/include/lldb/Host/posix/DomainSocket.h
index 3dbe6206da2c5..a840d474429ec 100644
--- a/lldb/include/lldb/Host/posix/DomainSocket.h
+++ b/lldb/include/lldb/Host/posix/DomainSocket.h
@@ -31,8 +31,12 @@ class DomainSocket : public Socket {
 
   std::vector GetListeningConnectionURI() const override;
 
+  static llvm::Expected>
+  FromBoundNativeSocket(NativeSocket sockfd, bool should_close);
+
 protected:
   DomainSocket(SocketProtocol protocol);
+  DomainSocket(SocketProtocol protocol, NativeSocket socket, bool 
should_close);
 
   virtual size_t GetNameOffset() const;
   virtual void DeleteSocketFile(llvm::StringRef name);

diff  --git a/lldb/source/Host/linux/AbstractSocket.cpp 
b/lldb/source/Host/linux/AbstractSocket.cpp
index 8393a80e86e72..681aa2d1ebc72 100644
--- a/lldb/source/Host/linux/AbstractSocket.cpp
+++ b/lldb/source/Host/linux/AbstractSocket.cpp
@@ -15,6 +15,9 @@ using namespace lldb_private;
 
 AbstractSocket::AbstractSocket() : DomainSocket(ProtocolUnixAbstract) {}
 
+AbstractSocket::AbstractSocket(NativeSocket socket, bool should_close)
+: DomainSocket(ProtocolUnixAbstract, socket, should_close) {}
+
 size_t AbstractSocket::GetNameOffset() const { return 1; }
 
 void AbstractSocket::DeleteSocketFile(llvm::StringRef name) {}

diff  --git a/lldb/source/Host/posix/DomainSocket.cpp 
b/lldb/source/Host/posix/DomainSocket.cpp
index 6c490cdda47ed..4f76e0c16d4c7 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -8,6 +8,9 @@
 
 #include "lldb/Host/posix/DomainSocket.h"
 #include "lldb/Utility/LLDBLog.h"
+#ifdef __linux__
+#include 
+#endif
 
 #include "llvm/Support/Errno.h"
 #include "llvm/Support/FileSystem.h"
@@ -67,6 +70,12 @@ DomainSocket::DomainSocket(NativeSocket socket,
   m_socket = socket;
 }
 
+DomainSocket::DomainSocket(SocketProtocol protocol, NativeSocket socket,
+   bool should_close)
+: Socket(protocol, should_close) {
+  m_socket = socket;
+}
+
 Status DomainSocket::Connect(llvm::StringRef name) {
   sockaddr_un saddr_un;
   socklen_t saddr_un_len;
@@ -182,3 +191,20 @@ std::vector 
DomainSocket::GetListeningConnectionURI() const {
 
   return {llvm::formatv("unix-connect://{0}", addr.sun_path)};
 }
+
+llvm::Expected>
+DomainSocket::FromBoundNativeSocket(NativeSocket sockfd, bool should_close) {
+  // Check if fd represents domain socket or abstract socket.
+  struct sockaddr_un addr;
+  socklen_t addr_len = sizeof(addr);
+  if (getsockname(sockfd, (struct sockaddr *)&addr, &addr_len) == -1)
+return llvm::createStringError("not a socket or error occurred");
+  if (addr.sun_family != AF_UNIX)
+return llvm::createStringError("Bad socket type");
+#ifdef __linux__
+  if (addr_len > offsetof(struct sockaddr_un, sun_path) &&
+  addr.sun_path[0] == '\0')
+return std::make_unique(sockfd, should_close);
+#endif
+  return std::make_unique(sockfd, should_close);
+}

diff  --git a/lldb/tools/lldb-server/lldb-platform.cpp 
b/lldb/tools/lldb-server/lldb-platform.cpp
index 23d36ffb4cb66..b9a85370d649c 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -455,15 +455,9 @@ int main_platform(int argc, char *argv[]) {
   lldb_private::Args inferior_arguments;
   inferior_arguments.SetArguments(argc, const_cast(argv));
 
-  Socket::SocketProtocol protocol = Socket::ProtocolUnixDomain;
-
+  Log *log = GetLog(LLDBLog::Platform);
   if (fd != SharedSocket::kInvalidFD) {
 // Child process will handle the connection and exit.
-if (g

[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

2025-04-25 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

2025-04-25 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> 2. Would you like me to create a cherry-pick into release/20.x branch, or is 
> there a separate process for cherry-picks (e.g., wait some time to validate, 
> submit a cherry-pick request somewhere, etc.)?

Please file and issue (here's an example: 
https://github.com/llvm/llvm-project/issues/135922) and add the LLVM 20.x 
Release milestone. You can use the `/cherry-pick` command to have the 
automation create a backporting PR. 

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

2025-04-25 Thread via lldb-commits

llvmbot wrote:


>> 2. Would you like me to create a cherry-pick into release/20.x branch, or is 
>> there a separate process for cherry-picks (e.g., wait some time to validate, 
>> submit a cherry-pick request somewhere, etc.)?
>
>Please file and issue (here's an example: 
>https://github.com/llvm/llvm-project/issues/135922) and add the LLVM 20.x 
>Release milestone. You can use the `/cherry-pick` command to have the 
>automation create a backporting PR. 

Error: Command failed due to missing milestone.

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

2025-04-25 Thread via lldb-commits

llvmbot wrote:


>> 2. Would you like me to create a cherry-pick into release/20.x branch, or is 
>> there a separate process for cherry-picks (e.g., wait some time to validate, 
>> submit a cherry-pick request somewhere, etc.)?
>
>Please file and issue (here's an example: 
>https://github.com/llvm/llvm-project/issues/135922) and add the LLVM 20.x 
>Release milestone. You can use the `/cherry-pick` command to have the 
>automation create a backporting PR. The reviewers can then express whether 
>they support back-porting it. It's fair to wait a little bit make sure this 
>makes this through the post-commit CI. 

Error: Command failed due to missing milestone.

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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

2025-04-25 Thread Emre Kultursay via lldb-commits

emrekultursay wrote:

Thanks folks:
1. Can you please squash-and-merge this PR? (I don't have write permissions)
2. Would you like me to create a cherry-pick into release/20.x branch, or is 
there a separate process for cherry-picks (e.g., wait some time to validate, 
submit a cherry-pick request somewhere, etc.)? 

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


[Lldb-commits] [lldb] b571aa4 - [lldb][NFC] Add missing newline between function definitions

2025-04-25 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2025-04-25T22:52:05+01:00
New Revision: b571aa49b1e07908b22bba3494461799e2f5c493

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

LOG: [lldb][NFC] Add missing newline between function definitions

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 943bc93348942..283e867d53bb7 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1886,6 +1886,7 @@ bool CPlusPlusLanguage::GetFunctionDisplayName(
 return false;
   }
 }
+
 bool CPlusPlusLanguage::HandleFrameFormatVariable(
 const SymbolContext &sc, const ExecutionContext *exe_ctx,
 FormatEntity::Entry::Type type, Stream &s) {



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


[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

2025-04-25 Thread Emre Kultursay via lldb-commits

emrekultursay wrote:

We're getting `SetSockAddr` error which can only fail if the path is too long. 
The path generated by `createUniqueDirectory` is an absolute path to a 
temporary directory. I guess it can be longer than 107 bytes on the CI machines.

All the other DomainSocket related tests skip the test if the generated path is 
longer than 107 bytes:

```
  // Skip the test if the $TMPDIR is too long to hold a domain socket.
  if (Path.size() > 107u)
return;
```

I'll add that to see if it fixes the issue.



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


  1   2   3   >