[Lldb-commits] [clang] [lldb] [llvm] [mlir] [NFC][Support] Add llvm::uninitialized_copy (PR #138174)

2025-05-01 Thread Rahul Joshi via lldb-commits

https://github.com/jurahul updated 
https://github.com/llvm/llvm-project/pull/138174

>From de1b49fc6b8819b591e48b81634567ceeffe5089 Mon Sep 17 00:00:00 2001
From: Rahul Joshi 
Date: Wed, 30 Apr 2025 23:47:37 -0700
Subject: [PATCH] [NFC][Support] Add llvm::uninitialized_copy

Add `llvm::uninitialized_copy` that accepts a range instead of two
iterators for the source of the copy and adopt it.
---
 clang/include/clang/AST/DeclCXX.h |  6 +-
 clang/include/clang/AST/DeclOpenACC.h |  9 +--
 clang/include/clang/AST/ExprCXX.h |  6 +-
 clang/include/clang/AST/OpenACCClause.h   | 72 +++
 clang/include/clang/AST/StmtOpenACC.h | 54 +++---
 clang/include/clang/Sema/ParsedTemplate.h |  4 +-
 clang/lib/AST/Decl.cpp|  6 +-
 clang/lib/AST/DeclObjC.cpp|  4 +-
 clang/lib/AST/DeclTemplate.cpp| 11 ++-
 clang/lib/AST/Expr.cpp|  8 +--
 clang/lib/AST/ExprCXX.cpp | 16 ++---
 clang/lib/AST/OpenACCClause.cpp   | 13 ++--
 clang/lib/AST/StmtOpenACC.cpp |  4 +-
 clang/lib/AST/Type.cpp|  8 +--
 clang/tools/libclang/CXIndexDataConsumer.cpp  |  3 +-
 lldb/source/Utility/Checksum.cpp  |  4 +-
 llvm/include/llvm/ADT/ArrayRef.h  |  2 +-
 llvm/include/llvm/ADT/STLExtras.h |  5 ++
 llvm/lib/Analysis/ScalarEvolution.cpp | 10 +--
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp |  3 +-
 llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp   |  4 +-
 llvm/lib/DebugInfo/MSF/MSFBuilder.cpp |  6 +-
 llvm/lib/IR/AttributeImpl.h   |  2 +-
 llvm/lib/ObjectYAML/MinidumpEmitter.cpp   |  2 +-
 llvm/lib/Support/FoldingSet.cpp   |  4 +-
 .../AMDGPU/MCTargetDesc/AMDGPUMCExpr.cpp  |  2 +-
 llvm/lib/Transforms/IPO/LowerTypeTests.cpp|  7 +-
 .../unittests/Support/TrailingObjectsTest.cpp | 11 ++-
 mlir/include/mlir/IR/BuiltinAttributes.td |  2 +-
 mlir/include/mlir/Support/StorageUniquer.h|  4 +-
 .../Dialect/Affine/Analysis/NestedMatcher.cpp |  4 +-
 mlir/lib/IR/AffineMapDetail.h |  3 +-
 mlir/lib/IR/Location.cpp  |  8 +--
 mlir/lib/IR/MLIRContext.cpp   |  2 +-
 mlir/lib/IR/TypeDetail.h  |  3 +-
 mlir/lib/Tools/PDLL/AST/Nodes.cpp | 42 ---
 36 files changed, 153 insertions(+), 201 deletions(-)

diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index dd325815ee28d..20720115bf6c3 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -3861,8 +3861,7 @@ class UsingPackDecl final
   InstantiatedFrom ? InstantiatedFrom->getDeclName()
: DeclarationName()),
 InstantiatedFrom(InstantiatedFrom), NumExpansions(UsingDecls.size()) {
-std::uninitialized_copy(UsingDecls.begin(), UsingDecls.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(UsingDecls, getTrailingObjects());
   }
 
   void anchor() override;
@@ -4233,8 +4232,7 @@ class DecompositionDecl final
   : VarDecl(Decomposition, C, DC, StartLoc, LSquareLoc, nullptr, T, TInfo,
 SC),
 NumBindings(Bindings.size()) {
-std::uninitialized_copy(Bindings.begin(), Bindings.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(Bindings, getTrailingObjects());
 for (auto *B : Bindings) {
   B->setDecomposedDecl(this);
   if (B->isParameterPack() && B->getBinding()) {
diff --git a/clang/include/clang/AST/DeclOpenACC.h 
b/clang/include/clang/AST/DeclOpenACC.h
index 8c612fbf1ec07..905d9bf636ea1 100644
--- a/clang/include/clang/AST/DeclOpenACC.h
+++ b/clang/include/clang/AST/DeclOpenACC.h
@@ -18,6 +18,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/OpenACCClause.h"
 #include "clang/Basic/OpenACCKinds.h"
+#include "llvm/ADT/STLExtras.h"
 
 namespace clang {
 
@@ -85,8 +86,8 @@ class OpenACCDeclareDecl final
   : OpenACCConstructDecl(OpenACCDeclare, DC, OpenACCDirectiveKind::Declare,
  StartLoc, DirLoc, EndLoc) {
 // Initialize the trailing storage.
-std::uninitialized_copy(Clauses.begin(), Clauses.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(Clauses,
+ getTrailingObjects());
 
 setClauseList(MutableArrayRef(getTrailingObjects(),
   Clauses.size()));
@@ -136,8 +137,8 @@ class OpenACCRoutineDecl final
 assert(LParenLoc.isValid() &&
"Cannot represent implicit name with this declaration");
 // Initialize the trailing storage.
-std::uninitialized_copy(Clauses.begin(), Clauses.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(Clauses,
+ getTrailingObj

[Lldb-commits] [clang] [lldb] [llvm] [mlir] [NFC][Support] Add llvm::uninitialized_copy (PR #138174)

2025-05-01 Thread Rahul Joshi via lldb-commits

https://github.com/jurahul updated 
https://github.com/llvm/llvm-project/pull/138174

>From fbe3ca0c2e4d195149f5e3e6b8d32797cf47b9df Mon Sep 17 00:00:00 2001
From: Rahul Joshi 
Date: Wed, 30 Apr 2025 23:47:37 -0700
Subject: [PATCH] [NFC][Support] Add llvm::uninitialized_copy

Add `llvm::uninitialized_copy` that accepts a range instead of two
iterators for the source of the copy and adopt it.
---
 clang/include/clang/AST/DeclCXX.h |  6 +-
 clang/include/clang/AST/DeclOpenACC.h |  9 +--
 clang/include/clang/AST/ExprCXX.h |  6 +-
 clang/include/clang/AST/OpenACCClause.h   | 72 +++
 clang/include/clang/AST/StmtOpenACC.h | 54 +++---
 clang/include/clang/Sema/ParsedTemplate.h |  4 +-
 clang/lib/AST/Decl.cpp|  6 +-
 clang/lib/AST/DeclObjC.cpp|  4 +-
 clang/lib/AST/DeclTemplate.cpp| 11 ++-
 clang/lib/AST/Expr.cpp|  8 +--
 clang/lib/AST/ExprCXX.cpp | 16 ++---
 clang/lib/AST/OpenACCClause.cpp   | 13 ++--
 clang/lib/AST/StmtOpenACC.cpp |  4 +-
 clang/lib/AST/Type.cpp|  8 +--
 clang/tools/libclang/CXIndexDataConsumer.cpp  |  3 +-
 lldb/source/Utility/Checksum.cpp  |  4 +-
 llvm/include/llvm/ADT/ArrayRef.h  |  2 +-
 llvm/include/llvm/ADT/STLExtras.h |  5 ++
 llvm/lib/Analysis/ScalarEvolution.cpp | 10 +--
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp |  3 +-
 llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp   |  4 +-
 llvm/lib/DebugInfo/MSF/MSFBuilder.cpp |  6 +-
 llvm/lib/IR/AttributeImpl.h   |  2 +-
 llvm/lib/ObjectYAML/MinidumpEmitter.cpp   |  2 +-
 llvm/lib/Support/FoldingSet.cpp   |  4 +-
 .../AMDGPU/MCTargetDesc/AMDGPUMCExpr.cpp  |  2 +-
 llvm/lib/Transforms/IPO/LowerTypeTests.cpp|  7 +-
 .../unittests/Support/TrailingObjectsTest.cpp | 11 ++-
 mlir/include/mlir/IR/BuiltinAttributes.td |  2 +-
 mlir/include/mlir/Support/StorageUniquer.h|  4 +-
 .../Dialect/Affine/Analysis/NestedMatcher.cpp |  4 +-
 mlir/lib/IR/AffineMapDetail.h |  3 +-
 mlir/lib/IR/Location.cpp  |  8 +--
 mlir/lib/IR/MLIRContext.cpp   |  2 +-
 mlir/lib/IR/TypeDetail.h  |  3 +-
 mlir/lib/Tools/PDLL/AST/Nodes.cpp | 42 ---
 36 files changed, 153 insertions(+), 201 deletions(-)

diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index dd325815ee28d..20720115bf6c3 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -3861,8 +3861,7 @@ class UsingPackDecl final
   InstantiatedFrom ? InstantiatedFrom->getDeclName()
: DeclarationName()),
 InstantiatedFrom(InstantiatedFrom), NumExpansions(UsingDecls.size()) {
-std::uninitialized_copy(UsingDecls.begin(), UsingDecls.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(UsingDecls, getTrailingObjects());
   }
 
   void anchor() override;
@@ -4233,8 +4232,7 @@ class DecompositionDecl final
   : VarDecl(Decomposition, C, DC, StartLoc, LSquareLoc, nullptr, T, TInfo,
 SC),
 NumBindings(Bindings.size()) {
-std::uninitialized_copy(Bindings.begin(), Bindings.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(Bindings, getTrailingObjects());
 for (auto *B : Bindings) {
   B->setDecomposedDecl(this);
   if (B->isParameterPack() && B->getBinding()) {
diff --git a/clang/include/clang/AST/DeclOpenACC.h 
b/clang/include/clang/AST/DeclOpenACC.h
index 8c612fbf1ec07..905d9bf636ea1 100644
--- a/clang/include/clang/AST/DeclOpenACC.h
+++ b/clang/include/clang/AST/DeclOpenACC.h
@@ -18,6 +18,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/OpenACCClause.h"
 #include "clang/Basic/OpenACCKinds.h"
+#include "llvm/ADT/STLExtras.h"
 
 namespace clang {
 
@@ -85,8 +86,8 @@ class OpenACCDeclareDecl final
   : OpenACCConstructDecl(OpenACCDeclare, DC, OpenACCDirectiveKind::Declare,
  StartLoc, DirLoc, EndLoc) {
 // Initialize the trailing storage.
-std::uninitialized_copy(Clauses.begin(), Clauses.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(Clauses,
+ getTrailingObjects());
 
 setClauseList(MutableArrayRef(getTrailingObjects(),
   Clauses.size()));
@@ -136,8 +137,8 @@ class OpenACCRoutineDecl final
 assert(LParenLoc.isValid() &&
"Cannot represent implicit name with this declaration");
 // Initialize the trailing storage.
-std::uninitialized_copy(Clauses.begin(), Clauses.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(Clauses,
+ getTrailingObj

[Lldb-commits] [lldb] [lldb-dap] Change the launch sequence (PR #138219)

2025-05-01 Thread John Harrison via lldb-commits


@@ -161,20 +161,22 @@ static void EventThreadFunction(DAP &dap) {
   case lldb::eStateSuspended:
 break;
   case lldb::eStateStopped:
-// We launch and attach in synchronous mode then the first stop
-// event will not be delivered. If we use "launchCommands" during a
-// launch or "attachCommands" during an attach we might some 
process
-// stop events which we do not want to send an event for. We will
-// manually send a stopped event in request_configurationDone(...)
-// so don't send any before then.
-if (dap.configuration_done_sent) {
-  // Only report a stopped event if the process was not
-  // automatically restarted.
-  if (!lldb::SBProcess::GetRestartedFromEvent(event)) {
-SendStdOutStdErr(dap, process);
+{
+  std::unique_lock lock(dap.ignore_stop_mutex);
+  if (dap.ignore_next_stop) {
+DAP_LOG(dap.log, "Ignoring process stop event");
 SendThreadStoppedEvent(dap);

ashgti wrote:

The line above this sounds like we should skip this?

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


[Lldb-commits] [lldb] [lldb] print a notice when `source list` paging reaches the end of th… (PR #137515)

2025-05-01 Thread via lldb-commits

https://github.com/hapee updated 
https://github.com/llvm/llvm-project/pull/137515

>From 0d448180a569fa3730f3608a1584de24cf832c88 Mon Sep 17 00:00:00 2001
From: hapee <623151...@qq.com>
Date: Sun, 27 Apr 2025 18:27:04 +0800
Subject: [PATCH] [lldb] print a notice when `source list` paging reaches the
 end of the file

---
 lldb/include/lldb/Core/SourceManager.h|  3 ++
 lldb/source/Commands/CommandObjectSource.cpp  |  9 ++
 lldb/source/Core/SourceManager.cpp|  5 +---
 .../command-list-reach-beginning-of-file.test | 29 +++
 .../command-list-reach-end-of-file.test   | 26 +
 5 files changed, 68 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
 create mode 100644 lldb/test/Shell/Commands/command-list-reach-end-of-file.test

diff --git a/lldb/include/lldb/Core/SourceManager.h 
b/lldb/include/lldb/Core/SourceManager.h
index d929f7bd9bf22..1244291596b73 100644
--- a/lldb/include/lldb/Core/SourceManager.h
+++ b/lldb/include/lldb/Core/SourceManager.h
@@ -155,6 +155,9 @@ class SourceManager {
   ~SourceManager();
 
   FileSP GetLastFile() { return GetFile(m_last_support_file_sp); }
+  bool AtLastLine(bool reverse) {
+return m_last_line == UINT32_MAX || (reverse && m_last_line == 1);
+  }
 
   size_t DisplaySourceLinesWithLineNumbers(
   lldb::SupportFileSP support_file_sp, uint32_t line, uint32_t column,
diff --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index c205813565d52..8c87af590a372 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -1067,7 +1067,16 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 &result.GetOutputStream(), m_options.num_lines,
 m_options.reverse, GetBreakpointLocations())) {
   result.SetStatus(eReturnStatusSuccessFinishResult);
+} else {
+  if (target.GetSourceManager().AtLastLine(m_options.reverse)) {
+result.AppendNoteWithFormatv(
+"Reached {0} of the file, no more to page",
+m_options.reverse ? "beginning" : "end");
+  } else {
+result.AppendNote("No source available");
+  }
 }
+
   } else {
 if (m_options.num_lines == 0)
   m_options.num_lines = 10;
diff --git a/lldb/source/Core/SourceManager.cpp 
b/lldb/source/Core/SourceManager.cpp
index d63d42de14e80..f786866a18137 100644
--- a/lldb/source/Core/SourceManager.cpp
+++ b/lldb/source/Core/SourceManager.cpp
@@ -360,10 +360,7 @@ size_t SourceManager::DisplayMoreWithLineNumbers(
 GetDefaultFileAndLine();
 
   if (last_file_sp) {
-if (m_last_line == UINT32_MAX)
-  return 0;
-
-if (reverse && m_last_line == 1)
+if (AtLastLine(reverse))
   return 0;
 
 if (count > 0)
diff --git a/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test 
b/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
new file mode 100644
index 0..5ca1b5c2306a7
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
@@ -0,0 +1,29 @@
+# RUN: %clang_host -g -O0 %S/Inputs/sigchld.c -o %t.out
+# RUN: %lldb %t.out -b -s %s 2>&1 | FileCheck %s
+
+list
+# CHECK: note: No source available 
+
+b main
+# CHECK: Breakpoint 1:
+
+r
+# CHECK: int main()
+
+list
+# CHECK: if (child_pid == 0)
+
+list -
+# CHECK: int main()
+
+list -10
+# CHECK: #include 
+
+list -
+# CHECK: note: Reached beginning of the file, no more to page
+
+list -
+# CHECK: note: Reached beginning of the file, no more to page
+
+list
+# CHECK: int main()
diff --git a/lldb/test/Shell/Commands/command-list-reach-end-of-file.test 
b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
new file mode 100644
index 0..c5e9c8169e7d9
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
@@ -0,0 +1,26 @@
+# RUN: %clang_host -g -O0 %S/Inputs/sigchld.c -o %t.out
+# RUN: %lldb %t.out -b -s %s 2>&1 | FileCheck %s
+
+list
+# CHECK: note: No source available 
+
+b main
+# CHECK: Breakpoint 1:
+
+r
+# CHECK: int main()
+
+list
+# CHECK: if (child_pid == 0)
+
+list
+# CHECK: printf("signo = %d\n", SIGCHLD);
+
+list
+# CHECK: return 0;
+
+list 
+# CHECK: note: Reached end of the file, no more to page
+
+list 
+# CHECK: note: Reached end of the file, no more to page
\ No newline at end of file

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


[Lldb-commits] [lldb] [lldb] print a notice when `source list` paging reaches the end of th… (PR #137515)

2025-05-01 Thread via lldb-commits


@@ -155,6 +155,9 @@ class SourceManager {
   ~SourceManager();
 
   FileSP GetLastFile() { return GetFile(m_last_support_file_sp); }
+  bool AsLastLine(bool reverse) {

hapee wrote:

> Is this a typo?

Yes, it is a mistake. I have fixed it.  Could you please review my commit 
again? @JDevlieghere 

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-01 Thread David Peixotto via lldb-commits


@@ -0,0 +1,142 @@
+"""
+Test saving a mini dump, from yamilized examples.
+"""
+
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ProcessSaveCoreMinidumpTestCaseYaml(TestBase):
+def process_from_yaml(self, yaml_file):
+minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + 
".dmp")
+self.yaml2obj(yaml_file, minidump_path)
+self.target = self.dbg.CreateTarget(None)
+self.process = self.target.LoadCore(minidump_path)
+return self.process
+
+def test_saving_sub_memory_range(self):
+"""
+Validate we can save a Minidump for a subsection of a memory range.
+I.E.
+If our memory range is 0x1000-0x2000 nd the user specifies 
0x1200-0x1800

dmpots wrote:

These examples are nice and easy to understand, but the YAML regions are 
defined with "hard" addresses like `0x7FFF12A84030`. Any reason we can't make 
the ranges in the YAML def easier to reason about?

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-01 Thread David Peixotto via lldb-commits


@@ -6689,6 +6689,25 @@ static void GetCoreFileSaveRangesStackOnly(Process 
&process,
   }
 }
 
+// TODO: We should refactor CoreFileMemoryRanges to use the lldb range type, 
and
+// then add an intersect method on it, or MemoryRegionInfo.
+static MemoryRegionInfo
+Intersect(const MemoryRegionInfo &lhs,
+  const Range &rhs) {

dmpots wrote:

Could we use `MemoryRegionInfo::RangeType` for the type here?

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-01 Thread David Peixotto via lldb-commits


@@ -6698,9 +6717,16 @@ static void GetUserSpecifiedCoreFileSaveRanges(Process 
&process,
 return;
 
   for (const auto &range : regions) {
-auto entry = option_ranges.FindEntryThatContains(range.GetRange());
-if (entry)
-  AddRegion(range, true, ranges);
+auto *entry = option_ranges.FindEntryThatIntersects(range.GetRange());
+if (entry) {
+  if (entry->GetRangeBase() != range.GetRange().GetRangeBase() ||

dmpots wrote:

Can we use

```
entry->GetRange() != range.GetRange()
```

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-01 Thread David Peixotto via lldb-commits


@@ -380,6 +380,25 @@ template  class 
RangeVector {
 return nullptr;
   }
 
+  const Entry *FindEntryThatIntersects(const Entry &range) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+assert(IsSorted());
+#endif
+if (!m_entries.empty()) {
+  typename Collection::const_iterator begin = m_entries.begin();
+  typename Collection::const_iterator end = m_entries.end();
+  typename Collection::const_iterator pos =
+  std::lower_bound(begin, end, range, BaseLessThan);
+
+  while (pos != begin && pos[-1].DoesIntersect(range))

dmpots wrote:

The indexing by -1 looks suspicious to me, but maybe its well defined. I would 
feel better about something like `std::prev(pos)->DoesIntersect(range)`.

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-01 Thread David Peixotto via lldb-commits


@@ -6689,6 +6689,25 @@ static void GetCoreFileSaveRangesStackOnly(Process 
&process,
   }
 }
 
+// TODO: We should refactor CoreFileMemoryRanges to use the lldb range type, 
and
+// then add an intersect method on it, or MemoryRegionInfo.
+static MemoryRegionInfo
+Intersect(const MemoryRegionInfo &lhs,
+  const Range &rhs) {
+  const lldb::addr_t lhs_base = lhs.GetRange().GetRangeBase();
+  const lldb::addr_t rhs_base = rhs.GetRangeBase();
+  const lldb::addr_t lhs_end = lhs.GetRange().GetRangeEnd();
+  const lldb::addr_t rhs_end = rhs.GetRangeEnd();
+
+  MemoryRegionInfo region_info;
+  region_info.SetLLDBPermissions(lhs.GetLLDBPermissions());

dmpots wrote:

Could we write this as

```
MemoryRegionInfo region_info = lhs;
region_info.GetRange() = lhs.GetRange().Intersect(rhs);
```

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-01 Thread David Peixotto via lldb-commits


@@ -0,0 +1,142 @@
+"""
+Test saving a mini dump, from yamilized examples.
+"""
+
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+

dmpots wrote:

Maybe we should test some degenerate cases like empty ranges and ranges that 
span exactly the full memory region?

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


[Lldb-commits] [lldb] [lldb][Formatters] Add --pointer-match-depth option to `type summary add` command. (PR #138209)

2025-05-01 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r HEAD~1...HEAD 
lldb/test/API/functionalities/data-formatter/data-formatter-ptr-matching/TestDataFormatterPtrMatching.py
``





View the diff from darker here.


``diff
--- TestDataFormatterPtrMatching.py 2025-05-01 22:09:31.00 +
+++ TestDataFormatterPtrMatching.py 2025-05-01 22:32:51.887090 +
@@ -36,66 +36,77 @@
 # Execute the cleanup function during test case tear down.
 self.addTearDownHook(cleanup)
 
 # By default, --pointer-match-depth is 1.
 self.runCmd('type summary add --cascade true -s "MyInt" "Int"')
-self.expect("frame variable", patterns=[
-r".* i = MyInt\n",
-r".* i_p = 0x.* MyInt\n",
-r".* i_pp = 0x[0-9a-f]+\n",
-r".* i_ppp = 0x[0-9a-f]+\n",
-r".* f = MyInt\n",
-r".* f_p = 0x[0-9a-f]+ MyInt\n",
-r".* f_pp = 0x[0-9a-f]+\n",
-r".* f_ppp = 0x[0-9a-f]+\n",
-r".* fp = 0x[0-9a-f]+ MyInt\n",
-r".* fp_p = 0x[0-9a-f]+\n",
-r".* fp_pp = 0x[0-9a-f]+\n",
-r".* b = MyInt\n",
-r".* b_p = 0x[0-9a-f]+ MyInt\n",
-r".* b_pp = 0x[0-9a-f]+\n",
-r".* bp = 0x[0-9a-f]+ MyInt\n",
-r".* bp_p = 0x[0-9a-f]+\n",
-r".* bp_pp = 0x[0-9a-f]+\n",
-])
+self.expect(
+"frame variable",
+patterns=[
+r".* i = MyInt\n",
+r".* i_p = 0x.* MyInt\n",
+r".* i_pp = 0x[0-9a-f]+\n",
+r".* i_ppp = 0x[0-9a-f]+\n",
+r".* f = MyInt\n",
+r".* f_p = 0x[0-9a-f]+ MyInt\n",
+r".* f_pp = 0x[0-9a-f]+\n",
+r".* f_ppp = 0x[0-9a-f]+\n",
+r".* fp = 0x[0-9a-f]+ MyInt\n",
+r".* fp_p = 0x[0-9a-f]+\n",
+r".* fp_pp = 0x[0-9a-f]+\n",
+r".* b = MyInt\n",
+r".* b_p = 0x[0-9a-f]+ MyInt\n",
+r".* b_pp = 0x[0-9a-f]+\n",
+r".* bp = 0x[0-9a-f]+ MyInt\n",
+r".* bp_p = 0x[0-9a-f]+\n",
+r".* bp_pp = 0x[0-9a-f]+\n",
+],
+)
 
 self.runCmd('type summary delete "Int"')
 self.runCmd(
-'type summary add --cascade true --pointer-match-depth 2 -s 
"MyInt" "Int"')
-self.expect("frame variable", patterns=[
-r".* i = MyInt\n",
-r".* i_p = 0x.* MyInt\n",
-r".* i_pp = 0x[0-9a-f]+ MyInt\n",
-r".* i_ppp = 0x[0-9a-f]+\n",
-r".* f = MyInt\n",
-r".* f_p = 0x[0-9a-f]+ MyInt\n",
-r".* f_pp = 0x[0-9a-f]+ MyInt\n",
-r".* f_ppp = 0x[0-9a-f]+\n",
-r".* fp = 0x[0-9a-f]+ MyInt\n",
-r".* fp_p = 0x[0-9a-f]+ MyInt\n",
-r".* fp_pp = 0x[0-9a-f]+\n",
-r".* b = MyInt\n",
-r".* b_p = 0x[0-9a-f]+ MyInt\n",
-r".* b_pp = 0x[0-9a-f]+ MyInt\n",
-r".* bp = 0x[0-9a-f]+ MyInt\n",
-r".* bp_p = 0x[0-9a-f]+ MyInt\n",
-r".* bp_pp = 0x[0-9a-f]+\n",
-])
+'type summary add --cascade true --pointer-match-depth 2 -s 
"MyInt" "Int"'
+)
+self.expect(
+"frame variable",
+patterns=[
+r".* i = MyInt\n",
+r".* i_p = 0x.* MyInt\n",
+r".* i_pp = 0x[0-9a-f]+ MyInt\n",
+r".* i_ppp = 0x[0-9a-f]+\n",
+r".* f = MyInt\n",
+r".* f_p = 0x[0-9a-f]+ MyInt\n",
+r".* f_pp = 0x[0-9a-f]+ MyInt\n",
+r".* f_ppp = 0x[0-9a-f]+\n",
+r".* fp = 0x[0-9a-f]+ MyInt\n",
+r".* fp_p = 0x[0-9a-f]+ MyInt\n",
+r".* fp_pp = 0x[0-9a-f]+\n",
+r".* b = MyInt\n",
+r".* b_p = 0x[0-9a-f]+ MyInt\n",
+r".* b_pp = 0x[0-9a-f]+ MyInt\n",
+r".* bp = 0x[0-9a-f]+ MyInt\n",
+r".* bp_p = 0x[0-9a-f]+ MyInt\n",
+r".* bp_pp = 0x[0-9a-f]+\n",
+],
+)
 
 self.runCmd('type summary delete "Int"')
 self.runCmd(
-'type summary add --cascade true --pointer-match-depth 2 -s 
"MyFoo" "Foo"')
-self.expect("frame variable", patterns=[
-r".* f = MyFoo\n",
-r".* f_p = 0x[0-9a-f]+ MyFoo\n",
-r".* f_pp = 0x[0-9a-f]+ MyFoo\n",
-r".* f_ppp = 0x[0-9a-f]+\n",
-r".* fp = 0x[0-9a-f]+\n",
-r".* fp_p = 0x[0-9a-f]+\n",
-r".* fp_pp = 0x[0-9a-f]+\n",
-r".* b = MyFoo\n",
-r".* b_p = 0x[0-9a-f]+ MyFoo\n",
-r".* b_pp = 0x[0-9a-f]+ MyFoo\n",
-r".* bp = 0x[0

[Lldb-commits] [lldb] [lldb][Formatters] Add --pointer-match-depth option to `type summary add` command. (PR #138209)

2025-05-01 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,h -- 
lldb/test/API/functionalities/data-formatter/data-formatter-ptr-matching/main.cpp
 lldb/include/lldb/API/SBTypeSummary.h 
lldb/include/lldb/DataFormatters/FormatClasses.h 
lldb/include/lldb/DataFormatters/FormatManager.h 
lldb/include/lldb/DataFormatters/FormattersContainer.h 
lldb/include/lldb/DataFormatters/TypeFormat.h 
lldb/include/lldb/DataFormatters/TypeSummary.h 
lldb/include/lldb/DataFormatters/TypeSynthetic.h 
lldb/source/API/SBTypeSummary.cpp lldb/source/Commands/CommandObjectType.cpp 
lldb/source/DataFormatters/FormatManager.cpp 
lldb/source/DataFormatters/TypeCategoryMap.cpp 
lldb/source/DataFormatters/TypeSummary.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/API/SBTypeSummary.cpp 
b/lldb/source/API/SBTypeSummary.cpp
index d7acb0670..58ec068ab 100644
--- a/lldb/source/API/SBTypeSummary.cpp
+++ b/lldb/source/API/SBTypeSummary.cpp
@@ -232,7 +232,7 @@ const char *SBTypeSummary::GetData() {
 
 uint32_t SBTypeSummary::GetPtrMatchDepth() {
   LLDB_INSTRUMENT_VA(this);
-  
+
   if (!IsValid())
 return 0;
   return m_opaque_sp->GetPtrMatchDepth();
diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp 
b/lldb/source/DataFormatters/TypeCategoryMap.cpp
index 8682e4b74..c318e1d2d 100644
--- a/lldb/source/DataFormatters/TypeCategoryMap.cpp
+++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp
@@ -184,10 +184,8 @@ void TypeCategoryMap::Get(FormattersMatchData &match_data, 
ImplSP &retval) {
   if (log) {
 for (auto match : match_data.GetMatchesVector()) {
   LLDB_LOGF(
-  log,
-  "[%s] candidate match = %s %s %s %s ptr-stripped-depth=%u",
-  __FUNCTION__,
-  match.GetTypeName().GetCString(),
+  log, "[%s] candidate match = %s %s %s %s ptr-stripped-depth=%u",
+  __FUNCTION__, match.GetTypeName().GetCString(),
   match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
   match.DidStripReference() ? "strip-reference" : "no-strip-reference",
   match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-ptr-matching/main.cpp
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-ptr-matching/main.cpp
index 5fafae53d..2d8c7193b 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-ptr-matching/main.cpp
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-ptr-matching/main.cpp
@@ -2,31 +2,31 @@ struct Int {
   int i;
 };
 typedef Int Foo;
-typedef Int* FooP;
+typedef Int *FooP;
 typedef Foo Bar;
-typedef Foo* BarP;
+typedef Foo *BarP;
 
 int main() {
   Int i = {42};
-  Int* i_p = &i;
-  Int** i_pp = &i_p;
-  Int*** i_ppp = &i_pp;
+  Int *i_p = &i;
+  Int **i_pp = &i_p;
+  Int ***i_ppp = &i_pp;
 
   Foo f = i;
-  Foo* f_p = &f;
-  Foo** f_pp = &f_p;
-  Foo*** f_ppp = &f_pp;
+  Foo *f_p = &f;
+  Foo **f_pp = &f_p;
+  Foo ***f_ppp = &f_pp;
 
   FooP fp = f_p;
-  FooP* fp_p = &fp;
-  FooP** fp_pp = &fp_p;
+  FooP *fp_p = &fp;
+  FooP **fp_pp = &fp_p;
 
   Bar b = i;
-  Bar* b_p = &b;
-  Bar** b_pp = &b_p;
+  Bar *b_p = &b;
+  Bar **b_pp = &b_p;
 
   BarP bp = b_p;
-  BarP* bp_p = &bp;
-  BarP** bp_pp = &bp_p;
+  BarP *bp_p = &bp;
+  BarP **bp_pp = &bp_p;
   return 0; // Set break point at this line.
 }

``




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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-05-01 Thread Jason Molenda via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-01 Thread Jacob Lalonde via lldb-commits


@@ -380,6 +380,25 @@ template  class 
RangeVector {
 return nullptr;
   }
 
+  const Entry *FindEntryThatIntersects(const Entry &range) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+assert(IsSorted());
+#endif
+if (!m_entries.empty()) {
+  typename Collection::const_iterator begin = m_entries.begin();
+  typename Collection::const_iterator end = m_entries.end();
+  typename Collection::const_iterator pos =
+  std::lower_bound(begin, end, range, BaseLessThan);
+
+  while (pos != begin && pos[-1].DoesIntersect(range))

Jlalond wrote:

I'm open to `std::prev`, but I mostly copied the examples from the other 
functions which did `pos[-1]`. 

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


[Lldb-commits] [lldb] Fix TestEvents.py after: 4fdb8cb (PR #138211)

2025-05-01 Thread via lldb-commits

https://github.com/jimingham created 
https://github.com/llvm/llvm-project/pull/138211

I changed the option name from at-first-stop (-F) to at-initial-stop (-I) but 
missed one place in the testsuite.

>From 6780540d600677083c692cebd99d921684948465 Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Thu, 1 May 2025 15:43:59 -0700
Subject: [PATCH] Fix TestEvents.py after: 4fdb8cb

I changed the option name from at-first-stop (-F) to at-initial-stop (-I) but
missed one place in the testsuite.
---
 lldb/test/API/python_api/event/TestEvents.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/test/API/python_api/event/TestEvents.py 
b/lldb/test/API/python_api/event/TestEvents.py
index 9b73a0e2e1e04..4a1b0d82c5c32 100644
--- a/lldb/test/API/python_api/event/TestEvents.py
+++ b/lldb/test/API/python_api/event/TestEvents.py
@@ -413,7 +413,7 @@ def test_shadow_listener(self):
 
 # Add our stop hook here, don't report on the initial attach:
 self.runCmd(
-f"target stop-hook add -P stop_hook.StopHook -k instance -v 
{self.instance} -F false"
+f"target stop-hook add -P stop_hook.StopHook -k instance -v 
{self.instance} -I false"
 )
 self.stop_counter = 0
 

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


[Lldb-commits] [lldb] Fix TestEvents.py after: 4fdb8cb (PR #138211)

2025-05-01 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (jimingham)


Changes

I changed the option name from at-first-stop (-F) to at-initial-stop (-I) but 
missed one place in the testsuite.

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


1 Files Affected:

- (modified) lldb/test/API/python_api/event/TestEvents.py (+1-1) 


``diff
diff --git a/lldb/test/API/python_api/event/TestEvents.py 
b/lldb/test/API/python_api/event/TestEvents.py
index 9b73a0e2e1e04..4a1b0d82c5c32 100644
--- a/lldb/test/API/python_api/event/TestEvents.py
+++ b/lldb/test/API/python_api/event/TestEvents.py
@@ -413,7 +413,7 @@ def test_shadow_listener(self):
 
 # Add our stop hook here, don't report on the initial attach:
 self.runCmd(
-f"target stop-hook add -P stop_hook.StopHook -k instance -v 
{self.instance} -F false"
+f"target stop-hook add -P stop_hook.StopHook -k instance -v 
{self.instance} -I false"
 )
 self.stop_counter = 0
 

``




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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-01 Thread Jacob Lalonde via lldb-commits


@@ -0,0 +1,142 @@
+"""
+Test saving a mini dump, from yamilized examples.
+"""
+
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+

Jlalond wrote:

There is actually `TestProcessSaveCoreMinidump` which covers these cases! I 
covered the new intersections cases but we have a test for invalid regions, 
empty regions and full ones.

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-01 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/138206

>From 91ce0997c03f87ec617ec2a113e7e88f1a88de11 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 1 May 2025 14:53:08 -0700
Subject: [PATCH 1/4] Change custom regions to be intersections, add test cases
 for sub regions and super regions, plus changes of permissions and invalid
 pages.

---
 lldb/include/lldb/Utility/RangeMap.h  |  19 +++
 lldb/source/Target/Process.cpp|  30 +++-
 .../TestProcessSaveCoreMinidumpYaml.py| 142 ++
 .../minidump_mem64.yaml   |  35 +
 4 files changed, 223 insertions(+), 3 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidumpYaml.py
 create mode 100644 
lldb/test/API/functionalities/process_save_core_minidump/minidump_mem64.yaml

diff --git a/lldb/include/lldb/Utility/RangeMap.h 
b/lldb/include/lldb/Utility/RangeMap.h
index 8af690e813c4a..f19c28268d55c 100644
--- a/lldb/include/lldb/Utility/RangeMap.h
+++ b/lldb/include/lldb/Utility/RangeMap.h
@@ -380,6 +380,25 @@ template  class 
RangeVector {
 return nullptr;
   }
 
+const Entry* FindEntryThatIntersects(const Entry &range) const {
+  #ifdef ASSERT_RANGEMAP_ARE_SORTED
+  assert(IsSorted());
+  #endif
+  if (!m_entries.empty()) {
+typename Collection::const_iterator begin = m_entries.begin();
+typename Collection::const_iterator end = m_entries.end();
+typename Collection::const_iterator pos =
+std::lower_bound(begin, end, range, BaseLessThan);
+  
+while (pos != begin && pos[-1].DoesIntersect(range))
+  --pos;
+  
+if (pos != end && pos->DoesIntersect(range))
+  return &(*pos);
+  }
+  return nullptr;
+}
+
   using const_iterator = typename Collection::const_iterator;
   const_iterator begin() const { return m_entries.begin(); }
   const_iterator end() const { return m_entries.end(); }
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 73557eb767c72..ee297e1ca3d4a 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -6689,6 +6689,23 @@ static void GetCoreFileSaveRangesStackOnly(Process 
&process,
   }
 }
 
+// TODO: We should refactor CoreFileMemoryRanges to use the lldb range type, 
and then
+// add an intersect method on it, or MemoryRegionInfo.
+static MemoryRegionInfo Intersect(const MemoryRegionInfo &lhs, const 
Range &rhs) {
+  const lldb::addr_t lhs_base = lhs.GetRange().GetRangeBase();
+  const lldb::addr_t rhs_base = rhs.GetRangeBase();
+  const lldb::addr_t lhs_end = lhs.GetRange().GetRangeEnd();
+  const lldb::addr_t rhs_end = rhs.GetRangeEnd();
+
+  MemoryRegionInfo region_info;
+  region_info.SetLLDBPermissions(lhs.GetLLDBPermissions());
+  auto &range = region_info.GetRange();
+  range.SetRangeBase(std::max(lhs_base, rhs_base));
+  range.SetRangeEnd(std::min(lhs_end, rhs_end));
+
+  return region_info;
+}
+
 static void GetUserSpecifiedCoreFileSaveRanges(Process &process,
const MemoryRegionInfos 
®ions,
const SaveCoreOptions &options,
@@ -6698,9 +6715,16 @@ static void GetUserSpecifiedCoreFileSaveRanges(Process 
&process,
 return;
 
   for (const auto &range : regions) {
-auto entry = option_ranges.FindEntryThatContains(range.GetRange());
-if (entry)
-  AddRegion(range, true, ranges);
+auto *entry = option_ranges.FindEntryThatIntersects(range.GetRange());
+if (entry) {
+  if (entry->GetRangeBase() != range.GetRange().GetRangeBase() 
+  || entry->GetRangeEnd() != range.GetRange().GetRangeEnd()) {
+AddRegion(Intersect(range, *entry), true, ranges);
+  } else {
+// If they match, add the range directly.
+AddRegion(range, true, ranges);
+  }
+}
   }
 }
 
diff --git 
a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidumpYaml.py
 
b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidumpYaml.py
new file mode 100644
index 0..b8f9d697c8864
--- /dev/null
+++ 
b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidumpYaml.py
@@ -0,0 +1,142 @@
+"""
+Test saving a mini dump, from yamilized examples.
+"""
+
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class ProcessSaveCoreMinidumpTestCaseYaml(TestBase):
+   def process_from_yaml(self, yaml_file):
+  minidump_path = 
self.getBuildArtifact(os.path.basename(yaml_file) + ".dmp")
+  self.yaml2obj(yaml_file, minidump_path)
+  self.target = self.dbg.CreateTarget(None)
+  self.process = self.target.LoadCore(minidump_path)
+  return self.process
+
+   def test_saving_sub_memory_range(s

[Lldb-commits] [lldb] Fix TestEvents.py after: 4fdb8cb (PR #138211)

2025-05-01 Thread Jacob Lalonde via lldb-commits

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


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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-01 Thread Jacob Lalonde via lldb-commits


@@ -0,0 +1,142 @@
+"""
+Test saving a mini dump, from yamilized examples.
+"""
+
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ProcessSaveCoreMinidumpTestCaseYaml(TestBase):
+def process_from_yaml(self, yaml_file):
+minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + 
".dmp")
+self.yaml2obj(yaml_file, minidump_path)
+self.target = self.dbg.CreateTarget(None)
+self.process = self.target.LoadCore(minidump_path)
+return self.process
+
+def test_saving_sub_memory_range(self):
+"""
+Validate we can save a Minidump for a subsection of a memory range.
+I.E.
+If our memory range is 0x1000-0x2000 nd the user specifies 
0x1200-0x1800

Jlalond wrote:

Gave this a shot (looks more like decimals), let me know you what you think 
@dmpots!

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-01 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,h -- 
lldb/include/lldb/Utility/RangeMap.h lldb/source/Target/Process.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 1a98dbd74..13ff12b4f 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -6708,10 +6708,9 @@ static void GetCoreFileSaveRangesStackOnly(Process 
&process,
 
 // TODO: We should refactor CoreFileMemoryRanges to use the lldb range type, 
and
 // then add an intersect method on it, or MemoryRegionInfo.
-static MemoryRegionInfo
-Intersect(const MemoryRegionInfo &lhs,
-  const MemoryRegionInfo::RangeType &rhs) {
-  
+static MemoryRegionInfo Intersect(const MemoryRegionInfo &lhs,
+  const MemoryRegionInfo::RangeType &rhs) {
+
   MemoryRegionInfo region_info;
   region_info.SetLLDBPermissions(lhs.GetLLDBPermissions());
   region_info.GetRange() = lhs.GetRange().Intersect(rhs);

``




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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-01 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/138206

>From 91ce0997c03f87ec617ec2a113e7e88f1a88de11 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 1 May 2025 14:53:08 -0700
Subject: [PATCH 1/4] Change custom regions to be intersections, add test cases
 for sub regions and super regions, plus changes of permissions and invalid
 pages.

---
 lldb/include/lldb/Utility/RangeMap.h  |  19 +++
 lldb/source/Target/Process.cpp|  30 +++-
 .../TestProcessSaveCoreMinidumpYaml.py| 142 ++
 .../minidump_mem64.yaml   |  35 +
 4 files changed, 223 insertions(+), 3 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidumpYaml.py
 create mode 100644 
lldb/test/API/functionalities/process_save_core_minidump/minidump_mem64.yaml

diff --git a/lldb/include/lldb/Utility/RangeMap.h 
b/lldb/include/lldb/Utility/RangeMap.h
index 8af690e813c4a..f19c28268d55c 100644
--- a/lldb/include/lldb/Utility/RangeMap.h
+++ b/lldb/include/lldb/Utility/RangeMap.h
@@ -380,6 +380,25 @@ template  class 
RangeVector {
 return nullptr;
   }
 
+const Entry* FindEntryThatIntersects(const Entry &range) const {
+  #ifdef ASSERT_RANGEMAP_ARE_SORTED
+  assert(IsSorted());
+  #endif
+  if (!m_entries.empty()) {
+typename Collection::const_iterator begin = m_entries.begin();
+typename Collection::const_iterator end = m_entries.end();
+typename Collection::const_iterator pos =
+std::lower_bound(begin, end, range, BaseLessThan);
+  
+while (pos != begin && pos[-1].DoesIntersect(range))
+  --pos;
+  
+if (pos != end && pos->DoesIntersect(range))
+  return &(*pos);
+  }
+  return nullptr;
+}
+
   using const_iterator = typename Collection::const_iterator;
   const_iterator begin() const { return m_entries.begin(); }
   const_iterator end() const { return m_entries.end(); }
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 73557eb767c72..ee297e1ca3d4a 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -6689,6 +6689,23 @@ static void GetCoreFileSaveRangesStackOnly(Process 
&process,
   }
 }
 
+// TODO: We should refactor CoreFileMemoryRanges to use the lldb range type, 
and then
+// add an intersect method on it, or MemoryRegionInfo.
+static MemoryRegionInfo Intersect(const MemoryRegionInfo &lhs, const 
Range &rhs) {
+  const lldb::addr_t lhs_base = lhs.GetRange().GetRangeBase();
+  const lldb::addr_t rhs_base = rhs.GetRangeBase();
+  const lldb::addr_t lhs_end = lhs.GetRange().GetRangeEnd();
+  const lldb::addr_t rhs_end = rhs.GetRangeEnd();
+
+  MemoryRegionInfo region_info;
+  region_info.SetLLDBPermissions(lhs.GetLLDBPermissions());
+  auto &range = region_info.GetRange();
+  range.SetRangeBase(std::max(lhs_base, rhs_base));
+  range.SetRangeEnd(std::min(lhs_end, rhs_end));
+
+  return region_info;
+}
+
 static void GetUserSpecifiedCoreFileSaveRanges(Process &process,
const MemoryRegionInfos 
®ions,
const SaveCoreOptions &options,
@@ -6698,9 +6715,16 @@ static void GetUserSpecifiedCoreFileSaveRanges(Process 
&process,
 return;
 
   for (const auto &range : regions) {
-auto entry = option_ranges.FindEntryThatContains(range.GetRange());
-if (entry)
-  AddRegion(range, true, ranges);
+auto *entry = option_ranges.FindEntryThatIntersects(range.GetRange());
+if (entry) {
+  if (entry->GetRangeBase() != range.GetRange().GetRangeBase() 
+  || entry->GetRangeEnd() != range.GetRange().GetRangeEnd()) {
+AddRegion(Intersect(range, *entry), true, ranges);
+  } else {
+// If they match, add the range directly.
+AddRegion(range, true, ranges);
+  }
+}
   }
 }
 
diff --git 
a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidumpYaml.py
 
b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidumpYaml.py
new file mode 100644
index 0..b8f9d697c8864
--- /dev/null
+++ 
b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidumpYaml.py
@@ -0,0 +1,142 @@
+"""
+Test saving a mini dump, from yamilized examples.
+"""
+
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class ProcessSaveCoreMinidumpTestCaseYaml(TestBase):
+   def process_from_yaml(self, yaml_file):
+  minidump_path = 
self.getBuildArtifact(os.path.basename(yaml_file) + ".dmp")
+  self.yaml2obj(yaml_file, minidump_path)
+  self.target = self.dbg.CreateTarget(None)
+  self.process = self.target.LoadCore(minidump_path)
+  return self.process
+
+   def test_saving_sub_memory_range(s

[Lldb-commits] [lldb] [lldb][Formatters] Add --pointer-match-depth option to `type summary add` command. (PR #138209)

2025-05-01 Thread via lldb-commits


@@ -96,6 +97,8 @@ class FormattersMatchCandidate {
 
   bool DidStripTypedef() const { return m_flags.stripped_typedef; }
 
+  uint32_t GetPtrStrippedDepth() const { return m_ptr_stripped_depth; }

jimingham wrote:

I think this reads better as GetPtrStrippingDepth than GetPtrStrippedDepth.  
You aren't asking about something that has been done, but about a thing you are 
planning to do, so active seems more appropriate.

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


[Lldb-commits] [lldb] 47424df - [lldb][test] Skip part of TestLldbGdbServer.py on Windows

2025-05-01 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2025-05-01T09:30:33Z
New Revision: 47424df2d5c6cc5a2b2d49a8cad438d8e75fec61

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

LOG: [lldb][test] Skip part of TestLldbGdbServer.py on Windows

See https://github.com/llvm/llvm-project/issues/138085.

Added: 


Modified: 
lldb/test/API/tools/lldb-server/TestLldbGdbServer.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py 
b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index 1bb5b8019274e..eef157c5f490a 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -83,6 +83,10 @@ def test_inferior_print_exit(self):
 context = self.expect_gdbremote_sequence()
 self.assertIsNotNone(context)
 
+# Sometimes fails:
+# regex '^\$QC([0-9a-fA-F]+)#' failed to match against content '$E45#ae'
+# See https://github.com/llvm/llvm-project/issues/138085.
+@skipIfWindows
 def test_first_launch_stop_reply_thread_matches_first_qC(self):
 self.build()
 procs = self.prep_debug_monitor_and_inferior()



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


[Lldb-commits] [lldb] 2dbab4c - [lldb][test] Disable a bunch of flakey lldb-dap tests

2025-05-01 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2025-05-01T10:01:14Z
New Revision: 2dbab4ca8ddb218af555d8d1fd86b72612387582

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

LOG: [lldb][test] Disable a bunch of flakey lldb-dap tests

These, or parts of these, are all failing every so often on Linaro's
build bots with:
raise ValueError(desc)
ValueError: no response for "disconnect"

Sorry to use a global disable here but this is happening too often
and spamming unrelated PRs.

I think it's the same issue as 
https://github.com/llvm/llvm-project/issues/137660.

Added: 


Modified: 
lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_breakpointLocations.py
lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py
lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py
lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py
lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py

Removed: 




diff  --git 
a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_breakpointLocations.py 
b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_breakpointLocations.py
index 1058157e2c668..4a99cacc761a3 100644
--- a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_breakpointLocations.py
+++ b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_breakpointLocations.py
@@ -11,7 +11,8 @@
 import lldbdap_testcase
 import os
 
-
+# DAP tests are flakey, see https://github.com/llvm/llvm-project/issues/137660.
+@skip
 class TestDAP_breakpointLocations(lldbdap_testcase.DAPTestCaseBase):
 def setUp(self):
 lldbdap_testcase.DAPTestCaseBase.setUp(self)

diff  --git a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py 
b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py
index 26df2573555df..6c6681804f250 100644
--- a/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py
+++ b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py
@@ -11,7 +11,8 @@
 import lldbdap_testcase
 import os
 
-
+# DAP tests are flakey, see https://github.com/llvm/llvm-project/issues/137660.
+@skip
 class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
 def setUp(self):
 lldbdap_testcase.DAPTestCaseBase.setUp(self)

diff  --git a/lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py 
b/lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py
index 25ecbb5cf106b..8398eeab7bba2 100644
--- a/lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py
+++ b/lldb/test/API/tools/lldb-dap/commands/TestDAP_commands.py
@@ -5,7 +5,8 @@
 from lldbsuite.test import lldbtest, lldbutil
 from lldbsuite.test.decorators import *
 
-
+# DAP tests are flakey, see https://github.com/llvm/llvm-project/issues/137660.
+@skip
 class TestDAP_commands(lldbdap_testcase.DAPTestCaseBase):
 def test_command_directive_quiet_on_success(self):
 program = self.getBuildArtifact("a.out")

diff  --git a/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py 
b/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
index 9e8ef5b289f2e..ebecb349ac177 100644
--- a/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
+++ b/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
@@ -10,7 +10,8 @@
 import lldbdap_testcase
 import os
 
-
+# DAP tests are flakey, see https://github.com/llvm/llvm-project/issues/137660.
+@skip
 class TestDAP_disassemble(lldbdap_testcase.DAPTestCaseBase):
 @skipIfWindows
 def test_disassemble(self):

diff  --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py 
b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
index e2f843bd337a6..d97fda730c46a 100644
--- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
+++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
@@ -10,7 +10,8 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
-
+# DAP tests are flakey, see https://github.com/llvm/llvm-project/issues/137660.
+@skip
 class TestDAP_evaluate(lldbdap_testcase.DAPTestCaseBase):
 def assertEvaluate(self, expression, regex):
 self.assertRegex(

diff  --git a/lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py 
b/lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py
index ea43fccf016a7..c71ba871b8a22 100644
--- a/lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py
+++ b/lldb/test/API/tools/lldb-dap/memory/TestDAP_memory.py
@@ -10,7 +10,8 @@
 import lldbdap_testcase
 import os
 
-
+# DAP tests are flakey, see https://github.com/llvm/llvm-project/issues/137660.
+@skip
 class TestDAP_memory(lldbdap_testcase.DAPTestCaseBase):
 def test_memory_refs_variables(self):
 """

diff  --git a/lldb/te

[Lldb-commits] [lldb] [lldb] Fix block address resolution for functions in multiple sections (PR #137955)

2025-05-01 Thread David Spickett via lldb-commits


@@ -283,39 +283,42 @@ uint32_t Block::GetRangeIndexContainingAddress(const 
Address &addr) {
   return m_ranges.FindEntryIndexThatContains(file_addr - func_file_addr);
 }
 
+static AddressRange ToAddressRange(const Address &func_addr,
+   const Block::Range &range) {
+  assert(func_addr.GetModule());
+  return AddressRange(func_addr.GetFileAddress() + range.base, range.size,

DavidSpickett wrote:

what exactly is `func_addr.GetFileAddress()` going to return? The entry point 
of the function, as an offset to the address of the file it's contained in, or 
the lowest address contained within the function?

https://github.com/llvm/llvm-project/pull/137955
___
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 raciness in launch and attach tests (PR #137920)

2025-05-01 Thread John Harrison via lldb-commits

ashgti wrote:

To clarify the DAP flow a little, see 'Launch Sequencing' in 
https://microsoft.github.io/debug-adapter-protocol/overview

Once the DAP server send the response to the `initialize` request the following 
happen in parallel:

* The `initialized` event triggers the client sending `setBreakpoints`, etc. 
with the `configurationDone` request at the end of the chain.
* `launch` or `attach` requests are sent and we send back a `process` event.

The flow from VSCode at least often ends up with:

* `initialize seq=1`
* `launch seq=2`
* `setBreakpoints seq=3`
* `configurationDone seq=4`

But these do not strictly have to be in that order.

The DAP server can respond to these events asynchronously but today the 
lldb-dap is single threaded for handling each of these responses.

Looking at the failing test 
https://lab.llvm.org/buildbot/#/builders/18/builds/15174/steps/6/logs/stdio, we 
had the following sequence:

```
{"command":"initialize", ...}
{"command":"attach", ...}
{"command":"setBreakpoints", ...}
{"command":"configurationDone", ...}
{"event":"stopped", ...}
```

But that stopped event here is wrong. This attach did not set `"stopOnEntry": 
true`, so that should have continued the process at point.

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


[Lldb-commits] [lldb] Make stop-hooks fire when lldb first gains control of a process. (PR #137410)

2025-05-01 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/137410

>From 8a5e25a6e850222fcbb94f685d46895d2666041f Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Fri, 25 Apr 2025 15:35:12 -0700
Subject: [PATCH 1/4] Make stop-hooks fire when lldb first gains control of a
 process.

---
 lldb/include/lldb/Target/Target.h |   11 +-
 lldb/source/Commands/CommandObjectTarget.cpp  |   16 +
 lldb/source/Commands/Options.td   |7 +-
 lldb/source/Target/Process.cpp|6 +
 lldb/source/Target/Target.cpp |   37 +-
 .../target/stop-hooks/TestStopHookScripted.py |6 +-
 .../target/stop-hooks/TestStopHooks.py|3 +-
 .../on-core-load/TestStopHookOnCoreLoad.py|   55 +
 .../stop-hooks/on-core-load/linux-x86_64.core |  Bin 0 -> 32768 bytes
 .../stop-hooks/on-core-load/stop_hook.py  |   28 +
 .../stop-hooks/on-core-load/test.core.yaml| 1056 +
 lldb/test/API/python_api/event/TestEvents.py  |3 +-
 12 files changed, 1218 insertions(+), 10 deletions(-)
 create mode 100644 
lldb/test/API/commands/target/stop-hooks/on-core-load/TestStopHookOnCoreLoad.py
 create mode 100644 
lldb/test/API/commands/target/stop-hooks/on-core-load/linux-x86_64.core
 create mode 100644 
lldb/test/API/commands/target/stop-hooks/on-core-load/stop_hook.py
 create mode 100644 
lldb/test/API/commands/target/stop-hooks/on-core-load/test.core.yaml

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 29183cc267721..7aa1fd18233c2 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1369,6 +1369,12 @@ class Target : public 
std::enable_shared_from_this,
 }
 
 bool GetAutoContinue() const { return m_auto_continue; }
+
+void SetRunAtFirstStop(bool at_first_stop) {
+  m_at_first_stop = at_first_stop;
+}
+
+bool GetRunAtFirstStop() const { return m_at_first_stop; }
 
 void GetDescription(Stream &s, lldb::DescriptionLevel level) const;
 virtual void GetSubclassDescription(Stream &s,
@@ -1380,6 +1386,7 @@ class Target : public 
std::enable_shared_from_this,
 std::unique_ptr m_thread_spec_up;
 bool m_active = true;
 bool m_auto_continue = false;
+bool m_at_first_stop = true;
 
 StopHook(lldb::TargetSP target_sp, lldb::user_id_t uid);
   };
@@ -1446,7 +1453,9 @@ class Target : public 
std::enable_shared_from_this,
 
   // Runs the stop hooks that have been registered for this target.
   // Returns true if the stop hooks cause the target to resume.
-  bool RunStopHooks();
+  // Pass at_initial_stop if this is the stop where lldb gains
+  // control over the process for the first time.
+  bool RunStopHooks(bool at_initial_stop = false);
 
   size_t GetStopHookSize();
 
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 3f7d3007ed168..3f73157155a02 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -4795,6 +4795,17 @@ class CommandObjectTargetStopHookAdd : public 
CommandObjectParsed,
 m_use_one_liner = true;
 m_one_liner.push_back(std::string(option_arg));
 break;
+
+  case 'F': {
+bool value, success;
+value = OptionArgParser::ToBoolean(option_arg, false, &success);
+if (success) {
+  m_at_first_stop = value;
+} else
+  error = Status::FromErrorStringWithFormat(
+  "invalid boolean value '%s' passed for -F option",
+  option_arg.str().c_str());
+  } break;
 
   default:
 llvm_unreachable("Unimplemented option");
@@ -4822,6 +4833,7 @@ class CommandObjectTargetStopHookAdd : public 
CommandObjectParsed,
   m_use_one_liner = false;
   m_one_liner.clear();
   m_auto_continue = false;
+  m_at_first_stop = true;
 }
 
 std::string m_class_name;
@@ -4842,6 +4854,7 @@ class CommandObjectTargetStopHookAdd : public 
CommandObjectParsed,
 // Instance variables to hold the values for one_liner options.
 bool m_use_one_liner = false;
 std::vector m_one_liner;
+bool m_at_first_stop;
 
 bool m_auto_continue = false;
   };
@@ -5006,6 +5019,9 @@ Filter Options:
 
 if (specifier_up)
   new_hook_sp->SetSpecifier(specifier_up.release());
+  
+// Should we run at first stop:
+new_hook_sp->SetRunAtFirstStop(m_options.m_at_first_stop);
 
 // Next see if any of the thread options have been entered:
 
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 53864ff29327d..50313ac2cacbc 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1050,8 +1050,13 @@ let Command = "target stop hook add" in {
 Arg<"FunctionName">, Desc<"Set the function name within which the stop 
hook"
 " will be run.">, Completion<"Symbol">;
   def target_stop_hook_add_auto_continue : Op

[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-01 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,h -- 
lldb/test/API/commands/frame/var-dil/basics/MemberOf/main.cpp 
lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/main.cpp 
lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/main.cpp 
lldb/include/lldb/ValueObject/DILAST.h lldb/include/lldb/ValueObject/DILEval.h 
lldb/include/lldb/ValueObject/DILLexer.h 
lldb/include/lldb/ValueObject/DILParser.h lldb/source/ValueObject/DILAST.cpp 
lldb/source/ValueObject/DILEval.cpp lldb/source/ValueObject/DILLexer.cpp 
lldb/source/ValueObject/DILParser.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/ValueObject/DILAST.h 
b/lldb/include/lldb/ValueObject/DILAST.h
index a74a12bd8..16ba34fab 100644
--- a/lldb/include/lldb/ValueObject/DILAST.h
+++ b/lldb/include/lldb/ValueObject/DILAST.h
@@ -94,7 +94,7 @@ public:
   MemberOfNode(uint32_t location, ASTNodeUP base, bool is_arrow,
ConstString name)
   : ASTNode(location, NodeKind::eMemberOfNode), m_base(std::move(base)),
-m_is_arrow(is_arrow), m_field_name(name) { }
+m_is_arrow(is_arrow), m_field_name(name) {}
 
   llvm::Expected Accept(Visitor *v) const override;
 
diff --git a/lldb/source/ValueObject/DILEval.cpp 
b/lldb/source/ValueObject/DILEval.cpp
index 1f1ad7161..e5c17fecb 100644
--- a/lldb/source/ValueObject/DILEval.cpp
+++ b/lldb/source/ValueObject/DILEval.cpp
@@ -280,7 +280,8 @@ Interpreter::EvaluateMemberOf(lldb::ValueObjectSP value,
 
   lldb::DynamicValueType use_dynamic =
   (!is_dynamic) ? lldb::eNoDynamicValues : lldb::eDynamicDontRunTarget;
-  // Walk the path from the base value to the value that contains the 
requested field.
+  // Walk the path from the base value to the value that contains the requested
+  // field.
   for (uint32_t idx : path) {
 member_val_sp = member_val_sp->GetChildAtIndex(idx, /*can_create*/ true);
   }
diff --git a/lldb/source/ValueObject/DILParser.cpp 
b/lldb/source/ValueObject/DILParser.cpp
index 9c5bc7177..c7008f589 100644
--- a/lldb/source/ValueObject/DILParser.cpp
+++ b/lldb/source/ValueObject/DILParser.cpp
@@ -127,10 +127,9 @@ ASTNodeUP DILParser::ParsePostfixExpression() {
 m_dil_lexer.Advance();
 Token member_token = CurToken();
 std::string member_id = ParseIdExpression();
-lhs = std::make_unique(member_token.GetLocation(),
- std::move(lhs),
- token.GetKind() == Token::arrow,
- ConstString(member_id));
+lhs = std::make_unique(
+member_token.GetLocation(), std::move(lhs),
+token.GetKind() == Token::arrow, ConstString(member_id));
   }
   return lhs;
 }
diff --git a/lldb/test/API/commands/frame/var-dil/basics/MemberOf/main.cpp 
b/lldb/test/API/commands/frame/var-dil/basics/MemberOf/main.cpp
index dace888be..755febcdc 100644
--- a/lldb/test/API/commands/frame/var-dil/basics/MemberOf/main.cpp
+++ b/lldb/test/API/commands/frame/var-dil/basics/MemberOf/main.cpp
@@ -1,15 +1,13 @@
-int
-main(int argc, char**argv)
-{
+int main(int argc, char **argv) {
   int x = 2;
   struct Sx {
 int x;
-int& r;
+int &r;
 char y;
   } s{1, x, 2};
 
-  Sx& sr = s;
-  Sx* sp = &s;
+  Sx &sr = s;
+  Sx *sp = &s;
 
   Sx sarr[2] = {{5, x, 2}, {1, x, 3}};
 
diff --git 
a/lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/main.cpp 
b/lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/main.cpp
index 6237523ac..c787f29f9 100644
--- 
a/lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/main.cpp
+++ 
b/lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/main.cpp
@@ -1,5 +1,4 @@
-int main(int argc, char** argv)
-{
+int main(int argc, char **argv) {
   struct A {
 struct {
   int x = 1;
@@ -22,7 +21,7 @@ int main(int argc, char** argv)
   int x = 5;
 };
 class {
- public:
+public:
   int y = 6;
 };
   } c;
diff --git 
a/lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/main.cpp 
b/lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/main.cpp
index 4d29af1b7..27177f3f0 100644
--- a/lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/main.cpp
+++ b/lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/main.cpp
@@ -1,5 +1,4 @@
-int main(int argc, char** argv)
-{
+int main(int argc, char **argv) {
   struct A {
 int a_;
   } a{1};
@@ -38,7 +37,7 @@ int main(int argc, char** argv)
   } bat;
   bat.weight_ = 10;
 
- // Empty bases example.
+  // Empty bases example.
   struct IPlugin {
 virtual ~IPlugin() {}
   };
@@ -74,14 +73,14 @@ int main(int argc, char** argv)
   struct Mixin {};
   struct Parent : private Mixin, publi

[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-01 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (cmtice)


Changes

Add the arrow and period operators, allowing DIL to find and access member 
fields.

---

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


18 Files Affected:

- (modified) lldb/docs/dil-expr-lang.ebnf (+7-3) 
- (modified) lldb/include/lldb/ValueObject/DILAST.h (+26) 
- (modified) lldb/include/lldb/ValueObject/DILEval.h (+8) 
- (modified) lldb/include/lldb/ValueObject/DILLexer.h (+2) 
- (modified) lldb/include/lldb/ValueObject/DILParser.h (+1) 
- (modified) lldb/source/ValueObject/DILAST.cpp (+4) 
- (modified) lldb/source/ValueObject/DILEval.cpp (+200) 
- (modified) lldb/source/ValueObject/DILLexer.cpp (+7-2) 
- (modified) lldb/source/ValueObject/DILParser.cpp (+24-3) 
- (added) lldb/test/API/commands/frame/var-dil/basics/MemberOf/Makefile (+3) 
- (added) 
lldb/test/API/commands/frame/var-dil/basics/MemberOf/TestFrameVarDILMemberOf.py 
(+47) 
- (added) lldb/test/API/commands/frame/var-dil/basics/MemberOf/main.cpp (+59) 
- (added) 
lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/Makefile 
(+3) 
- (added) 
lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/TestFrameVarDILMemberOfAnonymousMember.py
 (+62) 
- (added) 
lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/main.cpp 
(+74) 
- (added) 
lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/Makefile (+3) 
- (added) 
lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/TestFrameVarDILMemberOfInheritance.py
 (+49) 
- (added) 
lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/main.cpp (+87) 


``diff
diff --git a/lldb/docs/dil-expr-lang.ebnf b/lldb/docs/dil-expr-lang.ebnf
index c8bf4231b3e4a..580626862c005 100644
--- a/lldb/docs/dil-expr-lang.ebnf
+++ b/lldb/docs/dil-expr-lang.ebnf
@@ -5,13 +5,17 @@
 
 expression = unary_expression ;
 
-unary_expression = unary_operator expression
- | primary_expression ;
+unary_expression = postfix_expression
+ | unary_operator expression ;
 
 unary_operator = "*" | "&" ;
 
+postfix_expresson = primary_expression
+  | postfix_expression "." id_expression
+  | postfix_expression "->" id_expression ;
+
 primary_expression = id_expression
-   | "(" expression ")";
+   | "(" expression ")"  ;
 
 id_expression = unqualified_id
   | qualified_id
diff --git a/lldb/include/lldb/ValueObject/DILAST.h 
b/lldb/include/lldb/ValueObject/DILAST.h
index fe3827ef0516a..a74a12bd8be9d 100644
--- a/lldb/include/lldb/ValueObject/DILAST.h
+++ b/lldb/include/lldb/ValueObject/DILAST.h
@@ -20,6 +20,7 @@ namespace lldb_private::dil {
 enum class NodeKind {
   eErrorNode,
   eIdentifierNode,
+  eMemberOfNode,
   eUnaryOpNode,
 };
 
@@ -88,6 +89,29 @@ class IdentifierNode : public ASTNode {
   std::string m_name;
 };
 
+class MemberOfNode : public ASTNode {
+public:
+  MemberOfNode(uint32_t location, ASTNodeUP base, bool is_arrow,
+   ConstString name)
+  : ASTNode(location, NodeKind::eMemberOfNode), m_base(std::move(base)),
+m_is_arrow(is_arrow), m_field_name(name) { }
+
+  llvm::Expected Accept(Visitor *v) const override;
+
+  ASTNode *base() const { return m_base.get(); }
+  bool IsArrow() const { return m_is_arrow; }
+  ConstString FieldName() const { return m_field_name; }
+
+  static bool classof(const ASTNode *node) {
+return node->GetKind() == NodeKind::eMemberOfNode;
+  }
+
+private:
+  ASTNodeUP m_base;
+  bool m_is_arrow;
+  ConstString m_field_name;
+};
+
 class UnaryOpNode : public ASTNode {
 public:
   UnaryOpNode(uint32_t location, UnaryOpKind kind, ASTNodeUP operand)
@@ -118,6 +142,8 @@ class Visitor {
   virtual llvm::Expected
   Visit(const IdentifierNode *node) = 0;
   virtual llvm::Expected
+  Visit(const MemberOfNode *node) = 0;
+  virtual llvm::Expected
   Visit(const UnaryOpNode *node) = 0;
 };
 
diff --git a/lldb/include/lldb/ValueObject/DILEval.h 
b/lldb/include/lldb/ValueObject/DILEval.h
index b1dd3fdb49739..053daffaa41f2 100644
--- a/lldb/include/lldb/ValueObject/DILEval.h
+++ b/lldb/include/lldb/ValueObject/DILEval.h
@@ -49,8 +49,16 @@ class Interpreter : Visitor {
 private:
   llvm::Expected
   Visit(const IdentifierNode *node) override;
+  llvm::Expected Visit(const MemberOfNode *node) override;
   llvm::Expected Visit(const UnaryOpNode *node) override;
 
+  lldb::ValueObjectSP EvaluateMemberOf(lldb::ValueObjectSP value,
+   const std::vector &path,
+   bool use_synthetic, bool is_dynamic);
+
+  lldb::ValueObjectSP FindMemberWithName(lldb::ValueObjectSP base,
+ ConstString name, bool is_arrow);
+
   // Used by the interpreter to create objects, perform casts, etc.
   lldb::TargetSP m_target;
   llvm::StringRef m_expr;
diff --git a/l

[Lldb-commits] [lldb] [lldb] Do not bump memory modificator ID when "internal" debugger memory is updated (PR #129092)

2025-05-01 Thread Mikhail Zakharov via lldb-commits

real-mikhail wrote:

I assume that there will be no further comments here.

Since this is my first change in LLVM I cannot merge it myself. @jimingham may 
I kindly ask you to merge this PR?

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


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-01 Thread via lldb-commits

https://github.com/cmtice created 
https://github.com/llvm/llvm-project/pull/138093

Add the arrow and period operators, allowing DIL to find and access member 
fields.

>From fe9ac0fa05bb43ea718214746f0ea9b7eefc929a Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Thu, 1 May 2025 00:05:57 -0700
Subject: [PATCH] [LLDB] Add field member operators to DIL

Add the arrow and period operators, allowing DIL to find and access
member fields.
---
 lldb/docs/dil-expr-lang.ebnf  |  10 +-
 lldb/include/lldb/ValueObject/DILAST.h|  26 +++
 lldb/include/lldb/ValueObject/DILEval.h   |   8 +
 lldb/include/lldb/ValueObject/DILLexer.h  |   2 +
 lldb/include/lldb/ValueObject/DILParser.h |   1 +
 lldb/source/ValueObject/DILAST.cpp|   4 +
 lldb/source/ValueObject/DILEval.cpp   | 200 ++
 lldb/source/ValueObject/DILLexer.cpp  |   9 +-
 lldb/source/ValueObject/DILParser.cpp |  27 ++-
 .../frame/var-dil/basics/MemberOf/Makefile|   3 +
 .../MemberOf/TestFrameVarDILMemberOf.py   |  47 
 .../frame/var-dil/basics/MemberOf/main.cpp|  59 ++
 .../basics/MemberOfAnonymousMember/Makefile   |   3 +
 .../TestFrameVarDILMemberOfAnonymousMember.py |  62 ++
 .../basics/MemberOfAnonymousMember/main.cpp   |  74 +++
 .../basics/MemberOfInheritance/Makefile   |   3 +
 .../TestFrameVarDILMemberOfInheritance.py |  49 +
 .../basics/MemberOfInheritance/main.cpp   |  87 
 18 files changed, 666 insertions(+), 8 deletions(-)
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/MemberOf/Makefile
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/MemberOf/TestFrameVarDILMemberOf.py
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/MemberOf/main.cpp
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/Makefile
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/TestFrameVarDILMemberOfAnonymousMember.py
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/main.cpp
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/Makefile
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/TestFrameVarDILMemberOfInheritance.py
 create mode 100644 
lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/main.cpp

diff --git a/lldb/docs/dil-expr-lang.ebnf b/lldb/docs/dil-expr-lang.ebnf
index c8bf4231b3e4a..580626862c005 100644
--- a/lldb/docs/dil-expr-lang.ebnf
+++ b/lldb/docs/dil-expr-lang.ebnf
@@ -5,13 +5,17 @@
 
 expression = unary_expression ;
 
-unary_expression = unary_operator expression
- | primary_expression ;
+unary_expression = postfix_expression
+ | unary_operator expression ;
 
 unary_operator = "*" | "&" ;
 
+postfix_expresson = primary_expression
+  | postfix_expression "." id_expression
+  | postfix_expression "->" id_expression ;
+
 primary_expression = id_expression
-   | "(" expression ")";
+   | "(" expression ")"  ;
 
 id_expression = unqualified_id
   | qualified_id
diff --git a/lldb/include/lldb/ValueObject/DILAST.h 
b/lldb/include/lldb/ValueObject/DILAST.h
index fe3827ef0516a..a74a12bd8be9d 100644
--- a/lldb/include/lldb/ValueObject/DILAST.h
+++ b/lldb/include/lldb/ValueObject/DILAST.h
@@ -20,6 +20,7 @@ namespace lldb_private::dil {
 enum class NodeKind {
   eErrorNode,
   eIdentifierNode,
+  eMemberOfNode,
   eUnaryOpNode,
 };
 
@@ -88,6 +89,29 @@ class IdentifierNode : public ASTNode {
   std::string m_name;
 };
 
+class MemberOfNode : public ASTNode {
+public:
+  MemberOfNode(uint32_t location, ASTNodeUP base, bool is_arrow,
+   ConstString name)
+  : ASTNode(location, NodeKind::eMemberOfNode), m_base(std::move(base)),
+m_is_arrow(is_arrow), m_field_name(name) { }
+
+  llvm::Expected Accept(Visitor *v) const override;
+
+  ASTNode *base() const { return m_base.get(); }
+  bool IsArrow() const { return m_is_arrow; }
+  ConstString FieldName() const { return m_field_name; }
+
+  static bool classof(const ASTNode *node) {
+return node->GetKind() == NodeKind::eMemberOfNode;
+  }
+
+private:
+  ASTNodeUP m_base;
+  bool m_is_arrow;
+  ConstString m_field_name;
+};
+
 class UnaryOpNode : public ASTNode {
 public:
   UnaryOpNode(uint32_t location, UnaryOpKind kind, ASTNodeUP operand)
@@ -118,6 +142,8 @@ class Visitor {
   virtual llvm::Expected
   Visit(const IdentifierNode *node) = 0;
   virtual llvm::Expected
+  Visit(const MemberOfNode *node) = 0;
+  virtual llvm::Expected
   Visit(const UnaryOpNode *node) = 0;
 };
 
diff --git a/lldb/include/lldb/ValueObject/DILEval.h 
b/lldb/include/lldb/ValueObject/DILEval.h
index b1dd3fdb49739..053daffaa41f2 100644
--- a/lldb/include/lldb/ValueObject/DILEval.h
+++ b/lldb/include/lldb/ValueObject/DILEval.h
@@ -49,8 +49,16 

[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-01 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r HEAD~1...HEAD 
lldb/test/API/commands/frame/var-dil/basics/MemberOf/TestFrameVarDILMemberOf.py 
lldb/test/API/commands/frame/var-dil/basics/MemberOfAnonymousMember/TestFrameVarDILMemberOfAnonymousMember.py
 
lldb/test/API/commands/frame/var-dil/basics/MemberOfInheritance/TestFrameVarDILMemberOfInheritance.py
``





View the diff from darker here.


``diff
--- MemberOf/TestFrameVarDILMemberOf.py 2025-05-01 07:05:57.00 +
+++ MemberOf/TestFrameVarDILMemberOf.py 2025-05-01 07:10:01.907042 +
@@ -9,39 +9,50 @@
 
 import os
 import shutil
 import time
 
+
 class TestFrameVarDILMemberOf(TestBase):
 # If your test case doesn't stress debug info, then
 # set this to true.  That way it won't be run once for
 # each debug info format.
 NO_DEBUG_INFO_TESTCASE = True
 
 def test_frame_var(self):
 self.build()
-lldbutil.run_to_source_breakpoint(self, "Set a breakpoint here",
-  lldb.SBFileSpec("main.cpp"))
+lldbutil.run_to_source_breakpoint(
+self, "Set a breakpoint here", lldb.SBFileSpec("main.cpp")
+)
 
-self.expect("settings set target.experimental.use-DIL true",
-substrs=[""])
+self.expect("settings set target.experimental.use-DIL true", 
substrs=[""])
 self.expect_var_path("s.x", value="1")
 self.expect_var_path("s.r", value="2")
 self.expect_var_path("sr.x", value="1")
 self.expect_var_path("sr.r", value="2")
 self.expect_var_path("sp->x", value="1")
 self.expect_var_path("sp->r", value="2")
-self.expect_var_path("sarr->x", value="5");
+self.expect_var_path("sarr->x", value="5")
 self.expect_var_path("sarr->r", value="2")
 
-self.expect("frame variable 'sp->foo'", error=True,
-substrs=["no member named 'foo' in 'Sx'"])
+self.expect(
+"frame variable 'sp->foo'",
+error=True,
+substrs=["no member named 'foo' in 'Sx'"],
+)
 
-self.expect("frame variable 'sp.x'", error=True,
-substrs=["member reference type 'Sx *' is a "
- "pointer; did you mean to use '->'"])
-self.expect("frame variable 'sarr.x'", error=True,
-substrs=["no member named 'x' in 'Sx[2]'"])
+self.expect(
+"frame variable 'sp.x'",
+error=True,
+substrs=[
+"member reference type 'Sx *' is a " "pointer; did you mean to 
use '->'"
+],
+)
+self.expect(
+"frame variable 'sarr.x'",
+error=True,
+substrs=["no member named 'x' in 'Sx[2]'"],
+)
 
 # Test for record typedefs.
 self.expect_var_path("sa.x", value="3")
 self.expect_var_path("sa.y", value="'\\x04'")
--- MemberOfAnonymousMember/TestFrameVarDILMemberOfAnonymousMember.py   
2025-05-01 07:05:57.00 +
+++ MemberOfAnonymousMember/TestFrameVarDILMemberOfAnonymousMember.py   
2025-05-01 07:10:01.933926 +
@@ -9,29 +9,31 @@
 
 import os
 import shutil
 import time
 
+
 class TestFrameVarDILMemberOfAnonymousMember(TestBase):
 # If your test case doesn't stress debug info, then
 # set this to true.  That way it won't be run once for
 # each debug info format.
 NO_DEBUG_INFO_TESTCASE = True
 
 def test_frame_var(self):
 self.build()
-lldbutil.run_to_source_breakpoint(self, "Set a breakpoint here",
-  lldb.SBFileSpec("main.cpp"))
+lldbutil.run_to_source_breakpoint(
+self, "Set a breakpoint here", lldb.SBFileSpec("main.cpp")
+)
 
-self.expect("settings set target.experimental.use-DIL true",
-substrs=[""])
+self.expect("settings set target.experimental.use-DIL true", 
substrs=[""])
 self.expect_var_path("a.x", value="1")
 self.expect_var_path("a.y", value="2")
 
-self.expect("frame variable 'b.x'", error=True,
-substrs=["no member named 'x' in 'B'"])
-#self.expect_var_path("b.y", value="0")
+self.expect(
+"frame variable 'b.x'", error=True, substrs=["no member named 'x' 
in 'B'"]
+)
+# self.expect_var_path("b.y", value="0")
 self.expect_var_path("b.z", value="3")
 self.expect_var_path("b.w", value="4")
 self.expect_var_path("b.a.x", value="1")
 self.expect_var_path("b.a.y", value="2")
 
@@ -41,22 +43,30 @@
 self.expect_var_path("d.x", value="7")
 self.expect_var_path("d.y", value="8")
 self.expect_var_path("d.z", value="9")
 self.expect_var_path("d.w", value="10")
 

[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

2025-05-01 Thread via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [NFC][Support] Add llvm::uninitialized_copy (PR #138174)

2025-05-01 Thread Rahul Joshi via lldb-commits

https://github.com/jurahul created 
https://github.com/llvm/llvm-project/pull/138174

None

>From d6f69414e3ac5c1a22f6509149609258ef980c13 Mon Sep 17 00:00:00 2001
From: Rahul Joshi 
Date: Wed, 30 Apr 2025 23:47:37 -0700
Subject: [PATCH] [NFC][Support] Add llvm::uninitialized_copy

---
 clang/include/clang/AST/DeclCXX.h |  6 +-
 clang/include/clang/AST/DeclOpenACC.h |  9 +--
 clang/include/clang/AST/ExprCXX.h |  6 +-
 clang/include/clang/AST/OpenACCClause.h   | 72 +++
 clang/include/clang/AST/StmtOpenACC.h | 58 +++
 clang/include/clang/Sema/ParsedTemplate.h |  4 +-
 clang/lib/AST/Decl.cpp|  6 +-
 clang/lib/AST/DeclObjC.cpp|  4 +-
 clang/lib/AST/DeclTemplate.cpp| 11 ++-
 clang/lib/AST/Expr.cpp|  8 +--
 clang/lib/AST/ExprCXX.cpp | 16 ++---
 clang/lib/AST/OpenACCClause.cpp   | 13 ++--
 clang/lib/AST/StmtOpenACC.cpp |  4 +-
 clang/lib/AST/Type.cpp|  7 +-
 clang/tools/libclang/CXIndexDataConsumer.cpp  |  3 +-
 lldb/source/Utility/Checksum.cpp  |  4 +-
 llvm/include/llvm/ADT/ArrayRef.h  |  2 +-
 llvm/include/llvm/ADT/STLExtras.h |  5 ++
 llvm/lib/Analysis/ScalarEvolution.cpp | 10 +--
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp |  3 +-
 llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp   |  4 +-
 llvm/lib/DebugInfo/MSF/MSFBuilder.cpp |  6 +-
 llvm/lib/IR/AttributeImpl.h   |  2 +-
 llvm/lib/ObjectYAML/MinidumpEmitter.cpp   |  2 +-
 llvm/lib/Support/FoldingSet.cpp   |  4 +-
 .../AMDGPU/MCTargetDesc/AMDGPUMCExpr.cpp  |  2 +-
 llvm/lib/Transforms/IPO/LowerTypeTests.cpp|  7 +-
 .../unittests/Support/TrailingObjectsTest.cpp | 11 ++-
 mlir/include/mlir/IR/BuiltinAttributes.td |  2 +-
 mlir/include/mlir/Support/StorageUniquer.h|  4 +-
 .../Dialect/Affine/Analysis/NestedMatcher.cpp |  4 +-
 mlir/lib/IR/AffineMapDetail.h |  3 +-
 mlir/lib/IR/Location.cpp  |  8 +--
 mlir/lib/IR/MLIRContext.cpp   |  2 +-
 mlir/lib/IR/TypeDetail.h  |  3 +-
 mlir/lib/Tools/PDLL/AST/Nodes.cpp | 42 ---
 36 files changed, 154 insertions(+), 203 deletions(-)

diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index dd325815ee28d..20720115bf6c3 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -3861,8 +3861,7 @@ class UsingPackDecl final
   InstantiatedFrom ? InstantiatedFrom->getDeclName()
: DeclarationName()),
 InstantiatedFrom(InstantiatedFrom), NumExpansions(UsingDecls.size()) {
-std::uninitialized_copy(UsingDecls.begin(), UsingDecls.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(UsingDecls, getTrailingObjects());
   }
 
   void anchor() override;
@@ -4233,8 +4232,7 @@ class DecompositionDecl final
   : VarDecl(Decomposition, C, DC, StartLoc, LSquareLoc, nullptr, T, TInfo,
 SC),
 NumBindings(Bindings.size()) {
-std::uninitialized_copy(Bindings.begin(), Bindings.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(Bindings, getTrailingObjects());
 for (auto *B : Bindings) {
   B->setDecomposedDecl(this);
   if (B->isParameterPack() && B->getBinding()) {
diff --git a/clang/include/clang/AST/DeclOpenACC.h 
b/clang/include/clang/AST/DeclOpenACC.h
index 8c612fbf1ec07..905d9bf636ea1 100644
--- a/clang/include/clang/AST/DeclOpenACC.h
+++ b/clang/include/clang/AST/DeclOpenACC.h
@@ -18,6 +18,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/OpenACCClause.h"
 #include "clang/Basic/OpenACCKinds.h"
+#include "llvm/ADT/STLExtras.h"
 
 namespace clang {
 
@@ -85,8 +86,8 @@ class OpenACCDeclareDecl final
   : OpenACCConstructDecl(OpenACCDeclare, DC, OpenACCDirectiveKind::Declare,
  StartLoc, DirLoc, EndLoc) {
 // Initialize the trailing storage.
-std::uninitialized_copy(Clauses.begin(), Clauses.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(Clauses,
+ getTrailingObjects());
 
 setClauseList(MutableArrayRef(getTrailingObjects(),
   Clauses.size()));
@@ -136,8 +137,8 @@ class OpenACCRoutineDecl final
 assert(LParenLoc.isValid() &&
"Cannot represent implicit name with this declaration");
 // Initialize the trailing storage.
-std::uninitialized_copy(Clauses.begin(), Clauses.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(Clauses,
+ getTrailingObjects());
 setClauseList(MutableArrayRef(getTrailingObjects(),
   Clauses.siz

[Lldb-commits] [clang] [lldb] [llvm] [mlir] [NFC][Support] Add llvm::uninitialized_copy (PR #138174)

2025-05-01 Thread Rahul Joshi via lldb-commits

https://github.com/jurahul updated 
https://github.com/llvm/llvm-project/pull/138174

>From b34e9b6c708dfbe097504804a0a85e1169518911 Mon Sep 17 00:00:00 2001
From: Rahul Joshi 
Date: Wed, 30 Apr 2025 23:47:37 -0700
Subject: [PATCH] [NFC][Support] Add llvm::uninitialized_copy

---
 clang/include/clang/AST/DeclCXX.h |  6 +-
 clang/include/clang/AST/DeclOpenACC.h |  9 +--
 clang/include/clang/AST/ExprCXX.h |  6 +-
 clang/include/clang/AST/OpenACCClause.h   | 72 +++
 clang/include/clang/AST/StmtOpenACC.h | 58 +++
 clang/include/clang/Sema/ParsedTemplate.h |  4 +-
 clang/lib/AST/Decl.cpp|  6 +-
 clang/lib/AST/DeclObjC.cpp|  4 +-
 clang/lib/AST/DeclTemplate.cpp| 11 ++-
 clang/lib/AST/Expr.cpp|  8 +--
 clang/lib/AST/ExprCXX.cpp | 16 ++---
 clang/lib/AST/OpenACCClause.cpp   | 13 ++--
 clang/lib/AST/StmtOpenACC.cpp |  4 +-
 clang/lib/AST/Type.cpp|  8 +--
 clang/tools/libclang/CXIndexDataConsumer.cpp  |  3 +-
 lldb/source/Utility/Checksum.cpp  |  4 +-
 llvm/include/llvm/ADT/ArrayRef.h  |  2 +-
 llvm/include/llvm/ADT/STLExtras.h |  5 ++
 llvm/lib/Analysis/ScalarEvolution.cpp | 10 +--
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp |  3 +-
 llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp   |  4 +-
 llvm/lib/DebugInfo/MSF/MSFBuilder.cpp |  6 +-
 llvm/lib/IR/AttributeImpl.h   |  2 +-
 llvm/lib/ObjectYAML/MinidumpEmitter.cpp   |  2 +-
 llvm/lib/Support/FoldingSet.cpp   |  4 +-
 .../AMDGPU/MCTargetDesc/AMDGPUMCExpr.cpp  |  2 +-
 llvm/lib/Transforms/IPO/LowerTypeTests.cpp|  7 +-
 .../unittests/Support/TrailingObjectsTest.cpp | 11 ++-
 mlir/include/mlir/IR/BuiltinAttributes.td |  2 +-
 mlir/include/mlir/Support/StorageUniquer.h|  4 +-
 .../Dialect/Affine/Analysis/NestedMatcher.cpp |  4 +-
 mlir/lib/IR/AffineMapDetail.h |  3 +-
 mlir/lib/IR/Location.cpp  |  8 +--
 mlir/lib/IR/MLIRContext.cpp   |  2 +-
 mlir/lib/IR/TypeDetail.h  |  3 +-
 mlir/lib/Tools/PDLL/AST/Nodes.cpp | 42 ---
 36 files changed, 154 insertions(+), 204 deletions(-)

diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index dd325815ee28d..20720115bf6c3 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -3861,8 +3861,7 @@ class UsingPackDecl final
   InstantiatedFrom ? InstantiatedFrom->getDeclName()
: DeclarationName()),
 InstantiatedFrom(InstantiatedFrom), NumExpansions(UsingDecls.size()) {
-std::uninitialized_copy(UsingDecls.begin(), UsingDecls.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(UsingDecls, getTrailingObjects());
   }
 
   void anchor() override;
@@ -4233,8 +4232,7 @@ class DecompositionDecl final
   : VarDecl(Decomposition, C, DC, StartLoc, LSquareLoc, nullptr, T, TInfo,
 SC),
 NumBindings(Bindings.size()) {
-std::uninitialized_copy(Bindings.begin(), Bindings.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(Bindings, getTrailingObjects());
 for (auto *B : Bindings) {
   B->setDecomposedDecl(this);
   if (B->isParameterPack() && B->getBinding()) {
diff --git a/clang/include/clang/AST/DeclOpenACC.h 
b/clang/include/clang/AST/DeclOpenACC.h
index 8c612fbf1ec07..905d9bf636ea1 100644
--- a/clang/include/clang/AST/DeclOpenACC.h
+++ b/clang/include/clang/AST/DeclOpenACC.h
@@ -18,6 +18,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/OpenACCClause.h"
 #include "clang/Basic/OpenACCKinds.h"
+#include "llvm/ADT/STLExtras.h"
 
 namespace clang {
 
@@ -85,8 +86,8 @@ class OpenACCDeclareDecl final
   : OpenACCConstructDecl(OpenACCDeclare, DC, OpenACCDirectiveKind::Declare,
  StartLoc, DirLoc, EndLoc) {
 // Initialize the trailing storage.
-std::uninitialized_copy(Clauses.begin(), Clauses.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(Clauses,
+ getTrailingObjects());
 
 setClauseList(MutableArrayRef(getTrailingObjects(),
   Clauses.size()));
@@ -136,8 +137,8 @@ class OpenACCRoutineDecl final
 assert(LParenLoc.isValid() &&
"Cannot represent implicit name with this declaration");
 // Initialize the trailing storage.
-std::uninitialized_copy(Clauses.begin(), Clauses.end(),
-getTrailingObjects());
+llvm::uninitialized_copy(Clauses,
+ getTrailingObjects());
 setClauseList(MutableArrayRef(getTrailingObjects(),
   Clauses.size()))

[Lldb-commits] [lldb] [lldb] print a notice when `source list` paging reaches the end of th… (PR #137515)

2025-05-01 Thread via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] 6aa963f - [lldb] Do not bump memory modificator ID when "internal" debugger memory is updated (#129092)

2025-05-01 Thread via lldb-commits

Author: Mikhail Zakharov
Date: 2025-05-01T11:10:41-07:00
New Revision: 6aa963f780d63d4c8fa80de97dd79c932bc35f4e

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

LOG: [lldb] Do not bump memory modificator ID when "internal" debugger memory 
is updated (#129092)

This change adds a setting `target.process.track-memory-cache-changes`.
Disabling this setting prevents invalidating and updating values in
`ValueObject::UpdateValueIfNeeded` when only "internal" debugger memory
is updated. Writing to "internal" debugger memory happens when, for
instance, expressions are evaluated by visualizers (pretty printers).
One of the examples when cache invalidation has a particularly heavy
impact is visualizations of some collections: in some collections
getting collection size is an expensive operation (it requires traversal
of the collection).
At the same time evaluating user expression with side effects (visible
to target, not only to debugger) will still bump memory ID because:

- If expression is evaluated via interpreter: it will cause write to
"non-internal" memory
- If expression is JIT-compiled: then to call the function LLDB will
write to "non-internal" stack memory

The downside of disabled `target.process.track-memory-cache-changes`
setting is that convenience variables won't reevaluate synthetic
children automatically.

-

Co-authored-by: Mikhail Zakharov 

Added: 
lldb/test/Shell/Expr/TestExprWithSideEffect.cpp
lldb/test/Shell/Expr/TestExprWithSideEffectOnConvenienceVar.cpp
lldb/test/Shell/Expr/TestExprWithSideEffectOnConvenienceVarWindows.cpp
lldb/test/Shell/Expr/TestProcessModificationIdOnExpr.cpp

Modified: 
lldb/include/lldb/Target/Memory.h
lldb/include/lldb/Target/Process.h
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Commands/Options.td
lldb/source/Target/Memory.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/TargetProperties.td
lldb/test/API/commands/settings/TestSettings.py

Removed: 




diff  --git a/lldb/include/lldb/Target/Memory.h 
b/lldb/include/lldb/Target/Memory.h
index 2d1489a2c96ea..864ef6ca00802 100644
--- a/lldb/include/lldb/Target/Memory.h
+++ b/lldb/include/lldb/Target/Memory.h
@@ -125,6 +125,8 @@ class AllocatedMemoryCache {
 
   bool DeallocateMemory(lldb::addr_t ptr);
 
+  bool IsInCache(lldb::addr_t addr) const;
+
 protected:
   typedef std::shared_ptr AllocatedBlockSP;
 
@@ -133,7 +135,7 @@ class AllocatedMemoryCache {
 
   // Classes that inherit from MemoryCache can see and modify these
   Process &m_process;
-  std::recursive_mutex m_mutex;
+  mutable std::recursive_mutex m_mutex;
   typedef std::multimap PermissionsToBlockMap;
   PermissionsToBlockMap m_memory_map;
 

diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index f5ee01d3fa713..536a69fb89759 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -111,6 +111,7 @@ class ProcessProperties : public Properties {
   void SetOSPluginReportsAllThreads(bool does_report);
   bool GetSteppingRunsAllThreads() const;
   FollowForkMode GetFollowForkMode() const;
+  bool TrackMemoryCacheChanges() const;
 
 protected:
   Process *m_process; // Can be nullptr for global ProcessProperties
@@ -312,6 +313,18 @@ class ProcessModID {
 return lldb::EventSP();
   }
 
+  void Dump(Stream &stream) const {
+stream.Format("ProcessModID:\n"
+  "  m_stop_id: {0}\n  m_last_natural_stop_id: {1}\n"
+  "  m_resume_id: {2}\n  m_memory_id: {3}\n"
+  "  m_last_user_expression_resume: {4}\n"
+  "  m_running_user_expression: {5}\n"
+  "  m_running_utility_function: {6}\n",
+  m_stop_id, m_last_natural_stop_id, m_resume_id, m_memory_id,
+  m_last_user_expression_resume, m_running_user_expression,
+  m_running_utility_function);
+  }
+
 private:
   uint32_t m_stop_id = 0;
   uint32_t m_last_natural_stop_id = 0;

diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index ed80c854ed66e..d0f5eaf2dfd9a 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -1388,6 +1388,9 @@ class CommandObjectProcessStatus : public 
CommandObjectParsed {
   case 'v':
 m_verbose = true;
 break;
+  case 'd':
+m_dump = true;
+break;
   default:
 llvm_unreachable("Unimplemented option");
   }
@@ -1397,6 +1400,7 @@ class CommandObjectProcessStatus : public 
CommandObjectParsed {
 
 void OptionParsingStarting(ExecutionContext *execution_context) override {
   m_verbose = false;
+  m_dump = false;
 }
 

[Lldb-commits] [lldb] [lldb] Do not bump memory modificator ID when "internal" debugger memory is updated (PR #129092)

2025-05-01 Thread via lldb-commits

github-actions[bot] wrote:



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


[Lldb-commits] [lldb] [lldb] Do not bump memory modificator ID when "internal" debugger memory is updated (PR #129092)

2025-05-01 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Do not bump memory modificator ID when "internal" debugger memory is updated (PR #129092)

2025-05-01 Thread via lldb-commits

jimingham wrote:

Done.  Thanks for working on this.

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


[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

2025-05-01 Thread via lldb-commits

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

Sorry for more round trips, but can you remove the no-SBError overload.  Adding 
that was really a poor choice on my part (which I seem to want to repeat for 
some reason...)

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


[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

2025-05-01 Thread via lldb-commits


@@ -105,6 +105,10 @@ class LLDB_API SBThreadPlan {
   SBThreadPlan QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
  bool first_insn, SBError &error);
 
+  SBThreadPlan QueueThreadPlanForStepSingleInstruction(bool step_over);

jimingham wrote:

Yes, I should have thought of that.  We should leave out the no-error overload. 
 You can make that work by checking SBThreadPlan::IsValid, but you don't get 
the error message and it's much easier to forget to do that.

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


[Lldb-commits] [clang] [lldb] [clang] Add `__ptrauth_restricted_intptr` qualifier (PR #137580)

2025-05-01 Thread Aaron Ballman via lldb-commits

AaronBallman wrote:

> > Perhaps silly initial question: why do we need a whole different qualifier 
> > for this? Why can you not write `__ptrauth uintptr_t foo`?
> 
> Not a silly question, back when first implemented we spent time thinking 
> about this.
> 
> The concern was basically `T* __ptrauth(...)` can represent all valid 
> pointers, but `[u]intptr_t __ptrauth(...)` cannot represent all possible 
> integers, so we wanted the spelling to be very clear that this is not really 
> an int so making the annotation clear that it restricts what the int can do 
> seemed valuable. There's also the hypothetical hazard of `SomeTemplateParam 
> __ptrauth(...)` unexpectedly applying to an integer type so the spelling 
> difference is a hazard protection there.

Thank you for the explanation! This is a tough situation in some ways. We 
already went over all the reasons adding a new qualifier is a challenge when 
adding `__ptrauth`, so there's a very real question of whether the problems 
solved are sufficiently compelling to be worth having a second qualifier that's 
basically the same thing as the first. Qualifiers are intended to compose with 
other types in the type system, so this is a bit like there being two different 
`const` qualifiers, one for pointers and one for non-pointers.

I realize you've got downstream users making use of this additional qualifier. 
Can you mention how prevalent the use is? Do you have evidence that the second 
qualifier catches issues for users, or was this mostly a theoretical problem 
that you wanted to head off before users ran into it?

I'd like to avoid another RFC, but this is a sufficiently large extension that 
it may warrant it. My inclination is that this problem can be solved via good 
diagnostics with the other qualifier and so we don't really need an additional 
qualifier.

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


[Lldb-commits] [lldb] [llvm] [lldb] Disable statusline on Windows (PR #138111)

2025-05-01 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Fix block address resolution for functions in multiple sections (PR #137955)

2025-05-01 Thread David Spickett via lldb-commits


@@ -0,0 +1,102 @@
+# REQUIRES: x86, lld
+
+# RUN: split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %t/file.s -o %t/file.o
+# RUN: ld.lld %t/file.o -o %t/file.out -T %t/file.lds
+# RUN: %lldb %t/file.out -o "disassemble --name func1" -o exit | FileCheck %s
+
+# CHECK:  (lldb) disassemble --name func1
+# CHECK:  file.out`func1:
+# CHECK-NEXT: file.out[0x0] <+0>: int$0x2a
+# CHECK:  file.out`func1:
+# CHECK-NEXT: file.out[0x1000] <+4096>: int$0x2f
+
+
+#--- file.lds
+PHDRS {

DavidSpickett wrote:

This and the assembly need some more comments to point out why these are in 
this order and what triggers the tricky situations you're handling here.

https://github.com/llvm/llvm-project/pull/137955
___
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] Migrate ScopesRequest to structured types (PR #138116)

2025-05-01 Thread Ebuka Ezike via lldb-commits

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

None

>From 437c69ffb1f86733649a82aa2a991360dd40fd7c Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 29 Apr 2025 18:19:18 +0100
Subject: [PATCH 1/4] [lldb][lldb-dap] Migrate 'Scopes' to structured types.

---
 lldb/tools/lldb-dap/Handler/RequestHandler.h  | 11 +++
 .../lldb-dap/Handler/ScopesRequestHandler.cpp |  6 ++
 .../lldb-dap/Protocol/ProtocolRequests.cpp| 13 +++
 .../lldb-dap/Protocol/ProtocolRequests.h  | 13 +++
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp | 88 +--
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  | 80 +++--
 6 files changed, 199 insertions(+), 12 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h 
b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index fa3d76ed4a125..49ad8dd80c68e 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -423,6 +423,17 @@ class PauseRequestHandler : public LegacyRequestHandler {
   void operator()(const llvm::json::Object &request) const override;
 };
 
+class ScopesRequestHandler2 final
+: public RequestHandler> {
+public:
+  using RequestHandler::RequestHandler;
+  static llvm::StringLiteral GetCommand() { return "scopes"; }
+
+  llvm::Expected
+  Run(const protocol::ScopesArguments &args) const override;
+};
+
 class ScopesRequestHandler : public LegacyRequestHandler {
 public:
   using LegacyRequestHandler::LegacyRequestHandler;
diff --git a/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
index 7d1608f59f9a4..721230e2525b2 100644
--- a/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
@@ -64,6 +64,12 @@ namespace lldb_dap {
 // "required": [ "body" ]
 //   }]
 // }
+
+llvm::Expected
+ScopesRequestHandler2::Run(const protocol::ScopesArguments &args) const {
+  // lldb::SBFrame frame = dap.GetLLDBFrame()
+  return llvm::createStringError("something");
+};
 void ScopesRequestHandler::operator()(const llvm::json::Object &request) const 
{
   llvm::json::Object response;
   FillResponse(request, response);
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
index 61fea66490c30..d5630424ebdf7 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp
@@ -260,6 +260,19 @@ bool fromJSON(const json::Value &Params, 
LaunchRequestArguments &LRA,
  O.mapOptional("runInTerminal", LRA.runInTerminal) &&
  parseEnv(Params, LRA.env, P) && parseTimeout(Params, LRA.timeout, P);
 }
+bool fromJSON(const llvm::json::Value &Params, ScopesArguments &SCA,
+  llvm::json::Path P) {
+  json::ObjectMapper O(Params, P);
+  return O && O.map("frameId", SCA.frameId);
+}
+
+llvm::json::Value toJSON(const ScopesResponseBody &SCR) {
+  llvm::json::Array body;
+  for (const Scope &scope : SCR.scopes) {
+body.emplace_back(toJSON(scope));
+  }
+  return body;
+}
 
 bool fromJSON(const json::Value &Params, SourceArguments &SA, json::Path P) {
   json::ObjectMapper O(Params, P);
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h 
b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
index 33f93cc38799a..9ac5468608e1e 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.h
@@ -294,6 +294,19 @@ bool fromJSON(const llvm::json::Value &, 
LaunchRequestArguments &,
 /// field is required.
 using LaunchResponseBody = VoidResponse;
 
+struct ScopesArguments {
+  /// Retrieve the scopes for the stack frame identified by `frameId`. The
+  /// `frameId` must have been obtained in the current suspended state. See
+  /// 'Lifetime of Object References' in the Overview section for details.
+  uint64_t frameId;
+};
+bool fromJSON(const llvm::json::Value &, ScopesArguments &, llvm::json::Path);
+
+struct ScopesResponseBody {
+  std::vector scopes;
+};
+llvm::json::Value toJSON(const ScopesResponseBody &);
+
 /// Arguments for `source` request.
 struct SourceArguments {
   /// Specifies the source content to load. Either `source.path` or
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
index e64998c4ca488..0f382a8dc66c3 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
@@ -16,17 +16,18 @@ using namespace llvm;
 
 namespace lldb_dap::protocol {
 
-bool fromJSON(const json::Value &Params, PresentationHint &PH, json::Path P) {
+bool fromJSON(const json::Value &Params, Source::PresentationHint &PH,
+  json::Path P) {
   auto rawHint = Params.getAsString();
   if (!rawHint) {
 P.report("expected a string");
 return false;
   }
-  std::optional hint =
-  StringSwitch>(*rawHint)
-  .Case("normal", ePresentatio

[Lldb-commits] [lldb] [lldb][lldb-dap] Migrate ScopesRequest to structured types (PR #138116)

2025-05-01 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)


Changes



---

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


14 Files Affected:

- (modified) lldb/tools/lldb-dap/DAP.cpp (+1-14) 
- (modified) lldb/tools/lldb-dap/DAP.h (+1-3) 
- (modified) lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp (+3-1) 
- (modified) lldb/tools/lldb-dap/Handler/DataBreakpointInfoRequestHandler.cpp 
(+4-1) 
- (modified) lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp (+4-1) 
- (modified) lldb/tools/lldb-dap/Handler/RequestHandler.h (+7-3) 
- (modified) lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp (+56-65) 
- (modified) lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp (+4-1) 
- (modified) lldb/tools/lldb-dap/JSONUtils.cpp (-85) 
- (modified) lldb/tools/lldb-dap/JSONUtils.h (-21) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp (+14) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolRequests.h (+13) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp (+82-6) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolTypes.h (+74-6) 


``diff
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 4cb0d8e49004c..cad120ddd0621 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -514,9 +514,7 @@ lldb::SBThread DAP::GetLLDBThread(const llvm::json::Object 
&arguments) {
   return target.GetProcess().GetThreadByID(tid);
 }
 
-lldb::SBFrame DAP::GetLLDBFrame(const llvm::json::Object &arguments) {
-  const uint64_t frame_id =
-  GetInteger(arguments, "frameId").value_or(UINT64_MAX);
+lldb::SBFrame DAP::GetLLDBFrame(uint64_t frame_id) {
   lldb::SBProcess process = target.GetProcess();
   // Upper 32 bits is the thread index ID
   lldb::SBThread thread =
@@ -525,17 +523,6 @@ lldb::SBFrame DAP::GetLLDBFrame(const llvm::json::Object 
&arguments) {
   return thread.GetFrameAtIndex(GetLLDBFrameID(frame_id));
 }
 
-llvm::json::Value DAP::CreateTopLevelScopes() {
-  llvm::json::Array scopes;
-  scopes.emplace_back(
-  CreateScope("Locals", VARREF_LOCALS, variables.locals.GetSize(), false));
-  scopes.emplace_back(CreateScope("Globals", VARREF_GLOBALS,
-  variables.globals.GetSize(), false));
-  scopes.emplace_back(CreateScope("Registers", VARREF_REGS,
-  variables.registers.GetSize(), false));
-  return llvm::json::Value(std::move(scopes));
-}
-
 ReplMode DAP::DetectReplMode(lldb::SBFrame frame, std::string &expression,
  bool partial_expression) {
   // Check for the escape hatch prefix.
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index 88eedb0860cf1..d0b4e3987b88c 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -275,9 +275,7 @@ struct DAP {
   lldb::SBThread GetLLDBThread(lldb::tid_t id);
   lldb::SBThread GetLLDBThread(const llvm::json::Object &arguments);
 
-  lldb::SBFrame GetLLDBFrame(const llvm::json::Object &arguments);
-
-  llvm::json::Value CreateTopLevelScopes();
+  lldb::SBFrame GetLLDBFrame(uint64_t frame_id);
 
   void PopulateExceptionBreakpoints();
 
diff --git a/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp 
b/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp
index c72fc5686cd5b..65686cd23b243 100644
--- a/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/CompletionsHandler.cpp
@@ -136,7 +136,9 @@ void CompletionsRequestHandler::operator()(
   const auto *arguments = request.getObject("arguments");
 
   // If we have a frame, try to set the context for variable completions.
-  lldb::SBFrame frame = dap.GetLLDBFrame(*arguments);
+  const uint64_t frame_id =
+  GetInteger(*arguments, "frameId").value_or(UINT64_MAX);
+  lldb::SBFrame frame = dap.GetLLDBFrame(frame_id);
   if (frame.IsValid()) {
 frame.GetThread().GetProcess().SetSelectedThread(frame.GetThread());
 frame.GetThread().SetSelectedFrame(frame.GetFrameID());
diff --git a/lldb/tools/lldb-dap/Handler/DataBreakpointInfoRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DataBreakpointInfoRequestHandler.cpp
index 4d920f8556254..76407d230438d 100644
--- a/lldb/tools/lldb-dap/Handler/DataBreakpointInfoRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DataBreakpointInfoRequestHandler.cpp
@@ -118,7 +118,10 @@ void DataBreakpointInfoRequestHandler::operator()(
   const auto variablesReference =
   GetInteger(arguments, "variablesReference").value_or(0);
   llvm::StringRef name = GetString(arguments, "name").value_or("");
-  lldb::SBFrame frame = dap.GetLLDBFrame(*arguments);
+
+  const uint64_t frame_id =
+  GetInteger(arguments, "frameId").value_or(UINT64_MAX);
+  lldb::SBFrame frame = dap.GetLLDBFrame(frame_id);
   lldb::SBValue variable = dap.variables.FindVariable(variablesReference, 
name);
   std::string addr, size;
 
diff --git a/lldb/tools/lldb-dap/Handler/EvaluateR

[Lldb-commits] [lldb] [LLDB] Ptrace seize dead process (PR #137041)

2025-05-01 Thread Jacob Lalonde via lldb-commits


@@ -1304,6 +1304,9 @@ void GDBRemoteCommunicationServerCommon::
 if (!abi.empty())
   response.Printf("elf_abi:%s;", abi.c_str());
 response.Printf("ptrsize:%d;", proc_arch.GetAddressByteSize());
+std::optional non_resumable = proc_info.IsNonResumable();
+if (non_resumable)
+  response.Printf("non_resumable:%d", *non_resumable);

Jlalond wrote:

Your intuition is correct, for now this works, but in the future (if we want to 
support `O_TRACEEXIT`), we would need to update this. Currently I can get away 
with attach returning a process info that we can't resume. 

This is still very WIP, as I'm trying to sort with Greg the gotcha's. I will 
break this patch up into pieces soon :)

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


[Lldb-commits] [lldb] 09488bc - [lldb] Disable statusline on Windows (#138111)

2025-05-01 Thread via lldb-commits

Author: David Spickett
Date: 2025-05-01T16:40:47+01:00
New Revision: 09488bcfba77d1a16b0b83c2d6b1135e5e7d5302

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

LOG: [lldb] Disable statusline on Windows (#138111)

Something to do with control code handling in Windows terminals breaks
the statusline in various ways. It makes LLDB unusable and even if you
set the setting to disable statusline, it's too late, and the terminal
session is now in a weird state.

See https://github.com/llvm/llvm-project/issues/134846 for more details.

Until we figure this out, don't allow it to be used on Windows.

Added: 


Modified: 
lldb/source/Core/CoreProperties.td
lldb/source/Core/Debugger.cpp
llvm/docs/ReleaseNotes.md

Removed: 




diff  --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index bfba26f85748f..2498841b47d9f 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -177,7 +177,7 @@ let Definition = "debugger" in {
   def ShowStatusline: Property<"show-statusline", "Boolean">,
 Global,
 DefaultTrue,
-Desc<"Whether to show a statusline at the bottom of the terminal.">;
+Desc<"Whether to show a statusline at the bottom of the terminal (not 
supported on Windows).">;
   def Separator : Property<"separator", "String">,
   Global,
   DefaultStringValue<"│ ">,

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 25bb42bad152c..89018da8c685d 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -2031,6 +2031,9 @@ void Debugger::CancelForwardEvents(const ListenerSP 
&listener_sp) {
 }
 
 bool Debugger::StatuslineSupported() {
+// We have trouble with the contol codes on Windows, see
+// https://github.com/llvm/llvm-project/issues/134846.
+#ifndef _WIN32
   if (GetShowStatusline()) {
 if (lldb::LockableStreamFileSP stream_sp = GetOutputStreamSP()) {
   File &file = stream_sp->GetUnlockedFile();
@@ -2038,6 +2041,7 @@ bool Debugger::StatuslineSupported() {
  file.GetIsTerminalWithColors();
 }
   }
+#endif
   return false;
 }
 

diff  --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 3972e028abfd6..e3468eae22800 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -249,7 +249,8 @@ Changes to LLDB
 * A statusline was added to command-line LLDB to show progress events and
   information about the current state of the debugger at the bottom of the
   terminal. This is on by default and can be configured using the
-  `show-statusline` and `statusline-format` settings.
+  `show-statusline` and `statusline-format` settings. It is not currently
+  supported on Windows.
 * The `min-gdbserver-port` and `max-gdbserver-port` options have been removed
   from `lldb-server`'s platform mode. Since the changes to `lldb-server`'s port
   handling in LLDB 20, these options have had no effect.



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


[Lldb-commits] [lldb] [LLDB] Ptrace seize dead process (PR #137041)

2025-05-01 Thread David Spickett via lldb-commits


@@ -1304,6 +1304,9 @@ void GDBRemoteCommunicationServerCommon::
 if (!abi.empty())
   response.Printf("elf_abi:%s;", abi.c_str());
 response.Printf("ptrsize:%d;", proc_arch.GetAddressByteSize());
+std::optional non_resumable = proc_info.IsNonResumable();
+if (non_resumable)
+  response.Printf("non_resumable:%d", *non_resumable);

DavidSpickett wrote:

Cool, so something would get added to the remote protocol to make this work but 
exactly what we can decide later.

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


[Lldb-commits] [lldb] [llvm] [lldb] Disable statusline on Windows (PR #138111)

2025-05-01 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb] Disable statusline on Windows (PR #138111)

2025-05-01 Thread David Spickett via lldb-commits

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

Something to do with control code handling in Windows terminals breaks the 
statusline in various ways. It makes LLDB unusable and even if you set the 
setting to disable statusline, it's too late, and the terminal session is now 
in a weird state.

See https://github.com/llvm/llvm-project/issues/134846 for more details.

Until we figure this out, don't allow it to be used on Windows.

>From 12ad43188696a60e317b07d3d100fe841754c232 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Thu, 1 May 2025 10:44:29 +
Subject: [PATCH] [lldb] Disable statusline on Windows

Something to do with control code handling in Windows terminals
breaks the statusline in various ways. It makes LLDB unusable and
even if you set the setting to disable statusline, it's too late,
and the terminal session is now in a weird state.

See https://github.com/llvm/llvm-project/issues/134846
for more details.

Until we figure this out, don't allow it to be used on Windows.
---
 lldb/source/Core/CoreProperties.td | 2 +-
 lldb/source/Core/Debugger.cpp  | 4 
 llvm/docs/ReleaseNotes.md  | 3 ++-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index bfba26f85748f..2498841b47d9f 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -177,7 +177,7 @@ let Definition = "debugger" in {
   def ShowStatusline: Property<"show-statusline", "Boolean">,
 Global,
 DefaultTrue,
-Desc<"Whether to show a statusline at the bottom of the terminal.">;
+Desc<"Whether to show a statusline at the bottom of the terminal (not 
supported on Windows).">;
   def Separator : Property<"separator", "String">,
   Global,
   DefaultStringValue<"│ ">,
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 25bb42bad152c..89018da8c685d 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -2031,6 +2031,9 @@ void Debugger::CancelForwardEvents(const ListenerSP 
&listener_sp) {
 }
 
 bool Debugger::StatuslineSupported() {
+// We have trouble with the contol codes on Windows, see
+// https://github.com/llvm/llvm-project/issues/134846.
+#ifndef _WIN32
   if (GetShowStatusline()) {
 if (lldb::LockableStreamFileSP stream_sp = GetOutputStreamSP()) {
   File &file = stream_sp->GetUnlockedFile();
@@ -2038,6 +2041,7 @@ bool Debugger::StatuslineSupported() {
  file.GetIsTerminalWithColors();
 }
   }
+#endif
   return false;
 }
 
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 3972e028abfd6..e3468eae22800 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -249,7 +249,8 @@ Changes to LLDB
 * A statusline was added to command-line LLDB to show progress events and
   information about the current state of the debugger at the bottom of the
   terminal. This is on by default and can be configured using the
-  `show-statusline` and `statusline-format` settings.
+  `show-statusline` and `statusline-format` settings. It is not currently
+  supported on Windows.
 * The `min-gdbserver-port` and `max-gdbserver-port` options have been removed
   from `lldb-server`'s platform mode. Since the changes to `lldb-server`'s port
   handling in LLDB 20, these options have had no effect.

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


[Lldb-commits] [lldb] [llvm] [lldb] Disable statusline on Windows (PR #138111)

2025-05-01 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

Something to do with control code handling in Windows terminals breaks the 
statusline in various ways. It makes LLDB unusable and even if you set the 
setting to disable statusline, it's too late, and the terminal session is now 
in a weird state.

See https://github.com/llvm/llvm-project/issues/134846 for more details.

Until we figure this out, don't allow it to be used on Windows.

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


3 Files Affected:

- (modified) lldb/source/Core/CoreProperties.td (+1-1) 
- (modified) lldb/source/Core/Debugger.cpp (+4) 
- (modified) llvm/docs/ReleaseNotes.md (+2-1) 


``diff
diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index bfba26f85748f..2498841b47d9f 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -177,7 +177,7 @@ let Definition = "debugger" in {
   def ShowStatusline: Property<"show-statusline", "Boolean">,
 Global,
 DefaultTrue,
-Desc<"Whether to show a statusline at the bottom of the terminal.">;
+Desc<"Whether to show a statusline at the bottom of the terminal (not 
supported on Windows).">;
   def Separator : Property<"separator", "String">,
   Global,
   DefaultStringValue<"│ ">,
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 25bb42bad152c..89018da8c685d 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -2031,6 +2031,9 @@ void Debugger::CancelForwardEvents(const ListenerSP 
&listener_sp) {
 }
 
 bool Debugger::StatuslineSupported() {
+// We have trouble with the contol codes on Windows, see
+// https://github.com/llvm/llvm-project/issues/134846.
+#ifndef _WIN32
   if (GetShowStatusline()) {
 if (lldb::LockableStreamFileSP stream_sp = GetOutputStreamSP()) {
   File &file = stream_sp->GetUnlockedFile();
@@ -2038,6 +2041,7 @@ bool Debugger::StatuslineSupported() {
  file.GetIsTerminalWithColors();
 }
   }
+#endif
   return false;
 }
 
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 3972e028abfd6..e3468eae22800 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -249,7 +249,8 @@ Changes to LLDB
 * A statusline was added to command-line LLDB to show progress events and
   information about the current state of the debugger at the bottom of the
   terminal. This is on by default and can be configured using the
-  `show-statusline` and `statusline-format` settings.
+  `show-statusline` and `statusline-format` settings. It is not currently
+  supported on Windows.
 * The `min-gdbserver-port` and `max-gdbserver-port` options have been removed
   from `lldb-server`'s platform mode. Since the changes to `lldb-server`'s port
   handling in LLDB 20, these options have had no effect.

``




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


[Lldb-commits] [lldb] [llvm] [lldb] Disable statusline on Windows (PR #138111)

2025-05-01 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Tests are pexpect so they're not running on Windows anyway.

https://github.com/llvm/llvm-project/pull/138111
___
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][frontend] Require invocation to construct `CompilerInstance` (PR #137668)

2025-05-01 Thread Jan Svoboda via lldb-commits

https://github.com/jansvoboda11 closed 
https://github.com/llvm/llvm-project/pull/137668
___
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 raciness in launch and attach tests (PR #137920)

2025-05-01 Thread via lldb-commits

kusmour wrote:

> Also, the configuration done event can be emitted at any time during 
> initialization. It could even be emitted before the actual launching and 
> attaching happen.

No, this is something we can control. `configurationDone` request will only 
emit after `initialized` event. And lldb-dap only sends that after 
launch/attach response. (This is also not complying with the DAP, see below)

> The DAP server can respond to these events asynchronously but today the 
> lldb-dap is single threaded for handling each of these responses.

It's important to point out that in the DAP specification:

> After the response to `configurationDone` is sent, the debug adapter may 
> respond to the `launch` or `attach` request, and then the debug session has 
> started.

Technically the response of launch/attach should be the end of the chain. But 
because of the single threaded handling we can't do this. I don't think this is 
impacting the client side (at least for VSCode, it doesn't seem to do anything 
special upon an launch/attach response). But this suggests that lldb-dap should 
be able to async handling the requests/events.

https://github.com/llvm/llvm-project/pull/137920
___
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 raciness in launch and attach tests (PR #137920)

2025-05-01 Thread John Harrison via lldb-commits

ashgti wrote:

> Technically the response of launch/attach should be the end of the chain.  

Thats not how its implemented in VS Code at least:

* `initialize` is sent then `launch` or `attach` 
https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/debug/browser/debugService.ts#L674-L675,
 these two happen sequentially and its not coordinating this with the 
`initialized` event or `configurationDone` request.
*  When 
[`initialized`](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Initialized)
 is received, it triggers the setBreakpoints then `configurationDone` 
https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/debug/browser/debugSession.ts#L1063-L1091

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


[Lldb-commits] [lldb] [LLDB] Fix `ValueObject::AddressOf()` return value (PR #137688)

2025-05-01 Thread Ilia Kuklin via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Fix `ValueObject::AddressOf()` return value (PR #137688)

2025-05-01 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ilia Kuklin (kuilpd)


Changes

`ValueObject::AddressOf()` used to return address as a value which has it's own 
address, allowing to do `value.AddressOf().AddressOf()`.
This patch makes the return address a simple const value.

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


2 Files Affected:

- (modified) lldb/source/ValueObject/ValueObject.cpp (+5-2) 
- (modified) lldb/test/API/python_api/sbvalue_const_addrof/main.cpp (+25-22) 


``diff
diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index 8741cb7343166..1d8d112ccb0f4 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -2966,10 +2966,13 @@ ValueObjectSP ValueObject::AddressOf(Status &error) {
 std::string name(1, '&');
 name.append(m_name.AsCString(""));
 ExecutionContext exe_ctx(GetExecutionContextRef());
+
+lldb::DataBufferSP buffer(
+new lldb_private::DataBufferHeap(&addr, sizeof(lldb::addr_t)));
 m_addr_of_valobj_sp = ValueObjectConstResult::Create(
 exe_ctx.GetBestExecutionContextScope(),
-compiler_type.GetPointerType(), ConstString(name.c_str()), addr,
-eAddressTypeInvalid, m_data.GetAddressByteSize());
+compiler_type.GetPointerType(), ConstString(name.c_str()), buffer,
+endian::InlHostByteOrder(), exe_ctx.GetAddressByteSize());
   }
 } break;
 default:
diff --git a/lldb/test/API/python_api/sbvalue_const_addrof/main.cpp 
b/lldb/test/API/python_api/sbvalue_const_addrof/main.cpp
index 318a45bc21a85..ae6abc8613406 100644
--- a/lldb/test/API/python_api/sbvalue_const_addrof/main.cpp
+++ b/lldb/test/API/python_api/sbvalue_const_addrof/main.cpp
@@ -3,21 +3,21 @@
 
 struct RegisterContext
 {
-uintptr_t r0;
-uintptr_t r1;
-uintptr_t r2;
-uintptr_t r3;
-uintptr_t r4;
-uintptr_t pc;
-uintptr_t fp;
-uintptr_t sp;
+  uintptr_t r0;
+  uintptr_t r1;
+  uintptr_t r2;
+  uintptr_t r3;
+  uintptr_t r4;
+  uintptr_t pc;
+  uintptr_t fp;
+  uintptr_t sp;
 };
 
 struct ThreadInfo {
-uint32_t tid;
-const char *name;
-RegisterContext regs;
-ThreadInfo *next;
+  uint32_t tid;
+  const char *name;
+  RegisterContext regs;
+  ThreadInfo *next;
 };
 int main (int argc, char const *argv[], char const *envp[]);
 
@@ -27,14 +27,17 @@ ThreadInfo *g_thread_list_ptr = &g_thread1;
 
 int main (int argc, char const *argv[], char const *envp[])
 {
-printf ("g_thread_list is %p\n", g_thread_list_ptr);
-return 0; //% v = 
self.dbg.GetSelectedTarget().FindFirstGlobalVariable('g_thread_list_ptr')
-//% v_gla = v.GetChildMemberWithName('regs').GetLoadAddress()
-//% v_aof = 
v.GetChildMemberWithName('regs').AddressOf().GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS)
-//% expr = '(%s)0x%x' % (v.GetType().GetName(), v.GetValueAsUnsigned(0))
-//% e = v.CreateValueFromExpression('e', expr)
-//% e_gla = e.GetChildMemberWithName('regs').GetLoadAddress()
-//% e_aof = 
e.GetChildMemberWithName('regs').AddressOf().GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS)
-//% self.assertTrue(v_gla == e_gla, "GetLoadAddress() differs")
-//% self.assertTrue(v_aof == e_aof, "AddressOf() differs")
+  // clang-format off
+  printf ("g_thread_list is %p\n", g_thread_list_ptr);
+  return 0; //% v = 
self.dbg.GetSelectedTarget().FindFirstGlobalVariable('g_thread_list_ptr')
+  //% self.assertTrue(v.AddressOf().IsValid())
+  //% self.assertFalse(v.AddressOf().AddressOf().IsValid())
+  //% v_gla = v.GetChildMemberWithName('regs').GetLoadAddress()
+  //% v_aof = 
v.GetChildMemberWithName('regs').AddressOf().GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS)
+  //% expr = '(%s)0x%x' % (v.GetType().GetName(), v.GetValueAsUnsigned(0))
+  //% e = v.CreateValueFromExpression('e', expr)
+  //% e_gla = e.GetChildMemberWithName('regs').GetLoadAddress()
+  //% e_aof = 
e.GetChildMemberWithName('regs').AddressOf().GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS)
+  //% self.assertTrue(v_gla == e_gla, "GetLoadAddress() differs")
+  //% self.assertTrue(v_aof == e_aof, "AddressOf() differs")
 }

``




https://github.com/llvm/llvm-project/pull/137688
___
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 raciness in launch and attach tests (PR #137920)

2025-05-01 Thread John Harrison via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb/Host] Enable inheriting "non-inheritable" FDs (PR #126935)

2025-05-01 Thread David Spickett via lldb-commits


@@ -122,8 +123,14 @@ struct ForkLaunchInfo {
 ExitWithError(error_fd, "close");
   break;
 case FileAction::eFileActionDuplicate:
-  if (dup2(action.fd, action.arg) == -1)
-ExitWithError(error_fd, "dup2");
+  if (action.fd != action.arg) {

DavidSpickett wrote:

In what circumstances are action.fd and action.arg the same, or not the same?

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


[Lldb-commits] [lldb] [LLDB][SBSaveCoreOptions] Add new API to expose the expected core size in bytes (PR #138169)

2025-05-01 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/138169

>From ef04502d17c36044cd5fb96f333c328c8215f354 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 1 May 2025 10:11:10 -0700
Subject: [PATCH 1/2] Add new API to expose the expected size in bytes of a
 core before generation

---
 lldb/include/lldb/API/SBSaveCoreOptions.h | 13 
 lldb/include/lldb/Symbol/SaveCoreOptions.h|  2 ++
 lldb/source/API/SBSaveCoreOptions.cpp |  5 +
 lldb/source/Symbol/SaveCoreOptions.cpp| 18 
 .../TestSBSaveCoreOptions.py  | 21 +++
 .../sbsavecoreoptions/basic_minidump.yaml |  5 +
 6 files changed, 64 insertions(+)

diff --git a/lldb/include/lldb/API/SBSaveCoreOptions.h 
b/lldb/include/lldb/API/SBSaveCoreOptions.h
index c6d2ab6099b3c..4c051353a714e 100644
--- a/lldb/include/lldb/API/SBSaveCoreOptions.h
+++ b/lldb/include/lldb/API/SBSaveCoreOptions.h
@@ -119,6 +119,19 @@ class LLDB_API SBSaveCoreOptions {
   ///   an empty collection will be returned.
   SBThreadCollection GetThreadsToSave() const;
 
+  /// Get the current total number of bytes the core is expected to be but not
+  /// including the overhead of the core file format. Requires a Process and 
+  /// Style to be specified.
+  /// 
+  /// \note
+  ///   This can cause some modification of the underlying data store 
+  ///   as regions with no permissions, or invalid permissions will be removed
+  ///   and stacks will be minified up to their stack pointer + the redzone.
+  ///
+  /// \returns
+  ///   The expected size of the data contained in the core in bytes.
+  uint64_t GetCurrentSizeInBytes(SBError &error);
+
   /// Reset all options.
   void Clear();
 
diff --git a/lldb/include/lldb/Symbol/SaveCoreOptions.h 
b/lldb/include/lldb/Symbol/SaveCoreOptions.h
index bcf0087fbea5c..319d44a6b0c87 100644
--- a/lldb/include/lldb/Symbol/SaveCoreOptions.h
+++ b/lldb/include/lldb/Symbol/SaveCoreOptions.h
@@ -49,6 +49,8 @@ class SaveCoreOptions {
 
   lldb_private::ThreadCollection::collection GetThreadsToSave() const;
 
+  uint64_t GetCurrentSizeInBytes(Status &error);
+
   void Clear();
 
 private:
diff --git a/lldb/source/API/SBSaveCoreOptions.cpp 
b/lldb/source/API/SBSaveCoreOptions.cpp
index 35b9da569dfa1..b67df513fe91b 100644
--- a/lldb/source/API/SBSaveCoreOptions.cpp
+++ b/lldb/source/API/SBSaveCoreOptions.cpp
@@ -114,6 +114,11 @@ void SBSaveCoreOptions::Clear() {
   m_opaque_up->Clear();
 }
 
+uint64_t SBSaveCoreOptions::GetCurrentSizeInBytes(SBError &error) {
+  LLDB_INSTRUMENT_VA(this, error);
+  return m_opaque_up->GetCurrentSizeInBytes(error.ref());
+}
+
 lldb_private::SaveCoreOptions &SBSaveCoreOptions::ref() const {
   return *m_opaque_up.get();
 }
diff --git a/lldb/source/Symbol/SaveCoreOptions.cpp 
b/lldb/source/Symbol/SaveCoreOptions.cpp
index c9f6efeb25d22..1da3e1cc9f834 100644
--- a/lldb/source/Symbol/SaveCoreOptions.cpp
+++ b/lldb/source/Symbol/SaveCoreOptions.cpp
@@ -145,6 +145,24 @@ SaveCoreOptions::GetThreadsToSave() const {
   return thread_collection;
 }
 
+uint64_t SaveCoreOptions::GetCurrentSizeInBytes(Status &error) {
+  if (!m_process_sp) {
+error = Status::FromErrorString("Requires a process to be set.");
+return 0;
+  }
+
+  CoreFileMemoryRanges ranges;
+  error = m_process_sp->CalculateCoreFileSaveRanges(*this, ranges);
+  if (error.Fail())
+return 0;
+
+  uint64_t total_in_bytes = 0;
+  for (auto& core_range : ranges)
+total_in_bytes += core_range.data.range.size();
+
+  return total_in_bytes;
+}
+
 void SaveCoreOptions::ClearProcessSpecificData() {
   // Deliberately not following the formatter style here to indicate that
   // this method will be expanded in the future.
diff --git 
a/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py 
b/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py
index ace84e8497a59..215f8440cc68a 100644
--- a/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py
+++ b/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py
@@ -104,3 +104,24 @@ def test_removing_and_adding_insertion_order(self):
 thread_collection = options.GetThreadsToSave()
 self.assertEqual(thread_collection.GetSize(), 3)
 self.assertIn(middle_thread, thread_collection)
+
+def test_get_total_in_bytes(self):
+"""
+Tests that get total in bytes properly returns an error without a 
process, 
+and the readable regions with a process.
+"""
+
+options = lldb.SBSaveCoreOptions()
+options.SetStyle(lldb.eSaveCoreCustomOnly)
+process = self.get_basic_process()
+memory_range = lldb.SBMemoryRegionInfo()
+process.GetMemoryRegionInfo(0x7FFF12A84030, memory_range)
+options.AddMemoryRegionToSave(memory_range)
+error = lldb.SBError()
+total = options.GetCurrentSizeInBytes(error)
+self.assertTrue(error.Fail(), error.GetCString())
+ 

[Lldb-commits] [lldb] [LLDB][SBSaveCoreOptions] Add new API to expose the expected core size in bytes (PR #138169)

2025-05-01 Thread Jacob Lalonde via lldb-commits


@@ -119,6 +119,19 @@ class LLDB_API SBSaveCoreOptions {
   ///   an empty collection will be returned.
   SBThreadCollection GetThreadsToSave() const;
 
+  /// Get the current total number of bytes the core is expected to be but not
+  /// including the overhead of the core file format. Requires a Process and
+  /// Style to be specified.
+  ///
+  /// \note
+  ///   This can cause some modification of the underlying data store
+  ///   as regions with no permissions, or invalid permissions will be removed
+  ///   and stacks will be minified up to their stack pointer + the redzone.
+  ///
+  /// \returns
+  ///   The expected size of the data contained in the core in bytes.
+  uint64_t GetCurrentSizeInBytes(SBError &error);

Jlalond wrote:

@bulbazord Alex per usual I would appreciate your expert opinion on the new API 
phrasing and comments.

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


[Lldb-commits] [lldb] [LLDB][SBSaveCoreOptions] Add new API to expose the expected core size in bytes (PR #138169)

2025-05-01 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r HEAD~1...HEAD 
lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py
``





View the diff from darker here.


``diff
--- TestSBSaveCoreOptions.py2025-05-01 17:17:00.00 +
+++ TestSBSaveCoreOptions.py2025-05-01 17:19:15.050617 +
@@ -105,11 +105,11 @@
 self.assertEqual(thread_collection.GetSize(), 3)
 self.assertIn(middle_thread, thread_collection)
 
 def test_get_total_in_bytes(self):
 """
-Tests that get total in bytes properly returns an error without a 
process, 
+Tests that get total in bytes properly returns an error without a 
process,
 and the readable regions with a process.
 """
 
 options = lldb.SBSaveCoreOptions()
 options.SetStyle(lldb.eSaveCoreCustomOnly)

``




https://github.com/llvm/llvm-project/pull/138169
___
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 raciness in launch and attach tests (PR #137920)

2025-05-01 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Just throwing out some ideas that might simplify this. 
Is it possible to do the launching and attaching in asynchronous mode so that 
the stop events are always emitted? 
Also, the configuration done event can be emitted at any time during 
initialization. It could even be emitted before the actual launching and 
attaching happen.

Would any of this help?

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


[Lldb-commits] [lldb] [LLDB][SBSaveCoreOptions] Add new API to expose the expected core size in bytes (PR #138169)

2025-05-01 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)


Changes

My current internal work requires some sensitivity to IO usage. I had a work 
around to calculate the expected size of a Minidump, but I've added this PR so 
an automated system could look at the expected size of an LLDB generated 
Minidump and then choose if it has the space or wants to generate it.

There are some prerequisites to calculating the correct size, so I have the API 
take a reference for an SBError, I originally tried to return an SBError and 
instead take a uint64_t reference, but this made the API very difficult to use 
in python.

Added a test case as well.

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


6 Files Affected:

- (modified) lldb/include/lldb/API/SBSaveCoreOptions.h (+13) 
- (modified) lldb/include/lldb/Symbol/SaveCoreOptions.h (+2) 
- (modified) lldb/source/API/SBSaveCoreOptions.cpp (+5) 
- (modified) lldb/source/Symbol/SaveCoreOptions.cpp (+18) 
- (modified) 
lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py (+21) 
- (modified) lldb/test/API/python_api/sbsavecoreoptions/basic_minidump.yaml 
(+5) 


``diff
diff --git a/lldb/include/lldb/API/SBSaveCoreOptions.h 
b/lldb/include/lldb/API/SBSaveCoreOptions.h
index c6d2ab6099b3c..4c051353a714e 100644
--- a/lldb/include/lldb/API/SBSaveCoreOptions.h
+++ b/lldb/include/lldb/API/SBSaveCoreOptions.h
@@ -119,6 +119,19 @@ class LLDB_API SBSaveCoreOptions {
   ///   an empty collection will be returned.
   SBThreadCollection GetThreadsToSave() const;
 
+  /// Get the current total number of bytes the core is expected to be but not
+  /// including the overhead of the core file format. Requires a Process and 
+  /// Style to be specified.
+  /// 
+  /// \note
+  ///   This can cause some modification of the underlying data store 
+  ///   as regions with no permissions, or invalid permissions will be removed
+  ///   and stacks will be minified up to their stack pointer + the redzone.
+  ///
+  /// \returns
+  ///   The expected size of the data contained in the core in bytes.
+  uint64_t GetCurrentSizeInBytes(SBError &error);
+
   /// Reset all options.
   void Clear();
 
diff --git a/lldb/include/lldb/Symbol/SaveCoreOptions.h 
b/lldb/include/lldb/Symbol/SaveCoreOptions.h
index bcf0087fbea5c..319d44a6b0c87 100644
--- a/lldb/include/lldb/Symbol/SaveCoreOptions.h
+++ b/lldb/include/lldb/Symbol/SaveCoreOptions.h
@@ -49,6 +49,8 @@ class SaveCoreOptions {
 
   lldb_private::ThreadCollection::collection GetThreadsToSave() const;
 
+  uint64_t GetCurrentSizeInBytes(Status &error);
+
   void Clear();
 
 private:
diff --git a/lldb/source/API/SBSaveCoreOptions.cpp 
b/lldb/source/API/SBSaveCoreOptions.cpp
index 35b9da569dfa1..b67df513fe91b 100644
--- a/lldb/source/API/SBSaveCoreOptions.cpp
+++ b/lldb/source/API/SBSaveCoreOptions.cpp
@@ -114,6 +114,11 @@ void SBSaveCoreOptions::Clear() {
   m_opaque_up->Clear();
 }
 
+uint64_t SBSaveCoreOptions::GetCurrentSizeInBytes(SBError &error) {
+  LLDB_INSTRUMENT_VA(this, error);
+  return m_opaque_up->GetCurrentSizeInBytes(error.ref());
+}
+
 lldb_private::SaveCoreOptions &SBSaveCoreOptions::ref() const {
   return *m_opaque_up.get();
 }
diff --git a/lldb/source/Symbol/SaveCoreOptions.cpp 
b/lldb/source/Symbol/SaveCoreOptions.cpp
index c9f6efeb25d22..1da3e1cc9f834 100644
--- a/lldb/source/Symbol/SaveCoreOptions.cpp
+++ b/lldb/source/Symbol/SaveCoreOptions.cpp
@@ -145,6 +145,24 @@ SaveCoreOptions::GetThreadsToSave() const {
   return thread_collection;
 }
 
+uint64_t SaveCoreOptions::GetCurrentSizeInBytes(Status &error) {
+  if (!m_process_sp) {
+error = Status::FromErrorString("Requires a process to be set.");
+return 0;
+  }
+
+  CoreFileMemoryRanges ranges;
+  error = m_process_sp->CalculateCoreFileSaveRanges(*this, ranges);
+  if (error.Fail())
+return 0;
+
+  uint64_t total_in_bytes = 0;
+  for (auto& core_range : ranges)
+total_in_bytes += core_range.data.range.size();
+
+  return total_in_bytes;
+}
+
 void SaveCoreOptions::ClearProcessSpecificData() {
   // Deliberately not following the formatter style here to indicate that
   // this method will be expanded in the future.
diff --git 
a/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py 
b/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py
index ace84e8497a59..215f8440cc68a 100644
--- a/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py
+++ b/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py
@@ -104,3 +104,24 @@ def test_removing_and_adding_insertion_order(self):
 thread_collection = options.GetThreadsToSave()
 self.assertEqual(thread_collection.GetSize(), 3)
 self.assertIn(middle_thread, thread_collection)
+
+def test_get_total_in_bytes(self):
+"""
+Tests that get total in bytes properly returns an error without a 
process, 
+and the readable regions with a process.
+"""
+

[Lldb-commits] [lldb] [LLDB][SBSaveCoreOptions] Add new API to expose the expected core size in bytes (PR #138169)

2025-05-01 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond created 
https://github.com/llvm/llvm-project/pull/138169

My current internal work requires some sensitivity to IO usage. I had a work 
around to calculate the expected size of a Minidump, but I've added this PR so 
an automated system could look at the expected size of an LLDB generated 
Minidump and then choose if it has the space or wants to generate it.

There are some prerequisites to calculating the correct size, so I have the API 
take a reference for an SBError, I originally tried to return an SBError and 
instead take a uint64_t reference, but this made the API very difficult to use 
in python.

Added a test case as well.

>From ef04502d17c36044cd5fb96f333c328c8215f354 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 1 May 2025 10:11:10 -0700
Subject: [PATCH] Add new API to expose the expected size in bytes of a core
 before generation

---
 lldb/include/lldb/API/SBSaveCoreOptions.h | 13 
 lldb/include/lldb/Symbol/SaveCoreOptions.h|  2 ++
 lldb/source/API/SBSaveCoreOptions.cpp |  5 +
 lldb/source/Symbol/SaveCoreOptions.cpp| 18 
 .../TestSBSaveCoreOptions.py  | 21 +++
 .../sbsavecoreoptions/basic_minidump.yaml |  5 +
 6 files changed, 64 insertions(+)

diff --git a/lldb/include/lldb/API/SBSaveCoreOptions.h 
b/lldb/include/lldb/API/SBSaveCoreOptions.h
index c6d2ab6099b3c..4c051353a714e 100644
--- a/lldb/include/lldb/API/SBSaveCoreOptions.h
+++ b/lldb/include/lldb/API/SBSaveCoreOptions.h
@@ -119,6 +119,19 @@ class LLDB_API SBSaveCoreOptions {
   ///   an empty collection will be returned.
   SBThreadCollection GetThreadsToSave() const;
 
+  /// Get the current total number of bytes the core is expected to be but not
+  /// including the overhead of the core file format. Requires a Process and 
+  /// Style to be specified.
+  /// 
+  /// \note
+  ///   This can cause some modification of the underlying data store 
+  ///   as regions with no permissions, or invalid permissions will be removed
+  ///   and stacks will be minified up to their stack pointer + the redzone.
+  ///
+  /// \returns
+  ///   The expected size of the data contained in the core in bytes.
+  uint64_t GetCurrentSizeInBytes(SBError &error);
+
   /// Reset all options.
   void Clear();
 
diff --git a/lldb/include/lldb/Symbol/SaveCoreOptions.h 
b/lldb/include/lldb/Symbol/SaveCoreOptions.h
index bcf0087fbea5c..319d44a6b0c87 100644
--- a/lldb/include/lldb/Symbol/SaveCoreOptions.h
+++ b/lldb/include/lldb/Symbol/SaveCoreOptions.h
@@ -49,6 +49,8 @@ class SaveCoreOptions {
 
   lldb_private::ThreadCollection::collection GetThreadsToSave() const;
 
+  uint64_t GetCurrentSizeInBytes(Status &error);
+
   void Clear();
 
 private:
diff --git a/lldb/source/API/SBSaveCoreOptions.cpp 
b/lldb/source/API/SBSaveCoreOptions.cpp
index 35b9da569dfa1..b67df513fe91b 100644
--- a/lldb/source/API/SBSaveCoreOptions.cpp
+++ b/lldb/source/API/SBSaveCoreOptions.cpp
@@ -114,6 +114,11 @@ void SBSaveCoreOptions::Clear() {
   m_opaque_up->Clear();
 }
 
+uint64_t SBSaveCoreOptions::GetCurrentSizeInBytes(SBError &error) {
+  LLDB_INSTRUMENT_VA(this, error);
+  return m_opaque_up->GetCurrentSizeInBytes(error.ref());
+}
+
 lldb_private::SaveCoreOptions &SBSaveCoreOptions::ref() const {
   return *m_opaque_up.get();
 }
diff --git a/lldb/source/Symbol/SaveCoreOptions.cpp 
b/lldb/source/Symbol/SaveCoreOptions.cpp
index c9f6efeb25d22..1da3e1cc9f834 100644
--- a/lldb/source/Symbol/SaveCoreOptions.cpp
+++ b/lldb/source/Symbol/SaveCoreOptions.cpp
@@ -145,6 +145,24 @@ SaveCoreOptions::GetThreadsToSave() const {
   return thread_collection;
 }
 
+uint64_t SaveCoreOptions::GetCurrentSizeInBytes(Status &error) {
+  if (!m_process_sp) {
+error = Status::FromErrorString("Requires a process to be set.");
+return 0;
+  }
+
+  CoreFileMemoryRanges ranges;
+  error = m_process_sp->CalculateCoreFileSaveRanges(*this, ranges);
+  if (error.Fail())
+return 0;
+
+  uint64_t total_in_bytes = 0;
+  for (auto& core_range : ranges)
+total_in_bytes += core_range.data.range.size();
+
+  return total_in_bytes;
+}
+
 void SaveCoreOptions::ClearProcessSpecificData() {
   // Deliberately not following the formatter style here to indicate that
   // this method will be expanded in the future.
diff --git 
a/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py 
b/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py
index ace84e8497a59..215f8440cc68a 100644
--- a/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py
+++ b/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py
@@ -104,3 +104,24 @@ def test_removing_and_adding_insertion_order(self):
 thread_collection = options.GetThreadsToSave()
 self.assertEqual(thread_collection.GetSize(), 3)
 self.assertIn(middle_thread, thread_collection)
+
+def test_get_total_in_bytes(self):
+"""
+Tests that get total 

[Lldb-commits] [lldb] [LLDB][SBSaveCoreOptions] Add new API to expose the expected core size in bytes (PR #138169)

2025-05-01 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/138169

>From ef04502d17c36044cd5fb96f333c328c8215f354 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 1 May 2025 10:11:10 -0700
Subject: [PATCH 1/3] Add new API to expose the expected size in bytes of a
 core before generation

---
 lldb/include/lldb/API/SBSaveCoreOptions.h | 13 
 lldb/include/lldb/Symbol/SaveCoreOptions.h|  2 ++
 lldb/source/API/SBSaveCoreOptions.cpp |  5 +
 lldb/source/Symbol/SaveCoreOptions.cpp| 18 
 .../TestSBSaveCoreOptions.py  | 21 +++
 .../sbsavecoreoptions/basic_minidump.yaml |  5 +
 6 files changed, 64 insertions(+)

diff --git a/lldb/include/lldb/API/SBSaveCoreOptions.h 
b/lldb/include/lldb/API/SBSaveCoreOptions.h
index c6d2ab6099b3c..4c051353a714e 100644
--- a/lldb/include/lldb/API/SBSaveCoreOptions.h
+++ b/lldb/include/lldb/API/SBSaveCoreOptions.h
@@ -119,6 +119,19 @@ class LLDB_API SBSaveCoreOptions {
   ///   an empty collection will be returned.
   SBThreadCollection GetThreadsToSave() const;
 
+  /// Get the current total number of bytes the core is expected to be but not
+  /// including the overhead of the core file format. Requires a Process and 
+  /// Style to be specified.
+  /// 
+  /// \note
+  ///   This can cause some modification of the underlying data store 
+  ///   as regions with no permissions, or invalid permissions will be removed
+  ///   and stacks will be minified up to their stack pointer + the redzone.
+  ///
+  /// \returns
+  ///   The expected size of the data contained in the core in bytes.
+  uint64_t GetCurrentSizeInBytes(SBError &error);
+
   /// Reset all options.
   void Clear();
 
diff --git a/lldb/include/lldb/Symbol/SaveCoreOptions.h 
b/lldb/include/lldb/Symbol/SaveCoreOptions.h
index bcf0087fbea5c..319d44a6b0c87 100644
--- a/lldb/include/lldb/Symbol/SaveCoreOptions.h
+++ b/lldb/include/lldb/Symbol/SaveCoreOptions.h
@@ -49,6 +49,8 @@ class SaveCoreOptions {
 
   lldb_private::ThreadCollection::collection GetThreadsToSave() const;
 
+  uint64_t GetCurrentSizeInBytes(Status &error);
+
   void Clear();
 
 private:
diff --git a/lldb/source/API/SBSaveCoreOptions.cpp 
b/lldb/source/API/SBSaveCoreOptions.cpp
index 35b9da569dfa1..b67df513fe91b 100644
--- a/lldb/source/API/SBSaveCoreOptions.cpp
+++ b/lldb/source/API/SBSaveCoreOptions.cpp
@@ -114,6 +114,11 @@ void SBSaveCoreOptions::Clear() {
   m_opaque_up->Clear();
 }
 
+uint64_t SBSaveCoreOptions::GetCurrentSizeInBytes(SBError &error) {
+  LLDB_INSTRUMENT_VA(this, error);
+  return m_opaque_up->GetCurrentSizeInBytes(error.ref());
+}
+
 lldb_private::SaveCoreOptions &SBSaveCoreOptions::ref() const {
   return *m_opaque_up.get();
 }
diff --git a/lldb/source/Symbol/SaveCoreOptions.cpp 
b/lldb/source/Symbol/SaveCoreOptions.cpp
index c9f6efeb25d22..1da3e1cc9f834 100644
--- a/lldb/source/Symbol/SaveCoreOptions.cpp
+++ b/lldb/source/Symbol/SaveCoreOptions.cpp
@@ -145,6 +145,24 @@ SaveCoreOptions::GetThreadsToSave() const {
   return thread_collection;
 }
 
+uint64_t SaveCoreOptions::GetCurrentSizeInBytes(Status &error) {
+  if (!m_process_sp) {
+error = Status::FromErrorString("Requires a process to be set.");
+return 0;
+  }
+
+  CoreFileMemoryRanges ranges;
+  error = m_process_sp->CalculateCoreFileSaveRanges(*this, ranges);
+  if (error.Fail())
+return 0;
+
+  uint64_t total_in_bytes = 0;
+  for (auto& core_range : ranges)
+total_in_bytes += core_range.data.range.size();
+
+  return total_in_bytes;
+}
+
 void SaveCoreOptions::ClearProcessSpecificData() {
   // Deliberately not following the formatter style here to indicate that
   // this method will be expanded in the future.
diff --git 
a/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py 
b/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py
index ace84e8497a59..215f8440cc68a 100644
--- a/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py
+++ b/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py
@@ -104,3 +104,24 @@ def test_removing_and_adding_insertion_order(self):
 thread_collection = options.GetThreadsToSave()
 self.assertEqual(thread_collection.GetSize(), 3)
 self.assertIn(middle_thread, thread_collection)
+
+def test_get_total_in_bytes(self):
+"""
+Tests that get total in bytes properly returns an error without a 
process, 
+and the readable regions with a process.
+"""
+
+options = lldb.SBSaveCoreOptions()
+options.SetStyle(lldb.eSaveCoreCustomOnly)
+process = self.get_basic_process()
+memory_range = lldb.SBMemoryRegionInfo()
+process.GetMemoryRegionInfo(0x7FFF12A84030, memory_range)
+options.AddMemoryRegionToSave(memory_range)
+error = lldb.SBError()
+total = options.GetCurrentSizeInBytes(error)
+self.assertTrue(error.Fail(), error.GetCString())
+ 

[Lldb-commits] [lldb] [lldb/Host] Enable inheriting "non-inheritable" FDs (PR #126935)

2025-05-01 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett commented:

> Currently we're creating inheritable (~FD_CLOEXEC) file descriptors in the 
> (few) cases where we need to pass an FD to a subprocess. The problem with 
> these is that, in a multithreaded application such as lldb, there's 
> essentially no way to prevent them from being leaked into processes other 
> than the intended one.

The consequences of this are what exactly?

That the debugee may see differently numbered descriptors when run via lldb vs. 
normally?

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


[Lldb-commits] [lldb] [lldb/Host] Enable inheriting "non-inheritable" FDs (PR #126935)

2025-05-01 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb/Host] Enable inheriting "non-inheritable" FDs (PR #126935)

2025-05-01 Thread David Spickett via lldb-commits


@@ -87,3 +89,41 @@ TEST(Host, LaunchProcessSetsArgv0) {
   ASSERT_THAT_ERROR(Host::LaunchProcess(info).takeError(), Succeeded());
   ASSERT_THAT(exit_status.get_future().get(), 0);
 }
+
+#ifdef LLVM_ON_UNIX
+TEST(Host, LaunchProcessDuplicatesHandle) {
+  static constexpr llvm::StringLiteral test_msg("Hello subprocess!");
+
+  SubsystemRAII subsystems;
+
+  if (test_arg) {
+Pipe pipe(LLDB_INVALID_PIPE, (lldb::pipe_t)test_arg.getValue());
+llvm::Expected bytes_written =
+pipe.Write(test_msg.data(), test_msg.size());
+if (bytes_written && *bytes_written == test_msg.size())
+  exit(0);

DavidSpickett wrote:

This `if (test_arg)` gets executed when the code below re-launches the gtest 
executable, right?

Otherwise this just `exit`s and the rest is dead code.

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


[Lldb-commits] [lldb] [lldb/Host] Enable inheriting "non-inheritable" FDs (PR #126935)

2025-05-01 Thread David Spickett via lldb-commits


@@ -122,8 +123,14 @@ struct ForkLaunchInfo {
 ExitWithError(error_fd, "close");
   break;
 case FileAction::eFileActionDuplicate:
-  if (dup2(action.fd, action.arg) == -1)
-ExitWithError(error_fd, "dup2");
+  if (action.fd != action.arg) {
+if (dup2(action.fd, action.arg) == -1)
+  ExitWithError(error_fd, "dup2");
+  } else {
+if (fcntl(action.fd, F_SETFD,
+  fcntl(action.fd, F_GETFD) & ~FD_CLOEXEC) == -1)

DavidSpickett wrote:

So if the file descriptors are not the same, we want to duplicate what 
action.fd refers to, into the file descriptor action.arg. Seems logical, we can 
then pass the new file descriptor to the debugee, I think?

(unless this is forking into another part of lldb)

If they are not the same, then we don't want to close action.fd when we next 
exec, which is when we fork to run the debugee process? Is this because 
action.fd is for example opened by the system, not by lldb or the debugee and 
we don't want to interfere with that?

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


[Lldb-commits] [lldb] [lldb-dap] Add runInTerminal support for Windows (PR #138160)

2025-05-01 Thread via lldb-commits

https://github.com/DrSergei created 
https://github.com/llvm/llvm-project/pull/138160

Added `runInTerminal` support for Windows based on Windows Named Pipes. Adapted 
existed `FifoFile` class to Windows client-server pipes model. When server side 
owns the assosieted filesystem handle and client side only provide read-write 
acces to it. Also, fixed small typo in `JSONUtill.cpp` related to 
`runInTerminal` functionality.

>From c60a556561b70f8eab0781e5de9374aac87529d4 Mon Sep 17 00:00:00 2001
From: Druzhkov Sergei 
Date: Thu, 1 May 2025 18:46:22 +0300
Subject: [PATCH] [lldb-dap] Add runInTerminal support for Windows

---
 .../runInTerminal/TestDAP_runInTerminal.py|  3 -
 lldb/tools/lldb-dap/FifoFiles.cpp | 85 +--
 lldb/tools/lldb-dap/FifoFiles.h   | 36 ++--
 .../tools/lldb-dap/Handler/RequestHandler.cpp | 12 ++-
 lldb/tools/lldb-dap/JSONUtils.cpp |  2 +-
 lldb/tools/lldb-dap/RunInTerminal.cpp | 34 ++--
 lldb/tools/lldb-dap/RunInTerminal.h   | 29 ++-
 lldb/tools/lldb-dap/lldb-dap.cpp  | 72 ++--
 8 files changed, 237 insertions(+), 36 deletions(-)

diff --git 
a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py 
b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
index 9aab7ca3293db..d5355f3bacd9c 100644
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
@@ -43,7 +43,6 @@ def isTestSupported(self):
 except:
 return False
 
-@skipIfWindows
 @skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
 def test_runInTerminal(self):
 if not self.isTestSupported():
@@ -113,7 +112,6 @@ def test_runInTerminalWithObjectEnv(self):
 self.assertIn("FOO", request_envs)
 self.assertEqual("BAR", request_envs["FOO"])
 
-@skipIfWindows
 @skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
 def test_runInTerminalInvalidTarget(self):
 if not self.isTestSupported():
@@ -132,7 +130,6 @@ def test_runInTerminalInvalidTarget(self):
 response["message"],
 )
 
-@skipIfWindows
 @skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
 def test_missingArgInRunInTerminalLauncher(self):
 if not self.isTestSupported():
diff --git a/lldb/tools/lldb-dap/FifoFiles.cpp 
b/lldb/tools/lldb-dap/FifoFiles.cpp
index 1f1bba80bd3b1..43eb4679b592f 100644
--- a/lldb/tools/lldb-dap/FifoFiles.cpp
+++ b/lldb/tools/lldb-dap/FifoFiles.cpp
@@ -24,26 +24,53 @@ using namespace llvm;
 
 namespace lldb_dap {
 
-FifoFile::FifoFile(StringRef path) : m_path(path) {}
+#if defined(_WIN32)
+FifoFile::FifoFile(StringRef path, HANDLE handle, bool is_server)
+: m_path(path), m_is_server(is_server), m_pipe_fd(handle) {}
+#else
+FifoFile::FifoFile(StringRef path, bool is_server)
+: m_path(path), m_is_server(is_server) {}
+#endif
 
 FifoFile::~FifoFile() {
-#if !defined(_WIN32)
-  unlink(m_path.c_str());
+#if defined(_WIN32)
+  if (m_pipe_fd == INVALID_HANDLE_VALUE)
+return;
+  if (m_is_server)
+DisconnectNamedPipe(m_pipe_fd);
+  CloseHandle(m_pipe_fd);
+#else
+  if (m_is_server)
+unlink(m_path.c_str());
 #endif
 }
 
-Expected> CreateFifoFile(StringRef path) {
+Expected> CreateFifoFile(StringRef path,
+   bool is_server) {
 #if defined(_WIN32)
-  return createStringError(inconvertibleErrorCode(), "Unimplemented");
+  if (!is_server)
+return std::make_shared(path, INVALID_HANDLE_VALUE, is_server);
+  HANDLE handle =
+  CreateNamedPipeA(path.data(), PIPE_ACCESS_DUPLEX,
+   PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 1,
+   1024 * 16, 1024 * 16, 0, NULL);
+  if (handle == INVALID_HANDLE_VALUE)
+return createStringError(
+std::error_code(GetLastError(), std::generic_category()),
+"Couldn't create fifo file: %s", path.data());
+  return std::make_shared(path, handle, is_server);
 #else
+  if (!is_server)
+return std::make_shared(path, is_server);
   if (int err = mkfifo(path.data(), 0600))
 return createStringError(std::error_code(err, std::generic_category()),
  "Couldn't create fifo file: %s", path.data());
-  return std::make_shared(path);
+  return std::make_shared(path, is_server);
 #endif
 }
 
-FifoFileIO::FifoFileIO(StringRef fifo_file, StringRef other_endpoint_name)
+FifoFileIO::FifoFileIO(std::shared_ptr fifo_file,
+   StringRef other_endpoint_name)
 : m_fifo_file(fifo_file), m_other_endpoint_name(other_endpoint_name) {}
 
 Expected FifoFileIO::ReadJSON(std::chrono::milliseconds timeout) {
@@ -52,11 +79,27 @@ Expected 
FifoFileIO::ReadJSON(std::chrono::milliseconds timeout) {
   std::optional line;
   std::future *future =
   new std::future(std::async(std::launch::async, [&]() {
-std::ifstream reader(m_fifo_file, 

[Lldb-commits] [lldb] [lldb-dap] Add runInTerminal support for Windows (PR #138160)

2025-05-01 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[Lldb-commits] [lldb] [lldb-dap] Add runInTerminal support for Windows (PR #138160)

2025-05-01 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (DrSergei)


Changes

Added `runInTerminal` support for Windows based on Windows Named Pipes. Adapted 
existed `FifoFile` class to Windows client-server pipes model. When server side 
owns the assosieted filesystem handle and client side only provide read-write 
acces to it. Also, fixed small typo in `JSONUtill.cpp` related to 
`runInTerminal` functionality.

---

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


8 Files Affected:

- (modified) 
lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py (-3) 
- (modified) lldb/tools/lldb-dap/FifoFiles.cpp (+77-8) 
- (modified) lldb/tools/lldb-dap/FifoFiles.h (+31-5) 
- (modified) lldb/tools/lldb-dap/Handler/RequestHandler.cpp (+9-3) 
- (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+1-1) 
- (modified) lldb/tools/lldb-dap/RunInTerminal.cpp (+28-6) 
- (modified) lldb/tools/lldb-dap/RunInTerminal.h (+25-4) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+66-6) 


``diff
diff --git 
a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py 
b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
index 9aab7ca3293db..d5355f3bacd9c 100644
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
@@ -43,7 +43,6 @@ def isTestSupported(self):
 except:
 return False
 
-@skipIfWindows
 @skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
 def test_runInTerminal(self):
 if not self.isTestSupported():
@@ -113,7 +112,6 @@ def test_runInTerminalWithObjectEnv(self):
 self.assertIn("FOO", request_envs)
 self.assertEqual("BAR", request_envs["FOO"])
 
-@skipIfWindows
 @skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
 def test_runInTerminalInvalidTarget(self):
 if not self.isTestSupported():
@@ -132,7 +130,6 @@ def test_runInTerminalInvalidTarget(self):
 response["message"],
 )
 
-@skipIfWindows
 @skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
 def test_missingArgInRunInTerminalLauncher(self):
 if not self.isTestSupported():
diff --git a/lldb/tools/lldb-dap/FifoFiles.cpp 
b/lldb/tools/lldb-dap/FifoFiles.cpp
index 1f1bba80bd3b1..43eb4679b592f 100644
--- a/lldb/tools/lldb-dap/FifoFiles.cpp
+++ b/lldb/tools/lldb-dap/FifoFiles.cpp
@@ -24,26 +24,53 @@ using namespace llvm;
 
 namespace lldb_dap {
 
-FifoFile::FifoFile(StringRef path) : m_path(path) {}
+#if defined(_WIN32)
+FifoFile::FifoFile(StringRef path, HANDLE handle, bool is_server)
+: m_path(path), m_is_server(is_server), m_pipe_fd(handle) {}
+#else
+FifoFile::FifoFile(StringRef path, bool is_server)
+: m_path(path), m_is_server(is_server) {}
+#endif
 
 FifoFile::~FifoFile() {
-#if !defined(_WIN32)
-  unlink(m_path.c_str());
+#if defined(_WIN32)
+  if (m_pipe_fd == INVALID_HANDLE_VALUE)
+return;
+  if (m_is_server)
+DisconnectNamedPipe(m_pipe_fd);
+  CloseHandle(m_pipe_fd);
+#else
+  if (m_is_server)
+unlink(m_path.c_str());
 #endif
 }
 
-Expected> CreateFifoFile(StringRef path) {
+Expected> CreateFifoFile(StringRef path,
+   bool is_server) {
 #if defined(_WIN32)
-  return createStringError(inconvertibleErrorCode(), "Unimplemented");
+  if (!is_server)
+return std::make_shared(path, INVALID_HANDLE_VALUE, is_server);
+  HANDLE handle =
+  CreateNamedPipeA(path.data(), PIPE_ACCESS_DUPLEX,
+   PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 1,
+   1024 * 16, 1024 * 16, 0, NULL);
+  if (handle == INVALID_HANDLE_VALUE)
+return createStringError(
+std::error_code(GetLastError(), std::generic_category()),
+"Couldn't create fifo file: %s", path.data());
+  return std::make_shared(path, handle, is_server);
 #else
+  if (!is_server)
+return std::make_shared(path, is_server);
   if (int err = mkfifo(path.data(), 0600))
 return createStringError(std::error_code(err, std::generic_category()),
  "Couldn't create fifo file: %s", path.data());
-  return std::make_shared(path);
+  return std::make_shared(path, is_server);
 #endif
 }
 
-FifoFileIO::FifoFileIO(StringRef fifo_file, StringRef other_endpoint_name)
+FifoFileIO::FifoFileIO(std::shared_ptr fifo_file,
+   StringRef other_endpoint_name)
 : m_fifo_file(fifo_file), m_other_endpoint_name(other_endpoint_name) {}
 
 Expected FifoFileIO::ReadJSON(std::chrono::milliseconds timeout) {
@@ -52,11 +79,27 @@ Expected 
FifoFileIO::ReadJSON(std::chrono::milliseconds timeout) {
   std::optional line;
   std::future *future =
   new std::future(std::async(std::launch::async, [&]() {
-std::ifstream reader(m_fifo_file, std::ifstream::in);
+#if defined(_WIN32)
+std::string buffer;
+buffer.reserve(4

[Lldb-commits] [lldb] [LLDB] Ptrace seize dead process (PR #137041)

2025-05-01 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> This is pretty complicated to test because it requires integration with the 
> Kernel

Can you make the same thing happen without using a coredumper? I feel like the 
answer is a solid no but I'm not sure why.

Another way we can do it is to write a test that checks that if the remote says 
it's in a non-resumable state, we act in a certain way. Only half the story but 
it's something.

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


[Lldb-commits] [lldb] [LLDB] Ptrace seize dead process (PR #137041)

2025-05-01 Thread David Spickett via lldb-commits


@@ -1676,7 +1681,11 @@ GDBRemoteCommunication::PacketResult
 GDBRemoteCommunicationServerLLGS::Handle_vCont_actions(
 StringExtractorGDBRemote &packet) {
   StreamString response;
-  response.Printf("vCont;c;C;s;S;t");
+  if (m_current_process && m_current_process->CanResume()) {
+response.Printf("vCont;c;C;s;S;t");
+  } else {
+response.Printf("vCont");

DavidSpickett wrote:

What does this do if the process can't resume anyway?

https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packets.html#vCont-packet

Or is this just a WIP implementation, and doing something rather than nothing 
meant you didn't have to change a bunch of other stuff.

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


[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

2025-05-01 Thread Ebuka Ezike via lldb-commits


@@ -105,6 +105,10 @@ class LLDB_API SBThreadPlan {
   SBThreadPlan QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
  bool first_insn, SBError &error);
 
+  SBThreadPlan QueueThreadPlanForStepSingleInstruction(bool step_over);

da-viper wrote:

I think is better not to add this overload and force the user to handle the 
error, 

Since the previous overload was added to handle this problem 
[commit](https://github.com/llvm/llvm-project/commit/e103ae92ef2336854587778bd3ae88a87e409a5e)

@jimingham what do you think ? . 

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


[Lldb-commits] [lldb] [LLDB] Ptrace seize dead process (PR #137041)

2025-05-01 Thread David Spickett via lldb-commits


@@ -1304,6 +1304,9 @@ void GDBRemoteCommunicationServerCommon::
 if (!abi.empty())
   response.Printf("elf_abi:%s;", abi.c_str());
 response.Printf("ptrsize:%d;", proc_arch.GetAddressByteSize());
+std::optional non_resumable = proc_info.IsNonResumable();
+if (non_resumable)
+  response.Printf("non_resumable:%d", *non_resumable);

DavidSpickett wrote:

This is part of qProcessInfo 
(https://lldb.llvm.org/resources/lldbgdbremote.html#qprocessinfo) which is, I 
presume, only requested once because all the information is constant for the 
process lifetime.

At least for the situation at hand, non-resumeable is also constant. Though the 
process had to get into that state somehow, but if you were debugging it before 
the non-resumable point, it wouldn't have got into the non-resumeable state 
anyway so it makes no difference.

So unless anyone can think of a situation where non-resumeable could change, 
this packet is probably fine.

https://github.com/llvm/llvm-project/pull/137041
___
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 raciness in launch and attach tests (PR #137920)

2025-05-01 Thread via lldb-commits

kusmour wrote:

> > Technically the response of launch/attach should be the end of the chain.
> 
> Thats not how its implemented in VS Code at least:
> 
> * `initialize` is sent then `launch` or `attach` 
> https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/debug/browser/debugService.ts#L674-L675,
>  these two happen sequentially and its not coordinating this with the 
> `initialized` event or `configurationDone` request.
> * When 
> [`initialized`](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Initialized)
>  is received, it triggers the setBreakpoints then `configurationDone` 
> https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/debug/browser/debugSession.ts#L1063-L1091

Yes but that code doesn't define how adapter should respond to those requests, 
the specification does. What you showed above doesn't conflict with having the 
response being the end of the launch sequence and the mark of "the debug 
session has started". They don't need to coordinate with `initialized` event 
and they shouldn't. The adapter should use `initialized` to signal it can take 
breakpoint requests.

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


[Lldb-commits] [lldb] [lldb] Expose language plugin commands based based on language of current frame (PR #136766)

2025-05-01 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/136766

>From 94caf0b58ace58ae5159e3819f776ad6b2988329 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Tue, 22 Apr 2025 13:58:25 -0700
Subject: [PATCH 1/7] [lldb] Expose language plugin commands based based on
 language of current frame

---
 .../lldb/Interpreter/CommandInterpreter.h |  6 ++
 .../source/Interpreter/CommandInterpreter.cpp | 55 ++-
 2 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 724d88d65f6ac..26e0767951e7f 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -730,6 +730,12 @@ class CommandInterpreter : public Broadcaster,
   bool EchoCommandNonInteractive(llvm::StringRef line,
  const Flags &io_handler_flags) const;
 
+  /// Return the language specific command object for the current frame.
+  ///
+  /// For example, when stopped on a C++ frame, this returns the command object
+  /// for "language cplusplus" (`CommandObjectMultiwordItaniumABI`).
+  lldb::CommandObjectSP GetFrameLanguageCommand() const;
+
   // A very simple state machine which models the command handling transitions
   enum class CommandHandlingState {
 eIdle,
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index eb4741feb0aa5..2ff02ae5086b4 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1018,6 +1018,26 @@ CommandInterpreter::VerifyUserMultiwordCmdPath(Args 
&path, bool leaf_is_command,
   return cur_as_multi;
 }
 
+CommandObjectSP CommandInterpreter::GetFrameLanguageCommand() const {
+  if (auto frame_sp = GetExecutionContext().GetFrameSP()) {
+auto frame_language = Language::GetPrimaryLanguage(
+frame_sp->GuessLanguage().AsLanguageType());
+
+auto it = m_command_dict.find("language");
+if (it != m_command_dict.end()) {
+  // The root "language" command.
+  CommandObjectSP language_cmd_sp = it->second;
+
+  if (auto *plugin = Language::FindPlugin(frame_language)) {
+// "cplusplus", "objc", etc.
+auto lang_name = plugin->GetPluginName();
+return language_cmd_sp->GetSubcommandSPExact(lang_name);
+  }
+}
+  }
+  return {};
+}
+
 CommandObjectSP
 CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, bool include_aliases,
  bool exact, StringList *matches,
@@ -1050,11 +1070,20 @@ CommandInterpreter::GetCommandSP(llvm::StringRef 
cmd_str, bool include_aliases,
   command_sp = pos->second;
   }
 
+  // The `language` subcommand ("language objc", "language cplusplus", etc).
+  CommandObjectMultiword *lang_subcmd = nullptr;
+  if (!command_sp) {
+if (auto subcmd_sp = GetFrameLanguageCommand()) {
+  lang_subcmd = subcmd_sp->GetAsMultiwordCommand();
+  command_sp = subcmd_sp->GetSubcommandSPExact(cmd_str);
+}
+  }
+
   if (!exact && !command_sp) {
 // We will only get into here if we didn't find any exact matches.
 
 CommandObjectSP user_match_sp, user_mw_match_sp, alias_match_sp,
-real_match_sp;
+real_match_sp, lang_match_sp;
 
 StringList local_matches;
 if (matches == nullptr)
@@ -1064,6 +1093,7 @@ CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, 
bool include_aliases,
 unsigned int num_alias_matches = 0;
 unsigned int num_user_matches = 0;
 unsigned int num_user_mw_matches = 0;
+unsigned int num_lang_matches = 0;
 
 // Look through the command dictionaries one by one, and if we get only one
 // match from any of them in toto, then return that, otherwise return an
@@ -1121,11 +1151,28 @@ CommandInterpreter::GetCommandSP(llvm::StringRef 
cmd_str, bool include_aliases,
 user_mw_match_sp = pos->second;
 }
 
+if (lang_subcmd) {
+  num_lang_matches =
+  AddNamesMatchingPartialString(lang_subcmd->GetSubcommandDictionary(),
+cmd_str, *matches, descriptions);
+}
+
+if (num_lang_matches == 1) {
+  cmd.assign(matches->GetStringAtIndex(num_cmd_matches + num_alias_matches 
+
+   num_user_matches +
+   num_user_mw_matches));
+
+  auto &lang_dict = lang_subcmd->GetSubcommandDictionary();
+  auto pos = lang_dict.find(cmd);
+  if (pos != lang_dict.end())
+lang_match_sp = pos->second;
+}
+
 // If we got exactly one match, return that, otherwise return the match
 // list.
 
 if (num_user_matches + num_user_mw_matches + num_cmd_matches +
-num_alias_matches ==
+num_alias_matches + num_lang_matches ==
 1) {
   if (num_cmd_matches)
 return real_match_sp;
@@ -1133,8 +1180,10 @

[Lldb-commits] [lldb] [lldb] Expose language plugin commands based based on language of current frame (PR #136766)

2025-05-01 Thread Dave Lee via lldb-commits


@@ -1018,6 +1018,26 @@ CommandInterpreter::VerifyUserMultiwordCmdPath(Args 
&path, bool leaf_is_command,
   return cur_as_multi;
 }
 
+CommandObjectSP CommandInterpreter::GetFrameLanguageCommand() const {
+  if (auto frame_sp = GetExecutionContext().GetFrameSP()) {
+auto frame_language = Language::GetPrimaryLanguage(
+frame_sp->GuessLanguage().AsLanguageType());
+
+auto it = m_command_dict.find("language");
+if (it != m_command_dict.end()) {

kastiglione wrote:

done (and I added other early returns)

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


[Lldb-commits] [lldb] [lldb] Expose language plugin commands based based on language of current frame (PR #136766)

2025-05-01 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/136766

>From 94caf0b58ace58ae5159e3819f776ad6b2988329 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Tue, 22 Apr 2025 13:58:25 -0700
Subject: [PATCH 1/6] [lldb] Expose language plugin commands based based on
 language of current frame

---
 .../lldb/Interpreter/CommandInterpreter.h |  6 ++
 .../source/Interpreter/CommandInterpreter.cpp | 55 ++-
 2 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 724d88d65f6ac..26e0767951e7f 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -730,6 +730,12 @@ class CommandInterpreter : public Broadcaster,
   bool EchoCommandNonInteractive(llvm::StringRef line,
  const Flags &io_handler_flags) const;
 
+  /// Return the language specific command object for the current frame.
+  ///
+  /// For example, when stopped on a C++ frame, this returns the command object
+  /// for "language cplusplus" (`CommandObjectMultiwordItaniumABI`).
+  lldb::CommandObjectSP GetFrameLanguageCommand() const;
+
   // A very simple state machine which models the command handling transitions
   enum class CommandHandlingState {
 eIdle,
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index eb4741feb0aa5..2ff02ae5086b4 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1018,6 +1018,26 @@ CommandInterpreter::VerifyUserMultiwordCmdPath(Args 
&path, bool leaf_is_command,
   return cur_as_multi;
 }
 
+CommandObjectSP CommandInterpreter::GetFrameLanguageCommand() const {
+  if (auto frame_sp = GetExecutionContext().GetFrameSP()) {
+auto frame_language = Language::GetPrimaryLanguage(
+frame_sp->GuessLanguage().AsLanguageType());
+
+auto it = m_command_dict.find("language");
+if (it != m_command_dict.end()) {
+  // The root "language" command.
+  CommandObjectSP language_cmd_sp = it->second;
+
+  if (auto *plugin = Language::FindPlugin(frame_language)) {
+// "cplusplus", "objc", etc.
+auto lang_name = plugin->GetPluginName();
+return language_cmd_sp->GetSubcommandSPExact(lang_name);
+  }
+}
+  }
+  return {};
+}
+
 CommandObjectSP
 CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, bool include_aliases,
  bool exact, StringList *matches,
@@ -1050,11 +1070,20 @@ CommandInterpreter::GetCommandSP(llvm::StringRef 
cmd_str, bool include_aliases,
   command_sp = pos->second;
   }
 
+  // The `language` subcommand ("language objc", "language cplusplus", etc).
+  CommandObjectMultiword *lang_subcmd = nullptr;
+  if (!command_sp) {
+if (auto subcmd_sp = GetFrameLanguageCommand()) {
+  lang_subcmd = subcmd_sp->GetAsMultiwordCommand();
+  command_sp = subcmd_sp->GetSubcommandSPExact(cmd_str);
+}
+  }
+
   if (!exact && !command_sp) {
 // We will only get into here if we didn't find any exact matches.
 
 CommandObjectSP user_match_sp, user_mw_match_sp, alias_match_sp,
-real_match_sp;
+real_match_sp, lang_match_sp;
 
 StringList local_matches;
 if (matches == nullptr)
@@ -1064,6 +1093,7 @@ CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, 
bool include_aliases,
 unsigned int num_alias_matches = 0;
 unsigned int num_user_matches = 0;
 unsigned int num_user_mw_matches = 0;
+unsigned int num_lang_matches = 0;
 
 // Look through the command dictionaries one by one, and if we get only one
 // match from any of them in toto, then return that, otherwise return an
@@ -1121,11 +1151,28 @@ CommandInterpreter::GetCommandSP(llvm::StringRef 
cmd_str, bool include_aliases,
 user_mw_match_sp = pos->second;
 }
 
+if (lang_subcmd) {
+  num_lang_matches =
+  AddNamesMatchingPartialString(lang_subcmd->GetSubcommandDictionary(),
+cmd_str, *matches, descriptions);
+}
+
+if (num_lang_matches == 1) {
+  cmd.assign(matches->GetStringAtIndex(num_cmd_matches + num_alias_matches 
+
+   num_user_matches +
+   num_user_mw_matches));
+
+  auto &lang_dict = lang_subcmd->GetSubcommandDictionary();
+  auto pos = lang_dict.find(cmd);
+  if (pos != lang_dict.end())
+lang_match_sp = pos->second;
+}
+
 // If we got exactly one match, return that, otherwise return the match
 // list.
 
 if (num_user_matches + num_user_mw_matches + num_cmd_matches +
-num_alias_matches ==
+num_alias_matches + num_lang_matches ==
 1) {
   if (num_cmd_matches)
 return real_match_sp;
@@ -1133,8 +1180,10 @

[Lldb-commits] [lldb] 2bff80f - [lldb] Fix a warning

2025-05-01 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2025-05-01T12:27:08-07:00
New Revision: 2bff80f25d51e24d3c552e033a2863dd36ef648b

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

LOG: [lldb] Fix a warning

This patch fixes:

  lldb/source/Target/Memory.cpp:438:3: error: 'lock_guard' may not
  intend to support class template argument deduction
  [-Werror,-Wctad-maybe-unsupported]

Added: 


Modified: 
lldb/source/Target/Memory.cpp

Removed: 




diff  --git a/lldb/source/Target/Memory.cpp b/lldb/source/Target/Memory.cpp
index 9bfb8c349aa2c..a23a50718712d 100644
--- a/lldb/source/Target/Memory.cpp
+++ b/lldb/source/Target/Memory.cpp
@@ -435,7 +435,7 @@ bool AllocatedMemoryCache::DeallocateMemory(lldb::addr_t 
addr) {
 }
 
 bool AllocatedMemoryCache::IsInCache(lldb::addr_t addr) const {
-  std::lock_guard guard(m_mutex);
+  std::lock_guard guard(m_mutex);
 
   return llvm::any_of(m_memory_map, [addr](const auto &block) {
 return block.second->Contains(addr);



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


[Lldb-commits] [lldb] [lldb] Expose language plugin commands based based on language of current frame (PR #136766)

2025-05-01 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/136766

>From 94caf0b58ace58ae5159e3819f776ad6b2988329 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Tue, 22 Apr 2025 13:58:25 -0700
Subject: [PATCH 1/7] [lldb] Expose language plugin commands based based on
 language of current frame

---
 .../lldb/Interpreter/CommandInterpreter.h |  6 ++
 .../source/Interpreter/CommandInterpreter.cpp | 55 ++-
 2 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 724d88d65f6ac..26e0767951e7f 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -730,6 +730,12 @@ class CommandInterpreter : public Broadcaster,
   bool EchoCommandNonInteractive(llvm::StringRef line,
  const Flags &io_handler_flags) const;
 
+  /// Return the language specific command object for the current frame.
+  ///
+  /// For example, when stopped on a C++ frame, this returns the command object
+  /// for "language cplusplus" (`CommandObjectMultiwordItaniumABI`).
+  lldb::CommandObjectSP GetFrameLanguageCommand() const;
+
   // A very simple state machine which models the command handling transitions
   enum class CommandHandlingState {
 eIdle,
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index eb4741feb0aa5..2ff02ae5086b4 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1018,6 +1018,26 @@ CommandInterpreter::VerifyUserMultiwordCmdPath(Args 
&path, bool leaf_is_command,
   return cur_as_multi;
 }
 
+CommandObjectSP CommandInterpreter::GetFrameLanguageCommand() const {
+  if (auto frame_sp = GetExecutionContext().GetFrameSP()) {
+auto frame_language = Language::GetPrimaryLanguage(
+frame_sp->GuessLanguage().AsLanguageType());
+
+auto it = m_command_dict.find("language");
+if (it != m_command_dict.end()) {
+  // The root "language" command.
+  CommandObjectSP language_cmd_sp = it->second;
+
+  if (auto *plugin = Language::FindPlugin(frame_language)) {
+// "cplusplus", "objc", etc.
+auto lang_name = plugin->GetPluginName();
+return language_cmd_sp->GetSubcommandSPExact(lang_name);
+  }
+}
+  }
+  return {};
+}
+
 CommandObjectSP
 CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, bool include_aliases,
  bool exact, StringList *matches,
@@ -1050,11 +1070,20 @@ CommandInterpreter::GetCommandSP(llvm::StringRef 
cmd_str, bool include_aliases,
   command_sp = pos->second;
   }
 
+  // The `language` subcommand ("language objc", "language cplusplus", etc).
+  CommandObjectMultiword *lang_subcmd = nullptr;
+  if (!command_sp) {
+if (auto subcmd_sp = GetFrameLanguageCommand()) {
+  lang_subcmd = subcmd_sp->GetAsMultiwordCommand();
+  command_sp = subcmd_sp->GetSubcommandSPExact(cmd_str);
+}
+  }
+
   if (!exact && !command_sp) {
 // We will only get into here if we didn't find any exact matches.
 
 CommandObjectSP user_match_sp, user_mw_match_sp, alias_match_sp,
-real_match_sp;
+real_match_sp, lang_match_sp;
 
 StringList local_matches;
 if (matches == nullptr)
@@ -1064,6 +1093,7 @@ CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, 
bool include_aliases,
 unsigned int num_alias_matches = 0;
 unsigned int num_user_matches = 0;
 unsigned int num_user_mw_matches = 0;
+unsigned int num_lang_matches = 0;
 
 // Look through the command dictionaries one by one, and if we get only one
 // match from any of them in toto, then return that, otherwise return an
@@ -1121,11 +1151,28 @@ CommandInterpreter::GetCommandSP(llvm::StringRef 
cmd_str, bool include_aliases,
 user_mw_match_sp = pos->second;
 }
 
+if (lang_subcmd) {
+  num_lang_matches =
+  AddNamesMatchingPartialString(lang_subcmd->GetSubcommandDictionary(),
+cmd_str, *matches, descriptions);
+}
+
+if (num_lang_matches == 1) {
+  cmd.assign(matches->GetStringAtIndex(num_cmd_matches + num_alias_matches 
+
+   num_user_matches +
+   num_user_mw_matches));
+
+  auto &lang_dict = lang_subcmd->GetSubcommandDictionary();
+  auto pos = lang_dict.find(cmd);
+  if (pos != lang_dict.end())
+lang_match_sp = pos->second;
+}
+
 // If we got exactly one match, return that, otherwise return the match
 // list.
 
 if (num_user_matches + num_user_mw_matches + num_cmd_matches +
-num_alias_matches ==
+num_alias_matches + num_lang_matches ==
 1) {
   if (num_cmd_matches)
 return real_match_sp;
@@ -1133,8 +1180,10 @

[Lldb-commits] [lldb] [lldb-dap] Fix raciness in launch and attach tests (PR #137920)

2025-05-01 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> Is it possible to do the launching and attaching in asynchronous mode so that 
> the stop events are always emitted?

Yes, that's the alternative I mentioned the PR description: 

> An alternative approach could be to stop trying to hide the initial stop 
> event, and instead report it to the client unconditionally. Instead of 
> ignoring the stop for the asynchronous case, we could send a stop event after 
> we're done handling the synchronous case.

Thought I need to confirm that this would be compliant with the spec. I also 
think that from a user experience point of view, you probably don't want to see 
the stop (similar to how LLDB doesn't promote every private stop to a public 
stop). When attaching, we always stop. For launching, we hide the initial stop 
unless you requested stop-at-entry. 

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


[Lldb-commits] [lldb] [lldb] Do not bump memory modificator ID when "internal" debugger memory is updated (PR #129092)

2025-05-01 Thread Kazu Hirata via lldb-commits

kazutakahirata wrote:

@real-mikhail @jimingham I've landed 2bff80f25d51e24d3c552e033a2863dd36ef648b 
to fix a warning from this PR.  Thanks!

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


[Lldb-commits] [lldb] [lldb] Expose language plugin commands based based on language of current frame (PR #136766)

2025-05-01 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r HEAD~1...HEAD 
lldb/test/API/commands/command/language/TestFrameLanguageCommands.py 
lldb/test/API/commands/command/language/commands.py
``





View the diff from darker here.


``diff
--- TestFrameLanguageCommands.py2025-05-01 19:27:11.00 +
+++ TestFrameLanguageCommands.py2025-05-01 19:29:57.820344 +
@@ -1,9 +1,10 @@
 import lldb
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test.decorators import *
 import lldbsuite.test.lldbutil as lldbutil
+
 
 class TestCase(TestBase):
 def test(self):
 self.build()
 _, _, thread, _ = lldbutil.run_to_source_breakpoint(
--- commands.py 2025-05-01 19:27:11.00 +
+++ commands.py 2025-05-01 19:29:57.828082 +
@@ -1,5 +1,6 @@
 import lldb
+
 
 @lldb.command("tagged-pointer-collision")
 def noop(dbg, cmdstr, ctx, result, _):
 print("ran tagged-pointer-collision", file=result)

``




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


[Lldb-commits] [lldb] [lldb] Expose QueueThreadPlanForStepSingleInstruction function to SBThreadPlan (PR #137904)

2025-05-01 Thread Ely Ronnen via lldb-commits

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



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] Add runInTerminal support for Windows (PR #138160)

2025-05-01 Thread via lldb-commits

DrSergei wrote:

> There's an existing PR that adds this functionality as well: #121269 with 
> quite a bit of discussion. Does this PR have anything that's lacking in the 
> other PR?

It's quite similar. I use slightly different functionalites, but main idea is 
the same. Another PR looks abandoned. I am very interested in this 
functionality. You can close my PR and continue work on previous PR, thanks.


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


[Lldb-commits] [lldb] [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (PR #138020)

2025-05-01 Thread Chelsea Cassanova via lldb-commits


@@ -154,6 +154,20 @@ endif()
 
 add_definitions(-DLLDB_USE_OS_LOG)
 
+if(NOT CMAKE_OSX_SYSROOT)
+  execute_process(COMMAND xcodebuild -version -sdk macosx Path
+OUTPUT_VARIABLE SDKROOT
+ERROR_QUIET
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+  if(NOT EXISTS ${SDKROOT})
+message(FATAL_ERROR "Unable to obtain macOS SDK root, debugserver cannot 
be built.")
+  endif()
+
+  message(STATUS "Using macOS SDK root: ${SDKROOT}")
+  set(CMAKE_OSX_SYSROOT ${SDKROOT})
+endif()

chelcassanova wrote:

> The 
> [documentation](https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_SYSROOT.html)
>  also says that it should be set before the project()

Ah, I wasn't aware of that. In that case then I can update this to use a local 
variable instead of messing with the CMake variable itself.

Though I do also have a question. If CMake no longer computer this value and 
we're not computing it ourselves, is this now Clang's responsibility? The CMake 
4 release notes note that `Instead, compilers are expected to choose a default 
macOS SDK on their own` so I guess it is?

Either way, we can get the path we need from `xcrun` as you said.

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


[Lldb-commits] [lldb] [lldb] Support alternatives for scope format entries (PR #137751)

2025-05-01 Thread Jonas Devlieghere via lldb-commits


@@ -153,10 +173,37 @@ constexpr llvm::StringRef lookupStrings[] = {
 "${target.file.fullpath}",
 "${var.dummy-var-to-test-wildcard}"};
 
-TEST(FormatEntity, LookupAllEntriesInTree) {
+TEST_F(FormatEntityTest, LookupAllEntriesInTree) {
   for (const llvm::StringRef testString : lookupStrings) {
 Entry e;
 EXPECT_TRUE(FormatEntity::Parse(testString, e).Success())
 << "Formatting " << testString << " did not succeed";
   }
 }
+
+TEST_F(FormatEntityTest, Scope) {
+  // Scope with  one alternative.
+  EXPECT_THAT_EXPECTED(Format("{${frame.pc}|foo}"), HasValue("foo"));
+
+  // Scope with multiple alternatives.
+  EXPECT_THAT_EXPECTED(Format("{${frame.pc}|${function.name}|foo}"),
+   HasValue("foo"));
+
+  // Escaped pipe inside a scope.
+  EXPECT_THAT_EXPECTED(Format("{foo\\|bar}"), HasValue("foo|bar"));
+
+  // Unescaped pipe outside a scope.
+  EXPECT_THAT_EXPECTED(Format("foo|bar"), HasValue("foo|bar"));
+
+  // Nested scopes. Note that scopes always resolve.
+  EXPECT_THAT_EXPECTED(Format("{{${frame.pc}|foo}|{bar}}"), HasValue("foo"));
+  EXPECT_THAT_EXPECTED(Format("{{${frame.pc}}|{bar}}"), HasValue(""));

JDevlieghere wrote:

I'm on the fence. It's probably not too hard to implement (although you need to 
be careful to only trigger this for an alternative scope, a regular nested 
scope is okay). On the other hand, if you know how a scope works, I think this 
behaves pretty much as expected, it's just a rather unhelpful thing to do. I 
don't think we have precedence for diagnosing something like this. I can see 
how "clean" or "ugly" it is to implement and that might sway me one way or 
another. 

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


[Lldb-commits] [lldb] [lldb][cmake] Set `CMAKE_OSX_SYSROOT` when building debugserver with CMake 4 (PR #138020)

2025-05-01 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Add runInTerminal support for Windows (PR #138160)

2025-05-01 Thread via lldb-commits

DrSergei wrote:

Just a question, as far as I see, there is no `Static` scope and static 
variables are included in the `Global` scope. This may not be optimal for large 
projects with a large number of global variables (for example, global variables 
provided by libraries). Basically, there are not many static variables that are 
visible from the current frame, and they are more relevant. For, example 
codelldb and cortex-debug have `Static` scope. I can try to implement it, if 
you let. Also, some debug adapters provides opportunity to launch executable in 
external console. Looks like, DAP has support for that, I can work on that for 
lldb-dap.

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


[Lldb-commits] [lldb] [lldb] Expose language plugin commands based based on language of current frame (PR #136766)

2025-05-01 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/136766

>From 776dc6da5c5900adb97bb89a9ed7a60478bf05e1 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Tue, 22 Apr 2025 13:58:25 -0700
Subject: [PATCH 1/9] [lldb] Expose language plugin commands based based on
 language of current frame

---
 .../lldb/Interpreter/CommandInterpreter.h |  6 ++
 .../source/Interpreter/CommandInterpreter.cpp | 55 ++-
 2 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 724d88d65f6ac..26e0767951e7f 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -730,6 +730,12 @@ class CommandInterpreter : public Broadcaster,
   bool EchoCommandNonInteractive(llvm::StringRef line,
  const Flags &io_handler_flags) const;
 
+  /// Return the language specific command object for the current frame.
+  ///
+  /// For example, when stopped on a C++ frame, this returns the command object
+  /// for "language cplusplus" (`CommandObjectMultiwordItaniumABI`).
+  lldb::CommandObjectSP GetFrameLanguageCommand() const;
+
   // A very simple state machine which models the command handling transitions
   enum class CommandHandlingState {
 eIdle,
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index eb4741feb0aa5..2ff02ae5086b4 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1018,6 +1018,26 @@ CommandInterpreter::VerifyUserMultiwordCmdPath(Args 
&path, bool leaf_is_command,
   return cur_as_multi;
 }
 
+CommandObjectSP CommandInterpreter::GetFrameLanguageCommand() const {
+  if (auto frame_sp = GetExecutionContext().GetFrameSP()) {
+auto frame_language = Language::GetPrimaryLanguage(
+frame_sp->GuessLanguage().AsLanguageType());
+
+auto it = m_command_dict.find("language");
+if (it != m_command_dict.end()) {
+  // The root "language" command.
+  CommandObjectSP language_cmd_sp = it->second;
+
+  if (auto *plugin = Language::FindPlugin(frame_language)) {
+// "cplusplus", "objc", etc.
+auto lang_name = plugin->GetPluginName();
+return language_cmd_sp->GetSubcommandSPExact(lang_name);
+  }
+}
+  }
+  return {};
+}
+
 CommandObjectSP
 CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, bool include_aliases,
  bool exact, StringList *matches,
@@ -1050,11 +1070,20 @@ CommandInterpreter::GetCommandSP(llvm::StringRef 
cmd_str, bool include_aliases,
   command_sp = pos->second;
   }
 
+  // The `language` subcommand ("language objc", "language cplusplus", etc).
+  CommandObjectMultiword *lang_subcmd = nullptr;
+  if (!command_sp) {
+if (auto subcmd_sp = GetFrameLanguageCommand()) {
+  lang_subcmd = subcmd_sp->GetAsMultiwordCommand();
+  command_sp = subcmd_sp->GetSubcommandSPExact(cmd_str);
+}
+  }
+
   if (!exact && !command_sp) {
 // We will only get into here if we didn't find any exact matches.
 
 CommandObjectSP user_match_sp, user_mw_match_sp, alias_match_sp,
-real_match_sp;
+real_match_sp, lang_match_sp;
 
 StringList local_matches;
 if (matches == nullptr)
@@ -1064,6 +1093,7 @@ CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, 
bool include_aliases,
 unsigned int num_alias_matches = 0;
 unsigned int num_user_matches = 0;
 unsigned int num_user_mw_matches = 0;
+unsigned int num_lang_matches = 0;
 
 // Look through the command dictionaries one by one, and if we get only one
 // match from any of them in toto, then return that, otherwise return an
@@ -1121,11 +1151,28 @@ CommandInterpreter::GetCommandSP(llvm::StringRef 
cmd_str, bool include_aliases,
 user_mw_match_sp = pos->second;
 }
 
+if (lang_subcmd) {
+  num_lang_matches =
+  AddNamesMatchingPartialString(lang_subcmd->GetSubcommandDictionary(),
+cmd_str, *matches, descriptions);
+}
+
+if (num_lang_matches == 1) {
+  cmd.assign(matches->GetStringAtIndex(num_cmd_matches + num_alias_matches 
+
+   num_user_matches +
+   num_user_mw_matches));
+
+  auto &lang_dict = lang_subcmd->GetSubcommandDictionary();
+  auto pos = lang_dict.find(cmd);
+  if (pos != lang_dict.end())
+lang_match_sp = pos->second;
+}
+
 // If we got exactly one match, return that, otherwise return the match
 // list.
 
 if (num_user_matches + num_user_mw_matches + num_cmd_matches +
-num_alias_matches ==
+num_alias_matches + num_lang_matches ==
 1) {
   if (num_cmd_matches)
 return real_match_sp;
@@ -1133,8 +1180,10 @

[Lldb-commits] [lldb] [lldb] Expose language plugin commands based based on language of current frame (PR #136766)

2025-05-01 Thread Dave Lee via lldb-commits

kastiglione wrote:

@jimingham I've added 2f91d3f which includes a long help for `language` to 
describe this behavior. I'll look into making `help` show the output you 
suggest.

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-01 Thread David Peixotto via lldb-commits


@@ -0,0 +1,142 @@
+"""
+Test saving a mini dump, from yamilized examples.
+"""
+
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ProcessSaveCoreMinidumpTestCaseYaml(TestBase):
+def process_from_yaml(self, yaml_file):
+minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + 
".dmp")
+self.yaml2obj(yaml_file, minidump_path)
+self.target = self.dbg.CreateTarget(None)
+self.process = self.target.LoadCore(minidump_path)
+return self.process
+
+def test_saving_sub_memory_range(self):
+"""
+Validate we can save a Minidump for a subsection of a memory range.
+I.E.
+If our memory range is 0x1000-0x2000 nd the user specifies 
0x1200-0x1800
+we should still capture 0x1200 to 0x1800
+"""
+yaml = "minidump_mem64.yaml"
+proc = self.process_from_yaml(yaml)
+new_minidump_path = self.getBuildArtifact(__name__ + ".dmp")
+options = lldb.SBSaveCoreOptions()
+options.SetOutputFile(lldb.SBFileSpec(new_minidump_path))
+options.SetPluginName("minidump")
+options.SetStyle(lldb.eSaveCoreCustomOnly)
+
+size = 8
+begin = 0x2000
+end = begin + size
+custom_range = lldb.SBMemoryRegionInfo("", begin, end, 3, True, False)
+options.AddMemoryRegionToSave(custom_range)
+
+error = proc.SaveCore(options)
+self.assertTrue(error.Success(), error.GetCString())
+core_target = self.dbg.CreateTarget(None)
+core_process = core_target.LoadCore(new_minidump_path)
+
+error = lldb.SBError()
+core_process.ReadMemory(begin, size, error)
+self.assertTrue(error.Success(), error.GetCString())
+
+# Try to read 1 byte past the end
+core_process.ReadMemory(end + 1, 1, error)
+self.assertTrue(error.Fail(), error.GetCString())
+
+def test_saving_super_memory_range(self):
+"""
+Validate we can save a Minidump for a subsection of a memory range.
+I.E.
+If our memory range is 0x1000-0x2000 nd the user specifies 
0x0800-0x2800
+we should still capture 0x1000-0x2000
+"""
+yaml = "minidump_mem64.yaml"
+proc = self.process_from_yaml(yaml)
+new_minidump_path = self.getBuildArtifact(__name__ + ".dmp")
+options = lldb.SBSaveCoreOptions()
+options.SetOutputFile(lldb.SBFileSpec(new_minidump_path))
+options.SetPluginName("minidump")
+options.SetStyle(lldb.eSaveCoreCustomOnly)
+
+size = 0x100
+begin = 0x1000
+end = begin + size
+custom_range = lldb.SBMemoryRegionInfo("", begin - 16, end + 16, 3, 
True, False)
+options.AddMemoryRegionToSave(custom_range)
+
+error = proc.SaveCore(options)
+self.assertTrue(error.Success(), error.GetCString())
+core_target = self.dbg.CreateTarget(None)
+core_process = core_target.LoadCore(new_minidump_path)
+
+error = lldb.SBError()
+core_process.ReadMemory(begin, size, error)
+self.assertTrue(error.Success(), error.GetCString())
+
+def test_region_that_goes_out_of_bounds(self):
+"""
+Validate we can save a Minidump for a custom region
+that includes an end that enters an invalid (---) page.
+"""
+yaml = "minidump_mem64.yaml"
+proc = self.process_from_yaml(yaml)
+new_minidump_path = self.getBuildArtifact(__name__ + ".dmp")
+options = lldb.SBSaveCoreOptions()
+options.SetOutputFile(lldb.SBFileSpec(new_minidump_path))
+options.SetPluginName("minidump")
+options.SetStyle(lldb.eSaveCoreCustomOnly)
+
+size = 0x120
+begin = 0x1000
+end = begin + size
+custom_range = lldb.SBMemoryRegionInfo("", begin, end, 3, True, False)
+options.AddMemoryRegionToSave(custom_range)
+
+error = proc.SaveCore(options)
+self.assertTrue(error.Success(), error.GetCString())
+core_target = self.dbg.CreateTarget(None)
+core_process = core_target.LoadCore(new_minidump_path)
+
+error = lldb.SBError()
+core_process.ReadMemory(begin, 0x0020, error)
+self.assertTrue(error.Success(), error.GetCString())
+
+# Whole region should be unavailable
+core_process.ReadMemory(end, 1, error)

dmpots wrote:

This made me stop and think whether end would normally be included or not (i.e. 
is the end of the range inclusive). Seems it is, but using something like "real 
memory range end" + 1 (i.e. 0x1000+0x100+1) would make it a bit more clear that 
nothing outside the actual range should be valid.

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

[Lldb-commits] [lldb] [LLDB][SBSaveCore] Sbsavecore subregions bug (PR #138206)

2025-05-01 Thread David Peixotto via lldb-commits


@@ -0,0 +1,142 @@
+"""
+Test saving a mini dump, from yamilized examples.
+"""
+
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ProcessSaveCoreMinidumpTestCaseYaml(TestBase):
+def process_from_yaml(self, yaml_file):
+minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + 
".dmp")
+self.yaml2obj(yaml_file, minidump_path)
+self.target = self.dbg.CreateTarget(None)
+self.process = self.target.LoadCore(minidump_path)
+return self.process
+
+def test_saving_sub_memory_range(self):
+"""
+Validate we can save a Minidump for a subsection of a memory range.
+I.E.
+If our memory range is 0x1000-0x2000 nd the user specifies 
0x1200-0x1800
+we should still capture 0x1200 to 0x1800
+"""
+yaml = "minidump_mem64.yaml"
+proc = self.process_from_yaml(yaml)
+new_minidump_path = self.getBuildArtifact(__name__ + ".dmp")
+options = lldb.SBSaveCoreOptions()
+options.SetOutputFile(lldb.SBFileSpec(new_minidump_path))
+options.SetPluginName("minidump")
+options.SetStyle(lldb.eSaveCoreCustomOnly)
+
+size = 8
+begin = 0x2000
+end = begin + size
+custom_range = lldb.SBMemoryRegionInfo("", begin, end, 3, True, False)
+options.AddMemoryRegionToSave(custom_range)
+
+error = proc.SaveCore(options)
+self.assertTrue(error.Success(), error.GetCString())
+core_target = self.dbg.CreateTarget(None)
+core_process = core_target.LoadCore(new_minidump_path)
+
+error = lldb.SBError()
+core_process.ReadMemory(begin, size, error)
+self.assertTrue(error.Success(), error.GetCString())
+
+# Try to read 1 byte past the end
+core_process.ReadMemory(end + 1, 1, error)
+self.assertTrue(error.Fail(), error.GetCString())
+
+def test_saving_super_memory_range(self):
+"""
+Validate we can save a Minidump for a subsection of a memory range.
+I.E.
+If our memory range is 0x1000-0x2000 nd the user specifies 
0x0800-0x2800
+we should still capture 0x1000-0x2000
+"""
+yaml = "minidump_mem64.yaml"
+proc = self.process_from_yaml(yaml)
+new_minidump_path = self.getBuildArtifact(__name__ + ".dmp")
+options = lldb.SBSaveCoreOptions()
+options.SetOutputFile(lldb.SBFileSpec(new_minidump_path))
+options.SetPluginName("minidump")
+options.SetStyle(lldb.eSaveCoreCustomOnly)
+
+size = 0x100
+begin = 0x1000
+end = begin + size
+custom_range = lldb.SBMemoryRegionInfo("", begin - 16, end + 16, 3, 
True, False)
+options.AddMemoryRegionToSave(custom_range)
+
+error = proc.SaveCore(options)
+self.assertTrue(error.Success(), error.GetCString())
+core_target = self.dbg.CreateTarget(None)
+core_process = core_target.LoadCore(new_minidump_path)
+
+error = lldb.SBError()
+core_process.ReadMemory(begin, size, error)
+self.assertTrue(error.Success(), error.GetCString())

dmpots wrote:

Should we also check that reading a memory that was requested to be saved but 
was outside the real region returns an error (e.g. 0x1000-8)?

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


  1   2   >