[Lldb-commits] [lldb] [lldb] Disable TestConsecutiveBreakpoints.py for Windows x86_64 (PR #142192)

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

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


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


[Lldb-commits] [lldb] [lldb] Disable TestReverseContinueBreakpoints.py and TestReverseContinueWatchpoints.py for Windows x86_64 (PR #142193)

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

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


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


[Lldb-commits] [lldb] [lldb-dap][test] Fix DAP disassemble test (PR #142129)

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

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

>From 4c0bd999e60b7082fb30916c5f20d7ab064e76fe Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Fri, 30 May 2025 12:49:22 +0100
Subject: [PATCH 1/2] [lldb-dap][test] Fix DAP disassemble test

compare the instructions before and after setting breakpoint
to make sure they are the same. Do not use the source location as
it is not guaranteed to exist.
---
 .../disassemble/TestDAP_disassemble.py| 36 +++
 1 file changed, 22 insertions(+), 14 deletions(-)

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 a8b51864d118b..da7a337de5ea6 100644
--- a/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
+++ b/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
@@ -2,13 +2,9 @@
 Test lldb-dap disassemble request
 """
 
-
-import dap_server
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import skipIfWindows
+from lldbsuite.test.lldbtest import line_number
 import lldbdap_testcase
-import os
 
 
 class TestDAP_disassemble(lldbdap_testcase.DAPTestCaseBase):
@@ -23,15 +19,23 @@ def test_disassemble(self):
 self.set_source_breakpoints(source, [line_number(source, "// 
breakpoint 1")])
 self.continue_to_next_stop()
 
-_, pc_assembly = self.disassemble(frameIndex=0)
-self.assertIn("location", pc_assembly, "Source location missing.")
-self.assertIn("instruction", pc_assembly, "Assembly instruction 
missing.")
+insts_with_bp, pc_with_bp_assembly = self.disassemble(frameIndex=0)
+no_bp = self.set_source_breakpoints(source, [])
+self.assertEqual(len(no_bp), 0, "expect no breakpoints.")
+self.assertIn(
+"instruction", pc_with_bp_assembly, "Assembly instruction missing."
+)
 
-# The calling frame (qsort) is coming from a system library, as a 
result
-# we should not have a source location.
-_, qsort_assembly = self.disassemble(frameIndex=1)
-self.assertNotIn("location", qsort_assembly, "Source location not 
expected.")
-self.assertIn("instruction", pc_assembly, "Assembly instruction 
missing.")
+# the disassembly instructions should be the same even if there is a 
breakpoint;
+insts_no_bp, pc_no_bp_assembly = self.disassemble(frameIndex=0)
+self.assertDictEqual(
+insts_with_bp,
+insts_no_bp,
+"Expects instructions are the same after removing breakpoints.",
+)
+self.assertIn("instruction", pc_no_bp_assembly, "Assembly instruction 
missing.")
+
+self.continue_to_exit()
 
 @skipIfWindows
 def test_disassemble_backwards(self):
@@ -74,3 +78,7 @@ def test_disassemble_backwards(self):
 backwards_instructions,
 f"requested instruction should be preceeded by 
{backwards_instructions} instructions. Actual index: {frame_instruction_index}",
 )
+
+# clear breakpoints
+self.set_source_breakpoints(source, [])
+self.continue_to_exit()

>From c98ec8b5a87664d83802f502ae35596a35b48492 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Mon, 2 Jun 2025 09:41:23 +0100
Subject: [PATCH 2/2] [lldb-dap] add review changes

---
 .../lldb-dap/disassemble/TestDAP_disassemble.py   | 15 ---
 lldb/test/API/tools/lldb-dap/disassemble/main.c   |  4 +---
 2 files changed, 13 insertions(+), 6 deletions(-)

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 da7a337de5ea6..0562f20335a23 100644
--- a/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
+++ b/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
@@ -16,18 +16,27 @@ def test_disassemble(self):
 program = self.getBuildArtifact("a.out")
 self.build_and_launch(program)
 source = "main.c"
-self.set_source_breakpoints(source, [line_number(source, "// 
breakpoint 1")])
+bp_line_no = line_number(source, "// breakpoint 1")
+self.set_source_breakpoints(source, [bp_line_no])
 self.continue_to_next_stop()
 
 insts_with_bp, pc_with_bp_assembly = self.disassemble(frameIndex=0)
+self.assertIn("location", pc_with_bp_assembly, "Source location 
missing.")
+self.assertEqual(
+pc_with_bp_assembly["line"], bp_line_no, "Expects the same line 
number"
+)
 no_bp = self.set_source_breakpoints(source, [])
-self.assertEqual(len(no_bp), 0, "expect no breakpoints.")
+self.assertEqual(len(no_bp), 0, "Expects no breakpoints.")
 self.assertIn(
 "instruction", pc_with_bp_assembly, "Assembly instruction missing."
 )
 
-# the disassembly instruc

[Lldb-commits] [clang] [lldb] [lldb] Add filter option to AST dump command (PR #142164)

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

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

The LLDB parts look good.

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


[Lldb-commits] [clang] [lldb] [lldb] Add filter option to AST dump command (PR #142164)

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


@@ -8511,8 +8512,16 @@ TypeSystemClang::dump(lldb::opaque_compiler_type_t type) 
const {
 }
 #endif
 
-void TypeSystemClang::Dump(llvm::raw_ostream &output) {
-  GetTranslationUnitDecl()->dump(output);
+void TypeSystemClang::Dump(llvm::raw_ostream &output, llvm::StringRef filter) {
+  auto consumer =
+  clang::CreateASTDumper(output, filter,
+ /*DumpDecls=*/true,
+ /*Deserialize=*/false,
+ /*DumpLookups=*/false,
+ /*DumpDeclTypes=*/false, clang::ADOF_Default);
+  lldbassert(consumer);
+  lldbassert(m_ast_up);

labath wrote:

Use a plain assert? lldbassert is not going to help if you're going to 
dereference the pointer anyway.

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


[Lldb-commits] [clang] [lldb] [lldb] Add filter option to AST dump command (PR #142164)

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

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


[Lldb-commits] [clang] [lldb] [lldb] Add filter option to AST dump command (PR #142164)

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

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


[Lldb-commits] [lldb] 68fd6f4 - [lldb] Disable TestReverseContinueBreakpoints.py and TestReverseContinueWatchpoints.py for Windows x86_64 (#142193)

2025-06-02 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2025-06-02T14:01:45+04:00
New Revision: 68fd6f4eb86121d107dd4d0b282b11b48e82183b

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

LOG: [lldb] Disable TestReverseContinueBreakpoints.py and 
TestReverseContinueWatchpoints.py for Windows x86_64 (#142193)

See #138084 for details.

Added: 


Modified: 

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

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

Removed: 




diff  --git 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
index 0a5f2d88fb917..53c8cdd4540a2 100644
--- 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
+++ 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
@@ -63,10 +63,20 @@ def reverse_continue_breakpoint_internal(self, async_mode):
 self.assertEqual(threads_now, initial_threads)
 
 @skipIfRemote
+@skipIf(
+oslist=["windows"],
+archs=["x86_64"],
+bugnumber="github.com/llvm/llvm-project/issues/138084",
+)
 def test_reverse_continue_skip_breakpoint(self):
 self.reverse_continue_skip_breakpoint_internal(async_mode=False)
 
 @skipIfRemote
+@skipIf(
+oslist=["windows"],
+archs=["x86_64"],
+bugnumber="github.com/llvm/llvm-project/issues/138084",
+)
 def test_reverse_continue_skip_breakpoint_async(self):
 self.reverse_continue_skip_breakpoint_internal(async_mode=True)
 

diff  --git 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueWatchpoints.py
 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueWatchpoints.py
index a9e1bec5750e7..38cf5fced4944 100644
--- 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueWatchpoints.py
+++ 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueWatchpoints.py
@@ -64,12 +64,22 @@ def reverse_continue_watchpoint_internal(self, async_mode):
 @skipIfRemote
 # Watchpoints don't work in single-step mode
 @skipIf(macos_version=["<", "15.0"], archs=["arm64"])
+@skipIf(
+oslist=["windows"],
+archs=["x86_64"],
+bugnumber="github.com/llvm/llvm-project/issues/138084",
+)
 def test_reverse_continue_skip_watchpoint(self):
 self.reverse_continue_skip_watchpoint_internal(async_mode=False)
 
 @skipIfRemote
 # Watchpoints don't work in single-step mode
 @skipIf(macos_version=["<", "15.0"], archs=["arm64"])
+@skipIf(
+oslist=["windows"],
+archs=["x86_64"],
+bugnumber="github.com/llvm/llvm-project/issues/138084",
+)
 def test_reverse_continue_skip_watchpoint_async(self):
 self.reverse_continue_skip_watchpoint_internal(async_mode=True)
 



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


[Lldb-commits] [lldb] [lldb] Disable TestReverseContinueBreakpoints.py and TestReverseContinueWatchpoints.py for Windows x86_64 (PR #142193)

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

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


[Lldb-commits] [lldb] fb86264 - [lldb] Disable TestConsecutiveBreakpoints.py for Windows x86_64 (#142192)

2025-06-02 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2025-06-02T14:01:13+04:00
New Revision: fb86264f4049e866d4058ea151edb47381c85b77

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

LOG: [lldb] Disable TestConsecutiveBreakpoints.py for Windows x86_64 (#142192)

See #138083 for details.

Added: 


Modified: 

lldb/test/API/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
 
b/lldb/test/API/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
index ecea28c6e1f6d..351fae6b27678 100644
--- 
a/lldb/test/API/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
+++ 
b/lldb/test/API/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
@@ -91,6 +91,11 @@ def test_single_step(self):
 self.finish_test()
 
 @no_debug_info_test
+@skipIf(
+oslist=["windows"],
+archs=["x86_64"],
+bugnumber="github.com/llvm/llvm-project/issues/138083",
+)
 def test_single_step_thread_specific(self):
 """Test that single step stops, even though the second breakpoint is 
not valid."""
 self.prepare_test()



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


[Lldb-commits] [clang] [lldb] [lldb] Add filter option to AST dump command (PR #142164)

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

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

>From 662e07aa9bb6560f37c079ba6f13be17e7885b48 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 30 May 2025 15:44:09 +0100
Subject: [PATCH 1/6] [clang][Frontend] Add overload to ASTPrinter that doesn't
 own output stream

We're planning on using the ASTPrinter in LLDB for AST dumping. But it
currently takes the output stream via `unique_ptr`. In LLDB we don't
have the output stream available in this form and instead it would be
convenient if we could just pass a reference to the stream.

This patch adds that overload.

(cherry picked from commit 9bd15ee7ed44adc836bcd07ff7e856d7a32ba6a9)
---
 clang/include/clang/Frontend/ASTConsumers.h |  5 +
 clang/lib/Frontend/ASTConsumers.cpp | 20 
 2 files changed, 25 insertions(+)

diff --git a/clang/include/clang/Frontend/ASTConsumers.h 
b/clang/include/clang/Frontend/ASTConsumers.h
index 0e068bf5cccb5..890701b6ff188 100644
--- a/clang/include/clang/Frontend/ASTConsumers.h
+++ b/clang/include/clang/Frontend/ASTConsumers.h
@@ -35,6 +35,11 @@ CreateASTDumper(std::unique_ptr OS, StringRef 
FilterString,
 bool DumpDecls, bool Deserialize, bool DumpLookups,
 bool DumpDeclTypes, ASTDumpOutputFormat Format);
 
+std::unique_ptr
+CreateASTDumper(raw_ostream &OS, StringRef FilterString, bool DumpDecls,
+bool Deserialize, bool DumpLookups, bool DumpDeclTypes,
+ASTDumpOutputFormat Format);
+
 // AST Decl node lister: prints qualified names of all filterable AST Decl
 // nodes.
 std::unique_ptr CreateASTDeclNodeLister();
diff --git a/clang/lib/Frontend/ASTConsumers.cpp 
b/clang/lib/Frontend/ASTConsumers.cpp
index a6e35452b4fbe..a5ff4d44592d4 100644
--- a/clang/lib/Frontend/ASTConsumers.cpp
+++ b/clang/lib/Frontend/ASTConsumers.cpp
@@ -41,6 +41,13 @@ namespace {
   OutputKind(K), OutputFormat(Format), FilterString(FilterString),
   DumpLookups(DumpLookups), DumpDeclTypes(DumpDeclTypes) {}
 
+ASTPrinter(raw_ostream &Out, Kind K, ASTDumpOutputFormat Format,
+   StringRef FilterString, bool DumpLookups = false,
+   bool DumpDeclTypes = false)
+: Out(Out), OwnedOut(nullptr), OutputKind(K), OutputFormat(Format),
+  FilterString(FilterString), DumpLookups(DumpLookups),
+  DumpDeclTypes(DumpDeclTypes) {}
+
 void HandleTranslationUnit(ASTContext &Context) override {
   TranslationUnitDecl *D = Context.getTranslationUnitDecl();
 
@@ -176,6 +183,19 @@ clang::CreateASTDumper(std::unique_ptr Out, 
StringRef FilterString,
   Format, FilterString, DumpLookups, DumpDeclTypes);
 }
 
+std::unique_ptr
+clang::CreateASTDumper(raw_ostream &Out, StringRef FilterString, bool 
DumpDecls,
+   bool Deserialize, bool DumpLookups, bool DumpDeclTypes,
+   ASTDumpOutputFormat Format) {
+  assert((DumpDecls || Deserialize || DumpLookups) && "nothing to dump");
+  return std::make_unique(Out,
+  Deserialize ? ASTPrinter::DumpFull
+  : DumpDecls ? ASTPrinter::Dump
+  : ASTPrinter::None,
+  Format, FilterString, DumpLookups,
+  DumpDeclTypes);
+}
+
 std::unique_ptr clang::CreateASTDeclNodeLister() {
   return std::make_unique(nullptr);
 }

>From 0ba5a4f09caeb54008594adfb3b8efa2a740e5e6 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 30 May 2025 15:46:27 +0100
Subject: [PATCH 2/6] [lldb] Add filter option to AST dump command

This patch makes the `-ast-dump-filter` Clang option available to the
`target modules dump ast` command. This allows us to selectively dump
parts of the AST by name.

The AST can quickly grow way too large to skim on the console. This will
aid in debugging AST related issues.

Example:
```
(lldb) target modules dump ast --filter func
Dumping clang ast for 48 modules.
Dumping func:
FunctionDecl 0xc4b785008 <>  func 'void (int)' 
extern
|-ParmVarDecl 0xc4b7853d8 <>  x 'int'
`-AsmLabelAttr 0xc4b785358 <> Implicit "_Z4funcIiEvT_"

Dumping func:
FunctionDecl 0xc4b7850b8 <>  func 'void (int)' 
implicit_instantiation extern
|-TemplateArgument type 'int'
| `-BuiltinType 0xc4b85b110 'int'
`-ParmVarDecl 0xc4b7853d8 <>  x 'int'
```
---
 lldb/include/lldb/Symbol/SymbolFile.h |  2 +-
 lldb/include/lldb/Symbol/SymbolFileOnDemand.h |  2 +-
 lldb/include/lldb/Symbol/TypeSystem.h |  3 ++-
 lldb/source/Commands/CommandObjectTarget.cpp  | 23 +++
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  4 ++--
 .../SymbolFile/DWARF/SymbolFileDWARF.h|  2 +-
 .../DWARF/SymbolFileDWARFDebugMap.cpp |  6 ++---
 .../DWARF/SymbolFileDWARFDebugMap.h   |  2 +-
 .../SymbolFile/NativePDB/PdbAstBuilder.cpp|  4 ++--
 .../SymbolFile/NativePDB/PdbAstBuilder.h  |  2 +-
 

[Lldb-commits] [lldb] [lldb] Fix Linux core file tests hanging on Windows (PR #142143)

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

labath wrote:

This PR is correct. It would be nice to avoid this resume-core-file footgun, 
but I don't have an opinion on the proposed fix.

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


[Lldb-commits] [lldb] [lldb-dap][test] Fix DAP disassemble test (PR #142129)

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


@@ -23,15 +19,23 @@ def test_disassemble(self):
 self.set_source_breakpoints(source, [line_number(source, "// 
breakpoint 1")])
 self.continue_to_next_stop()
 
-_, pc_assembly = self.disassemble(frameIndex=0)
-self.assertIn("location", pc_assembly, "Source location missing.")
-self.assertIn("instruction", pc_assembly, "Assembly instruction 
missing.")
+insts_with_bp, pc_with_bp_assembly = self.disassemble(frameIndex=0)
+no_bp = self.set_source_breakpoints(source, [])
+self.assertEqual(len(no_bp), 0, "expect no breakpoints.")
+self.assertIn(
+"instruction", pc_with_bp_assembly, "Assembly instruction missing."
+)
 
-# The calling frame (qsort) is coming from a system library, as a 
result
-# we should not have a source location.
-_, qsort_assembly = self.disassemble(frameIndex=1)
-self.assertNotIn("location", qsort_assembly, "Source location not 
expected.")
-self.assertIn("instruction", pc_assembly, "Assembly instruction 
missing.")
+# the disassembly instructions should be the same even if there is a 
breakpoint;

da-viper wrote:

The instructions returned should be same with or without breakpoints, I updated 
the comment to clarify it. 

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


[Lldb-commits] [lldb] [lldb] Disable TestConsecutiveBreakpoints.py for Windows x86_64 (PR #142192)

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

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


[Lldb-commits] [lldb] [lldb-dap] Reimplement `runInTerminal` with signals (PR #142374)

2025-06-02 Thread Hu Jialun via lldb-commits

https://github.com/SuibianP updated 
https://github.com/llvm/llvm-project/pull/142374

>From a9c971019378236f7b4c680ff96c526625ff29ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jialun=20Hu=20=EF=BC=88=E8=83=A1=E4=BD=B3=E4=BC=A6?=
 =?UTF-8?q?=EF=BC=89?= 
Date: Mon, 2 Jun 2025 16:16:11 +0800
Subject: [PATCH] [lldb-dap] Reimplement runInTerminal with signals

runInTerminal is currently implemented using JSON messages over FIFOs,
which feels too clunky for the simple job of passing a PID.

Instead, take advantage of si_pid available from sa_sigaction handler,
and send a user signal instead. Both synchronisation and timeout are
preserved with the protocol below,

1. Debugger waits for SIGUSR1 under timeout with pselect
2. Launcher forks into child, sends SIGUSR1 to debugger and suspends
3. Debugger receives SIGUSR1, captures the sender (launcher child) PID,
   attaches to and resumes it
4. Launcher child resumes and exec's into target
5. Launcher parent waitpid's and kills irresponsive child after timeout

With this, the entirety of FifoFiles and RunInTerminal can be dropped.

Refs: https://github.com/llvm/llvm-project/pull/121269#issuecomment-2901401482
---
 .../runInTerminal/TestDAP_runInTerminal.py| 117 
 lldb/tools/lldb-dap/CMakeLists.txt|   2 -
 lldb/tools/lldb-dap/FifoFiles.cpp | 101 ---
 lldb/tools/lldb-dap/FifoFiles.h   |  85 -
 .../tools/lldb-dap/Handler/RequestHandler.cpp |  99 +++---
 lldb/tools/lldb-dap/JSONUtils.cpp |   5 +-
 lldb/tools/lldb-dap/JSONUtils.h   |   5 +-
 lldb/tools/lldb-dap/Options.td|  15 +-
 lldb/tools/lldb-dap/RunInTerminal.cpp | 170 --
 lldb/tools/lldb-dap/RunInTerminal.h   | 131 --
 lldb/tools/lldb-dap/tool/lldb-dap.cpp |  90 +-
 11 files changed, 126 insertions(+), 694 deletions(-)
 delete mode 100644 lldb/tools/lldb-dap/FifoFiles.cpp
 delete mode 100644 lldb/tools/lldb-dap/FifoFiles.h
 delete mode 100644 lldb/tools/lldb-dap/RunInTerminal.cpp
 delete mode 100644 lldb/tools/lldb-dap/RunInTerminal.h

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 65c931210d400..3b6571621e541 100644
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
@@ -131,120 +131,3 @@ def test_runInTerminalInvalidTarget(self):
 "'INVALIDPROGRAM' does not exist",
 response["body"]["error"]["format"],
 )
-
-@skipIfWindows
-@skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
-def test_missingArgInRunInTerminalLauncher(self):
-if not self.isTestSupported():
-return
-proc = subprocess.run(
-[self.lldbDAPExec, "--launch-target", "INVALIDPROGRAM"],
-capture_output=True,
-universal_newlines=True,
-)
-self.assertNotEqual(proc.returncode, 0)
-self.assertIn(
-'"--launch-target" requires "--comm-file" to be specified', 
proc.stderr
-)
-
-@skipIfWindows
-@skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
-def test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self):
-if not self.isTestSupported():
-return
-comm_file = os.path.join(self.getBuildDir(), "comm-file")
-os.mkfifo(comm_file)
-
-proc = subprocess.Popen(
-[
-self.lldbDAPExec,
-"--comm-file",
-comm_file,
-"--launch-target",
-"INVALIDPROGRAM",
-],
-universal_newlines=True,
-stderr=subprocess.PIPE,
-)
-
-self.readPidMessage(comm_file)
-self.sendDidAttachMessage(comm_file)
-self.assertIn("No such file or directory", 
self.readErrorMessage(comm_file))
-
-_, stderr = proc.communicate()
-self.assertIn("No such file or directory", stderr)
-
-@skipIfWindows
-@skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
-def test_FakeAttachedRunInTerminalLauncherWithValidProgram(self):
-if not self.isTestSupported():
-return
-comm_file = os.path.join(self.getBuildDir(), "comm-file")
-os.mkfifo(comm_file)
-
-proc = subprocess.Popen(
-[
-self.lldbDAPExec,
-"--comm-file",
-comm_file,
-"--launch-target",
-"echo",
-"foo",
-],
-universal_newlines=True,
-stdout=subprocess.PIPE,
-)
-
-self.readPidMessage(comm_file)
-self.sendDidAttachMessage(comm_file)
-
-stdout, _ = proc.communicate()
-self.assertIn("foo", stdout)
-
-@skipIfWindows
-@skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
-

[Lldb-commits] [lldb] [lldb][AIX] Added support to load DW_ranges section (PR #142356)

2025-06-02 Thread Dhruv Srivastava via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb] Emit an error when using --wait-for without a name or pid (PR #142424)

2025-06-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Motivated by https://discourse.llvm.org/t/why-is-wait-for-not-attaching/86636

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


2 Files Affected:

- (added) lldb/test/Shell/Driver/TestWaitFor.test (+2) 
- (modified) lldb/tools/driver/Driver.cpp (+6) 


``diff
diff --git a/lldb/test/Shell/Driver/TestWaitFor.test 
b/lldb/test/Shell/Driver/TestWaitFor.test
new file mode 100644
index 0..3afaef84d0111
--- /dev/null
+++ b/lldb/test/Shell/Driver/TestWaitFor.test
@@ -0,0 +1,2 @@
+# RUN: not %lldb --wait-for 2>&1 | FileCheck %s
+# CHECK: error: --wait-for requires a name (--attach-name) or pid 
(--attach-pid)
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index e19fded051941..3de48609d385c 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -280,6 +280,12 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, 
bool &exiting) {
   }
 
   if (args.hasArg(OPT_wait_for)) {
+if (!args.hasArg(OPT_attach_name) || !args.hasArg(OPT_attach_pid)) {
+  error.SetErrorStringWithFormat(
+  "--wait-for requires a name (--attach-name) or pid (--attach-pid)");
+  return error;
+}
+
 m_option_data.m_wait_for = true;
   }
 

``




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


[Lldb-commits] [lldb] [lldb][headers] Create Python script to fix up framework headers (PR #142051)

2025-06-02 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/142051

>From b47eaa64397da7ea5d2a7ca46bea4513a37755f0 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 28 May 2025 15:45:45 -0700
Subject: [PATCH] [lldb][headers] Create Python script to fix up framework
 headers

This commit replaces the shell script that fixes up includes for the
LLDB framework with a Python script. This script will also be used when
fixing up includes for the LLDBRPC.framework.
---
 lldb/cmake/modules/LLDBFramework.cmake|  34 ++---
 lldb/scripts/framework-header-fix.py  | 129 ++
 lldb/scripts/framework-header-fix.sh  |  17 ---
 .../Shell/Scripts/Inputs/Main/SBAddress.h |  13 ++
 .../Shell/Scripts/Inputs/RPC/RPCSBAddress.h   |   9 ++
 .../Shell/Scripts/TestFrameworkFixScript.test |  16 +++
 .../Scripts/TestRPCFrameworkFixScript.test|  14 ++
 7 files changed, 196 insertions(+), 36 deletions(-)
 create mode 100755 lldb/scripts/framework-header-fix.py
 delete mode 100755 lldb/scripts/framework-header-fix.sh
 create mode 100644 lldb/test/Shell/Scripts/Inputs/Main/SBAddress.h
 create mode 100644 lldb/test/Shell/Scripts/Inputs/RPC/RPCSBAddress.h
 create mode 100644 lldb/test/Shell/Scripts/TestFrameworkFixScript.test
 create mode 100644 lldb/test/Shell/Scripts/TestRPCFrameworkFixScript.test

diff --git a/lldb/cmake/modules/LLDBFramework.cmake 
b/lldb/cmake/modules/LLDBFramework.cmake
index 471aeaaad3c0d..9c2ad4ea6f0d6 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -68,24 +68,16 @@ if(NOT APPLE_EMBEDDED)
   )
 endif()
 
-# At configuration time, collect headers for the framework bundle and copy them
-# into a staging directory. Later we can copy over the entire folder.
-file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
-set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/API/SBLanguages.h)
-file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
-file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
-list(REMOVE_ITEM root_public_headers ${root_private_headers})
-
 find_program(unifdef_EXECUTABLE unifdef)
 
-set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders)
-foreach(header
-${public_headers}
-${generated_public_headers}
-${root_public_headers})
+# All necessary header files will be staged in the include directory in the 
build directory,
+# so just copy the files from there into the framework's staging directory.
+set(lldb_build_dir_header_staging ${CMAKE_BINARY_DIR}/include/lldb)
+set(lldb_framework_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders)
+foreach(header ${lldb_build_dir_header_staging})
 
   get_filename_component(basename ${header} NAME)
-  set(staged_header ${lldb_header_staging}/${basename})
+  set(staged_header ${lldb_framework_header_staging}/${basename})
 
   if(unifdef_EXECUTABLE)
 # unifdef returns 0 when the file is unchanged and 1 if something was 
changed.
@@ -107,14 +99,18 @@ endforeach()
 # Wrap output in a target, so lldb-framework can depend on it.
 add_custom_target(liblldb-resource-headers DEPENDS lldb-sbapi-dwarf-enums 
${lldb_staged_headers})
 set_target_properties(liblldb-resource-headers PROPERTIES FOLDER 
"LLDB/Resources")
+
+# We're taking the header files from where they've been staged in the build 
directory's include folder,
+# so create a dependency on the build step that creates that directory.
+add_dependencies(liblldb-resource-headers liblldb-header-staging)
 add_dependencies(liblldb liblldb-resource-headers)
 
-# At build time, copy the staged headers into the framework bundle (and do
-# some post-processing in-place).
+# Take the headers from the staging directory and fix up their includes for 
the framework.
+# Then write them to the output directory.
+# Also, run unifdef to remove any specified guards from the header files.
 add_custom_command(TARGET liblldb POST_BUILD
-  COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} 
$/Headers
-  COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh 
$/Headers ${LLDB_VERSION}
-  COMMENT "LLDB.framework: copy framework headers"
+  COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.py -f lldb_main -i 
${lldb_framework_header_staging} -o $/Headers -p 
${unifdef_EXECUTABLE} USWIG
+  COMMENT "LLDB.framework: Fix up and copy framework headers"
 )
 
 # Copy vendor-specific headers from clang (without staging).
diff --git a/lldb/scripts/framework-header-fix.py 
b/lldb/scripts/framework-header-fix.py
new file mode 100755
index 0..e6ea4e9bf917f
--- /dev/null
+++ b/lldb/scripts/framework-header-fix.py
@@ -0,0 +1,129 @@
+#!/usr/bin/env python3
+
+"""
+Usage:  
+
+This script is used when building LLDB.framework or LLDBRPC.framework. For 
each framework, local includes are converted to their respective framework 
includes.
+
+This script is used in 2 ways:
+1. It is used on header fil

[Lldb-commits] [lldb] [lldb] Add Python properties to SBBreakpoint(Location) (PR #142215)

2025-06-02 Thread via lldb-commits

jimingham wrote:

It would be better to add the same properties to the SBBreakpointName that the 
test failures showed up than to revert that test change.  If SBBreakpoint's and 
SBBreakpointLocations have these properties, SBBreakpoint names should as well.

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


[Lldb-commits] [lldb] def17cd - [lldb][AIX] Added support to load DW_ranges section (#142356)

2025-06-02 Thread via lldb-commits

Author: Hemang Gadhavi
Date: 2025-06-02T22:32:08+05:30
New Revision: def17cd38f48147ec2ab29674fc5746782c62b47

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

LOG: [lldb][AIX] Added support to load DW_ranges section (#142356)

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. https://github.com/llvm/llvm-project/issues/101657
The complete changes for porting are present in this draft PR:
https://github.com/llvm/llvm-project/pull/102601

- [lldb] [AIX] Added support to load Dwarf Ranges(.dwranges) section.

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp 
b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index e629355cd40b9..84d05e173f83f 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -239,6 +239,7 @@ void ObjectFileXCOFF::CreateSectionsWithBitness(
  .Case(".dwinfo", eSectionTypeDWARFDebugInfo)
  .Case(".dwline", eSectionTypeDWARFDebugLine)
  .Case(".dwabrev", eSectionTypeDWARFDebugAbbrev)
+ .Case(".dwrnges", eSectionTypeDWARFDebugRanges)
  .Default(eSectionTypeInvalid);
 }
 



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


[Lldb-commits] [lldb] [lldb][AIX] Added support to load DW_ranges section (PR #142356)

2025-06-02 Thread Dhruv Srivastava via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (PR #142224)

2025-06-02 Thread Greg Clayton via lldb-commits


@@ -120,6 +120,21 @@ TEST(Perf, RealPtraceScope) {
   << "Sensible values of ptrace_scope are between 0 and 3";
 }
 
+TEST(Perf, RealPtraceScopeWhenNotExist) {
+  // We first check we can NOT read /proc/sys/kernel/yama/ptrace_scope
+  auto buffer_or_error =
+  errorOrToExpected(getProcFile("sys/kernel/yama/ptrace_scope"));
+  if (buffer_or_error)
+GTEST_SKIP() << "In order for this test to run, "
+"/proc/sys/kernel/yama/ptrace_scope should not exist";

clayborg wrote:

Should we be  early returning here if `/proc/sys/kernel/yama/ptrace_scope` 
doesn't exist?

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


[Lldb-commits] [lldb] include telemetry session-id in diagnostic msg when enabled (PR #135924)

2025-06-02 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2025-06-02 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (PR #142224)

2025-06-02 Thread Greg Clayton via lldb-commits


@@ -120,6 +120,21 @@ TEST(Perf, RealPtraceScope) {
   << "Sensible values of ptrace_scope are between 0 and 3";
 }
 
+TEST(Perf, RealPtraceScopeWhenNotExist) {
+  // We first check we can NOT read /proc/sys/kernel/yama/ptrace_scope
+  auto buffer_or_error =
+  errorOrToExpected(getProcFile("sys/kernel/yama/ptrace_scope"));
+  if (buffer_or_error)
+GTEST_SKIP() << "In order for this test to run, "
+"/proc/sys/kernel/yama/ptrace_scope should not exist";

clayborg wrote:

Looks like GTEST_SKIP does do an early return somehow after checking the 
documentation.

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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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

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

None

>From 69efc48d722d18600018f25db0f9ea46b9fd1d97 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Wed, 28 May 2025 14:02:01 +0100
Subject: [PATCH] [lldb-dap] Use structured types for stepInTargets request

---
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  16 +-
 .../Handler/StepInTargetsRequestHandler.cpp   | 200 +++---
 .../lldb-dap/Protocol/ProtocolRequests.cpp|   9 +
 .../lldb-dap/Protocol/ProtocolRequests.h  |  15 ++
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  27 +++
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  29 +++
 lldb/unittests/DAP/ProtocolTypesTest.cpp  |  20 ++
 7 files changed, 186 insertions(+), 130 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h 
b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index 3a965bcc87a5e..559929ffb21e8 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -356,7 +356,21 @@ class StepInRequestHandler : public 
RequestHandler> {
+public:
+  using RequestHandler::RequestHandler;
+  static llvm::StringLiteral GetCommand() { return "stepInTargets"; }
+  FeatureSet GetSupportedFeatures() const override {
+return {protocol::eAdapterFeatureStepInTargetsRequest};
+  }
+  llvm::Expected
+  Run(const protocol::StepInTargetsArguments &args) const override;
+};
+
+class StepInTargetsRequestHandler2 : public LegacyRequestHandler {
 public:
   using LegacyRequestHandler::LegacyRequestHandler;
   static llvm::StringLiteral GetCommand() { return "stepInTargets"; }
diff --git a/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
index 9b99791599f82..1a76371be2d58 100644
--- a/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
@@ -7,143 +7,85 @@
 
//===--===//
 
 #include "DAP.h"
-#include "EventHelper.h"
-#include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBInstruction.h"
+#include "lldb/lldb-defines.h"
 
+using namespace lldb_dap::protocol;
 namespace lldb_dap {
 
-// "StepInTargetsRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "This request retrieves the possible step-in targets for
-// the specified stack frame.\nThese targets can be used in the `stepIn`
-// request.\nClients should only call this request if the corresponding
-// capability `supportsStepInTargetsRequest` is true.", "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "stepInTargets" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/StepInTargetsArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "StepInTargetsArguments": {
-//   "type": "object",
-//   "description": "Arguments for `stepInTargets` request.",
-//   "properties": {
-// "frameId": {
-//   "type": "integer",
-//   "description": "The stack frame for which to retrieve the possible
-//   step-in targets."
-// }
-//   },
-//   "required": [ "frameId" ]
-// },
-// "StepInTargetsResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to `stepInTargets` request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "targets": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/StepInTarget"
-// },
-// "description": "The possible step-in targets of the specified
-// source location."
-//   }
-// },
-// "required": [ "targets" ]
-//   }
-// },
-// "required": [ "body" ]
-//   }]
-// }
-void StepInTargetsRequestHandler::operator()(
-const llvm::json::Object &request) const {
-  llvm::json::Object response;
-  FillResponse(request, response);
-  const auto *arguments = request.getObject("arguments");
-
+// This request retrieves the possible step-in targets for the specified stack
+// frame.
+// These targets can be used in the `stepIn` request.
+// Clients should only call this request if the corresponding capability
+// `supportsStepInTargetsRequest` is true.
+llvm::Expected
+StepInTargetsRequestHandler::Run(const StepInTargetsArguments &args) const {
   dap.step_in_targets.clear();
-  lldb::SBFrame frame = dap.GetLLDBFrame(*arguments);
-  if (frame.IsValid()) {
-lldb::SBAddress pc_addr = frame.GetPCAddress();
-lldb::SBAddress line_end_addr =
-pc_addr.GetLineEntry().GetSameLineContiguousAddressRangeEnd(true);
-lldb::SBInstructionList insts = dap.target.ReadInstructions(
-pc_addr

[Lldb-commits] [lldb] [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (PR #142224)

2025-06-02 Thread Jordan Rupprecht via lldb-commits


@@ -104,7 +104,7 @@ TEST(Perf, RealLogicalCoreIDs) {
   ASSERT_GT((int)cpu_ids->size(), 0) << "We must see at least one core";
 }
 
-TEST(Perf, RealPtraceScope) {
+TEST(Perf, RealPtraceScopeWhenExist) {

rupprecht wrote:

I think it's a bug that I wrote `if (!*ptrace_scope_file)` instead of `if 
(!ptrace_scope_file)` -- I don't think there was anything I had in mind when 
writing it that way, e.g. if we should be able to assume the ptrace scope file 
exists & is readable. I'm surprised nobody noticed this bug earlier.

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


[Lldb-commits] [lldb] [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (PR #142224)

2025-06-02 Thread Jordan Rupprecht via lldb-commits

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


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

2025-06-02 Thread David Peixotto via lldb-commits

https://github.com/dmpots updated 
https://github.com/llvm/llvm-project/pull/134418

>From e240bda8fcea9db4d9c456929ba811feb8d4152b Mon Sep 17 00:00:00 2001
From: David Peixotto 
Date: Tue, 11 Mar 2025 13:02:14 -0700
Subject: [PATCH 01/20] Add commands to list/enable/disable plugins

This commit adds three new commands for managing plugins. The `list`
command will show which plugins are currently registered and their
enabled state. The `enable` and `disable` commands can be used to
enable or disable plugins.

A disabled plugin will not show up to the PluginManager when it iterates
over available plugins of a particular type.

The purpose of these commands is to provide more visibility into registered
plugins and allow users to disable plugins for experimental perf reasons.

There are a few limitations to the current implementation

  1. Only SystemRuntime plugins are currently supported. We can easily
 extend the existing implementation to support more types.
  2. Only "statically" know plugin types are supported (i.e. those
 managed by the PluginManager and not from `plugin load`). It is
 possibly we could support dynamic plugins as well, but I have
 not looked into it yet.
---
 lldb/source/Commands/CommandObjectPlugin.cpp  | 335 ++
 .../source/Commands/CommandObjectSettings.cpp |   1 +
 lldb/source/Commands/Options.td   |   5 +
 .../command-plugin-enable+disable.test|  53 +++
 .../Shell/Commands/command-plugin-list.test   |  51 +++
 5 files changed, 445 insertions(+)
 create mode 100644 lldb/test/Shell/Commands/command-plugin-enable+disable.test
 create mode 100644 lldb/test/Shell/Commands/command-plugin-list.test

diff --git a/lldb/source/Commands/CommandObjectPlugin.cpp 
b/lldb/source/Commands/CommandObjectPlugin.cpp
index f3108b8a768d2..68261d24ffe1f 100644
--- a/lldb/source/Commands/CommandObjectPlugin.cpp
+++ b/lldb/source/Commands/CommandObjectPlugin.cpp
@@ -7,8 +7,11 @@
 
//===--===//
 
 #include "CommandObjectPlugin.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Host/OptionParser.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
+#include "llvm/Support/GlobPattern.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -46,12 +49,344 @@ class CommandObjectPluginLoad : public CommandObjectParsed 
{
   }
 };
 
+namespace {
+#define LLDB_OPTIONS_plugin_list
+#include "CommandOptions.inc"
+
+// These option definitions are shared by the plugin list/enable/disable
+// commands.
+class PluginListCommandOptions : public Options {
+public:
+  PluginListCommandOptions() = default;
+
+  ~PluginListCommandOptions() override = default;
+
+  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ExecutionContext *execution_context) override {
+Status error;
+const int short_option = m_getopt_table[option_idx].val;
+
+switch (short_option) {
+case 'x':
+  m_exact_name_match = true;
+  break;
+default:
+  llvm_unreachable("Unimplemented option");
+}
+
+return error;
+  }
+
+  void OptionParsingStarting(ExecutionContext *execution_context) override {
+m_exact_name_match = false;
+  }
+
+  llvm::ArrayRef GetDefinitions() override {
+return llvm::ArrayRef(g_plugin_list_options);
+  }
+
+  // Instance variables to hold the values for command options.
+  bool m_exact_name_match = false;
+};
+
+// Define some data structures to describe known plugin "namespaces".
+// The PluginManager is organized into a series of static functions
+// that operate on different types of plugin. For example SystemRuntime
+// and ObjectFile plugins.
+//
+// The namespace name is used a prefix when matching plugin names. For example,
+// if we have an "elf" plugin in the "object-file" namespace then we will
+// match a plugin name pattern against the "object-file.elf" name.
+//
+// The plugin namespace here is used so we can operate on all the plugins
+// of a given type so it is easy to enable or disable them as a group.
+using GetPluginInfo = std::function()>;
+using SetPluginEnabled = std::function;
+struct PluginNamespace {
+  llvm::StringRef name;
+  GetPluginInfo get_info;
+  SetPluginEnabled set_enabled;
+};
+
+// Currently supported set of plugin namespaces. This will be expanded
+// over time.
+PluginNamespace PluginNamespaces[] = {
+{"system-runtime", PluginManager::GetSystemRuntimePluginInfo,
+ PluginManager::SetSystemRuntimePluginEnabled}};
+
+// Helper function to perform an action on each matching plugin.
+// The action callback is given the containing namespace along with plugin info
+// for each matching plugin.
+static int ActOnMatchingPlugins(
+llvm::GlobPattern pattern,
+std::function &plugin_info)>
+action) {
+  int num_matching = 0;
+
+  for (const PluginNamespace &plugin_namespace : PluginNamespaces) {
+std::vecto

[Lldb-commits] [lldb] [LLDB][NFC] Add accessor for SessionId (PR #142444)

2025-06-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vy Nguyen (oontvoo)


Changes



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


1 Files Affected:

- (modified) lldb/include/lldb/Core/Telemetry.h (+2) 


``diff
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 7889cda40e75f..5be68de6fcd7f 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -243,6 +243,8 @@ class TelemetryManager : public llvm::telemetry::Manager {
 protected:
   TelemetryManager(std::unique_ptr config);
 
+  inline const std::string &GetSessionId() const { return m_id; }
+
   static void SetInstance(std::unique_ptr manger);
 
 private:

``




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


[Lldb-commits] [lldb] [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (PR #142224)

2025-06-02 Thread via lldb-commits

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


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

2025-06-02 Thread David Peixotto via lldb-commits


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

dmpots wrote:

Left it enabled by default.

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


[Lldb-commits] [lldb] 8e8da88 - [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (#142224)

2025-06-02 Thread via lldb-commits

Author: royitaqi
Date: 2025-06-02T10:43:58-07:00
New Revision: 8e8da88d46dcb1ba6ffe266779dd047fa772497e

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

LOG: [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (#142224)

# Symptom

We have seen SIGSEGV like this:
```
* thread #1, name = 'lldb-server', stop reason = SIGSEGV
frame #0: 0x7f39e529c993 libc.so.6`__pthread_kill_internal(signo=11, 
threadid=) at pthread_kill.c:46:37
...
  * frame #5: 0x56027c94fe48 
lldb-server`lldb_private::process_linux::GetPtraceScope() + 72
frame #6: 0x56027c92f94f 
lldb-server`lldb_private::process_linux::NativeProcessLinux::Attach(int) + 1087
...
```
See [full stack trace](https://pastebin.com/X0d6QhYj).

This happens on Linux where LLDB doesn't have access to
`/proc/sys/kernel/yama/ptrace_scope`.

A similar error (an unchecked `Error`) can be reproduced by running the
newly added unit test without the fix. See the "Test" section below.


# Root cause

`GetPtraceScope()`
([code](https://github.com/llvm/llvm-project/blob/328f40f408c218f25695ea42c844e43bef38660b/lldb/source/Plugins/Process/Linux/Procfs.cpp#L77))
has the following `if` statement:
```
llvm::Expected lldb_private::process_linux::GetPtraceScope() {
  ErrorOr> ptrace_scope_file =
  getProcFile("sys/kernel/yama/ptrace_scope");
  if (!*ptrace_scope_file)
return errorCodeToError(ptrace_scope_file.getError());
  ...
}
```

The intention of the `if` statement is to check whether the
`ptrace_scope_file` is an `Error` or not, and return the error if it is.
However, the `operator*` of `ErrorOr` returns the value that is stored
(which is a `std::unique_ptr`), so what the `if` condition
actually do is to check if the unique pointer is non-null.

Note that the method `ErrorOr::getStorage()` ([called
by](https://github.com/llvm/llvm-project/blob/328f40f408c218f25695ea42c844e43bef38660b/llvm/include/llvm/Support/ErrorOr.h#L162-L164)
`ErrorOr::operator *`) **does** assert on whether or not `HasError` has
been set (see
[ErrorOr.h](https://github.com/llvm/llvm-project/blob/328f40f408c218f25695ea42c844e43bef38660b/llvm/include/llvm/Support/ErrorOr.h#L235-L243)).
However, it seems this wasn't executed, probably because the LLDB was a
release build.

# Fix

The fix is simply remove the `*` in the said `if` statement.

Added: 


Modified: 
lldb/source/Plugins/Process/Linux/Procfs.cpp
lldb/unittests/Process/Linux/ProcfsTests.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/Linux/Procfs.cpp 
b/lldb/source/Plugins/Process/Linux/Procfs.cpp
index d3bd396fbaeab..4349a2b1adb9d 100644
--- a/lldb/source/Plugins/Process/Linux/Procfs.cpp
+++ b/lldb/source/Plugins/Process/Linux/Procfs.cpp
@@ -74,7 +74,7 @@ lldb_private::process_linux::GetAvailableLogicalCoreIDs() {
 llvm::Expected lldb_private::process_linux::GetPtraceScope() {
   ErrorOr> ptrace_scope_file =
   getProcFile("sys/kernel/yama/ptrace_scope");
-  if (!*ptrace_scope_file)
+  if (!ptrace_scope_file)
 return errorCodeToError(ptrace_scope_file.getError());
   // The contents should be something like "1\n". Trim it so we get "1".
   StringRef buffer = (*ptrace_scope_file)->getBuffer().trim();

diff  --git a/lldb/unittests/Process/Linux/ProcfsTests.cpp 
b/lldb/unittests/Process/Linux/ProcfsTests.cpp
index e7af1f469c2bf..534e3e132ec62 100644
--- a/lldb/unittests/Process/Linux/ProcfsTests.cpp
+++ b/lldb/unittests/Process/Linux/ProcfsTests.cpp
@@ -104,7 +104,7 @@ TEST(Perf, RealLogicalCoreIDs) {
   ASSERT_GT((int)cpu_ids->size(), 0) << "We must see at least one core";
 }
 
-TEST(Perf, RealPtraceScope) {
+TEST(Perf, RealPtraceScopeWhenExist) {
   // We first check we can read /proc/sys/kernel/yama/ptrace_scope
   auto buffer_or_error =
   errorOrToExpected(getProcFile("sys/kernel/yama/ptrace_scope"));
@@ -120,6 +120,21 @@ TEST(Perf, RealPtraceScope) {
   << "Sensible values of ptrace_scope are between 0 and 3";
 }
 
+TEST(Perf, RealPtraceScopeWhenNotExist) {
+  // We first check we can NOT read /proc/sys/kernel/yama/ptrace_scope
+  auto buffer_or_error =
+  errorOrToExpected(getProcFile("sys/kernel/yama/ptrace_scope"));
+  if (buffer_or_error)
+GTEST_SKIP() << "In order for this test to run, "
+"/proc/sys/kernel/yama/ptrace_scope should not exist";
+  consumeError(buffer_or_error.takeError());
+
+  // At this point we should fail parsing the ptrace_scope value.
+  Expected ptrace_scope = GetPtraceScope();
+  ASSERT_FALSE((bool)ptrace_scope);
+  consumeError(ptrace_scope.takeError());
+}
+
 #ifdef LLVM_ENABLE_THREADING
 TEST(Support, getProcFile_Tid) {
   auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(), "comm");



___
lldb-commits mailing list
lld

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

2025-06-02 Thread David Peixotto via lldb-commits


@@ -46,12 +49,206 @@ class CommandObjectPluginLoad : public CommandObjectParsed 
{
   }
 };
 
+namespace {
+// Helper function to perform an action on each matching plugin.
+// The action callback is given the containing namespace along with plugin info
+// for each matching plugin.
+static int ActOnMatchingPlugins(
+const llvm::StringRef pattern,
+std::function &plugin_info)>
+action) {
+  int num_matching = 0;
+
+  for (const PluginNamespace &plugin_namespace :
+   PluginManager::GetPluginNamespaces()) {
+const bool match_namespace =
+pattern.empty() || pattern == plugin_namespace.name;
+
+std::vector matching_plugins;
+for (const RegisteredPluginInfo &plugin_info :
+ plugin_namespace.get_info()) {
+
+  // If we match the namespace, we can skip the plugin name check.
+  bool match_qualified_name = false;
+  if (!match_namespace) {
+std::string qualified_name =
+(plugin_namespace.name + "." + plugin_info.name).str();
+match_qualified_name = pattern == qualified_name;
+  }
+
+  if (match_namespace || match_qualified_name)
+matching_plugins.push_back(plugin_info);
+}
+
+if (!matching_plugins.empty()) {
+  num_matching += matching_plugins.size();
+  action(plugin_namespace, matching_plugins);
+}
+  }
+
+  return num_matching;
+}
+
+// Call the "SetEnable" function for each matching plugins.
+// Used to share the majority of the code between the enable
+// and disable commands.
+int SetEnableOnMatchingPlugins(const llvm::StringRef &pattern,
+   CommandReturnObject &result, bool enabled) {
+  return ActOnMatchingPlugins(
+  pattern, [&](const PluginNamespace &plugin_namespace,
+   const std::vector &plugins) {
+result.AppendMessage(plugin_namespace.name);
+for (const auto &plugin : plugins) {
+  if (!plugin_namespace.set_enabled(plugin.name, enabled)) {
+result.AppendErrorWithFormat("failed to enable plugin %s.%s",
+ plugin_namespace.name.data(),
+ plugin.name.data());
+continue;
+  }
+
+  result.AppendMessageWithFormat(
+  "  %s %-30s %s\n", enabled ? "[+]" : "[-]", plugin.name.data(),
+  plugin.description.data());
+}
+  });
+}
+} // namespace
+
+class CommandObjectPluginList : public CommandObjectParsed {
+public:
+  CommandObjectPluginList(CommandInterpreter &interpreter)
+  : CommandObjectParsed(interpreter, "plugin list",
+"Report info about registered LLDB plugins.",
+nullptr) {
+AddSimpleArgumentList(eArgTypeManagedPlugin);
+SetHelpLong(R"(
+Display information about registered plugins.
+The plugin information is formatted as shown below:
+
+
+  [+]   Plugin #1 description
+  [-]   Plugin #2 description
+
+An enabled plugin is marked with [+] and a disabled plugin is marked with [-].
+
+Plugins can be listed by namespace and name with:
+
+  plugin list [.]
+
+Plugins can be listed by namespace alone or with a fully qualified name. When 
listed
+with just a namespace all plugins in that namespace are listed.  When no 
arguments
+are given all plugins are listed.
+
+Examples:
+List all plugins
+
+  (lldb) plugin list
+
+List all plugins in the system-runtime namespace
+
+  (lldb) plugin list system-runtime
+
+List only the plugin 'foo' matching a fully qualified name exactly
+
+  (lldb) plugin list system-runtime.foo
+)");
+  }
+
+  ~CommandObjectPluginList() override = default;
+
+protected:
+  void DoExecute(Args &command, CommandReturnObject &result) override {
+size_t argc = command.GetArgumentCount();
+if (argc > 1) {
+  result.AppendError("'plugin load' requires one argument");
+  return;
+}
+llvm::StringRef pattern = argc ? command[0].ref() : "";
+result.SetStatus(eReturnStatusSuccessFinishResult);
+
+int num_matching = ActOnMatchingPlugins(
+pattern, [&](const PluginNamespace &plugin_namespace,
+ const std::vector &plugins) {
+  result.AppendMessage(plugin_namespace.name);
+  for (auto &plugin : plugins) {
+result.AppendMessageWithFormat(
+"  %s %-30s %s\n", plugin.enabled ? "[+]" : "[-]",
+plugin.name.data(), plugin.description.data());
+  }
+});
+
+if (num_matching == 0)
+  result.AppendErrorWithFormat("Found no matching plugins");
+  }
+};
+
+class CommandObjectPluginEnable : public CommandObjectParsed {

dmpots wrote:

Decided to disallow empty args for enable/disable. We can always add a `--all` 
option later if desired.

https://github.com/llvm/llvm-project/pull/134418
___
lldb-commits mailing list
lldb-commits@lists.

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

2025-06-02 Thread David Peixotto via lldb-commits


@@ -464,6 +466,24 @@ llvm::json::Value DebuggerStats::ReportStatistics(
 }
   }
 
+  if (include_plugins) {
+json::Object plugin_stats;
+for (const PluginNamespace &plugin_ns :
+ PluginManager::GetPluginNamespaces()) {
+  json::Array namespace_stats;
+
+  for (const RegisteredPluginInfo &plugin : plugin_ns.get_info()) {
+json::Object plugin_json;
+plugin_json.try_emplace("name", plugin.name);
+plugin_json.try_emplace("enabled", plugin.enabled);
+
+namespace_stats.emplace_back(std::move(plugin_json));
+  }
+  plugin_stats.try_emplace(plugin_ns.name, std::move(namespace_stats));
+}
+global_stats.try_emplace("plugins", std::move(plugin_stats));
+  }
+

dmpots wrote:

Moved the code to the PluginManager and added support for `plugin list --json` 
on the command line.

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


[Lldb-commits] [lldb] [LLDB][NFC] Add accessor for SessionId (PR #142444)

2025-06-02 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo created 
https://github.com/llvm/llvm-project/pull/142444

None

>From 38e85beda6ddc9b102fab5ec9133364a75ac5022 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Mon, 2 Jun 2025 13:40:40 -0400
Subject: [PATCH] Add accessor for SessionId

---
 lldb/include/lldb/Core/Telemetry.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 7889cda40e75f..5be68de6fcd7f 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -243,6 +243,8 @@ class TelemetryManager : public llvm::telemetry::Manager {
 protected:
   TelemetryManager(std::unique_ptr config);
 
+  inline const std::string &GetSessionId() const { return m_id; }
+
   static void SetInstance(std::unique_ptr manger);
 
 private:

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


[Lldb-commits] [lldb] 88c1403 - [LLDB][NFC] Add accessor for SessionId (#142444)

2025-06-02 Thread via lldb-commits

Author: Vy Nguyen
Date: 2025-06-02T13:46:03-04:00
New Revision: 88c1403981dee9844042a99dc357d8034cf5d197

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

LOG: [LLDB][NFC] Add accessor for SessionId (#142444)

Added: 


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

Removed: 




diff  --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 7889cda40e75f..5be68de6fcd7f 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -243,6 +243,8 @@ class TelemetryManager : public llvm::telemetry::Manager {
 protected:
   TelemetryManager(std::unique_ptr config);
 
+  inline const std::string &GetSessionId() const { return m_id; }
+
   static void SetInstance(std::unique_ptr manger);
 
 private:



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


[Lldb-commits] [lldb] [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (PR #142224)

2025-06-02 Thread Jordan Rupprecht via lldb-commits

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

Thank you!

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


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

2025-06-02 Thread David Peixotto via lldb-commits


@@ -46,12 +49,206 @@ class CommandObjectPluginLoad : public CommandObjectParsed 
{
   }
 };
 
+namespace {
+// Helper function to perform an action on each matching plugin.
+// The action callback is given the containing namespace along with plugin info
+// for each matching plugin.
+static int ActOnMatchingPlugins(
+const llvm::StringRef pattern,
+std::function &plugin_info)>
+action) {
+  int num_matching = 0;
+
+  for (const PluginNamespace &plugin_namespace :
+   PluginManager::GetPluginNamespaces()) {
+const bool match_namespace =
+pattern.empty() || pattern == plugin_namespace.name;
+
+std::vector matching_plugins;
+for (const RegisteredPluginInfo &plugin_info :
+ plugin_namespace.get_info()) {
+
+  // If we match the namespace, we can skip the plugin name check.
+  bool match_qualified_name = false;
+  if (!match_namespace) {
+std::string qualified_name =
+(plugin_namespace.name + "." + plugin_info.name).str();
+match_qualified_name = pattern == qualified_name;
+  }
+
+  if (match_namespace || match_qualified_name)
+matching_plugins.push_back(plugin_info);
+}
+
+if (!matching_plugins.empty()) {
+  num_matching += matching_plugins.size();
+  action(plugin_namespace, matching_plugins);
+}
+  }
+
+  return num_matching;
+}
+
+// Call the "SetEnable" function for each matching plugins.
+// Used to share the majority of the code between the enable
+// and disable commands.
+int SetEnableOnMatchingPlugins(const llvm::StringRef &pattern,
+   CommandReturnObject &result, bool enabled) {
+  return ActOnMatchingPlugins(
+  pattern, [&](const PluginNamespace &plugin_namespace,
+   const std::vector &plugins) {
+result.AppendMessage(plugin_namespace.name);
+for (const auto &plugin : plugins) {
+  if (!plugin_namespace.set_enabled(plugin.name, enabled)) {
+result.AppendErrorWithFormat("failed to enable plugin %s.%s",
+ plugin_namespace.name.data(),
+ plugin.name.data());
+continue;
+  }
+
+  result.AppendMessageWithFormat(
+  "  %s %-30s %s\n", enabled ? "[+]" : "[-]", plugin.name.data(),
+  plugin.description.data());
+}
+  });
+}
+} // namespace
+
+class CommandObjectPluginList : public CommandObjectParsed {
+public:
+  CommandObjectPluginList(CommandInterpreter &interpreter)
+  : CommandObjectParsed(interpreter, "plugin list",
+"Report info about registered LLDB plugins.",
+nullptr) {
+AddSimpleArgumentList(eArgTypeManagedPlugin);
+SetHelpLong(R"(
+Display information about registered plugins.
+The plugin information is formatted as shown below:
+
+
+  [+]   Plugin #1 description
+  [-]   Plugin #2 description
+
+An enabled plugin is marked with [+] and a disabled plugin is marked with [-].
+
+Plugins can be listed by namespace and name with:
+
+  plugin list [.]
+
+Plugins can be listed by namespace alone or with a fully qualified name. When 
listed
+with just a namespace all plugins in that namespace are listed.  When no 
arguments
+are given all plugins are listed.
+
+Examples:
+List all plugins
+
+  (lldb) plugin list
+
+List all plugins in the system-runtime namespace
+
+  (lldb) plugin list system-runtime
+
+List only the plugin 'foo' matching a fully qualified name exactly
+
+  (lldb) plugin list system-runtime.foo
+)");
+  }
+
+  ~CommandObjectPluginList() override = default;
+
+protected:
+  void DoExecute(Args &command, CommandReturnObject &result) override {
+size_t argc = command.GetArgumentCount();
+if (argc > 1) {
+  result.AppendError("'plugin load' requires one argument");
+  return;
+}
+llvm::StringRef pattern = argc ? command[0].ref() : "";
+result.SetStatus(eReturnStatusSuccessFinishResult);
+
+int num_matching = ActOnMatchingPlugins(
+pattern, [&](const PluginNamespace &plugin_namespace,
+ const std::vector &plugins) {
+  result.AppendMessage(plugin_namespace.name);
+  for (auto &plugin : plugins) {
+result.AppendMessageWithFormat(
+"  %s %-30s %s\n", plugin.enabled ? "[+]" : "[-]",
+plugin.name.data(), plugin.description.data());
+  }
+});
+
+if (num_matching == 0)
+  result.AppendErrorWithFormat("Found no matching plugins");
+  }
+};
+
+class CommandObjectPluginEnable : public CommandObjectParsed {
+public:
+  CommandObjectPluginEnable(CommandInterpreter &interpreter)
+  : CommandObjectParsed(interpreter, "plugin enable",
+"Enable registered LLDB plugins.", nullptr) {
+AddSimpleArgumentList(eArgTypeManagedPlugin);
+  }
+
+  ~CommandObject

[Lldb-commits] [lldb] [LLDB][NFC] Add accessor for SessionId (PR #142444)

2025-06-02 Thread Vy Nguyen via lldb-commits

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


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

2025-06-02 Thread David Peixotto via lldb-commits

https://github.com/dmpots updated 
https://github.com/llvm/llvm-project/pull/134418

>From e240bda8fcea9db4d9c456929ba811feb8d4152b Mon Sep 17 00:00:00 2001
From: David Peixotto 
Date: Tue, 11 Mar 2025 13:02:14 -0700
Subject: [PATCH 01/21] Add commands to list/enable/disable plugins

This commit adds three new commands for managing plugins. The `list`
command will show which plugins are currently registered and their
enabled state. The `enable` and `disable` commands can be used to
enable or disable plugins.

A disabled plugin will not show up to the PluginManager when it iterates
over available plugins of a particular type.

The purpose of these commands is to provide more visibility into registered
plugins and allow users to disable plugins for experimental perf reasons.

There are a few limitations to the current implementation

  1. Only SystemRuntime plugins are currently supported. We can easily
 extend the existing implementation to support more types.
  2. Only "statically" know plugin types are supported (i.e. those
 managed by the PluginManager and not from `plugin load`). It is
 possibly we could support dynamic plugins as well, but I have
 not looked into it yet.
---
 lldb/source/Commands/CommandObjectPlugin.cpp  | 335 ++
 .../source/Commands/CommandObjectSettings.cpp |   1 +
 lldb/source/Commands/Options.td   |   5 +
 .../command-plugin-enable+disable.test|  53 +++
 .../Shell/Commands/command-plugin-list.test   |  51 +++
 5 files changed, 445 insertions(+)
 create mode 100644 lldb/test/Shell/Commands/command-plugin-enable+disable.test
 create mode 100644 lldb/test/Shell/Commands/command-plugin-list.test

diff --git a/lldb/source/Commands/CommandObjectPlugin.cpp 
b/lldb/source/Commands/CommandObjectPlugin.cpp
index f3108b8a768d2..68261d24ffe1f 100644
--- a/lldb/source/Commands/CommandObjectPlugin.cpp
+++ b/lldb/source/Commands/CommandObjectPlugin.cpp
@@ -7,8 +7,11 @@
 
//===--===//
 
 #include "CommandObjectPlugin.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Host/OptionParser.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
+#include "llvm/Support/GlobPattern.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -46,12 +49,344 @@ class CommandObjectPluginLoad : public CommandObjectParsed 
{
   }
 };
 
+namespace {
+#define LLDB_OPTIONS_plugin_list
+#include "CommandOptions.inc"
+
+// These option definitions are shared by the plugin list/enable/disable
+// commands.
+class PluginListCommandOptions : public Options {
+public:
+  PluginListCommandOptions() = default;
+
+  ~PluginListCommandOptions() override = default;
+
+  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ExecutionContext *execution_context) override {
+Status error;
+const int short_option = m_getopt_table[option_idx].val;
+
+switch (short_option) {
+case 'x':
+  m_exact_name_match = true;
+  break;
+default:
+  llvm_unreachable("Unimplemented option");
+}
+
+return error;
+  }
+
+  void OptionParsingStarting(ExecutionContext *execution_context) override {
+m_exact_name_match = false;
+  }
+
+  llvm::ArrayRef GetDefinitions() override {
+return llvm::ArrayRef(g_plugin_list_options);
+  }
+
+  // Instance variables to hold the values for command options.
+  bool m_exact_name_match = false;
+};
+
+// Define some data structures to describe known plugin "namespaces".
+// The PluginManager is organized into a series of static functions
+// that operate on different types of plugin. For example SystemRuntime
+// and ObjectFile plugins.
+//
+// The namespace name is used a prefix when matching plugin names. For example,
+// if we have an "elf" plugin in the "object-file" namespace then we will
+// match a plugin name pattern against the "object-file.elf" name.
+//
+// The plugin namespace here is used so we can operate on all the plugins
+// of a given type so it is easy to enable or disable them as a group.
+using GetPluginInfo = std::function()>;
+using SetPluginEnabled = std::function;
+struct PluginNamespace {
+  llvm::StringRef name;
+  GetPluginInfo get_info;
+  SetPluginEnabled set_enabled;
+};
+
+// Currently supported set of plugin namespaces. This will be expanded
+// over time.
+PluginNamespace PluginNamespaces[] = {
+{"system-runtime", PluginManager::GetSystemRuntimePluginInfo,
+ PluginManager::SetSystemRuntimePluginEnabled}};
+
+// Helper function to perform an action on each matching plugin.
+// The action callback is given the containing namespace along with plugin info
+// for each matching plugin.
+static int ActOnMatchingPlugins(
+llvm::GlobPattern pattern,
+std::function &plugin_info)>
+action) {
+  int num_matching = 0;
+
+  for (const PluginNamespace &plugin_namespace : PluginNamespaces) {
+std::vecto

[Lldb-commits] [lldb] [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (PR #142224)

2025-06-02 Thread via lldb-commits


@@ -74,7 +74,7 @@ lldb_private::process_linux::GetAvailableLogicalCoreIDs() {
 llvm::Expected lldb_private::process_linux::GetPtraceScope() {
   ErrorOr> ptrace_scope_file =
   getProcFile("sys/kernel/yama/ptrace_scope");
-  if (!*ptrace_scope_file)
+  if (!ptrace_scope_file)

royitaqi wrote:

Removing the newly added `if` per @labath 's comment.

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


[Lldb-commits] [lldb] [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (PR #142224)

2025-06-02 Thread via lldb-commits

royitaqi wrote:

Updated according to @labath 's comment.

@JDevlieghere / @clayborg: Gentle ping - Do you guys want to review, or should 
I go ahead and land with @labath 's approval?

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


[Lldb-commits] [lldb] [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (PR #142224)

2025-06-02 Thread via lldb-commits

https://github.com/royitaqi updated 
https://github.com/llvm/llvm-project/pull/142224

>From 58b8a322a8cc6e3cce3d3e2d405fb915c338791a Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Fri, 30 May 2025 14:21:06 -0700
Subject: [PATCH 1/5] Fix crash and add test

---
 lldb/source/Plugins/Process/Linux/Procfs.cpp |  2 +-
 lldb/unittests/Process/Linux/ProcfsTests.cpp | 14 +-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Process/Linux/Procfs.cpp 
b/lldb/source/Plugins/Process/Linux/Procfs.cpp
index d3bd396fbaeab..4349a2b1adb9d 100644
--- a/lldb/source/Plugins/Process/Linux/Procfs.cpp
+++ b/lldb/source/Plugins/Process/Linux/Procfs.cpp
@@ -74,7 +74,7 @@ lldb_private::process_linux::GetAvailableLogicalCoreIDs() {
 llvm::Expected lldb_private::process_linux::GetPtraceScope() {
   ErrorOr> ptrace_scope_file =
   getProcFile("sys/kernel/yama/ptrace_scope");
-  if (!*ptrace_scope_file)
+  if (!ptrace_scope_file)
 return errorCodeToError(ptrace_scope_file.getError());
   // The contents should be something like "1\n". Trim it so we get "1".
   StringRef buffer = (*ptrace_scope_file)->getBuffer().trim();
diff --git a/lldb/unittests/Process/Linux/ProcfsTests.cpp 
b/lldb/unittests/Process/Linux/ProcfsTests.cpp
index e7af1f469c2bf..cbddccb89a215 100644
--- a/lldb/unittests/Process/Linux/ProcfsTests.cpp
+++ b/lldb/unittests/Process/Linux/ProcfsTests.cpp
@@ -104,7 +104,7 @@ TEST(Perf, RealLogicalCoreIDs) {
   ASSERT_GT((int)cpu_ids->size(), 0) << "We must see at least one core";
 }
 
-TEST(Perf, RealPtraceScope) {
+TEST(Perf, RealPtraceScopeWhenExist) {
   // We first check we can read /proc/sys/kernel/yama/ptrace_scope
   auto buffer_or_error =
   errorOrToExpected(getProcFile("sys/kernel/yama/ptrace_scope"));
@@ -120,6 +120,18 @@ TEST(Perf, RealPtraceScope) {
   << "Sensible values of ptrace_scope are between 0 and 3";
 }
 
+TEST(Perf, RealPtraceScopeWhenNotExist) {
+  // We first check we can NOT read /proc/sys/kernel/yama/ptrace_scope
+  auto buffer_or_error =
+  errorOrToExpected(getProcFile("sys/kernel/yama/ptrace_scope"));
+  if (buffer_or_error)
+GTEST_SKIP() << "In order for this test to run, 
sys/kernel/yama/ptrace_scope should not exist";
+
+  // At this point we should fail parsing the ptrace_scope value.
+  Expected ptrace_scope = GetPtraceScope();
+  ASSERT_FALSE((bool)ptrace_scope);
+}
+
 #ifdef LLVM_ENABLE_THREADING
 TEST(Support, getProcFile_Tid) {
   auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(), "comm");

>From 02a2ba2d67105b1fadec0a9e0c0ee7d914a24e72 Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Fri, 30 May 2025 14:39:46 -0700
Subject: [PATCH 2/5] Fix test

---
 lldb/unittests/Process/Linux/ProcfsTests.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lldb/unittests/Process/Linux/ProcfsTests.cpp 
b/lldb/unittests/Process/Linux/ProcfsTests.cpp
index cbddccb89a215..a795fa4e019c5 100644
--- a/lldb/unittests/Process/Linux/ProcfsTests.cpp
+++ b/lldb/unittests/Process/Linux/ProcfsTests.cpp
@@ -125,11 +125,13 @@ TEST(Perf, RealPtraceScopeWhenNotExist) {
   auto buffer_or_error =
   errorOrToExpected(getProcFile("sys/kernel/yama/ptrace_scope"));
   if (buffer_or_error)
-GTEST_SKIP() << "In order for this test to run, 
sys/kernel/yama/ptrace_scope should not exist";
+GTEST_SKIP() << "In order for this test to run, 
/proc/sys/kernel/yama/ptrace_scope should not exist";
+  consumeError(buffer_or_error.takeError());
 
   // At this point we should fail parsing the ptrace_scope value.
   Expected ptrace_scope = GetPtraceScope();
   ASSERT_FALSE((bool)ptrace_scope);
+  consumeError(ptrace_scope.takeError());
 }
 
 #ifdef LLVM_ENABLE_THREADING

>From 02e9d8b60dcd8797e29874b64fe1369bfb7821b6 Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Fri, 30 May 2025 15:55:06 -0700
Subject: [PATCH 3/5] Add if for unique_ptr

---
 lldb/source/Plugins/Process/Linux/Procfs.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lldb/source/Plugins/Process/Linux/Procfs.cpp 
b/lldb/source/Plugins/Process/Linux/Procfs.cpp
index 4349a2b1adb9d..7ef4f3a102c2c 100644
--- a/lldb/source/Plugins/Process/Linux/Procfs.cpp
+++ b/lldb/source/Plugins/Process/Linux/Procfs.cpp
@@ -76,6 +76,9 @@ llvm::Expected 
lldb_private::process_linux::GetPtraceScope() {
   getProcFile("sys/kernel/yama/ptrace_scope");
   if (!ptrace_scope_file)
 return errorCodeToError(ptrace_scope_file.getError());
+  if (!*ptrace_scope_file)
+return createStringError(inconvertibleErrorCode(),
+  "ptrace_scope buffer is nullptr");
   // The contents should be something like "1\n". Trim it so we get "1".
   StringRef buffer = (*ptrace_scope_file)->getBuffer().trim();
   int ptrace_scope_value;

>From e55bbbed66bb1b49bc23a7d24d70055865424ba5 Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Fri, 30 May 2025 15:55:46 -0700
Subject: [PATCH 4/5] Fix format

---
 lldb/source/Plugins/Process/Linux/Procfs.cpp | 2 +-
 lldb/unittests/Process/Linux/ProcfsT

[Lldb-commits] [lldb] 7365f02 - [lldb][NFC] Remove unused macro ENABLE_MEMORY_CACHING (#142231)

2025-06-02 Thread via lldb-commits

Author: Alex Langford
Date: 2025-06-02T11:15:40-07:00
New Revision: 7365f029de77321d189bf138b73ff97502bbb77d

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

LOG: [lldb][NFC] Remove unused macro ENABLE_MEMORY_CACHING (#142231)

This macro does not do what is described. The only thing it actually
does control is whether or not the process's memory cache gets flushed
when writing to an address. It does not override the setting
`target.process.disable-memory-cache`.

Instead of making it work as intended, I chose to remove the macro. I
don't see much value in being able to override the setting with a
preprocessor macro.

Added: 


Modified: 
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index c377feec86c16..84299f5f9a775 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -80,16 +80,6 @@ using namespace lldb;
 using namespace lldb_private;
 using namespace std::chrono;
 
-// Comment out line below to disable memory caching, overriding the process
-// setting target.process.disable-memory-cache
-#define ENABLE_MEMORY_CACHING
-
-#ifdef ENABLE_MEMORY_CACHING
-#define DISABLE_MEM_CACHE_DEFAULT false
-#else
-#define DISABLE_MEM_CACHE_DEFAULT true
-#endif
-
 class ProcessOptionValueProperties
 : public Cloneable {
 public:
@@ -2297,9 +2287,7 @@ size_t Process::WriteMemory(addr_t addr, const void *buf, 
size_t size,
   if (ABISP abi_sp = GetABI())
 addr = abi_sp->FixAnyAddress(addr);
 
-#if defined(ENABLE_MEMORY_CACHING)
   m_memory_cache.Flush(addr, size);
-#endif
 
   if (buf == nullptr || size == 0)
 return 0;



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


[Lldb-commits] [lldb] e9fad0e - [lldb] Refactor away UB in SBValue::GetLoadAddress (#141799)

2025-06-02 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-06-02T09:39:56+02:00
New Revision: e9fad0e91c49ca0f2669989dbad95664cbc9cbf3

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

LOG: [lldb] Refactor away UB in SBValue::GetLoadAddress (#141799)

The problem was in calling GetLoadAddress on a value in the error state,
where `ValueObject::GetLoadAddress` could end up accessing the
uninitialized "address type" by-ref return value from `GetAddressOf`.
This probably happened because each function expected the other to
initialize it.

We can guarantee initialization by turning this into a proper return
value.

I've added a test, but it only (reliably) crashes if lldb is built with
ubsan.

Added: 


Modified: 
lldb/include/lldb/ValueObject/ValueObject.h
lldb/include/lldb/ValueObject/ValueObjectConstResult.h
lldb/include/lldb/ValueObject/ValueObjectConstResultChild.h
lldb/include/lldb/ValueObject/ValueObjectConstResultImpl.h
lldb/source/API/SBValue.cpp
lldb/source/Commands/CommandObjectWatchpoint.cpp
lldb/source/DataFormatters/CXXFunctionPointer.cpp
lldb/source/DataFormatters/FormattersHelpers.cpp
lldb/source/DataFormatters/TypeFormat.cpp
lldb/source/DataFormatters/ValueObjectPrinter.cpp
lldb/source/Expression/Materializer.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp

lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
lldb/source/ValueObject/ValueObject.cpp
lldb/source/ValueObject/ValueObjectChild.cpp
lldb/source/ValueObject/ValueObjectConstResult.cpp
lldb/source/ValueObject/ValueObjectConstResultChild.cpp
lldb/source/ValueObject/ValueObjectConstResultImpl.cpp
lldb/source/ValueObject/ValueObjectVTable.cpp
lldb/test/API/python_api/value/TestValueAPI.py

Removed: 




diff  --git a/lldb/include/lldb/ValueObject/ValueObject.h 
b/lldb/include/lldb/ValueObject/ValueObject.h
index 0add8ebeccdc8..3c62f3c17619e 100644
--- a/lldb/include/lldb/ValueObject/ValueObject.h
+++ b/lldb/include/lldb/ValueObject/ValueObject.h
@@ -573,10 +573,14 @@ class ValueObject {
   /// child as well.
   void SetName(ConstString name) { m_name = name; }
 
-  virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
-AddressType *address_type = nullptr);
+  struct AddrAndType {
+lldb::addr_t address = LLDB_INVALID_ADDRESS;
+AddressType type = eAddressTypeInvalid;
+  };
+
+  virtual AddrAndType GetAddressOf(bool scalar_is_load_address = true);
 
-  lldb::addr_t GetPointerValue(AddressType *address_type = nullptr);
+  AddrAndType GetPointerValue();
 
   lldb::ValueObjectSP GetSyntheticChild(ConstString key) const;
 

diff  --git a/lldb/include/lldb/ValueObject/ValueObjectConstResult.h 
b/lldb/include/lldb/ValueObject/ValueObjectConstResult.h
index 2ee531f5858e1..1e4b81c4dc7f1 100644
--- a/lldb/include/lldb/ValueObject/ValueObjectConstResult.h
+++ b/lldb/include/lldb/ValueObject/ValueObjectConstResult.h
@@ -86,8 +86,7 @@ class ValueObjectConstResult : public ValueObject {
 
   lldb::ValueObjectSP AddressOf(Status &error) override;
 
-  lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
-AddressType *address_type = nullptr) override;
+  AddrAndType GetAddressOf(bool scalar_is_load_address = true) override;
 
   size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
 uint32_t item_count = 1) override;

diff  --git a/lldb/include/lldb/ValueObject/ValueObjectConstResultChild.h 
b/lldb/include/lldb/ValueObject/ValueObjectConstResultChild.h
index ad97b885684ee..c502ec41dfe90 100644
--- a/lldb/include/lldb/ValueObject/ValueObjectConstResultChild.h
+++ b/lldb/include/lldb/ValueObject/ValueObjectConstResultChild.h
@@ -48,8 +48,7 @@ class ValueObjectConstResultChild : public ValueObjectChild {
 
   lldb::ValueObjectSP AddressOf(Status &error) override;
 
-  lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
-AddressType *address_type = nullptr) override;
+  AddrAndType GetAddressOf(bool scalar_is_load_address = true) override;
 
   size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
 uint32_t item_count = 1) override;

diff  --git a/lldb/include/lldb/ValueObject/ValueObjectConstResultImpl.h 
b/lldb/include

[Lldb-commits] [lldb] [lldb] Refactor away UB in SBValue::GetLoadAddress (PR #141799)

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

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


[Lldb-commits] [lldb] Have lldb-dap extension support multi-root workspace (PR #142470)

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

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


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


[Lldb-commits] [lldb] [lldb] Emit an error when using --wait-for without a name or pid (PR #142424)

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


@@ -280,6 +280,12 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, 
bool &exiting) {
   }
 
   if (args.hasArg(OPT_wait_for)) {
+if (!args.hasArg(OPT_attach_name) || !args.hasArg(OPT_attach_pid)) {

JDevlieghere wrote:

Thanks for checking. I'll update the help. 

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


[Lldb-commits] [lldb] [lldb-dap] Correct the disconnect helper on server shutdown. (PR #142508)

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

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


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


[Lldb-commits] [lldb] [lldb] Emit an error when using --wait-for without a name or pid (PR #142424)

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

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

>From 988faae7eebaea3869d6717c35ac8757e19aa7d8 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Mon, 2 Jun 2025 09:21:17 -0700
Subject: [PATCH] [lldb] Emit an error when using --wait-for without a name

Emit an error when using --wait-for without a name and correct the help
output to specify a name must be provided, rather than a name or PID.

Motivated by https://discourse.llvm.org/t/why-is-wait-for-not-attaching/86636
---
 lldb/test/Shell/Driver/TestWaitFor.test | 2 ++
 lldb/tools/driver/Driver.cpp| 6 ++
 lldb/tools/driver/Options.td| 8 +---
 3 files changed, 13 insertions(+), 3 deletions(-)
 create mode 100644 lldb/test/Shell/Driver/TestWaitFor.test

diff --git a/lldb/test/Shell/Driver/TestWaitFor.test 
b/lldb/test/Shell/Driver/TestWaitFor.test
new file mode 100644
index 0..dde8e747713ad
--- /dev/null
+++ b/lldb/test/Shell/Driver/TestWaitFor.test
@@ -0,0 +1,2 @@
+# RUN: not %lldb --wait-for 2>&1 | FileCheck %s
+# CHECK: error: --wait-for requires a name (--attach-name)
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index e19fded051941..16cc736441b59 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -280,6 +280,12 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, 
bool &exiting) {
   }
 
   if (args.hasArg(OPT_wait_for)) {
+if (!args.hasArg(OPT_attach_name)) {
+  error.SetErrorStringWithFormat(
+  "--wait-for requires a name (--attach-name)");
+  return error;
+}
+
 m_option_data.m_wait_for = true;
   }
 
diff --git a/lldb/tools/driver/Options.td b/lldb/tools/driver/Options.td
index a24fb3826b909..1d8372c4aa404 100644
--- a/lldb/tools/driver/Options.td
+++ b/lldb/tools/driver/Options.td
@@ -19,9 +19,11 @@ def: Separate<["-"], "n">,
   HelpText<"Alias for --attach-name">,
   Group;
 
-def wait_for: F<"wait-for">,
-  HelpText<"Tells the debugger to wait for a process with the given pid or 
name to launch before attaching.">,
-  Group;
+def wait_for
+: F<"wait-for">,
+  HelpText<"Tells the debugger to wait for the process with the name "
+   "specified by --attach-name to launch before attaching.">,
+  Group;
 def: Flag<["-"], "w">,
   Alias,
   HelpText<"Alias for --wait-for">,

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


[Lldb-commits] [lldb] [lldb] Emit an error when using --wait-for without a name or pid (PR #142424)

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

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


[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

2025-06-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)


Changes



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


7 Files Affected:

- (modified) lldb/tools/lldb-dap/Handler/RequestHandler.h (+15-1) 
- (modified) lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp 
(+71-129) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp (+9) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolRequests.h (+15) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp (+27) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolTypes.h (+29) 
- (modified) lldb/unittests/DAP/ProtocolTypesTest.cpp (+20) 


``diff
diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h 
b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index 3a965bcc87a5e..559929ffb21e8 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -356,7 +356,21 @@ class StepInRequestHandler : public 
RequestHandler> {
+public:
+  using RequestHandler::RequestHandler;
+  static llvm::StringLiteral GetCommand() { return "stepInTargets"; }
+  FeatureSet GetSupportedFeatures() const override {
+return {protocol::eAdapterFeatureStepInTargetsRequest};
+  }
+  llvm::Expected
+  Run(const protocol::StepInTargetsArguments &args) const override;
+};
+
+class StepInTargetsRequestHandler2 : public LegacyRequestHandler {
 public:
   using LegacyRequestHandler::LegacyRequestHandler;
   static llvm::StringLiteral GetCommand() { return "stepInTargets"; }
diff --git a/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
index 9b99791599f82..1a76371be2d58 100644
--- a/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepInTargetsRequestHandler.cpp
@@ -7,143 +7,85 @@
 
//===--===//
 
 #include "DAP.h"
-#include "EventHelper.h"
-#include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBInstruction.h"
+#include "lldb/lldb-defines.h"
 
+using namespace lldb_dap::protocol;
 namespace lldb_dap {
 
-// "StepInTargetsRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "This request retrieves the possible step-in targets for
-// the specified stack frame.\nThese targets can be used in the `stepIn`
-// request.\nClients should only call this request if the corresponding
-// capability `supportsStepInTargetsRequest` is true.", "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "stepInTargets" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/StepInTargetsArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "StepInTargetsArguments": {
-//   "type": "object",
-//   "description": "Arguments for `stepInTargets` request.",
-//   "properties": {
-// "frameId": {
-//   "type": "integer",
-//   "description": "The stack frame for which to retrieve the possible
-//   step-in targets."
-// }
-//   },
-//   "required": [ "frameId" ]
-// },
-// "StepInTargetsResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to `stepInTargets` request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "targets": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/StepInTarget"
-// },
-// "description": "The possible step-in targets of the specified
-// source location."
-//   }
-// },
-// "required": [ "targets" ]
-//   }
-// },
-// "required": [ "body" ]
-//   }]
-// }
-void StepInTargetsRequestHandler::operator()(
-const llvm::json::Object &request) const {
-  llvm::json::Object response;
-  FillResponse(request, response);
-  const auto *arguments = request.getObject("arguments");
-
+// This request retrieves the possible step-in targets for the specified stack
+// frame.
+// These targets can be used in the `stepIn` request.
+// Clients should only call this request if the corresponding capability
+// `supportsStepInTargetsRequest` is true.
+llvm::Expected
+StepInTargetsRequestHandler::Run(const StepInTargetsArguments &args) const {
   dap.step_in_targets.clear();
-  lldb::SBFrame frame = dap.GetLLDBFrame(*arguments);
-  if (frame.IsValid()) {
-lldb::SBAddress pc_addr = frame.GetPCAddress();
-lldb::SBAddress line_end_addr =
-pc_addr.GetLineEntry().GetSameLineContiguousAddressRangeEnd(true);
-lldb::SBInstructionList insts = dap.target.ReadInstructions(
-pc_addr, line_end_addr, /*flavor_string=*/nullptr);
-
-if (!insts.IsValid()) {
-  resp

[Lldb-commits] [lldb] [lldb][NFC] Remove unused macro ENABLE_MEMORY_CACHING (PR #142231)

2025-06-02 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] Have lldb-dap extension support multi-root workspace (PR #142470)

2025-06-02 Thread via lldb-commits

https://github.com/award999 created 
https://github.com/llvm/llvm-project/pull/142470

- Allow running when no workspace folder is present, and do not override the 
`cwd` set in the launch configuration
- Support getting configuration from workspace file

Issue: #142469

>From 5eec6c7d71bb3bc9c6b8fda79e7e72e604790a2a Mon Sep 17 00:00:00 2001
From: Adam Ward 
Date: Mon, 2 Jun 2025 15:47:47 -0400
Subject: [PATCH] Have lldb-dap extension support multi-root workspace

- Allow running when no workspace folder is present, and do not override
  the `cwd` set in the launch configuration
- Support getting configuration from workspace file

Issue: #142469
---
 lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts 
b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
index d61b81e4c041f..b5db45b56d6a6 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -169,7 +169,7 @@ export async function createDebugAdapterExecutable(
   workspaceFolder: vscode.WorkspaceFolder | undefined,
   configuration: vscode.DebugConfiguration,
 ): Promise {
-  const config = vscode.workspace.getConfiguration("lldb-dap", 
workspaceFolder);
+  const config = vscode.workspace.workspaceFile ? 
vscode.workspace.getConfiguration("lldb-dap") : 
vscode.workspace.getConfiguration("lldb-dap", workspaceFolder);
   const log_path = config.get("log-path");
   let env: { [key: string]: string } = {};
   if (log_path) {
@@ -184,7 +184,7 @@ export async function createDebugAdapterExecutable(
   ...configEnvironment,
   ...env,
 },
-cwd: workspaceFolder!!.uri.fsPath,
+cwd: configuration.cwd ?? workspaceFolder?.uri.fsPath,
   };
   const dbgArgs = await getDAPArguments(workspaceFolder, configuration);
 

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


[Lldb-commits] [lldb] Have lldb-dap extension support multi-root workspace (PR #142470)

2025-06-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (award999)


Changes

- Allow running when no workspace folder is present, and do not override the 
`cwd` set in the launch configuration
- Support getting configuration from workspace file

Issue: #142469

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


1 Files Affected:

- (modified) lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts (+2-2) 


``diff
diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts 
b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
index d61b81e4c041f..b5db45b56d6a6 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -169,7 +169,7 @@ export async function createDebugAdapterExecutable(
   workspaceFolder: vscode.WorkspaceFolder | undefined,
   configuration: vscode.DebugConfiguration,
 ): Promise {
-  const config = vscode.workspace.getConfiguration("lldb-dap", 
workspaceFolder);
+  const config = vscode.workspace.workspaceFile ? 
vscode.workspace.getConfiguration("lldb-dap") : 
vscode.workspace.getConfiguration("lldb-dap", workspaceFolder);
   const log_path = config.get("log-path");
   let env: { [key: string]: string } = {};
   if (log_path) {
@@ -184,7 +184,7 @@ export async function createDebugAdapterExecutable(
   ...configEnvironment,
   ...env,
 },
-cwd: workspaceFolder!!.uri.fsPath,
+cwd: configuration.cwd ?? workspaceFolder?.uri.fsPath,
   };
   const dbgArgs = await getDAPArguments(workspaceFolder, configuration);
 

``




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


[Lldb-commits] [lldb] Have lldb-dap extension support multi-root workspace (PR #142470)

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


[Lldb-commits] [lldb] [lldb] Fix data race in statusline format handling (PR #142489)

2025-06-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

This fixes a data race between the main thread and the default event handler 
thread. The statusline format option value was protected by a mutex, but it was 
returned as a pointer, allowing one thread to access it while another was 
modifying it.

Avoid the data race by returning format values by value instead of by pointer.

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


9 Files Affected:

- (modified) lldb/include/lldb/Core/Debugger.h (+6-6) 
- (modified) lldb/include/lldb/Interpreter/OptionValue.h (+3-3) 
- (modified) lldb/source/Core/Debugger.cpp (+19-21) 
- (modified) lldb/source/Core/Disassembler.cpp (+5-12) 
- (modified) lldb/source/Core/Statusline.cpp (+3-3) 
- (modified) lldb/source/Interpreter/OptionValue.cpp (+3-3) 
- (modified) lldb/source/Target/StackFrame.cpp (+2-2) 
- (modified) lldb/source/Target/Thread.cpp (+2-4) 
- (modified) lldb/source/Target/ThreadPlanTracer.cpp (+2-2) 


``diff
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index c9e5310cded1a..d73aba1e3ce58 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -243,17 +243,17 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool GetAutoConfirm() const;
 
-  const FormatEntity::Entry *GetDisassemblyFormat() const;
+  FormatEntity::Entry GetDisassemblyFormat() const;
 
-  const FormatEntity::Entry *GetFrameFormat() const;
+  FormatEntity::Entry GetFrameFormat() const;
 
-  const FormatEntity::Entry *GetFrameFormatUnique() const;
+  FormatEntity::Entry GetFrameFormatUnique() const;
 
   uint64_t GetStopDisassemblyMaxSize() const;
 
-  const FormatEntity::Entry *GetThreadFormat() const;
+  FormatEntity::Entry GetThreadFormat() const;
 
-  const FormatEntity::Entry *GetThreadStopFormat() const;
+  FormatEntity::Entry GetThreadStopFormat() const;
 
   lldb::ScriptLanguage GetScriptLanguage() const;
 
@@ -297,7 +297,7 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool GetShowStatusline() const;
 
-  const FormatEntity::Entry *GetStatuslineFormat() const;
+  FormatEntity::Entry GetStatuslineFormat() const;
   bool SetStatuslineFormat(const FormatEntity::Entry &format);
 
   llvm::StringRef GetSeparator() const;
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index e3c139155b0ef..69f84419416c6 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -284,6 +284,8 @@ class OptionValue {
   return GetStringValue();
 if constexpr (std::is_same_v)
   return GetArchSpecValue();
+if constexpr (std::is_same_v)
+  return GetFormatEntity();
 if constexpr (std::is_enum_v)
   if (std::optional value = GetEnumerationValue())
 return static_cast(*value);
@@ -295,8 +297,6 @@ class OptionValue {
 typename std::remove_pointer::type>::type,
 std::enable_if_t, bool> = true>
   T GetValueAs() const {
-if constexpr (std::is_same_v)
-  return GetFormatEntity();
 if constexpr (std::is_same_v)
   return GetRegexValue();
 return {};
@@ -382,7 +382,7 @@ class OptionValue {
   std::optional GetUUIDValue() const;
   bool SetUUIDValue(const UUID &uuid);
 
-  const FormatEntity::Entry *GetFormatEntity() const;
+  FormatEntity::Entry GetFormatEntity() const;
   bool SetFormatEntityValue(const FormatEntity::Entry &entry);
 
   const RegularExpression *GetRegexValue() const;
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 519a2528ca7e0..112ef3572aa98 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -294,19 +294,19 @@ bool Debugger::GetAutoConfirm() const {
   idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
-const FormatEntity::Entry *Debugger::GetDisassemblyFormat() const {
+FormatEntity::Entry Debugger::GetDisassemblyFormat() const {
   constexpr uint32_t idx = ePropertyDisassemblyFormat;
-  return GetPropertyAtIndexAs(idx);
+  return GetPropertyAtIndexAs(idx, {});
 }
 
-const FormatEntity::Entry *Debugger::GetFrameFormat() const {
+FormatEntity::Entry Debugger::GetFrameFormat() const {
   constexpr uint32_t idx = ePropertyFrameFormat;
-  return GetPropertyAtIndexAs(idx);
+  return GetPropertyAtIndexAs(idx, {});
 }
 
-const FormatEntity::Entry *Debugger::GetFrameFormatUnique() const {
+FormatEntity::Entry Debugger::GetFrameFormatUnique() const {
   constexpr uint32_t idx = ePropertyFrameFormatUnique;
-  return GetPropertyAtIndexAs(idx);
+  return GetPropertyAtIndexAs(idx, {});
 }
 
 uint64_t Debugger::GetStopDisassemblyMaxSize() const {
@@ -350,14 +350,14 @@ void Debugger::SetPrompt(llvm::StringRef p) {
   GetCommandInterpreter().UpdatePrompt(new_prompt);
 }
 
-const FormatEntity::Entry *Debugger::GetThreadFormat() const {
+FormatEntity::Entry Debugger::GetThreadFormat

[Lldb-commits] [lldb] [lldb-dap] Use structured types for stepInTargets request (PR #142439)

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


@@ -414,6 +415,34 @@ bool fromJSON(const llvm::json::Value &, 
SteppingGranularity &,
   llvm::json::Path);
 llvm::json::Value toJSON(const SteppingGranularity &);
 
+/// A `StepInTarget` can be used in the `stepIn` request and determines into
+/// which single target the `stepIn` request should step.
+struct StepInTarget {
+  /// Unique identifier for a step-in target.
+  uint64_t id = std::numeric_limits::max();

JDevlieghere wrote:

Should this use `LLDB_INVALID_FRAME_ID`? 

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


[Lldb-commits] [lldb] b9a5285 - [lldb-dap] Bump the version to 0.2.15

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

Author: Jonas Devlieghere
Date: 2025-06-02T14:43:24-07:00
New Revision: b9a528553a8d0fadaa167ea2b5c0f860cc0b33dc

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

LOG: [lldb-dap] Bump the version to 0.2.15

Added: 


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

Removed: 




diff  --git a/lldb/tools/lldb-dap/package.json 
b/lldb/tools/lldb-dap/package.json
index 20d418d727bbc..0f51c4f935e33 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -1,7 +1,7 @@
 {
   "name": "lldb-dap",
   "displayName": "LLDB DAP",
-  "version": "0.2.14",
+  "version": "0.2.15",
   "publisher": "llvm-vs-code-extensions",
   "homepage": "https://lldb.llvm.org";,
   "description": "Debugging with LLDB in Visual Studio Code",



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


[Lldb-commits] [lldb] [lldb] Add Python properties to SBBreakpoint and similar (PR #142215)

2025-06-02 Thread via lldb-commits

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

Thanks!  LGTM

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


[Lldb-commits] [lldb] Have lldb-dap extension support multi-root workspace (PR #142470)

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

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


[Lldb-commits] [lldb] [lldb] Emit an error when using --wait-for without a name or pid (PR #142424)

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


@@ -280,6 +280,12 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, 
bool &exiting) {
   }
 
   if (args.hasArg(OPT_wait_for)) {
+if (!args.hasArg(OPT_attach_name) || !args.hasArg(OPT_attach_pid)) {

JDevlieghere wrote:

According to our `--help` output and man page, we do. I didn't check the code 
(yet).

```
--wait-for
   Tells the debugger to wait for a process with the given pid or name to 
launch before attaching.
```

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


[Lldb-commits] [lldb] [lldb][headers] Create Python script to fix up framework headers (PR #142051)

2025-06-02 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/142051

>From b47eaa64397da7ea5d2a7ca46bea4513a37755f0 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 28 May 2025 15:45:45 -0700
Subject: [PATCH 1/2] [lldb][headers] Create Python script to fix up framework
 headers

This commit replaces the shell script that fixes up includes for the
LLDB framework with a Python script. This script will also be used when
fixing up includes for the LLDBRPC.framework.
---
 lldb/cmake/modules/LLDBFramework.cmake|  34 ++---
 lldb/scripts/framework-header-fix.py  | 129 ++
 lldb/scripts/framework-header-fix.sh  |  17 ---
 .../Shell/Scripts/Inputs/Main/SBAddress.h |  13 ++
 .../Shell/Scripts/Inputs/RPC/RPCSBAddress.h   |   9 ++
 .../Shell/Scripts/TestFrameworkFixScript.test |  16 +++
 .../Scripts/TestRPCFrameworkFixScript.test|  14 ++
 7 files changed, 196 insertions(+), 36 deletions(-)
 create mode 100755 lldb/scripts/framework-header-fix.py
 delete mode 100755 lldb/scripts/framework-header-fix.sh
 create mode 100644 lldb/test/Shell/Scripts/Inputs/Main/SBAddress.h
 create mode 100644 lldb/test/Shell/Scripts/Inputs/RPC/RPCSBAddress.h
 create mode 100644 lldb/test/Shell/Scripts/TestFrameworkFixScript.test
 create mode 100644 lldb/test/Shell/Scripts/TestRPCFrameworkFixScript.test

diff --git a/lldb/cmake/modules/LLDBFramework.cmake 
b/lldb/cmake/modules/LLDBFramework.cmake
index 471aeaaad3c0d..9c2ad4ea6f0d6 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -68,24 +68,16 @@ if(NOT APPLE_EMBEDDED)
   )
 endif()
 
-# At configuration time, collect headers for the framework bundle and copy them
-# into a staging directory. Later we can copy over the entire folder.
-file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
-set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/API/SBLanguages.h)
-file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
-file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
-list(REMOVE_ITEM root_public_headers ${root_private_headers})
-
 find_program(unifdef_EXECUTABLE unifdef)
 
-set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders)
-foreach(header
-${public_headers}
-${generated_public_headers}
-${root_public_headers})
+# All necessary header files will be staged in the include directory in the 
build directory,
+# so just copy the files from there into the framework's staging directory.
+set(lldb_build_dir_header_staging ${CMAKE_BINARY_DIR}/include/lldb)
+set(lldb_framework_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders)
+foreach(header ${lldb_build_dir_header_staging})
 
   get_filename_component(basename ${header} NAME)
-  set(staged_header ${lldb_header_staging}/${basename})
+  set(staged_header ${lldb_framework_header_staging}/${basename})
 
   if(unifdef_EXECUTABLE)
 # unifdef returns 0 when the file is unchanged and 1 if something was 
changed.
@@ -107,14 +99,18 @@ endforeach()
 # Wrap output in a target, so lldb-framework can depend on it.
 add_custom_target(liblldb-resource-headers DEPENDS lldb-sbapi-dwarf-enums 
${lldb_staged_headers})
 set_target_properties(liblldb-resource-headers PROPERTIES FOLDER 
"LLDB/Resources")
+
+# We're taking the header files from where they've been staged in the build 
directory's include folder,
+# so create a dependency on the build step that creates that directory.
+add_dependencies(liblldb-resource-headers liblldb-header-staging)
 add_dependencies(liblldb liblldb-resource-headers)
 
-# At build time, copy the staged headers into the framework bundle (and do
-# some post-processing in-place).
+# Take the headers from the staging directory and fix up their includes for 
the framework.
+# Then write them to the output directory.
+# Also, run unifdef to remove any specified guards from the header files.
 add_custom_command(TARGET liblldb POST_BUILD
-  COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} 
$/Headers
-  COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh 
$/Headers ${LLDB_VERSION}
-  COMMENT "LLDB.framework: copy framework headers"
+  COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.py -f lldb_main -i 
${lldb_framework_header_staging} -o $/Headers -p 
${unifdef_EXECUTABLE} USWIG
+  COMMENT "LLDB.framework: Fix up and copy framework headers"
 )
 
 # Copy vendor-specific headers from clang (without staging).
diff --git a/lldb/scripts/framework-header-fix.py 
b/lldb/scripts/framework-header-fix.py
new file mode 100755
index 0..e6ea4e9bf917f
--- /dev/null
+++ b/lldb/scripts/framework-header-fix.py
@@ -0,0 +1,129 @@
+#!/usr/bin/env python3
+
+"""
+Usage:  
+
+This script is used when building LLDB.framework or LLDBRPC.framework. For 
each framework, local includes are converted to their respective framework 
includes.
+
+This script is used in 2 ways:
+1. It is used on header

[Lldb-commits] [lldb] [lldb] Fix data race in statusline format handling (PR #142489)

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

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

>From bbdaa75ba4baa54d17fb1f8bbf6280b7e4521b84 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Mon, 2 Jun 2025 14:16:23 -0700
Subject: [PATCH 1/2] [lldb] Fix data race in statusline format handling

This fixes a data race between the main thread and the default event
handler thread. The statusline format option value was protected by a
mutex, but it was returned as a pointer, allowing one thread to access
it while another was modifying it.

Avoid the data race by returning format values by value instead of by
pointer.
---
 lldb/include/lldb/Core/Debugger.h   | 12 +++
 lldb/include/lldb/Interpreter/OptionValue.h |  6 ++--
 lldb/source/Core/Debugger.cpp   | 40 ++---
 lldb/source/Core/Disassembler.cpp   | 17 +++--
 lldb/source/Core/Statusline.cpp |  6 ++--
 lldb/source/Interpreter/OptionValue.cpp |  6 ++--
 lldb/source/Target/StackFrame.cpp   |  4 +--
 lldb/source/Target/Thread.cpp   |  6 ++--
 lldb/source/Target/ThreadPlanTracer.cpp |  4 +--
 9 files changed, 45 insertions(+), 56 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index c9e5310cded1a..d73aba1e3ce58 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -243,17 +243,17 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool GetAutoConfirm() const;
 
-  const FormatEntity::Entry *GetDisassemblyFormat() const;
+  FormatEntity::Entry GetDisassemblyFormat() const;
 
-  const FormatEntity::Entry *GetFrameFormat() const;
+  FormatEntity::Entry GetFrameFormat() const;
 
-  const FormatEntity::Entry *GetFrameFormatUnique() const;
+  FormatEntity::Entry GetFrameFormatUnique() const;
 
   uint64_t GetStopDisassemblyMaxSize() const;
 
-  const FormatEntity::Entry *GetThreadFormat() const;
+  FormatEntity::Entry GetThreadFormat() const;
 
-  const FormatEntity::Entry *GetThreadStopFormat() const;
+  FormatEntity::Entry GetThreadStopFormat() const;
 
   lldb::ScriptLanguage GetScriptLanguage() const;
 
@@ -297,7 +297,7 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool GetShowStatusline() const;
 
-  const FormatEntity::Entry *GetStatuslineFormat() const;
+  FormatEntity::Entry GetStatuslineFormat() const;
   bool SetStatuslineFormat(const FormatEntity::Entry &format);
 
   llvm::StringRef GetSeparator() const;
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index e3c139155b0ef..69f84419416c6 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -284,6 +284,8 @@ class OptionValue {
   return GetStringValue();
 if constexpr (std::is_same_v)
   return GetArchSpecValue();
+if constexpr (std::is_same_v)
+  return GetFormatEntity();
 if constexpr (std::is_enum_v)
   if (std::optional value = GetEnumerationValue())
 return static_cast(*value);
@@ -295,8 +297,6 @@ class OptionValue {
 typename std::remove_pointer::type>::type,
 std::enable_if_t, bool> = true>
   T GetValueAs() const {
-if constexpr (std::is_same_v)
-  return GetFormatEntity();
 if constexpr (std::is_same_v)
   return GetRegexValue();
 return {};
@@ -382,7 +382,7 @@ class OptionValue {
   std::optional GetUUIDValue() const;
   bool SetUUIDValue(const UUID &uuid);
 
-  const FormatEntity::Entry *GetFormatEntity() const;
+  FormatEntity::Entry GetFormatEntity() const;
   bool SetFormatEntityValue(const FormatEntity::Entry &entry);
 
   const RegularExpression *GetRegexValue() const;
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 519a2528ca7e0..112ef3572aa98 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -294,19 +294,19 @@ bool Debugger::GetAutoConfirm() const {
   idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
-const FormatEntity::Entry *Debugger::GetDisassemblyFormat() const {
+FormatEntity::Entry Debugger::GetDisassemblyFormat() const {
   constexpr uint32_t idx = ePropertyDisassemblyFormat;
-  return GetPropertyAtIndexAs(idx);
+  return GetPropertyAtIndexAs(idx, {});
 }
 
-const FormatEntity::Entry *Debugger::GetFrameFormat() const {
+FormatEntity::Entry Debugger::GetFrameFormat() const {
   constexpr uint32_t idx = ePropertyFrameFormat;
-  return GetPropertyAtIndexAs(idx);
+  return GetPropertyAtIndexAs(idx, {});
 }
 
-const FormatEntity::Entry *Debugger::GetFrameFormatUnique() const {
+FormatEntity::Entry Debugger::GetFrameFormatUnique() const {
   constexpr uint32_t idx = ePropertyFrameFormatUnique;
-  return GetPropertyAtIndexAs(idx);
+  return GetPropertyAtIndexAs(idx, {});
 }
 
 uint64_t Debugger::GetStopDisassemblyMaxSize() const {
@@ -350,14 +350,14 @@ void Debugger::SetPrompt(llvm::StringRef p) {
   GetCommandI

[Lldb-commits] [lldb] [lldb] Emit an error when using --wait-for without a name or pid (PR #142424)

2025-06-02 Thread via lldb-commits

https://github.com/jimingham edited 
https://github.com/llvm/llvm-project/pull/142424
___
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-06-02 Thread Prabhu Rajasekaran via lldb-commits

Prabhuk wrote:

My team builds lldb on linux X64 and running into a test failure since this 
patch had landed.
Builder link: 
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/lldb-linux-x64/b8713139267610948369/overview

I am taking a closer look. CC: @mysterymath 


```
FAIL: lldb-api :: commands/target/stop-hooks/TestStopHookScripted.py (285 of 
2899)
 TEST 'lldb-api :: 
commands/target/stop-hooks/TestStopHookScripted.py' FAILED 
Script:
--
/b/s/w/ir/x/w/install-cpython-x86_64-linux-gnu/bin/python3 
/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS 
--env LLVM_LIBS_DIR=/b/s/w/ir/x/w/llvm_build/./lib --env 
LLVM_INCLUDE_DIR=/b/s/w/ir/x/w/llvm_build/include --env 
LLVM_TOOLS_DIR=/b/s/w/ir/x/w/llvm_build/./bin --arch x86_64 --build-dir 
/b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex --lldb-module-cache-dir 
/b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/module-cache-lldb/lldb-api 
--clang-module-cache-dir 
/b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/module-cache-clang/lldb-api 
--executable /b/s/w/ir/x/w/llvm_build/./bin/lldb --compiler 
/b/s/w/ir/x/w/cipd/clang/bin/clang --dsymutil 
/b/s/w/ir/x/w/llvm_build/./bin/dsymutil --make /b/s/w/ir/x/w/cipd/bin/make 
--llvm-tools-dir /b/s/w/ir/x/w/llvm_build/./bin --lldb-obj-root 
/b/s/w/ir/x/w/llvm_build/tools/lldb --lldb-libs-dir 
/b/s/w/ir/x/w/llvm_build/./lib --cmake-build-type Release 
--skip-category=pexpect 
/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/commands/target/stop-hooks -p 
TestStopHookScripted.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://llvm.googlesource.com/a/llvm-project revision 
d313c09b288c31f93819408048b0b64ca5c5fc2b)
  clang revision d313c09b288c31f93819408048b0b64ca5c5fc2b
  llvm revision d313c09b288c31f93819408048b0b64ca5c5fc2b
I have stopped 1 times.
Returning value: 1 from handle_stop.
I have stopped 1 times.
Returning value: 1 from handle_stop.
I have stopped 2 times.
Returning value: 1 from handle_stop.
I have stopped 1 times.
Returning value: 1 from handle_stop.
I have stopped 2 times.
Returning value: 1 from handle_stop.
I have stopped 1 times.
Returning value: 0 from handle_stop.
I have stopped 2 times.
Error running expression: can't evaluate expressions when the process is 
running.Returning value: 0 from handle_stop.
I have stopped 1 times.
Returning value: 1 from handle_stop.
I have stopped 2 times.
Returning value: 1 from handle_stop.
I have stopped 1 times.
Returning value: 1 from handle_stop.
I have stopped 1 times.
Returning value: 1 from handle_stop.
Skipping the following test categories: ['pexpect', 'dsym', 'gmodules', 
'debugserver', 'objc']
I am okay
I am okay

--
Command Output (stderr):
--
PASS: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: test_bad_handler 
(TestStopHookScripted.TestStopHooks.test_bad_handler)
PASS: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
test_stop_hooks_scripted 
(TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted)
FAIL: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
test_stop_hooks_scripted_auto_continue 
(TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_auto_continue)
PASS: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
test_stop_hooks_scripted_no_entry 
(TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_no_entry)
PASS: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
test_stop_hooks_scripted_return_false 
(TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_return_false)
FAIL: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
test_stop_hooks_scripted_right_func 
(TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_right_func)
PASS: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
test_stop_hooks_scripted_right_lines 
(TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_right_lines)
FAIL: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
test_stop_hooks_scripted_wrong_func 
(TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_wrong_func)
PASS: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
test_stop_hooks_scripted_wrong_lines 
(TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_wrong_lines)
==
FAIL: test_stop_hooks_scripted_auto_continue 
(TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_auto_continue)
   Test that the --auto-continue flag works
--
Traceback (most recent call last):
  File 
"/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py",
 line 77, in test_stop_hooks_scripted_auto_continue
self.do_test_auto_continue(False)
  File 
"/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py",
 line 118, in do_test_auto_continue
self.assertEqual(var.GetValueAsUnsigned(), 6, "Updated g_var")
AssertionError: 11 != 

[Lldb-commits] [lldb] [lldb][headers] Create Python script to fix up framework headers (PR #142051)

2025-06-02 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/142051

>From b47eaa64397da7ea5d2a7ca46bea4513a37755f0 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 28 May 2025 15:45:45 -0700
Subject: [PATCH 1/2] [lldb][headers] Create Python script to fix up framework
 headers

This commit replaces the shell script that fixes up includes for the
LLDB framework with a Python script. This script will also be used when
fixing up includes for the LLDBRPC.framework.
---
 lldb/cmake/modules/LLDBFramework.cmake|  34 ++---
 lldb/scripts/framework-header-fix.py  | 129 ++
 lldb/scripts/framework-header-fix.sh  |  17 ---
 .../Shell/Scripts/Inputs/Main/SBAddress.h |  13 ++
 .../Shell/Scripts/Inputs/RPC/RPCSBAddress.h   |   9 ++
 .../Shell/Scripts/TestFrameworkFixScript.test |  16 +++
 .../Scripts/TestRPCFrameworkFixScript.test|  14 ++
 7 files changed, 196 insertions(+), 36 deletions(-)
 create mode 100755 lldb/scripts/framework-header-fix.py
 delete mode 100755 lldb/scripts/framework-header-fix.sh
 create mode 100644 lldb/test/Shell/Scripts/Inputs/Main/SBAddress.h
 create mode 100644 lldb/test/Shell/Scripts/Inputs/RPC/RPCSBAddress.h
 create mode 100644 lldb/test/Shell/Scripts/TestFrameworkFixScript.test
 create mode 100644 lldb/test/Shell/Scripts/TestRPCFrameworkFixScript.test

diff --git a/lldb/cmake/modules/LLDBFramework.cmake 
b/lldb/cmake/modules/LLDBFramework.cmake
index 471aeaaad3c0d..9c2ad4ea6f0d6 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -68,24 +68,16 @@ if(NOT APPLE_EMBEDDED)
   )
 endif()
 
-# At configuration time, collect headers for the framework bundle and copy them
-# into a staging directory. Later we can copy over the entire folder.
-file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
-set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/API/SBLanguages.h)
-file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
-file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
-list(REMOVE_ITEM root_public_headers ${root_private_headers})
-
 find_program(unifdef_EXECUTABLE unifdef)
 
-set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders)
-foreach(header
-${public_headers}
-${generated_public_headers}
-${root_public_headers})
+# All necessary header files will be staged in the include directory in the 
build directory,
+# so just copy the files from there into the framework's staging directory.
+set(lldb_build_dir_header_staging ${CMAKE_BINARY_DIR}/include/lldb)
+set(lldb_framework_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders)
+foreach(header ${lldb_build_dir_header_staging})
 
   get_filename_component(basename ${header} NAME)
-  set(staged_header ${lldb_header_staging}/${basename})
+  set(staged_header ${lldb_framework_header_staging}/${basename})
 
   if(unifdef_EXECUTABLE)
 # unifdef returns 0 when the file is unchanged and 1 if something was 
changed.
@@ -107,14 +99,18 @@ endforeach()
 # Wrap output in a target, so lldb-framework can depend on it.
 add_custom_target(liblldb-resource-headers DEPENDS lldb-sbapi-dwarf-enums 
${lldb_staged_headers})
 set_target_properties(liblldb-resource-headers PROPERTIES FOLDER 
"LLDB/Resources")
+
+# We're taking the header files from where they've been staged in the build 
directory's include folder,
+# so create a dependency on the build step that creates that directory.
+add_dependencies(liblldb-resource-headers liblldb-header-staging)
 add_dependencies(liblldb liblldb-resource-headers)
 
-# At build time, copy the staged headers into the framework bundle (and do
-# some post-processing in-place).
+# Take the headers from the staging directory and fix up their includes for 
the framework.
+# Then write them to the output directory.
+# Also, run unifdef to remove any specified guards from the header files.
 add_custom_command(TARGET liblldb POST_BUILD
-  COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} 
$/Headers
-  COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh 
$/Headers ${LLDB_VERSION}
-  COMMENT "LLDB.framework: copy framework headers"
+  COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.py -f lldb_main -i 
${lldb_framework_header_staging} -o $/Headers -p 
${unifdef_EXECUTABLE} USWIG
+  COMMENT "LLDB.framework: Fix up and copy framework headers"
 )
 
 # Copy vendor-specific headers from clang (without staging).
diff --git a/lldb/scripts/framework-header-fix.py 
b/lldb/scripts/framework-header-fix.py
new file mode 100755
index 0..e6ea4e9bf917f
--- /dev/null
+++ b/lldb/scripts/framework-header-fix.py
@@ -0,0 +1,129 @@
+#!/usr/bin/env python3
+
+"""
+Usage:  
+
+This script is used when building LLDB.framework or LLDBRPC.framework. For 
each framework, local includes are converted to their respective framework 
includes.
+
+This script is used in 2 ways:
+1. It is used on header

[Lldb-commits] [lldb] [lldb] Emit an error when using --wait-for without a name or pid (PR #142424)

2025-06-02 Thread via lldb-commits


@@ -280,6 +280,12 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, 
bool &exiting) {
   }
 
   if (args.hasArg(OPT_wait_for)) {
+if (!args.hasArg(OPT_attach_name) || !args.hasArg(OPT_attach_pid)) {

jimingham wrote:

I don't think we do `--wait-for` for PID's do we?  I think we only do it for 
name.  wait-for for a PID is a somewhat odd operation...

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


[Lldb-commits] [lldb] [lldb] Fix data race in statusline format handling (PR #142489)

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

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

This fixes a data race between the main thread and the default event handler 
thread. The statusline format option value was protected by a mutex, but it was 
returned as a pointer, allowing one thread to access it while another was 
modifying it.

Avoid the data race by returning format values by value instead of by pointer.

>From bbdaa75ba4baa54d17fb1f8bbf6280b7e4521b84 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Mon, 2 Jun 2025 14:16:23 -0700
Subject: [PATCH] [lldb] Fix data race in statusline format handling

This fixes a data race between the main thread and the default event
handler thread. The statusline format option value was protected by a
mutex, but it was returned as a pointer, allowing one thread to access
it while another was modifying it.

Avoid the data race by returning format values by value instead of by
pointer.
---
 lldb/include/lldb/Core/Debugger.h   | 12 +++
 lldb/include/lldb/Interpreter/OptionValue.h |  6 ++--
 lldb/source/Core/Debugger.cpp   | 40 ++---
 lldb/source/Core/Disassembler.cpp   | 17 +++--
 lldb/source/Core/Statusline.cpp |  6 ++--
 lldb/source/Interpreter/OptionValue.cpp |  6 ++--
 lldb/source/Target/StackFrame.cpp   |  4 +--
 lldb/source/Target/Thread.cpp   |  6 ++--
 lldb/source/Target/ThreadPlanTracer.cpp |  4 +--
 9 files changed, 45 insertions(+), 56 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index c9e5310cded1a..d73aba1e3ce58 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -243,17 +243,17 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool GetAutoConfirm() const;
 
-  const FormatEntity::Entry *GetDisassemblyFormat() const;
+  FormatEntity::Entry GetDisassemblyFormat() const;
 
-  const FormatEntity::Entry *GetFrameFormat() const;
+  FormatEntity::Entry GetFrameFormat() const;
 
-  const FormatEntity::Entry *GetFrameFormatUnique() const;
+  FormatEntity::Entry GetFrameFormatUnique() const;
 
   uint64_t GetStopDisassemblyMaxSize() const;
 
-  const FormatEntity::Entry *GetThreadFormat() const;
+  FormatEntity::Entry GetThreadFormat() const;
 
-  const FormatEntity::Entry *GetThreadStopFormat() const;
+  FormatEntity::Entry GetThreadStopFormat() const;
 
   lldb::ScriptLanguage GetScriptLanguage() const;
 
@@ -297,7 +297,7 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool GetShowStatusline() const;
 
-  const FormatEntity::Entry *GetStatuslineFormat() const;
+  FormatEntity::Entry GetStatuslineFormat() const;
   bool SetStatuslineFormat(const FormatEntity::Entry &format);
 
   llvm::StringRef GetSeparator() const;
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index e3c139155b0ef..69f84419416c6 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -284,6 +284,8 @@ class OptionValue {
   return GetStringValue();
 if constexpr (std::is_same_v)
   return GetArchSpecValue();
+if constexpr (std::is_same_v)
+  return GetFormatEntity();
 if constexpr (std::is_enum_v)
   if (std::optional value = GetEnumerationValue())
 return static_cast(*value);
@@ -295,8 +297,6 @@ class OptionValue {
 typename std::remove_pointer::type>::type,
 std::enable_if_t, bool> = true>
   T GetValueAs() const {
-if constexpr (std::is_same_v)
-  return GetFormatEntity();
 if constexpr (std::is_same_v)
   return GetRegexValue();
 return {};
@@ -382,7 +382,7 @@ class OptionValue {
   std::optional GetUUIDValue() const;
   bool SetUUIDValue(const UUID &uuid);
 
-  const FormatEntity::Entry *GetFormatEntity() const;
+  FormatEntity::Entry GetFormatEntity() const;
   bool SetFormatEntityValue(const FormatEntity::Entry &entry);
 
   const RegularExpression *GetRegexValue() const;
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 519a2528ca7e0..112ef3572aa98 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -294,19 +294,19 @@ bool Debugger::GetAutoConfirm() const {
   idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
-const FormatEntity::Entry *Debugger::GetDisassemblyFormat() const {
+FormatEntity::Entry Debugger::GetDisassemblyFormat() const {
   constexpr uint32_t idx = ePropertyDisassemblyFormat;
-  return GetPropertyAtIndexAs(idx);
+  return GetPropertyAtIndexAs(idx, {});
 }
 
-const FormatEntity::Entry *Debugger::GetFrameFormat() const {
+FormatEntity::Entry Debugger::GetFrameFormat() const {
   constexpr uint32_t idx = ePropertyFrameFormat;
-  return GetPropertyAtIndexAs(idx);
+  return GetPropertyAtIndexAs(idx, {});
 }
 
-const FormatEntity::Entry *Debugger::GetFrameFormatUnique() const {
+FormatEntity:

[Lldb-commits] [lldb] [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (PR #142224)

2025-06-02 Thread Greg Clayton via lldb-commits


@@ -120,6 +120,21 @@ TEST(Perf, RealPtraceScope) {
   << "Sensible values of ptrace_scope are between 0 and 3";
 }
 
+TEST(Perf, RealPtraceScopeWhenNotExist) {
+  // We first check we can NOT read /proc/sys/kernel/yama/ptrace_scope
+  auto buffer_or_error =
+  errorOrToExpected(getProcFile("sys/kernel/yama/ptrace_scope"));
+  if (buffer_or_error)
+GTEST_SKIP() << "In order for this test to run, "
+"/proc/sys/kernel/yama/ptrace_scope should not exist";

clayborg wrote:

Does GTEST_SKIP cause an early return? And if the file does exist, do we want 
to create noise in the gtest output? We just want to make sure that if the file 
doesn't exist, we don't crash right?

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


[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)

2025-06-02 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/138031

>From bb382b5e3f9bb5c64c5ea11fd2cb3ea94833c56a Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 30 Apr 2025 14:15:39 -0700
Subject: [PATCH] [lldb][RPC] Upstream lldb-rpc-gen tool

This commit upstreams the `lldb-rpc-gen` tool, a ClangTool that
generates the LLDB RPC client and server interfaces.

https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804
---
 .../tools/lldb-rpc/lldb-rpc-gen/RPCCommon.cpp | 502 ++
 lldb/tools/lldb-rpc/lldb-rpc-gen/RPCCommon.h  | 107 
 .../lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp| 415 +++
 3 files changed, 1024 insertions(+)
 create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/RPCCommon.cpp
 create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/RPCCommon.h
 create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp

diff --git a/lldb/tools/lldb-rpc/lldb-rpc-gen/RPCCommon.cpp 
b/lldb/tools/lldb-rpc/lldb-rpc-gen/RPCCommon.cpp
new file mode 100644
index 0..ef2db7c5516fe
--- /dev/null
+++ b/lldb/tools/lldb-rpc/lldb-rpc-gen/RPCCommon.cpp
@@ -0,0 +1,502 @@
+//===-- RPCCommon.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RPCCommon.h"
+
+#include "clang/AST/AST.h"
+#include "clang/AST/Attr.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/Mangle.h"
+#include "clang/Lex/Lexer.h"
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+// We intentionally do not generate some classes because they are currently
+// inconvenient, they aren't really used by most consumers, or we're not sure
+// why they exist.
+static constexpr llvm::StringRef DisallowedClasses[] = {
+"SBCommunication",  // What is this used for?
+"SBInputReader",// What is this used for?
+"SBCommandPluginInterface", // This is hard to support, we can do it if
+// really needed though.
+"SBCommand", // There's nothing too difficult about this one, but many of
+ // its methods take a SBCommandPluginInterface pointer so
+ // there's no reason to support this.
+};
+
+// We intentionally avoid generating certain methods either because they are
+// difficult to support correctly or they aren't really used much from C++.
+// NOTE: These methods are marked as deprecated using LLDB_DEPRECATED.
+// Normally this macro defines to the deprecated annotation, but this
+// functionality is removed in SBDefines.h when generating SWIG bindings which
+// we use for testing. Because of this, there is no annotation for the tool to
+// pick up on so this list will be used while we have this restriction in
+// SBDefines.h.
+static constexpr llvm::StringRef DisallowedMethods[] = {
+// The threading functionality in SBHostOS is deprecated and thus we do not
+// generate them. It would be ideal to add the annotations to the methods
+// and then support not generating deprecated methods. However, without
+// annotations the generator generates most things correctly. This one is
+// problematic because it returns a pointer to an "opaque" structure
+// (thread_t) that is not `void *`, so special casing it is more effort 
than
+// it's worth.
+"_ZN4lldb8SBHostOS10ThreadJoinEP17_opaque_pthread_tPPvPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCancelEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCreateEPKcPFPvS3_ES3_PNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadDetachEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS13ThreadCreatedEPKc",
+};
+
+static constexpr llvm::StringRef ClassesWithoutDefaultCtor[] = {
+"SBHostOS",
+"SBReproducer",
+};
+
+static constexpr llvm::StringRef ClassesWithoutCopyOperations[] = {
+"SBHostOS",
+"SBReproducer",
+"SBStream",
+"SBProgress",
+};
+
+static constexpr llvm::StringRef MethodsWithPointerPlusLen[] = {
+"_ZN4lldb6SBData11ReadRawDataERNS_7SBErrorEyPvm",
+"_ZN4lldb6SBData7SetDataERNS_7SBErrorEPKvmNS_9ByteOrderEh",
+"_ZN4lldb6SBData20SetDataWithOwnershipERNS_7SBErrorEPKvmNS_9ByteOrderEh",
+"_ZN4lldb6SBData25CreateDataFromUInt64ArrayENS_9ByteOrderEjPym",
+"_ZN4lldb6SBData25CreateDataFromUInt32ArrayENS_9ByteOrderEjPjm",
+"_ZN4lldb6SBData25CreateDataFromSInt64ArrayENS_9ByteOrderEjPxm",
+"_ZN4lldb6SBData25CreateDataFromSInt32ArrayENS_9ByteOrderEjPim",
+"_ZN4lldb6SBData25CreateDataFromDoubleArrayENS_9ByteOrderEjPdm",
+"_ZN4lldb6SBData22SetDataFromUInt64ArrayEPym",
+"_Z

[Lldb-commits] [lldb] [lldb] Add Python properties to SBBreakpoint(Location) (PR #142215)

2025-06-02 Thread Dave Lee via lldb-commits

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

>From b969aeffa2726ef4e0714bde9de72a5292a8d8fa Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Fri, 30 May 2025 14:11:19 -0700
Subject: [PATCH 1/4] [lldb] Add Python properties to SBBreakpointr(Location)

---
 lldb/bindings/interface/SBBreakpointExtensions.i|  9 +
 .../interface/SBBreakpointLocationExtensions.i  | 13 +
 2 files changed, 22 insertions(+)

diff --git a/lldb/bindings/interface/SBBreakpointExtensions.i 
b/lldb/bindings/interface/SBBreakpointExtensions.i
index 6bc781a327778..82fc3ab0e7c04 100644
--- a/lldb/bindings/interface/SBBreakpointExtensions.i
+++ b/lldb/bindings/interface/SBBreakpointExtensions.i
@@ -50,6 +50,15 @@ STRING_EXTENSION_OUTSIDE(SBBreakpoint)
 enabled = property(IsEnabled, SetEnabled, doc='''A read/write property 
that configures whether this breakpoint is enabled or not.''')
 one_shot = property(IsOneShot, SetOneShot, doc='''A read/write 
property that configures whether this breakpoint is one-shot (deleted when hit) 
or not.''')
 num_locations = property(GetNumLocations, None, doc='''A read only 
property that returns the count of locations of this breakpoint.''')
+auto_continue = property(GetAutoContinue, SetAutoContinue, doc='A 
read/write property that configures the auto-continue property of this 
breakpoint.')
+condition = property(GetCondition, SetCondition, doc='A read/write 
property that configures the condition of this breakpoint.')
+hit_count = property(GetHitCount, doc='A read only property that 
returns the hit count of this breakpoint.')
+ignore_count = property(GetIgnoreCount, SetIgnoreCount, doc='A 
read/write property that configures the ignore count of this breakpoint.')
+queue_name = property(GetQueueName, SetQueueName, doc='A read/write 
property that configures the queue name criteria of this breakpoint.')
+target = property(GetTarget, doc='A read only property that returns 
the target of this breakpoint.')
+thread_id = property(GetThreadID, SetThreadID, doc='A read/write 
property that configures the thread id criteria of this breakpoint.')
+thread_index = property(GetThreadIndex, SetThreadIndex, doc='A 
read/write property that configures the thread index criteria of this 
breakpoint.')
+thread_name = property(GetThreadName, SetThreadName, doc='A read/write 
property that configures the thread name criteria of this breakpoint.')
 %}
 #endif
 }
diff --git a/lldb/bindings/interface/SBBreakpointLocationExtensions.i 
b/lldb/bindings/interface/SBBreakpointLocationExtensions.i
index 40027790a5e8d..12c87eb2c0fe6 100644
--- a/lldb/bindings/interface/SBBreakpointLocationExtensions.i
+++ b/lldb/bindings/interface/SBBreakpointLocationExtensions.i
@@ -7,6 +7,19 @@ STRING_EXTENSION_LEVEL_OUTSIDE(SBBreakpointLocation, 
lldb::eDescriptionLevelFull
 # our own equality operator here
 def __eq__(self, other):
   return not self.__ne__(other)
+
+addr = property(GetAddress, doc='A read only property that returns the 
address of this breakpoint location.')
+auto_continue = property(GetAutoContinue, SetAutoContinue, doc='A 
read/write property that configures the auto-continue property of this 
breakpoint location.')
+breakpoint = property(GetBreakpoint, doc='A read only property that 
returns the parent breakpoint of this breakpoint location.')
+condition = property(GetCondition, SetCondition, doc='A read/write 
property that configures the condition of this breakpoint location.')
+hit_count = property(GetHitCount, doc='A read only property that returns 
the hit count of this breakpoint location.')
+id = property(GetID, doc='A read only property that returns the id of this 
breakpoint location.')
+ignore_count = property(GetIgnoreCount, SetIgnoreCount, doc='A read/write 
property that configures the ignore count of this breakpoint location.')
+load_addr = property(GetLoadAddress, doc='A read only property that 
returns the load address of this breakpoint location.')
+queue_name = property(GetQueueName, SetQueueName, doc='A read/write 
property that configures the queue name criteria of this breakpoint location.')
+thread_id = property(GetThreadID, SetThreadID, doc='A read/write property 
that configures the thread id criteria of this breakpoint location.')
+thread_index = property(GetThreadIndex, SetThreadIndex, doc='A read/write 
property that configures the thread index criteria of this breakpoint 
location.')
+thread_name = property(GetThreadName, SetThreadName, doc='A read/write 
property that configures the thread name criteria of this breakpoint location.')
 %}
 #endif
 }

>From b8652064283aeb6b3937b0544d0d87e4f14fcb15 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Sat, 31 May 2025 11:25:07 -0700
Subject: [PATCH 2/4] Update some tests to use properties

---
 .../TestBreakpointIgnoreCount.py

[Lldb-commits] [lldb] [lldb] Add Python properties to SBBreakpoint and similar (PR #142215)

2025-06-02 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add Python properties to SBBreakpoint and similar (PR #142215)

2025-06-02 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (PR #142224)

2025-06-02 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Reuse source object logics (PR #141426)

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

ashgti wrote:

FYI, I am not a code owner of lldb-dap or lldb. I think its usually best to 
wait for one of the owners to sign off before submitting.

See https://github.com/llvm/llvm-project/blob/main/lldb/Maintainers.md for the 
full list of active maintainers.

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


[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)

2025-06-02 Thread Chelsea Cassanova via lldb-commits

chelcassanova wrote:

I updated this patch to remove everything that isn't related to how the tool 
works with the server emitters. This should simplify this patch and make it so 
that when later emitters are put up (such as the client and bindings emitters), 
the tool can be updated to accommodate for those.

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


[Lldb-commits] [lldb] [lldb] Fix data race in statusline format handling (PR #142489)

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

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

As far as I can tell this looks safe now.

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


[Lldb-commits] [lldb] [lldb] Fix data race in statusline format handling (PR #142489)

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


@@ -144,9 +144,9 @@ void Statusline::Redraw(bool update) {
   }
 
   StreamString stream;
-  if (auto *format = m_debugger.GetStatuslineFormat())
-FormatEntity::Format(*format, stream, &symbol_ctx, &exe_ctx, nullptr,
- nullptr, false, false);
+  FormatEntity::Entry format = m_debugger.GetStatuslineFormat();
+  FormatEntity::Format(format, stream, &symbol_ctx, &exe_ctx, nullptr, nullptr,
+   false, false);
 
   Draw(std::string(stream.GetString()));

adrian-prantl wrote:

Draw(stream.GetString().str())

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


[Lldb-commits] [lldb] [lldb] Fix data race in statusline format handling (PR #142489)

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


@@ -380,11 +380,11 @@ bool OptionValue::SetLanguageValue(lldb::LanguageType 
new_language) {
   return false;
 }
 
-const FormatEntity::Entry *OptionValue::GetFormatEntity() const {
+FormatEntity::Entry OptionValue::GetFormatEntity() const {
   std::lock_guard lock(m_mutex);
   if (const OptionValueFormatEntity *option_value = GetAsFormatEntity())
-return &option_value->GetCurrentValue();
-  return nullptr;
+return option_value->GetCurrentValue();

adrian-prantl wrote:

This looks safe.

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


[Lldb-commits] [lldb] [lldb] Fix data race in statusline format handling (PR #142489)

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


@@ -1534,15 +1534,13 @@ bool Debugger::FormatDisassemblerAddress(const 
FormatEntity::Entry *format,
  const ExecutionContext *exe_ctx,
  const Address *addr, Stream &s) {
   FormatEntity::Entry format_entry;
+  if (format)

adrian-prantl wrote:

This is a weird API.

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


[Lldb-commits] [lldb] [lldb] Fix data race in statusline format handling (PR #142489)

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

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


[Lldb-commits] [lldb] [lldb] Fix data race in statusline format handling (PR #142489)

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


@@ -1534,15 +1534,13 @@ bool Debugger::FormatDisassemblerAddress(const 
FormatEntity::Entry *format,
  const ExecutionContext *exe_ctx,
  const Address *addr, Stream &s) {
   FormatEntity::Entry format_entry;
+  if (format)
+format_entry = *format;
+  else if (exe_ctx != nullptr && exe_ctx->HasTargetScope())

adrian-prantl wrote:

```suggestion
  else if (exe_ctx && exe_ctx->HasTargetScope())
```

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


[Lldb-commits] [lldb] Have lldb-dap extension support multi-root workspace (PR #142470)

2025-06-02 Thread via lldb-commits

github-actions[bot] wrote:



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


[Lldb-commits] [lldb] 9d356c3 - Have lldb-dap extension support multi-root workspace (#142470)

2025-06-02 Thread via lldb-commits

Author: award999
Date: 2025-06-02T14:31:40-07:00
New Revision: 9d356c39b7a594a1ce3a27c2487febc382f5a5a7

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

LOG: Have lldb-dap extension support multi-root workspace (#142470)

- Allow running when no workspace folder is present, and do not override
the `cwd` set in the launch configuration
- Support getting configuration from workspace file

Fixes #142469

Added: 


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

Removed: 




diff  --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts 
b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
index d61b81e4c041f..b5db45b56d6a6 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -169,7 +169,7 @@ export async function createDebugAdapterExecutable(
   workspaceFolder: vscode.WorkspaceFolder | undefined,
   configuration: vscode.DebugConfiguration,
 ): Promise {
-  const config = vscode.workspace.getConfiguration("lldb-dap", 
workspaceFolder);
+  const config = vscode.workspace.workspaceFile ? 
vscode.workspace.getConfiguration("lldb-dap") : 
vscode.workspace.getConfiguration("lldb-dap", workspaceFolder);
   const log_path = config.get("log-path");
   let env: { [key: string]: string } = {};
   if (log_path) {
@@ -184,7 +184,7 @@ export async function createDebugAdapterExecutable(
   ...configEnvironment,
   ...env,
 },
-cwd: workspaceFolder!!.uri.fsPath,
+cwd: configuration.cwd ?? workspaceFolder?.uri.fsPath,
   };
   const dbgArgs = await getDAPArguments(workspaceFolder, configuration);
 



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


[Lldb-commits] [lldb] [lldb] Fix data race in statusline format handling (PR #142489)

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

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

>From bbdaa75ba4baa54d17fb1f8bbf6280b7e4521b84 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Mon, 2 Jun 2025 14:16:23 -0700
Subject: [PATCH 1/2] [lldb] Fix data race in statusline format handling

This fixes a data race between the main thread and the default event
handler thread. The statusline format option value was protected by a
mutex, but it was returned as a pointer, allowing one thread to access
it while another was modifying it.

Avoid the data race by returning format values by value instead of by
pointer.
---
 lldb/include/lldb/Core/Debugger.h   | 12 +++
 lldb/include/lldb/Interpreter/OptionValue.h |  6 ++--
 lldb/source/Core/Debugger.cpp   | 40 ++---
 lldb/source/Core/Disassembler.cpp   | 17 +++--
 lldb/source/Core/Statusline.cpp |  6 ++--
 lldb/source/Interpreter/OptionValue.cpp |  6 ++--
 lldb/source/Target/StackFrame.cpp   |  4 +--
 lldb/source/Target/Thread.cpp   |  6 ++--
 lldb/source/Target/ThreadPlanTracer.cpp |  4 +--
 9 files changed, 45 insertions(+), 56 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index c9e5310cded1a..d73aba1e3ce58 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -243,17 +243,17 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool GetAutoConfirm() const;
 
-  const FormatEntity::Entry *GetDisassemblyFormat() const;
+  FormatEntity::Entry GetDisassemblyFormat() const;
 
-  const FormatEntity::Entry *GetFrameFormat() const;
+  FormatEntity::Entry GetFrameFormat() const;
 
-  const FormatEntity::Entry *GetFrameFormatUnique() const;
+  FormatEntity::Entry GetFrameFormatUnique() const;
 
   uint64_t GetStopDisassemblyMaxSize() const;
 
-  const FormatEntity::Entry *GetThreadFormat() const;
+  FormatEntity::Entry GetThreadFormat() const;
 
-  const FormatEntity::Entry *GetThreadStopFormat() const;
+  FormatEntity::Entry GetThreadStopFormat() const;
 
   lldb::ScriptLanguage GetScriptLanguage() const;
 
@@ -297,7 +297,7 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool GetShowStatusline() const;
 
-  const FormatEntity::Entry *GetStatuslineFormat() const;
+  FormatEntity::Entry GetStatuslineFormat() const;
   bool SetStatuslineFormat(const FormatEntity::Entry &format);
 
   llvm::StringRef GetSeparator() const;
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index e3c139155b0ef..69f84419416c6 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -284,6 +284,8 @@ class OptionValue {
   return GetStringValue();
 if constexpr (std::is_same_v)
   return GetArchSpecValue();
+if constexpr (std::is_same_v)
+  return GetFormatEntity();
 if constexpr (std::is_enum_v)
   if (std::optional value = GetEnumerationValue())
 return static_cast(*value);
@@ -295,8 +297,6 @@ class OptionValue {
 typename std::remove_pointer::type>::type,
 std::enable_if_t, bool> = true>
   T GetValueAs() const {
-if constexpr (std::is_same_v)
-  return GetFormatEntity();
 if constexpr (std::is_same_v)
   return GetRegexValue();
 return {};
@@ -382,7 +382,7 @@ class OptionValue {
   std::optional GetUUIDValue() const;
   bool SetUUIDValue(const UUID &uuid);
 
-  const FormatEntity::Entry *GetFormatEntity() const;
+  FormatEntity::Entry GetFormatEntity() const;
   bool SetFormatEntityValue(const FormatEntity::Entry &entry);
 
   const RegularExpression *GetRegexValue() const;
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 519a2528ca7e0..112ef3572aa98 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -294,19 +294,19 @@ bool Debugger::GetAutoConfirm() const {
   idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
-const FormatEntity::Entry *Debugger::GetDisassemblyFormat() const {
+FormatEntity::Entry Debugger::GetDisassemblyFormat() const {
   constexpr uint32_t idx = ePropertyDisassemblyFormat;
-  return GetPropertyAtIndexAs(idx);
+  return GetPropertyAtIndexAs(idx, {});
 }
 
-const FormatEntity::Entry *Debugger::GetFrameFormat() const {
+FormatEntity::Entry Debugger::GetFrameFormat() const {
   constexpr uint32_t idx = ePropertyFrameFormat;
-  return GetPropertyAtIndexAs(idx);
+  return GetPropertyAtIndexAs(idx, {});
 }
 
-const FormatEntity::Entry *Debugger::GetFrameFormatUnique() const {
+FormatEntity::Entry Debugger::GetFrameFormatUnique() const {
   constexpr uint32_t idx = ePropertyFrameFormatUnique;
-  return GetPropertyAtIndexAs(idx);
+  return GetPropertyAtIndexAs(idx, {});
 }
 
 uint64_t Debugger::GetStopDisassemblyMaxSize() const {
@@ -350,14 +350,14 @@ void Debugger::SetPrompt(llvm::StringRef p) {
   GetCommandI

[Lldb-commits] [lldb] [lldb] Emit an error when using --wait-for without a name or pid (PR #142424)

2025-06-02 Thread via lldb-commits


@@ -280,6 +280,12 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, 
bool &exiting) {
   }
 
   if (args.hasArg(OPT_wait_for)) {
+if (!args.hasArg(OPT_attach_name) || !args.hasArg(OPT_attach_pid)) {

jimingham wrote:

Process::Attach does:

```
  lldb::pid_t attach_pid = attach_info.GetProcessID();
  Status error;
  if (attach_pid == LLDB_INVALID_PROCESS_ID) {
char process_name[PATH_MAX];

if (attach_info.GetExecutableFile().GetPath(process_name,
sizeof(process_name))) {
  const bool wait_for_launch = attach_info.GetWaitForLaunch();

```

and then:

```
  if (attach_pid != LLDB_INVALID_PROCESS_ID) {
error = WillAttachToProcessWithID(attach_pid);
if (error.Success()) {
  m_public_run_lock.SetRunning();

  // Now attach using these arguments.
  m_should_detach = true;
  const bool restarted = false;
  SetPublicState(eStateAttaching, restarted);
  error = DoAttachToProcessWithID(attach_pid, attach_info);

```

so the help is wrong...

https://github.com/llvm/llvm-project/pull/142424
___
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-06-02 Thread via lldb-commits

jimingham wrote:

Try:

diff --git a/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py 
b/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
index b71f3421f983..782d6f2004ea 100644
--- a/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
+++ b/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
@@ -89,9 +89,9 @@ class TestStopHooks(TestBase):
 result = lldb.SBCommandReturnObject()
 
 if return_true:
-command = "target stop-hook add -P stop_hook.stop_handler -k 
increment -v 5 -k return_false -v 1 -n step_out_of_me"
+command = "target stop-hook add -I 0 -P stop_hook.stop_handler -k 
increment -v 5 -k return_false -v 1 -n step_out_of_me"
 else:
-command = "target stop-hook add -G 1 -P stop_hook.stop_handler -k 
increment -v 5 -n step_out_of_me"
+command = "target stop-hook add -I 0 -G 1 -P 
stop_hook.stop_handler -k increment -v 5 -n step_out_of_me"
 
 self.interp.HandleCommand(command, result)
 self.assertTrue(result.Succeeded(), "Set the target stop hook")

And see if that fixes it.  Not sure why this is only causing failures on x86 
Linux, but these tests aren't testing the initial stop so if it's getting in 
the way of the test it's fine to turn it off for that test.

Jim


> On Jun 2, 2025, at 3:14 PM, Prabhu Rajasekaran ***@***.***> wrote:
> 
> 
> Prabhuk
>  left a comment 
> (llvm/llvm-project#137410)
>  
> My team builds lldb on linux X64 and running into a test failure since this 
> patch had landed.
> Builder link: 
> https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/lldb-linux-x64/b8713139267610948369/overview
> 
> I am taking a closer look. CC: @mysterymath 
> FAIL: lldb-api :: commands/target/stop-hooks/TestStopHookScripted.py (285 of 
> 2899)
>  TEST 'lldb-api :: 
> commands/target/stop-hooks/TestStopHookScripted.py' FAILED 
> 
> Script:
> --
> /b/s/w/ir/x/w/install-cpython-x86_64-linux-gnu/bin/python3 
> /b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS 
> --env LLVM_LIBS_DIR=/b/s/w/ir/x/w/llvm_build/./lib --env 
> LLVM_INCLUDE_DIR=/b/s/w/ir/x/w/llvm_build/include --env 
> LLVM_TOOLS_DIR=/b/s/w/ir/x/w/llvm_build/./bin --arch x86_64 --build-dir 
> /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex --lldb-module-cache-dir 
> /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/module-cache-lldb/lldb-api 
> --clang-module-cache-dir 
> /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/module-cache-clang/lldb-api 
> --executable /b/s/w/ir/x/w/llvm_build/./bin/lldb --compiler 
> /b/s/w/ir/x/w/cipd/clang/bin/clang --dsymutil 
> /b/s/w/ir/x/w/llvm_build/./bin/dsymutil --make /b/s/w/ir/x/w/cipd/bin/make 
> --llvm-tools-dir /b/s/w/ir/x/w/llvm_build/./bin --lldb-obj-root 
> /b/s/w/ir/x/w/llvm_build/tools/lldb --lldb-libs-dir 
> /b/s/w/ir/x/w/llvm_build/./lib --cmake-build-type Release 
> --skip-category=pexpect 
> /b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/commands/target/stop-hooks -p 
> TestStopHookScripted.py
> --
> Exit Code: 1
> 
> Command Output (stdout):
> --
> lldb version 21.0.0git (https://llvm.googlesource.com/a/llvm-project revision 
> d313c09b288c31f93819408048b0b64ca5c5fc2b)
>   clang revision d313c09b288c31f93819408048b0b64ca5c5fc2b
>   llvm revision d313c09b288c31f93819408048b0b64ca5c5fc2b
> I have stopped 1 times.
> Returning value: 1 from handle_stop.
> I have stopped 1 times.
> Returning value: 1 from handle_stop.
> I have stopped 2 times.
> Returning value: 1 from handle_stop.
> I have stopped 1 times.
> Returning value: 1 from handle_stop.
> I have stopped 2 times.
> Returning value: 1 from handle_stop.
> I have stopped 1 times.
> Returning value: 0 from handle_stop.
> I have stopped 2 times.
> Error running expression: can't evaluate expressions when the process is 
> running.Returning value: 0 from handle_stop.
> I have stopped 1 times.
> Returning value: 1 from handle_stop.
> I have stopped 2 times.
> Returning value: 1 from handle_stop.
> I have stopped 1 times.
> Returning value: 1 from handle_stop.
> I have stopped 1 times.
> Returning value: 1 from handle_stop.
> Skipping the following test categories: ['pexpect', 'dsym', 'gmodules', 
> 'debugserver', 'objc']
> I am okay
> I am okay
> 
> --
> Command Output (stderr):
> --
> PASS: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: test_bad_handler 
> (TestStopHookScripted.TestStopHooks.test_bad_handler)
> PASS: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
> test_stop_hooks_scripted 
> (TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted)
> FAIL: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
> test_stop_hooks_scripted_auto_continue 
> (TestStopHookScripted.TestStopHooks.test_stop_hooks_scripted_auto_continue)
> PASS: LLDB (/b/s/w/ir/x/w/cipd/clang/bin/clang-x86_64) :: 
> test_stop_

[Lldb-commits] [lldb] Have lldb-dap extension support multi-root workspace (PR #142470)

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

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

LGTM

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


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

2025-06-02 Thread David Peixotto via lldb-commits


@@ -46,12 +49,206 @@ class CommandObjectPluginLoad : public CommandObjectParsed 
{
   }
 };
 
+namespace {
+// Helper function to perform an action on each matching plugin.
+// The action callback is given the containing namespace along with plugin info
+// for each matching plugin.
+static int ActOnMatchingPlugins(
+const llvm::StringRef pattern,
+std::function &plugin_info)>
+action) {
+  int num_matching = 0;
+
+  for (const PluginNamespace &plugin_namespace :
+   PluginManager::GetPluginNamespaces()) {
+const bool match_namespace =
+pattern.empty() || pattern == plugin_namespace.name;
+
+std::vector matching_plugins;
+for (const RegisteredPluginInfo &plugin_info :
+ plugin_namespace.get_info()) {
+
+  // If we match the namespace, we can skip the plugin name check.
+  bool match_qualified_name = false;
+  if (!match_namespace) {
+std::string qualified_name =
+(plugin_namespace.name + "." + plugin_info.name).str();
+match_qualified_name = pattern == qualified_name;
+  }
+
+  if (match_namespace || match_qualified_name)
+matching_plugins.push_back(plugin_info);
+}
+
+if (!matching_plugins.empty()) {
+  num_matching += matching_plugins.size();
+  action(plugin_namespace, matching_plugins);
+}
+  }
+
+  return num_matching;
+}
+
+// Call the "SetEnable" function for each matching plugins.
+// Used to share the majority of the code between the enable
+// and disable commands.
+int SetEnableOnMatchingPlugins(const llvm::StringRef &pattern,
+   CommandReturnObject &result, bool enabled) {
+  return ActOnMatchingPlugins(
+  pattern, [&](const PluginNamespace &plugin_namespace,
+   const std::vector &plugins) {
+result.AppendMessage(plugin_namespace.name);
+for (const auto &plugin : plugins) {
+  if (!plugin_namespace.set_enabled(plugin.name, enabled)) {
+result.AppendErrorWithFormat("failed to enable plugin %s.%s",
+ plugin_namespace.name.data(),
+ plugin.name.data());
+continue;
+  }
+
+  result.AppendMessageWithFormat(
+  "  %s %-30s %s\n", enabled ? "[+]" : "[-]", plugin.name.data(),
+  plugin.description.data());
+}
+  });
+}
+} // namespace
+
+class CommandObjectPluginList : public CommandObjectParsed {
+public:
+  CommandObjectPluginList(CommandInterpreter &interpreter)

dmpots wrote:

Added the options and updated the tests to exercise them.

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


[Lldb-commits] [clang] [lldb] [Clang][PowerPC] Add __dmr type and DMF integer calculation builtins (PR #142480)

2025-06-02 Thread Maryam Moghadas via lldb-commits

https://github.com/maryammo created 
https://github.com/llvm/llvm-project/pull/142480

Define the __dmr type used to manipulate the new DMR registers introduced by 
the Dense Math Facility (DMF) on PowerPC, and add six Clang builtins that 
correspond to the integer outer-product accumulate to ACC instructions: 
__builtin_mma_dmxvi8gerx4, __builtin_mma_pmdmxvi8gerx4, 
__builtin_mma_dmxvi8gerx4pp, __builtin_mma_pmdmxvi8gerx4pp, 
__builtin_mma_dmxvi8gerx4spp, and __builtin_mma_pmdmxvi8gerx4spp.

>From 5ef7a4ca7c2a838a6b2100968d5023e0797b2848 Mon Sep 17 00:00:00 2001
From: Maryam Moghadas 
Date: Mon, 2 Jun 2025 19:54:57 +
Subject: [PATCH] [Clang][PowerPC] Add __dmr type and DMF integer calculation
 builtins

Define the __dmr type used to manipulate the new DMR registers introduced by
the Dense Math Facility (DMF) on PowerPC, and add six Clang builtins that
correspond to the integer outer-product accumulate to ACC instructions:
__builtin_mma_dmxvi8gerx4, __builtin_mma_pmdmxvi8gerx4,
__builtin_mma_dmxvi8gerx4pp, __builtin_mma_pmdmxvi8gerx4pp,
__builtin_mma_dmxvi8gerx4spp, and __builtin_mma_pmdmxvi8gerx4spp.
---
 clang/include/clang/Basic/BuiltinsPPC.def |  12 ++
 clang/include/clang/Basic/PPCTypes.def|   1 +
 clang/lib/AST/ASTContext.cpp  |   1 +
 clang/test/AST/ast-dump-ppc-types.c   |  13 +-
 .../CodeGen/PowerPC/builtins-ppc-mmaplus.c|  94 +
 .../PowerPC/ppc-future-mma-builtin-err.c  |  21 ++
 ...ppc-future-paired-vec-memops-builtin-err.c |  20 ++
 .../test/CodeGen/PowerPC/ppc-mmaplus-types.c  | 184 ++
 .../test/CodeGenCXX/ppc-mangle-mma-types.cpp  |   5 +
 clang/test/Sema/ppc-pair-mma-types.c  |  98 ++
 .../TypeSystem/Clang/TypeSystemClang.cpp  |   1 +
 11 files changed, 447 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/CodeGen/PowerPC/builtins-ppc-mmaplus.c
 create mode 100644 clang/test/CodeGen/PowerPC/ppc-future-mma-builtin-err.c
 create mode 100644 
clang/test/CodeGen/PowerPC/ppc-future-paired-vec-memops-builtin-err.c
 create mode 100644 clang/test/CodeGen/PowerPC/ppc-mmaplus-types.c

diff --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index bb7d54bbb793e..099500754a0e0 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -1134,6 +1134,18 @@ UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2np, 
"vW512*VVi15i15i3", true,
  "mma,paired-vector-memops")
 UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2nn, "vW512*VVi15i15i3", true,
  "mma,paired-vector-memops")
+UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4, "vW1024*W256V", false,
+ "mma,paired-vector-memops")
+UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4, "vW1024*W256Vi255i15i15", false,
+ "mma,paired-vector-memops")
+UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4pp, "vW1024*W256V", true,
+ "mma,paired-vector-memops")
+UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4pp, "vW1024*W256Vi255i15i15", true,
+ "mma,paired-vector-memops")
+UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4spp,  "vW1024*W256V", true,
+ "mma,paired-vector-memops")
+UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4spp, "vW1024*W256Vi255i15i15", true,
+ "mma,paired-vector-memops")
 
 // FIXME: Obviously incomplete.
 
diff --git a/clang/include/clang/Basic/PPCTypes.def 
b/clang/include/clang/Basic/PPCTypes.def
index 9e2cb2aedc9fc..cfc9de3a473d4 100644
--- a/clang/include/clang/Basic/PPCTypes.def
+++ b/clang/include/clang/Basic/PPCTypes.def
@@ -30,6 +30,7 @@
 #endif
 
 
+PPC_VECTOR_MMA_TYPE(__dmr, VectorDmr, 1024)
 PPC_VECTOR_MMA_TYPE(__vector_quad, VectorQuad, 512)
 PPC_VECTOR_VSX_TYPE(__vector_pair, VectorPair, 256)
 
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 45f9602856840..ffb4ca61b00c4 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3455,6 +3455,7 @@ static void encodeTypeForFunctionPointerAuth(const 
ASTContext &Ctx,
 case BuiltinType::BFloat16:
 case BuiltinType::VectorQuad:
 case BuiltinType::VectorPair:
+case BuiltinType::VectorDmr:
   OS << "?";
   return;
 
diff --git a/clang/test/AST/ast-dump-ppc-types.c 
b/clang/test/AST/ast-dump-ppc-types.c
index 26ae5441f20d7..a430268284413 100644
--- a/clang/test/AST/ast-dump-ppc-types.c
+++ b/clang/test/AST/ast-dump-ppc-types.c
@@ -1,9 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu future \
+// RUN:   -ast-dump  %s | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu pwr10 \
-// RUN:   -ast-dump -ast-dump-filter __vector %s | FileCheck %s
+// RUN:   -ast-dump  %s | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu pwr9 \
-// RUN:   -ast-dump -ast-dump-filter __vector %s | FileCheck %s
+// RUN:   -ast-dump  %s | File

[Lldb-commits] [clang] [lldb] [Clang][PowerPC] Add __dmr type and DMF integer calculation builtins (PR #142480)

2025-06-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Maryam Moghadas (maryammo)


Changes

Define the __dmr type used to manipulate the new DMR registers introduced by 
the Dense Math Facility (DMF) on PowerPC, and add six Clang builtins that 
correspond to the integer outer-product accumulate to ACC instructions: 
__builtin_mma_dmxvi8gerx4, __builtin_mma_pmdmxvi8gerx4, 
__builtin_mma_dmxvi8gerx4pp, __builtin_mma_pmdmxvi8gerx4pp, 
__builtin_mma_dmxvi8gerx4spp, and __builtin_mma_pmdmxvi8gerx4spp.

---

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


11 Files Affected:

- (modified) clang/include/clang/Basic/BuiltinsPPC.def (+12) 
- (modified) clang/include/clang/Basic/PPCTypes.def (+1) 
- (modified) clang/lib/AST/ASTContext.cpp (+1) 
- (modified) clang/test/AST/ast-dump-ppc-types.c (+10-3) 
- (added) clang/test/CodeGen/PowerPC/builtins-ppc-mmaplus.c (+94) 
- (added) clang/test/CodeGen/PowerPC/ppc-future-mma-builtin-err.c (+21) 
- (added) clang/test/CodeGen/PowerPC/ppc-future-paired-vec-memops-builtin-err.c 
(+20) 
- (added) clang/test/CodeGen/PowerPC/ppc-mmaplus-types.c (+184) 
- (modified) clang/test/CodeGenCXX/ppc-mangle-mma-types.cpp (+5) 
- (modified) clang/test/Sema/ppc-pair-mma-types.c (+98) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+1) 


``diff
diff --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index bb7d54bbb793e..099500754a0e0 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -1134,6 +1134,18 @@ UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2np, 
"vW512*VVi15i15i3", true,
  "mma,paired-vector-memops")
 UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2nn, "vW512*VVi15i15i3", true,
  "mma,paired-vector-memops")
+UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4, "vW1024*W256V", false,
+ "mma,paired-vector-memops")
+UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4, "vW1024*W256Vi255i15i15", false,
+ "mma,paired-vector-memops")
+UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4pp, "vW1024*W256V", true,
+ "mma,paired-vector-memops")
+UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4pp, "vW1024*W256Vi255i15i15", true,
+ "mma,paired-vector-memops")
+UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4spp,  "vW1024*W256V", true,
+ "mma,paired-vector-memops")
+UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4spp, "vW1024*W256Vi255i15i15", true,
+ "mma,paired-vector-memops")
 
 // FIXME: Obviously incomplete.
 
diff --git a/clang/include/clang/Basic/PPCTypes.def 
b/clang/include/clang/Basic/PPCTypes.def
index 9e2cb2aedc9fc..cfc9de3a473d4 100644
--- a/clang/include/clang/Basic/PPCTypes.def
+++ b/clang/include/clang/Basic/PPCTypes.def
@@ -30,6 +30,7 @@
 #endif
 
 
+PPC_VECTOR_MMA_TYPE(__dmr, VectorDmr, 1024)
 PPC_VECTOR_MMA_TYPE(__vector_quad, VectorQuad, 512)
 PPC_VECTOR_VSX_TYPE(__vector_pair, VectorPair, 256)
 
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 45f9602856840..ffb4ca61b00c4 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3455,6 +3455,7 @@ static void encodeTypeForFunctionPointerAuth(const 
ASTContext &Ctx,
 case BuiltinType::BFloat16:
 case BuiltinType::VectorQuad:
 case BuiltinType::VectorPair:
+case BuiltinType::VectorDmr:
   OS << "?";
   return;
 
diff --git a/clang/test/AST/ast-dump-ppc-types.c 
b/clang/test/AST/ast-dump-ppc-types.c
index 26ae5441f20d7..a430268284413 100644
--- a/clang/test/AST/ast-dump-ppc-types.c
+++ b/clang/test/AST/ast-dump-ppc-types.c
@@ -1,9 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu future \
+// RUN:   -ast-dump  %s | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu pwr10 \
-// RUN:   -ast-dump -ast-dump-filter __vector %s | FileCheck %s
+// RUN:   -ast-dump  %s | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu pwr9 \
-// RUN:   -ast-dump -ast-dump-filter __vector %s | FileCheck %s
+// RUN:   -ast-dump  %s | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu pwr8 \
-// RUN:   -ast-dump -ast-dump-filter __vector %s | FileCheck %s
+// RUN:   -ast-dump  %s | FileCheck %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck %s \
 // RUN:   --check-prefix=CHECK-X86_64
 // RUN: %clang_cc1 -triple arm-unknown-unknown -ast-dump %s | FileCheck %s \
@@ -15,16 +17,21 @@
 // are correctly defined. We also added checks on a couple of other targets to
 // ensure the types are target-dependent.
 
+// CHECK: TypedefDecl {{.*}} implicit __dmr '__dmr'
+// CHECK: `-BuiltinType {{.*}} '__dmr'
 // CHECK: TypedefDecl {{.*}} implicit __vector_quad '__vector_quad'
 // CHECK-NEXT: -BuiltinType {{.*}} '__vector_qua

[Lldb-commits] [clang] [lldb] [Clang][PowerPC] Add __dmr type and DMF integer calculation builtins (PR #142480)

2025-06-02 Thread Maryam Moghadas via lldb-commits

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


[Lldb-commits] [lldb] [lldb][AIX] Added support to load DW_ranges section (PR #142356)

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

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


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


[Lldb-commits] [lldb] [lldb] Fix data race in statusline format handling (PR #142489)

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

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

>From bbdaa75ba4baa54d17fb1f8bbf6280b7e4521b84 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Mon, 2 Jun 2025 14:16:23 -0700
Subject: [PATCH 1/3] [lldb] Fix data race in statusline format handling

This fixes a data race between the main thread and the default event
handler thread. The statusline format option value was protected by a
mutex, but it was returned as a pointer, allowing one thread to access
it while another was modifying it.

Avoid the data race by returning format values by value instead of by
pointer.
---
 lldb/include/lldb/Core/Debugger.h   | 12 +++
 lldb/include/lldb/Interpreter/OptionValue.h |  6 ++--
 lldb/source/Core/Debugger.cpp   | 40 ++---
 lldb/source/Core/Disassembler.cpp   | 17 +++--
 lldb/source/Core/Statusline.cpp |  6 ++--
 lldb/source/Interpreter/OptionValue.cpp |  6 ++--
 lldb/source/Target/StackFrame.cpp   |  4 +--
 lldb/source/Target/Thread.cpp   |  6 ++--
 lldb/source/Target/ThreadPlanTracer.cpp |  4 +--
 9 files changed, 45 insertions(+), 56 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index c9e5310cded1a..d73aba1e3ce58 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -243,17 +243,17 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool GetAutoConfirm() const;
 
-  const FormatEntity::Entry *GetDisassemblyFormat() const;
+  FormatEntity::Entry GetDisassemblyFormat() const;
 
-  const FormatEntity::Entry *GetFrameFormat() const;
+  FormatEntity::Entry GetFrameFormat() const;
 
-  const FormatEntity::Entry *GetFrameFormatUnique() const;
+  FormatEntity::Entry GetFrameFormatUnique() const;
 
   uint64_t GetStopDisassemblyMaxSize() const;
 
-  const FormatEntity::Entry *GetThreadFormat() const;
+  FormatEntity::Entry GetThreadFormat() const;
 
-  const FormatEntity::Entry *GetThreadStopFormat() const;
+  FormatEntity::Entry GetThreadStopFormat() const;
 
   lldb::ScriptLanguage GetScriptLanguage() const;
 
@@ -297,7 +297,7 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool GetShowStatusline() const;
 
-  const FormatEntity::Entry *GetStatuslineFormat() const;
+  FormatEntity::Entry GetStatuslineFormat() const;
   bool SetStatuslineFormat(const FormatEntity::Entry &format);
 
   llvm::StringRef GetSeparator() const;
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index e3c139155b0ef..69f84419416c6 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -284,6 +284,8 @@ class OptionValue {
   return GetStringValue();
 if constexpr (std::is_same_v)
   return GetArchSpecValue();
+if constexpr (std::is_same_v)
+  return GetFormatEntity();
 if constexpr (std::is_enum_v)
   if (std::optional value = GetEnumerationValue())
 return static_cast(*value);
@@ -295,8 +297,6 @@ class OptionValue {
 typename std::remove_pointer::type>::type,
 std::enable_if_t, bool> = true>
   T GetValueAs() const {
-if constexpr (std::is_same_v)
-  return GetFormatEntity();
 if constexpr (std::is_same_v)
   return GetRegexValue();
 return {};
@@ -382,7 +382,7 @@ class OptionValue {
   std::optional GetUUIDValue() const;
   bool SetUUIDValue(const UUID &uuid);
 
-  const FormatEntity::Entry *GetFormatEntity() const;
+  FormatEntity::Entry GetFormatEntity() const;
   bool SetFormatEntityValue(const FormatEntity::Entry &entry);
 
   const RegularExpression *GetRegexValue() const;
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 519a2528ca7e0..112ef3572aa98 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -294,19 +294,19 @@ bool Debugger::GetAutoConfirm() const {
   idx, g_debugger_properties[idx].default_uint_value != 0);
 }
 
-const FormatEntity::Entry *Debugger::GetDisassemblyFormat() const {
+FormatEntity::Entry Debugger::GetDisassemblyFormat() const {
   constexpr uint32_t idx = ePropertyDisassemblyFormat;
-  return GetPropertyAtIndexAs(idx);
+  return GetPropertyAtIndexAs(idx, {});
 }
 
-const FormatEntity::Entry *Debugger::GetFrameFormat() const {
+FormatEntity::Entry Debugger::GetFrameFormat() const {
   constexpr uint32_t idx = ePropertyFrameFormat;
-  return GetPropertyAtIndexAs(idx);
+  return GetPropertyAtIndexAs(idx, {});
 }
 
-const FormatEntity::Entry *Debugger::GetFrameFormatUnique() const {
+FormatEntity::Entry Debugger::GetFrameFormatUnique() const {
   constexpr uint32_t idx = ePropertyFrameFormatUnique;
-  return GetPropertyAtIndexAs(idx);
+  return GetPropertyAtIndexAs(idx, {});
 }
 
 uint64_t Debugger::GetStopDisassemblyMaxSize() const {
@@ -350,14 +350,14 @@ void Debugger::SetPrompt(llvm::StringRef p) {
   GetCommandI

[Lldb-commits] [lldb] [lldb] Emit an error when using --wait-for without a name or pid (PR #142424)

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

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


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


[Lldb-commits] [lldb] [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (PR #142224)

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

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


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


[Lldb-commits] [lldb] [lldb] Fix SIGSEGV in `GetPtraceScope()` in `Procfs.cpp` (PR #142224)

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


@@ -74,7 +74,7 @@ lldb_private::process_linux::GetAvailableLogicalCoreIDs() {
 llvm::Expected lldb_private::process_linux::GetPtraceScope() {
   ErrorOr> ptrace_scope_file =
   getProcFile("sys/kernel/yama/ptrace_scope");
-  if (!*ptrace_scope_file)
+  if (!ptrace_scope_file)

labath wrote:

I don't think we do. The default for functions returning 
`Expected/ErrorOr>` is that they return a valid object in the 
non-error case. If they aren't they should very explicitly document what it 
means to "successfully return nothing"

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


[Lldb-commits] [clang] [lldb] [lldb] Add filter option to AST dump command (PR #142164)

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

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

>From 662e07aa9bb6560f37c079ba6f13be17e7885b48 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 30 May 2025 15:44:09 +0100
Subject: [PATCH 1/6] [clang][Frontend] Add overload to ASTPrinter that doesn't
 own output stream

We're planning on using the ASTPrinter in LLDB for AST dumping. But it
currently takes the output stream via `unique_ptr`. In LLDB we don't
have the output stream available in this form and instead it would be
convenient if we could just pass a reference to the stream.

This patch adds that overload.

(cherry picked from commit 9bd15ee7ed44adc836bcd07ff7e856d7a32ba6a9)
---
 clang/include/clang/Frontend/ASTConsumers.h |  5 +
 clang/lib/Frontend/ASTConsumers.cpp | 20 
 2 files changed, 25 insertions(+)

diff --git a/clang/include/clang/Frontend/ASTConsumers.h 
b/clang/include/clang/Frontend/ASTConsumers.h
index 0e068bf5cccb5..890701b6ff188 100644
--- a/clang/include/clang/Frontend/ASTConsumers.h
+++ b/clang/include/clang/Frontend/ASTConsumers.h
@@ -35,6 +35,11 @@ CreateASTDumper(std::unique_ptr OS, StringRef 
FilterString,
 bool DumpDecls, bool Deserialize, bool DumpLookups,
 bool DumpDeclTypes, ASTDumpOutputFormat Format);
 
+std::unique_ptr
+CreateASTDumper(raw_ostream &OS, StringRef FilterString, bool DumpDecls,
+bool Deserialize, bool DumpLookups, bool DumpDeclTypes,
+ASTDumpOutputFormat Format);
+
 // AST Decl node lister: prints qualified names of all filterable AST Decl
 // nodes.
 std::unique_ptr CreateASTDeclNodeLister();
diff --git a/clang/lib/Frontend/ASTConsumers.cpp 
b/clang/lib/Frontend/ASTConsumers.cpp
index a6e35452b4fbe..a5ff4d44592d4 100644
--- a/clang/lib/Frontend/ASTConsumers.cpp
+++ b/clang/lib/Frontend/ASTConsumers.cpp
@@ -41,6 +41,13 @@ namespace {
   OutputKind(K), OutputFormat(Format), FilterString(FilterString),
   DumpLookups(DumpLookups), DumpDeclTypes(DumpDeclTypes) {}
 
+ASTPrinter(raw_ostream &Out, Kind K, ASTDumpOutputFormat Format,
+   StringRef FilterString, bool DumpLookups = false,
+   bool DumpDeclTypes = false)
+: Out(Out), OwnedOut(nullptr), OutputKind(K), OutputFormat(Format),
+  FilterString(FilterString), DumpLookups(DumpLookups),
+  DumpDeclTypes(DumpDeclTypes) {}
+
 void HandleTranslationUnit(ASTContext &Context) override {
   TranslationUnitDecl *D = Context.getTranslationUnitDecl();
 
@@ -176,6 +183,19 @@ clang::CreateASTDumper(std::unique_ptr Out, 
StringRef FilterString,
   Format, FilterString, DumpLookups, DumpDeclTypes);
 }
 
+std::unique_ptr
+clang::CreateASTDumper(raw_ostream &Out, StringRef FilterString, bool 
DumpDecls,
+   bool Deserialize, bool DumpLookups, bool DumpDeclTypes,
+   ASTDumpOutputFormat Format) {
+  assert((DumpDecls || Deserialize || DumpLookups) && "nothing to dump");
+  return std::make_unique(Out,
+  Deserialize ? ASTPrinter::DumpFull
+  : DumpDecls ? ASTPrinter::Dump
+  : ASTPrinter::None,
+  Format, FilterString, DumpLookups,
+  DumpDeclTypes);
+}
+
 std::unique_ptr clang::CreateASTDeclNodeLister() {
   return std::make_unique(nullptr);
 }

>From 0ba5a4f09caeb54008594adfb3b8efa2a740e5e6 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 30 May 2025 15:46:27 +0100
Subject: [PATCH 2/6] [lldb] Add filter option to AST dump command

This patch makes the `-ast-dump-filter` Clang option available to the
`target modules dump ast` command. This allows us to selectively dump
parts of the AST by name.

The AST can quickly grow way too large to skim on the console. This will
aid in debugging AST related issues.

Example:
```
(lldb) target modules dump ast --filter func
Dumping clang ast for 48 modules.
Dumping func:
FunctionDecl 0xc4b785008 <>  func 'void (int)' 
extern
|-ParmVarDecl 0xc4b7853d8 <>  x 'int'
`-AsmLabelAttr 0xc4b785358 <> Implicit "_Z4funcIiEvT_"

Dumping func:
FunctionDecl 0xc4b7850b8 <>  func 'void (int)' 
implicit_instantiation extern
|-TemplateArgument type 'int'
| `-BuiltinType 0xc4b85b110 'int'
`-ParmVarDecl 0xc4b7853d8 <>  x 'int'
```
---
 lldb/include/lldb/Symbol/SymbolFile.h |  2 +-
 lldb/include/lldb/Symbol/SymbolFileOnDemand.h |  2 +-
 lldb/include/lldb/Symbol/TypeSystem.h |  3 ++-
 lldb/source/Commands/CommandObjectTarget.cpp  | 23 +++
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  4 ++--
 .../SymbolFile/DWARF/SymbolFileDWARF.h|  2 +-
 .../DWARF/SymbolFileDWARFDebugMap.cpp |  6 ++---
 .../DWARF/SymbolFileDWARFDebugMap.h   |  2 +-
 .../SymbolFile/NativePDB/PdbAstBuilder.cpp|  4 ++--
 .../SymbolFile/NativePDB/PdbAstBuilder.h  |  2 +-
 

  1   2   >