[Lldb-commits] [lldb] [lldb] Fix evaluating expressions without JIT in an object context (PR #145599)

2025-06-25 Thread Igor Kudrin via lldb-commits

https://github.com/igorkudrin updated 
https://github.com/llvm/llvm-project/pull/145599

>From fac89bb1b51496761b156f22dcff85cbe86bf9d2 Mon Sep 17 00:00:00 2001
From: Igor Kudrin 
Date: Mon, 23 Jun 2025 23:39:52 -0700
Subject: [PATCH 1/2] [lldb] Fix evaluating expressions without JIT in an
 object context

If a server does not support allocating memory in an inferior process or
when debugging a core file, evaluating an expression in the context of a
value object results in an error:

```
error: :43:1: use of undeclared identifier '$__lldb_class'
   43 | $__lldb_class::$__lldb_expr(void *$__lldb_arg)
  | ^
```

Such expressions require a live address to be stored in the value
object. However, `EntityResultVariable::Dematerialize()` only sets
`ret->m_live_sp` if JIT is available, even if the address points to the
process memory and no custom allocations were made. Similarly,
`EntityPersistentVariable::Dematerialize()` tries to deallocate memory
based on the same check, resulting in an error if the memory was not
previously allocated in `EntityPersistentVariable::Materialize()`.

As an unintended bonus, the patch also fixes a FIXME case in
`TestCxxChar8_t.py`.
---
 lldb/source/Expression/Materializer.cpp   |  29 ---
 .../postmortem/elf-core/expr/TestExpr.py  |  48 ++
 .../elf-core/expr/linux-x86_64.core   | Bin 0 -> 40960 bytes
 .../postmortem/elf-core/expr/linux-x86_64.out | Bin 0 -> 10816 bytes
 .../postmortem/elf-core/expr/main.cpp |  15 ++
 .../API/lang/cpp/char8_t/TestCxxChar8_t.py|   4 +-
 6 files changed, 73 insertions(+), 23 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/postmortem/elf-core/expr/TestExpr.py
 create mode 100644 
lldb/test/API/functionalities/postmortem/elf-core/expr/linux-x86_64.core
 create mode 100755 
lldb/test/API/functionalities/postmortem/elf-core/expr/linux-x86_64.out
 create mode 100644 
lldb/test/API/functionalities/postmortem/elf-core/expr/main.cpp

diff --git a/lldb/source/Expression/Materializer.cpp 
b/lldb/source/Expression/Materializer.cpp
index 79c804c6c4214..5f0dcd42289f6 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -329,22 +329,10 @@ class EntityPersistentVariable : public 
Materializer::Entity {
   return;
 }
 
-lldb::ProcessSP process_sp =
-map.GetBestExecutionContextScope()->CalculateProcess();
-if (!process_sp || !process_sp->CanJIT()) {
-  // Allocations are not persistent so persistent variables cannot stay
-  // materialized.
-
-  m_persistent_variable_sp->m_flags |=
-  ExpressionVariable::EVNeedsAllocation;
-
-  DestroyAllocation(map, err);
-  if (!err.Success())
-return;
-} else if (m_persistent_variable_sp->m_flags &
-   ExpressionVariable::EVNeedsAllocation &&
-   !(m_persistent_variable_sp->m_flags &
- ExpressionVariable::EVKeepInTarget)) {
+if (m_persistent_variable_sp->m_flags &
+ExpressionVariable::EVNeedsAllocation &&
+!(m_persistent_variable_sp->m_flags &
+  ExpressionVariable::EVKeepInTarget)) {
   DestroyAllocation(map, err);
   if (!err.Success())
 return;
@@ -1086,9 +1074,8 @@ class EntityResultVariable : public Materializer::Entity {
   m_delegate->DidDematerialize(ret);
 }
 
-bool can_persist =
-(m_is_program_reference && process_sp && process_sp->CanJIT() &&
- !(address >= frame_bottom && address < frame_top));
+bool can_persist = m_is_program_reference &&
+   !(address >= frame_bottom && address < frame_top);
 
 if (can_persist && m_keep_in_memory) {
   ret->m_live_sp = ValueObjectConstResult::Create(exe_scope, m_type, name,
@@ -1118,7 +1105,9 @@ class EntityResultVariable : public Materializer::Entity {
 map.Free(m_temporary_allocation, free_error);
   }
 } else {
-  ret->m_flags |= ExpressionVariable::EVIsLLDBAllocated;
+  ret->m_flags |= m_is_program_reference
+  ? ExpressionVariable::EVIsProgramReference
+  : ExpressionVariable::EVIsLLDBAllocated;
 }
 
 m_temporary_allocation = LLDB_INVALID_ADDRESS;
diff --git a/lldb/test/API/functionalities/postmortem/elf-core/expr/TestExpr.py 
b/lldb/test/API/functionalities/postmortem/elf-core/expr/TestExpr.py
new file mode 100644
index 0..b397359e7a476
--- /dev/null
+++ b/lldb/test/API/functionalities/postmortem/elf-core/expr/TestExpr.py
@@ -0,0 +1,48 @@
+"""
+Test evaluating expressions when debugging core file.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipIfLLVMTargetMissing("X86")
+class CoreExprTestCase(TestBase):
+def test_result_var(self):
+"""Test that the result variable can be used in subsequent 
expressions."""
+
+target = self.dbg.CreateT

[Lldb-commits] [lldb] [lldb] make PlatformAndroid/AdbClient::GetSyncService threadsafe (PR #145382)

2025-06-25 Thread Chad Smith via lldb-commits

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


[Lldb-commits] [lldb] Reland "[lldb][target] Add progress report for wait-attaching to proc… (PR #145111)

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


@@ -16,6 +16,28 @@ def setUp(self):
 self.broadcaster, lldb.SBDebugger.eBroadcastBitProgress
 )
 
+def test_wait_attach_progress_reporting(self):
+"""Test that progress reports for wait attaching work as intended."""
+target = self.dbg.CreateTarget(None)
+
+# The waiting to attach progress message will get emitted upon
+# trying to attach, but it's not going to be the event picked
+# up by checking with fetch_next_event, so go through all emitted
+# progres events and check that the waiting to attach one was emitted 
at all.
+target.AttachToProcessWithName(
+self.listener,
+"a.out",

DavidSpickett wrote:

Does this not bring back the previous problem that sometimes there will be an 
a.out process and attaching to it may get in the way of something else trying 
to debug it?

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


[Lldb-commits] [lldb] 97b8cec - [lldb][lldb-dap] Skip runInTerminalWithObjectEnv test on Windows

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

Author: David Spickett
Date: 2025-06-25T09:31:06Z
New Revision: 97b8cec789fe3b8558a6d2b7fac269c5606ab4a3

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

LOG: [lldb][lldb-dap] Skip runInTerminalWithObjectEnv test on Windows

It is failing on our Windows on Arm bot:
AssertionError: False is not true : launch failed (Unimplemented)

Given that all the others are skipped on Windows, I assume this
failure is expected too.

Added: 


Modified: 
lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py

Removed: 




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 3d07cd8b20e28..8c9468d6243c7 100644
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
@@ -73,6 +73,7 @@ def test_runInTerminal(self):
 
 self.continue_to_exit()
 
+@skipIfWindows
 @skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
 def test_runInTerminalWithObjectEnv(self):
 """



___
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] Refactor runInTerminal Tests. (PR #144954)

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

Michael137 wrote:

These tests are failing on the macOS sanitized bot bot. First failure started 
here: 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake-sanitized/1858/execution/node/89/log/

This patch is in the changelist. @da-viper mind taking a look? Or should we 
skip this on ASAN?

```
12:51:48  ==
12:51:48  FAIL: test_basic_functionality 
(TestDAP_restart_runInTerminal.TestDAP_restart_runInTerminal)
12:51:48 Test basic restarting functionality when the process is running in
12:51:48  --
12:51:48  Traceback (most recent call last):
12:51:48File 
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py",
 line 149, in wrapper
12:51:48  return func(*args, **kwargs)
12:51:48File 
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py",
 line 46, in test_basic_functionality
12:51:48  self.build_and_launch(program, runInTerminal=True)
12:51:48File 
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py",
 line 488, in build_and_launch
12:51:48  return self.launch(program, **kwargs)
12:51:48File 
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py",
 line 470, in launch
12:51:48  self.assertTrue(
12:51:48  AssertionError: False is not true : launch failed (process exited 
during launch or attach)
12:51:48  
Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/lldb-build/bin/clang
```

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


[Lldb-commits] [lldb] Default transcript dumping in "statistics dump" to false (PR #145436)

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

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

LGTM

Any chance we could add a test for the warning?

https://github.com/llvm/llvm-project/pull/145436
___
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] Refactor runInTerminal Tests. (PR #144954)

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

Michael137 wrote:

Happy to skip on ASAN (we already do that due to timeout issues in other tests)

https://github.com/llvm/llvm-project/pull/144954
___
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] Refactor runInTerminal Tests. (PR #144954)

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

Michael137 wrote:

I think ASAN just makes it more likely for things to time out

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


[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

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

https://github.com/Michael137 commented:

Is there a test-plan for DWARF64? Is there a buildbot running the test-suite 
with DWARF64 somewhere?

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


[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

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


@@ -1073,20 +1073,7 @@ const lldb_private::DWARFDataExtractor 
&DWARFUnit::GetData() const {
  : m_dwarf.GetDWARFContext().getOrLoadDebugInfoData();
 }
 
-uint32_t DWARFUnit::GetHeaderByteSize() const {
-  switch (m_header.getUnitType()) {
-  case llvm::dwarf::DW_UT_compile:
-  case llvm::dwarf::DW_UT_partial:
-return GetVersion() < 5 ? 11 : 12;
-  case llvm::dwarf::DW_UT_skeleton:
-  case llvm::dwarf::DW_UT_split_compile:
-return 20;
-  case llvm::dwarf::DW_UT_type:
-  case llvm::dwarf::DW_UT_split_type:
-return GetVersion() < 5 ? 23 : 24;
-  }
-  llvm_unreachable("invalid UnitType.");
-}
+uint32_t DWARFUnit::GetHeaderByteSize() const { return m_header.getSize(); }

DavidSpickett wrote:

This should be it's own NFC change PR.

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


[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

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


@@ -121,8 +124,12 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor 
&data,
   assert(m_unit);
   if (m_unit->GetVersion() <= 2)
 ref_addr_size = m_unit->GetAddressByteSize();
-  else
-ref_addr_size = 4;
+  else {
+if (m_unit->GetFormat() == DwarfFormat::DWARF32)
+  ref_addr_size = 4;
+else if (m_unit->GetFormat() == DwarfFormat::DWARF64)
+  ref_addr_size = 8;
+  }

Michael137 wrote:

Can't we just always use `m_unit->GetAddressByteSize`?

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


[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

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


@@ -165,26 +172,27 @@ static FormSize g_form_sizes[] = {
 {1, 1}, // 0x0b DW_FORM_data1
 {1, 1}, // 0x0c DW_FORM_flag
 {0, 0}, // 0x0d DW_FORM_sdata
-{1, 4}, // 0x0e DW_FORM_strp
+{0, 0}, // 0x0e DW_FORM_strp (4 bytes for DWARF32, 8 bytes for DWARF64)
 {0, 0}, // 0x0f DW_FORM_udata
 {0, 0}, // 0x10 DW_FORM_ref_addr (addr size for DWARF2 and earlier, 4 bytes
 // for DWARF32, 8 bytes for DWARF32 in DWARF 3 and later
-{1, 1},  // 0x11 DW_FORM_ref1
-{1, 2},  // 0x12 DW_FORM_ref2
-{1, 4},  // 0x13 DW_FORM_ref4
-{1, 8},  // 0x14 DW_FORM_ref8
-{0, 0},  // 0x15 DW_FORM_ref_udata
-{0, 0},  // 0x16 DW_FORM_indirect
-{1, 4},  // 0x17 DW_FORM_sec_offset
+{1, 1}, // 0x11 DW_FORM_ref1
+{1, 2}, // 0x12 DW_FORM_ref2
+{1, 4}, // 0x13 DW_FORM_ref4
+{1, 8}, // 0x14 DW_FORM_ref8
+{0, 0}, // 0x15 DW_FORM_ref_udata
+{0, 0}, // 0x16 DW_FORM_indirect
+{0,
+ 0}, // 0x17 DW_FORM_sec_offset (4 bytes for DWARF32, 8 bytes for DWARF64)
 {0, 0},  // 0x18 DW_FORM_exprloc
 {1, 0},  // 0x19 DW_FORM_flag_present
 {0, 0},  // 0x1a DW_FORM_strx (ULEB128)
 {0, 0},  // 0x1b DW_FORM_addrx (ULEB128)
 {1, 4},  // 0x1c DW_FORM_ref_sup4
 {0, 0},  // 0x1d DW_FORM_strp_sup (4 bytes for DWARF32, 8 bytes for 
DWARF64)
 {1, 16}, // 0x1e DW_FORM_data16
-{1, 4},  // 0x1f DW_FORM_line_strp
-{1, 8},  // 0x20 DW_FORM_ref_sig8
+{0, 0}, // 0x1f DW_FORM_line_strp (4 bytes for DWARF32, 8 bytes for 
DWARF64)
+{1, 8}, // 0x20 DW_FORM_ref_sig8

DavidSpickett wrote:

Stick to the original formatting here so the diff is a bit cleaner. If 
clang-format complains about that, just ignore it.

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


[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

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

https://github.com/DavidSpickett edited 
https://github.com/llvm/llvm-project/pull/145645
___
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] Refactor runInTerminal Tests. (PR #144954)

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

da-viper wrote:

> This patch is in the changelist. @da-viper mind taking a look? Or should we 
> skip this on ASAN?

The test most likely was not running on previous builds (because of the binary 
size check) now it get caught.

It does not look like an ASAN problem but I am running a local build ( on linux 
will take a while ) to check If I hit the same issue to rule out ASAN.

https://github.com/llvm/llvm-project/pull/144954
___
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] Refactor runInTerminal Tests. (PR #144954)

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

da-viper wrote:

> Happy to skip on ASAN (we already do that due to timeout issues in other 
> tests)

Happy with that.

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


[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

2025-06-25 Thread Hemang Gadhavi via lldb-commits


@@ -165,26 +172,27 @@ static FormSize g_form_sizes[] = {
 {1, 1}, // 0x0b DW_FORM_data1
 {1, 1}, // 0x0c DW_FORM_flag
 {0, 0}, // 0x0d DW_FORM_sdata
-{1, 4}, // 0x0e DW_FORM_strp
+{0, 0}, // 0x0e DW_FORM_strp (4 bytes for DWARF32, 8 bytes for DWARF64)
 {0, 0}, // 0x0f DW_FORM_udata
 {0, 0}, // 0x10 DW_FORM_ref_addr (addr size for DWARF2 and earlier, 4 bytes
 // for DWARF32, 8 bytes for DWARF32 in DWARF 3 and later
-{1, 1},  // 0x11 DW_FORM_ref1
-{1, 2},  // 0x12 DW_FORM_ref2
-{1, 4},  // 0x13 DW_FORM_ref4
-{1, 8},  // 0x14 DW_FORM_ref8
-{0, 0},  // 0x15 DW_FORM_ref_udata
-{0, 0},  // 0x16 DW_FORM_indirect
-{1, 4},  // 0x17 DW_FORM_sec_offset
+{1, 1}, // 0x11 DW_FORM_ref1
+{1, 2}, // 0x12 DW_FORM_ref2
+{1, 4}, // 0x13 DW_FORM_ref4
+{1, 8}, // 0x14 DW_FORM_ref8
+{0, 0}, // 0x15 DW_FORM_ref_udata
+{0, 0}, // 0x16 DW_FORM_indirect
+{0,
+ 0}, // 0x17 DW_FORM_sec_offset (4 bytes for DWARF32, 8 bytes for DWARF64)
 {0, 0},  // 0x18 DW_FORM_exprloc
 {1, 0},  // 0x19 DW_FORM_flag_present
 {0, 0},  // 0x1a DW_FORM_strx (ULEB128)
 {0, 0},  // 0x1b DW_FORM_addrx (ULEB128)
 {1, 4},  // 0x1c DW_FORM_ref_sup4
 {0, 0},  // 0x1d DW_FORM_strp_sup (4 bytes for DWARF32, 8 bytes for 
DWARF64)
 {1, 16}, // 0x1e DW_FORM_data16
-{1, 4},  // 0x1f DW_FORM_line_strp
-{1, 8},  // 0x20 DW_FORM_ref_sig8
+{0, 0}, // 0x1f DW_FORM_line_strp (4 bytes for DWARF32, 8 bytes for 
DWARF64)
+{1, 8}, // 0x20 DW_FORM_ref_sig8

HemangGadhavi wrote:

Yes exactly clang-format complaining that's why I modified. 
But yes I will change it.  

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


[Lldb-commits] [lldb] [lldb] Fix qEcho message handling. (PR #145675)

2025-06-25 Thread via lldb-commits

https://github.com/eleviant created 
https://github.com/llvm/llvm-project/pull/145675

This fixes issues found in e066f35c6981c720e3a7e5883efc40c861b3b7, which was 
later reverted. The problem was with "k" message which was sent with 
sync_on_timeout flag set to true, so lldb was waiting for response, which is 
currently not being sent by lldb-server. Not waiting for response at all seems 
to be not a solution, because on MAC OS X lldb waits for response from "k" to 
gracefully kill inferior.

>From a70386049dc93c0c495fdc285629a1a8dbeffe8c Mon Sep 17 00:00:00 2001
From: Evgeny Leviant 
Date: Wed, 25 Jun 2025 11:01:29 +0200
Subject: [PATCH] [lldb] Fix qEcho message handling.

This fixes issues found in e066f35c6981c720e3a7e5883efc40c861b3b7,
which was later reverted. The problem was with "k" message which
was sent with sync_on_timeout flag set to true, so lldb was waiting
for response, which is currently not being sent by lldb-server. Not
waiting for response at all seems to be not a solution, because on
MAC OS X lldb waits for response from "k" to gracefully kill inferior.
---
 .../Python/lldbsuite/test/gdbclientutils.py   | 10 +++
 .../gdb-remote/GDBRemoteClientBase.cpp|  9 +--
 .../Process/gdb-remote/GDBRemoteClientBase.h  |  6 +-
 .../gdb-remote/GDBRemoteCommunication.cpp |  3 +-
 .../GDBRemoteCommunicationClient.cpp  |  6 +-
 .../script_alias/TestCommandScriptAlias.py|  1 +
 .../gdb_remote_client/TestGDBRemoteClient.py  | 72 +++
 7 files changed, 98 insertions(+), 9 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py 
b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
index 753de22b9cfee..b603c35c8df09 100644
--- a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
+++ b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
@@ -92,6 +92,9 @@ class MockGDBServerResponder:
 class RESPONSE_DISCONNECT:
 pass
 
+class RESPONSE_NONE:
+pass
+
 def __init__(self):
 self.packetLog = []
 
@@ -181,6 +184,8 @@ def respond(self, packet):
 return self.qQueryGDBServer()
 if packet == "qHostInfo":
 return self.qHostInfo()
+if packet.startswith("qEcho"):
+return self.qEcho(int(packet.split(":")[1]))
 if packet == "qGetWorkingDir":
 return self.qGetWorkingDir()
 if packet == "qOffsets":
@@ -237,6 +242,9 @@ def qProcessInfo(self):
 def qHostInfo(self):
 return "ptrsize:8;endian:little;"
 
+def qEcho(self):
+return "E04"
+
 def qQueryGDBServer(self):
 return "E04"
 
@@ -655,6 +663,8 @@ def _handlePacket(self, packet):
 if not isinstance(response, list):
 response = [response]
 for part in response:
+if part is MockGDBServerResponder.RESPONSE_NONE:
+continue
 if part is MockGDBServerResponder.RESPONSE_DISCONNECT:
 raise self.TerminateConnectionException()
 self._sendPacket(part)
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
index 394b62559da76..406fa06ea011a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
@@ -180,7 +180,7 @@ bool GDBRemoteClientBase::Interrupt(std::chrono::seconds 
interrupt_timeout) {
 GDBRemoteCommunication::PacketResult
 GDBRemoteClientBase::SendPacketAndWaitForResponse(
 llvm::StringRef payload, StringExtractorGDBRemote &response,
-std::chrono::seconds interrupt_timeout) {
+std::chrono::seconds interrupt_timeout, bool sync_on_timeout) {
   Lock lock(*this, interrupt_timeout);
   if (!lock) {
 if (Log *log = GetLog(GDBRLog::Process))
@@ -191,7 +191,7 @@ GDBRemoteClientBase::SendPacketAndWaitForResponse(
 return PacketResult::ErrorSendFailed;
   }
 
-  return SendPacketAndWaitForResponseNoLock(payload, response);
+  return SendPacketAndWaitForResponseNoLock(payload, response, 
sync_on_timeout);
 }
 
 GDBRemoteCommunication::PacketResult
@@ -236,14 +236,15 @@ 
GDBRemoteClientBase::SendPacketAndReceiveResponseWithOutputSupport(
 
 GDBRemoteCommunication::PacketResult
 GDBRemoteClientBase::SendPacketAndWaitForResponseNoLock(
-llvm::StringRef payload, StringExtractorGDBRemote &response) {
+llvm::StringRef payload, StringExtractorGDBRemote &response,
+bool sync_on_timeout) {
   PacketResult packet_result = SendPacketNoLock(payload);
   if (packet_result != PacketResult::Success)
 return packet_result;
 
   const size_t max_response_retries = 3;
   for (size_t i = 0; i < max_response_retries; ++i) {
-packet_result = ReadPacket(response, GetPacketTimeout(), true);
+packet_result = ReadPacket(response, GetPacketTimeout(), sync_on_timeout);
 // Make sure we received a response
 if (packet_result != PacketResult::Success)
   return packet_result;
dif

[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

2025-06-25 Thread Hemang Gadhavi via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Extract debug server location code (PR #145706)

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

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

.. from the guts of GDBRemoteCommunication to ~top level.

This is motivated by #131519 and by the fact that's impossible to guess whether 
the author of a symlink intended it to be a "convenience shortcut" -- meaning 
it should be resolved before looking for related files; or an "implementation 
detail" -- meaning the related files should be located near the symlink itself.

This debate is particularly ridiculous when it comes to lldb-server running in 
platform mode, because it also functions as a debug server, so what we really 
just need to do is to pass /proc/self/exe in a platform-independent manner.

Moving the location logic higher up achieves that as lldb-platform (on 
non-macos) can pass `HostInfo::GetProgramFileSpec`, while liblldb can use the 
existing complex logic (which only worked on liblldb anyway as lldb-platform 
doesn't have a lldb_private::Platform instance).

Another benefit of this patch is a reduction in dependency from 
GDBRemoteCommunication to the rest of liblldb (achieved by avoiding the 
Platform dependency).

>From 7222b6d9b98ee6d1aa95b03f0bc84e1161a5a05f Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 25 Jun 2025 15:22:26 +0200
Subject: [PATCH] [lldb] Extract debug server location code

.. from the guts of GDBRemoteCommunication to ~top level.

This is motivated by #131519 and by the fact that's impossible to guess
whether the author of a symlink intended it to be a "convenience
shortcut" -- meaning it should be resolved before looking for related
files; or an "implementation detail" -- meaning the related files should
be located near the symlink itself.

This debate is particularly ridiculous when it comes to lldb-server
running in platform mode, because it also functions as a debug server,
so what we really just need to do is to pass /proc/self/exe in a
platform-independent manner.

Moving the location logic higher up achieves that as lldb-platform (on
non-macos) can pass `HostInfo::GetProgramFileSpec`, while liblldb can
use the existing complex logic (which only worked on liblldb anyway as
lldb-platform doesn't have a lldb_private::Platform instance).

Another benefit of this patch is a reduction in dependency from
GDBRemoteCommunication to the rest of liblldb (achieved by avoiding the
Platform dependency).
---
 .../gdb-remote/GDBRemoteCommunication.cpp | 77 +--
 .../gdb-remote/GDBRemoteCommunication.h   | 12 +--
 .../GDBRemoteCommunicationServerPlatform.cpp  | 22 +++---
 .../GDBRemoteCommunicationServerPlatform.h|  4 +-
 .../Process/gdb-remote/ProcessGDBRemote.cpp   | 62 ++-
 .../TestPlatformLaunchGDBServer.py| 69 +++--
 .../tools/lldb-dap/console/TestDAP_console.py |  4 +-
 lldb/tools/lldb-server/lldb-platform.cpp  | 43 +--
 8 files changed, 160 insertions(+), 133 deletions(-)

diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index bea2faff2330e..cea553e0ac9a2 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -11,7 +11,6 @@
 #include "lldb/Host/Config.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
-#include "lldb/Host/HostInfo.h"
 #include "lldb/Host/Pipe.h"
 #include "lldb/Host/ProcessLaunchInfo.h"
 #include "lldb/Host/Socket.h"
@@ -33,14 +32,6 @@
 #include 
 #include 
 
-#if defined(__APPLE__)
-#define DEBUGSERVER_BASENAME "debugserver"
-#elif defined(_WIN32)
-#define DEBUGSERVER_BASENAME "lldb-server.exe"
-#else
-#define DEBUGSERVER_BASENAME "lldb-server"
-#endif
-
 #if HAVE_LIBCOMPRESSION
 #include 
 #endif
@@ -835,77 +826,11 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t 
*src, size_t src_len,
   return GDBRemoteCommunication::PacketType::Invalid;
 }
 
-FileSpec GDBRemoteCommunication::GetDebugserverPath(Platform *platform) {
-  Log *log = GetLog(GDBRLog::Process);
-  // If we locate debugserver, keep that located version around
-  static FileSpec g_debugserver_file_spec;
-  FileSpec debugserver_file_spec;
-
-  Environment host_env = Host::GetEnvironment();
-
-  // Always check to see if we have an environment override for the path to the
-  // debugserver to use and use it if we do.
-  std::string env_debugserver_path = host_env.lookup("LLDB_DEBUGSERVER_PATH");
-  if (!env_debugserver_path.empty()) {
-debugserver_file_spec.SetFile(env_debugserver_path,
-  FileSpec::Style::native);
-LLDB_LOGF(log,
-  "GDBRemoteCommunication::%s() gdb-remote stub exe path set "
-  "from environment variable: %s",
-  __FUNCTION__, env_debugserver_path.c_str());
-  } else
-debugserver_file_spec = g_debugserver_file_spec;
-  bool debugserver_exists =
-  FileSystem::Instance().Exists(debugserver_file_spec);
-  

[Lldb-commits] [lldb] [lldb][docs] Document qWatchpointSupportInfo (PR #145709)

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

DavidSpickett wrote:

As far as I can tell this is only used as a binary to tell if we have any 
hardware breakpoints, or none. Even though the packet returns the exact number.

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


[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

2025-06-25 Thread Hemang Gadhavi via lldb-commits

HemangGadhavi wrote:


> Also wondering about testing this. What tools can produce DWARF64?
> 
@DavidSpickett answer to your question, we can produce `DWARF64` by enabling 
-`gdwarf64` clang compilation flag. But that could be different for different 
compiler 

> Run `check-lldb` with DWARF64 enabled everywhere you can. So that means 
> adding it to CMAKE_C/CXX_FLAGS for the build, to 
> `lldb/test/Shell/helper/build.py` for shell tests and somewhere to make the 
> API tests use it. Istr there is a makefile for that.

Thanks for the suggestion, I will start with the unittest by enabling the 
`DWARF64` and also try to create some testcases related to `DWARF64` as you 
mentioned which has greater offset compared to the `DWARF32`

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


[Lldb-commits] [lldb] [lldb][Mach-O] Allow "process metadata" LC_NOTE to supply registers (PR #144627)

2025-06-25 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/144627

>From 92348b28fb02901e9437b92c1ddf8cfed31c Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Tue, 17 Jun 2025 18:57:11 -0700
Subject: [PATCH 01/10] [lldb][Mach-O] Allow "process metadata" LC_NOTE to
 supply registers

The "process metadata" LC_NOTE allows for thread IDs to be specified
in a Mach-O corefile.  This extends the JSON recognzied in that
LC_NOTE to allow for additional registers to be supplied on a
per-thread basis.

The registers included in a Mach-O corefile LC_THREAD load command
can only be one of the register flavors that the kernel (xnu) defines
in  for arm64 -- the general purpose
registers, floating point registers, exception registers.

JTAG style corefile producers may have access to many additional
registers beyond these that EL0 programs typically use, for instance
TCR_EL1 on AArch64, and people developing low level code need access
to these registers.  This patch defines a format for including these
registers for any thread.

The JSON in "process metadata" is a dictionary that must have a
`threads` key.  The value is an array of entries, one per LC_THREAD
in the Mach-O corefile.  The number of entries must match the
LC_THREADs so they can be correctly associated.

Each thread's dictionary must have two keys, `sets`, and `registers`.
`sets` is an array of register set names.  If a register set name
matches one from the LC_THREAD core registers, any registers that
are defined will be added to that register set.  e.g. metadata can
add a register to the "General Purpose Registers" set that lldb
shows users.

`registers` is an array of dictionaries, one per register.  Each
register must have the keys `name`, `value`, `bitsize`, and `set`.
It may provide additional keys like `alt-name`, that
`DynamicRegisterInfo::SetRegisterInfo` recognizes.

This `sets` + `registers` formatting is the same that is used by
the `target.process.python-os-plugin-path` script interface uses,
both are parsed by `DynamicRegisterInfo`.  The one addition is that
in this LC_NOTE metadata, each register must also have a `value`
field, with the value provided in big-endian base 10, as usual with
JSON.

In RegisterContextUnifiedCore, I combine the register sets & registers
from the LC_THREAD for a specific thread, and the metadata sets &
registers for that thread from the LC_NOTE.  Even if no LC_NOTE
is present, this class ingests the LC_THREAD register contexts and
reformats it to its internal stores before returning itself as the
RegisterContex, instead of shortcutting and returning the core's
native RegisterContext.  I could have gone either way with that,
but in the end I decided if the code is correct, we should live on
it always.

I added a test where we process save-core to create a userland corefile,
then use a utility "add-lcnote" to strip the existing "process metadata"
LC_NOTE that lldb put in it, and adds a new one from a JSON string.

rdar://74358787
---
 lldb/include/lldb/Symbol/ObjectFile.h |  17 +-
 .../ObjectFile/Mach-O/ObjectFileMachO.cpp |  61 ++-
 .../ObjectFile/Mach-O/ObjectFileMachO.h   |   2 +
 .../Plugins/Process/mach-core/CMakeLists.txt  |   1 +
 .../mach-core/RegisterContextUnifiedCore.cpp  | 293 +
 .../mach-core/RegisterContextUnifiedCore.h|  57 +++
 .../Process/mach-core/ThreadMachCore.cpp  |  55 ++-
 .../lc-note/additional-registers/Makefile |  11 +
 .../TestMetadataRegisters.py  | 100 +
 .../additional-registers/add-lcnote.cpp   | 384 ++
 .../lc-note/additional-registers/main.c   |  11 +
 11 files changed, 957 insertions(+), 35 deletions(-)
 create mode 100644 
lldb/source/Plugins/Process/mach-core/RegisterContextUnifiedCore.cpp
 create mode 100644 
lldb/source/Plugins/Process/mach-core/RegisterContextUnifiedCore.h
 create mode 100644 lldb/test/API/macosx/lc-note/additional-registers/Makefile
 create mode 100644 
lldb/test/API/macosx/lc-note/additional-registers/TestMetadataRegisters.py
 create mode 100644 
lldb/test/API/macosx/lc-note/additional-registers/add-lcnote.cpp
 create mode 100644 lldb/test/API/macosx/lc-note/additional-registers/main.c

diff --git a/lldb/include/lldb/Symbol/ObjectFile.h 
b/lldb/include/lldb/Symbol/ObjectFile.h
index 43567592dd447..1b9ae1fb31a69 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -18,6 +18,7 @@
 #include "lldb/Utility/Endian.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/FileSpecList.h"
+#include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/UUID.h"
 #include "lldb/lldb-private.h"
 #include "llvm/Support/Threading.h"
@@ -544,9 +545,9 @@ class ObjectFile : public 
std::enable_shared_from_this,
 return false;
   }
 
-  /// Get metadata about threads from the corefile.
+  /// Get metadata about thread ids from the corefile.
   ///
-  /// The corefile may have metadata (e.g. a Mach-O "thread ext

[Lldb-commits] [lldb] [lldb] Extract debug server location code (PR #145706)

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

labath wrote:

@yuvald-sweet-security 

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


[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

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


@@ -121,8 +124,12 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor 
&data,
   assert(m_unit);
   if (m_unit->GetVersion() <= 2)
 ref_addr_size = m_unit->GetAddressByteSize();
-  else
-ref_addr_size = 4;
+  else {
+if (m_unit->GetFormat() == DwarfFormat::DWARF32)
+  ref_addr_size = 4;
+else if (m_unit->GetFormat() == DwarfFormat::DWARF64)
+  ref_addr_size = 8;
+  }

Michael137 wrote:

Ah yea that's the one I meant

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


[Lldb-commits] [lldb] [lldb] Extract debug server location code (PR #145706)

2025-06-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

.. from the guts of GDBRemoteCommunication to ~top level.

This is motivated by #131519 and by the fact that's impossible to guess 
whether the author of a symlink intended it to be a "convenience shortcut" -- 
meaning it should be resolved before looking for related files; or an 
"implementation detail" -- meaning the related files should be located near the 
symlink itself.

This debate is particularly ridiculous when it comes to lldb-server running in 
platform mode, because it also functions as a debug server, so what we really 
just need to do is to pass /proc/self/exe in a platform-independent manner.

Moving the location logic higher up achieves that as lldb-platform (on 
non-macos) can pass `HostInfo::GetProgramFileSpec`, while liblldb can use the 
existing complex logic (which only worked on liblldb anyway as lldb-platform 
doesn't have a lldb_private::Platform instance).

Another benefit of this patch is a reduction in dependency from 
GDBRemoteCommunication to the rest of liblldb (achieved by avoiding the 
Platform dependency).

---

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


8 Files Affected:

- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
(+1-76) 
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h 
(+4-8) 
- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp 
(+11-11) 
- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h 
(+3-1) 
- (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
(+58-4) 
- (modified) 
lldb/test/API/commands/platform/launchgdbserver/TestPlatformLaunchGDBServer.py 
(+46-23) 
- (modified) lldb/test/API/tools/lldb-dap/console/TestDAP_console.py (+2-2) 
- (modified) lldb/tools/lldb-server/lldb-platform.cpp (+35-8) 


``diff
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index bea2faff2330e..cea553e0ac9a2 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -11,7 +11,6 @@
 #include "lldb/Host/Config.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
-#include "lldb/Host/HostInfo.h"
 #include "lldb/Host/Pipe.h"
 #include "lldb/Host/ProcessLaunchInfo.h"
 #include "lldb/Host/Socket.h"
@@ -33,14 +32,6 @@
 #include 
 #include 
 
-#if defined(__APPLE__)
-#define DEBUGSERVER_BASENAME "debugserver"
-#elif defined(_WIN32)
-#define DEBUGSERVER_BASENAME "lldb-server.exe"
-#else
-#define DEBUGSERVER_BASENAME "lldb-server"
-#endif
-
 #if HAVE_LIBCOMPRESSION
 #include 
 #endif
@@ -835,77 +826,11 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t 
*src, size_t src_len,
   return GDBRemoteCommunication::PacketType::Invalid;
 }
 
-FileSpec GDBRemoteCommunication::GetDebugserverPath(Platform *platform) {
-  Log *log = GetLog(GDBRLog::Process);
-  // If we locate debugserver, keep that located version around
-  static FileSpec g_debugserver_file_spec;
-  FileSpec debugserver_file_spec;
-
-  Environment host_env = Host::GetEnvironment();
-
-  // Always check to see if we have an environment override for the path to the
-  // debugserver to use and use it if we do.
-  std::string env_debugserver_path = host_env.lookup("LLDB_DEBUGSERVER_PATH");
-  if (!env_debugserver_path.empty()) {
-debugserver_file_spec.SetFile(env_debugserver_path,
-  FileSpec::Style::native);
-LLDB_LOGF(log,
-  "GDBRemoteCommunication::%s() gdb-remote stub exe path set "
-  "from environment variable: %s",
-  __FUNCTION__, env_debugserver_path.c_str());
-  } else
-debugserver_file_spec = g_debugserver_file_spec;
-  bool debugserver_exists =
-  FileSystem::Instance().Exists(debugserver_file_spec);
-  if (!debugserver_exists) {
-// The debugserver binary is in the LLDB.framework/Resources directory.
-debugserver_file_spec = HostInfo::GetSupportExeDir();
-if (debugserver_file_spec) {
-  debugserver_file_spec.AppendPathComponent(DEBUGSERVER_BASENAME);
-  debugserver_exists = 
FileSystem::Instance().Exists(debugserver_file_spec);
-  if (debugserver_exists) {
-LLDB_LOGF(log,
-  "GDBRemoteCommunication::%s() found gdb-remote stub exe 
'%s'",
-  __FUNCTION__, debugserver_file_spec.GetPath().c_str());
-
-g_debugserver_file_spec = debugserver_file_spec;
-  } else {
-if (platform)
-  debugserver_file_spec =
-  platform->LocateExecutable(DEBUGSERVER_BASENAME);
-else
-  debugserver_file_spec.Clear();
-if (debugserver_file_spec) {
-  // Platform::LocateExecutable() wouldn't return 

[Lldb-commits] [lldb] [lldb] Make MCP server instance global (PR #145616)

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

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

>From 5ed60a3aa5022694a593e2885ad6e563df6ffa37 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 24 Jun 2025 16:22:46 -0700
Subject: [PATCH 1/2] [lldb] Make MCP server instance global

Rather than having one MCP server per debugger, make the MCP server
global and pass a debugger id along with tool invocations that require
one. This PR also adds a second tool to list the available debuggers
with their targets so the model can decide which debugger instance to
use.
---
 lldb/include/lldb/Core/Debugger.h |  6 --
 lldb/include/lldb/Core/ProtocolServer.h   |  5 +-
 lldb/include/lldb/lldb-forward.h  |  2 +-
 lldb/include/lldb/lldb-private-interfaces.h   |  3 +-
 .../Commands/CommandObjectProtocolServer.cpp  | 51 +++--
 lldb/source/Core/Debugger.cpp | 23 --
 lldb/source/Core/ProtocolServer.cpp   | 34 -
 .../Protocol/MCP/ProtocolServerMCP.cpp| 26 +++
 .../Plugins/Protocol/MCP/ProtocolServerMCP.h  |  6 +-
 lldb/source/Plugins/Protocol/MCP/Tool.cpp | 74 +++
 lldb/source/Plugins/Protocol/MCP/Tool.h   | 24 +++---
 .../Protocol/ProtocolMCPServerTest.cpp| 20 ++---
 12 files changed, 143 insertions(+), 131 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 9f82466a83417..2087ef2a11562 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -602,10 +602,6 @@ class Debugger : public 
std::enable_shared_from_this,
   void FlushProcessOutput(Process &process, bool flush_stdout,
   bool flush_stderr);
 
-  void AddProtocolServer(lldb::ProtocolServerSP protocol_server_sp);
-  void RemoveProtocolServer(lldb::ProtocolServerSP protocol_server_sp);
-  lldb::ProtocolServerSP GetProtocolServer(llvm::StringRef protocol) const;
-
   SourceManager::SourceFileCache &GetSourceFileCache() {
 return m_source_file_cache;
   }
@@ -776,8 +772,6 @@ class Debugger : public 
std::enable_shared_from_this,
   mutable std::mutex m_progress_reports_mutex;
   /// @}
 
-  llvm::SmallVector m_protocol_servers;
-
   std::mutex m_destroy_callback_mutex;
   lldb::callback_token_t m_destroy_callback_next_token = 0;
   struct DestroyCallbackInfo {
diff --git a/lldb/include/lldb/Core/ProtocolServer.h 
b/lldb/include/lldb/Core/ProtocolServer.h
index fafe460904323..937256c10aec1 100644
--- a/lldb/include/lldb/Core/ProtocolServer.h
+++ b/lldb/include/lldb/Core/ProtocolServer.h
@@ -20,8 +20,9 @@ class ProtocolServer : public PluginInterface {
   ProtocolServer() = default;
   virtual ~ProtocolServer() = default;
 
-  static lldb::ProtocolServerSP Create(llvm::StringRef name,
-   Debugger &debugger);
+  static ProtocolServer *GetOrCreate(llvm::StringRef name);
+
+  static std::vector GetSupportedProtocols();
 
   struct Connection {
 Socket::SocketProtocol protocol;
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index 558818e8e2309..2bc85a2d2afa6 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -391,7 +391,7 @@ typedef std::shared_ptr PlatformSP;
 typedef std::shared_ptr ProcessSP;
 typedef std::shared_ptr ProcessAttachInfoSP;
 typedef std::shared_ptr ProcessLaunchInfoSP;
-typedef std::shared_ptr ProtocolServerSP;
+typedef std::unique_ptr ProtocolServerUP;
 typedef std::weak_ptr ProcessWP;
 typedef std::shared_ptr RegisterCheckpointSP;
 typedef std::shared_ptr RegisterContextSP;
diff --git a/lldb/include/lldb/lldb-private-interfaces.h 
b/lldb/include/lldb/lldb-private-interfaces.h
index 34eaaa8e581e9..249b25c251ac2 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -81,8 +81,7 @@ typedef lldb::PlatformSP (*PlatformCreateInstance)(bool force,
 typedef lldb::ProcessSP (*ProcessCreateInstance)(
 lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
 const FileSpec *crash_file_path, bool can_connect);
-typedef lldb::ProtocolServerSP (*ProtocolServerCreateInstance)(
-Debugger &debugger);
+typedef lldb::ProtocolServerUP (*ProtocolServerCreateInstance)();
 typedef lldb::RegisterTypeBuilderSP (*RegisterTypeBuilderCreateInstance)(
 Target &target);
 typedef lldb::ScriptInterpreterSP (*ScriptInterpreterCreateInstance)(
diff --git a/lldb/source/Commands/CommandObjectProtocolServer.cpp 
b/lldb/source/Commands/CommandObjectProtocolServer.cpp
index 115754769f3e3..55bd42ed1a533 100644
--- a/lldb/source/Commands/CommandObjectProtocolServer.cpp
+++ b/lldb/source/Commands/CommandObjectProtocolServer.cpp
@@ -23,20 +23,6 @@ using namespace lldb_private;
 #define LLDB_OPTIONS_mcp
 #include "CommandOptions.inc"
 
-static std::vector GetSupportedProtocols() {
-  std::vector supported_protocols;
-  size_t i = 0;
-
-  for (llvm::StringRef protocol_name =
-   PluginM

[Lldb-commits] [lldb] [lldb] Make MCP server instance global (PR #145616)

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

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


[Lldb-commits] [lldb] [lldb] Add DWARFExpressionEntry and GetExpressionEntryAtAddress() to … (PR #144238)

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


@@ -58,6 +59,19 @@ class DWARFExpressionList {
   }
 
   lldb::addr_t GetFuncFileAddress() { return m_func_file_addr; }
+  
+  /// Represents an entry in the DWARFExpressionList with all needed metadata.
+  struct DWARFExpressionEntry {
+AddressRange file_range; /// Represents a DWARF location range in the 
DWARF unit’s file‐address space

adrian-prantl wrote:

Either:
```
AddressRange file_range; ///< Represents a DWARF location range in the DWARF 
unit’s file‐address space.
```
or (preferred)
```
 /// Represents a DWARF location range in the DWARF unit’s file‐address space.
 AddressRange file_range;
```

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


[Lldb-commits] [lldb] [lldb][RISCV] fix LR/SC atomic sequence handling in lldb-server (PR #127505)

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

DavidSpickett wrote:

Yeah to my surprise it's `re.search` not `re.match`. Makes sense in hindsight 
though.

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


[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

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

DavidSpickett wrote:

>Thats what I need suggestions and inputs what changes we can accommodate to 
>better support the DWARF64.

Start by looking at the main differences DWARF64 has. Write DWARF64 specific 
tests that cover those corner cases e.g. that some symbol can now be described 
as a greater size or have a greater offset, whatever it is.

I'm assuming the answer isn't "everything changes", because the changes in this 
PR are very minimal.

Run `check-lldb` with DWARF64 enabled everywhere you can. So that means adding 
it to CMAKE_C/CXX_FLAGS for the build, to `lldb/test/Shell/helper/build.py` for 
shell tests and somewhere to make the API tests use it. Istr there is a 
makefile for that.

Anything that fails there, reduce the failure down to a targeted test case that 
can be run anywhere without having to run the whole test suite with DWARF64 
enabled. So if you fail to set a breakpoint because the symbol lookup didn't 
work, reduce that to a test that constructs the DWARF64 data manually and does 
a symbol lookup.

Then we end up with DWARF64 specific tests that can run on all the existing 
buildbots.

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


[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

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

labath wrote:

Also note that there are remnants of our previous attempt at dwarf64 support 
(which was deleted many years ago) lying around the DWARFDataExtractor class. 
However, since this isn't how *llvm*'s DWARFDataExtractor works, I think we 
should not be using that (instead, we should delete it). LLVM's current 
approach is kind of similar to what you're doing actually, but instead of 
peppering the code with `if dwarf64` blocks, they have a function to return the 
correct dwarf offset size (`FormParams::getDwarfOffsetByteSize`). We should do 
something similar. We already have the FormParams object accessible from inside 
our DWARFUnit (through the m_header field), so I think it'd be best to replace 
`GetFormat` method you added with `GetFormParams`, and then the parsing code 
would do a `m_unit->GetFormParams().getDwarfOffsetByteSize`

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


[Lldb-commits] [lldb] [lldb] include `LLVMTargetParser` in `LINK_COMPONENTS` (PR #145606)

2025-06-25 Thread Charles Zablit via lldb-commits

https://github.com/charles-zablit approved this pull request.


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


[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

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


@@ -121,8 +124,12 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor 
&data,
   assert(m_unit);
   if (m_unit->GetVersion() <= 2)
 ref_addr_size = m_unit->GetAddressByteSize();
-  else
-ref_addr_size = 4;
+  else {
+if (m_unit->GetFormat() == DwarfFormat::DWARF32)
+  ref_addr_size = 4;
+else if (m_unit->GetFormat() == DwarfFormat::DWARF64)
+  ref_addr_size = 8;
+  }

labath wrote:

No, but we can use `getDwarfOffsetByteSize`. Address size (of the architecture) 
is completely orthogonal to the size of dwarf references.

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


[Lldb-commits] [lldb] [lldb] Clean up GDBRemoteCommunication::StartDebugserverProcess (PR #145021)

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


@@ -1084,55 +1052,30 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
 
   if (socket_pipe.CanWrite())
 socket_pipe.CloseWriteFileDescriptor();
-  if (socket_pipe.CanRead()) {
-// Read port from pipe with 10 second timeout.
-std::string port_str;
-while (error.Success()) {
-  char buf[10];
-  if (llvm::Expected num_bytes =
-  socket_pipe.Read(buf, std::size(buf), std::chrono::seconds(10))) 
{
-if (*num_bytes == 0)
-  break;
-port_str.append(buf, *num_bytes);
-  } else {
-error = Status::FromError(num_bytes.takeError());
-  }
-}
-if (error.Success() && (port != nullptr)) {
-  // NB: Deliberately using .c_str() to stop at embedded '\0's
-  llvm::StringRef port_ref = port_str.c_str();
-  uint16_t child_port = 0;
-  // FIXME: improve error handling
-  llvm::to_integer(port_ref, child_port);
-  if (*port == 0 || *port == child_port) {
-*port = child_port;
-LLDB_LOG(log, "debugserver listens on port {0}", *port);
-  } else {
-LLDB_LOG(log,
- "debugserver listening on port {0} but requested port was 
{1}",
- child_port, (*port));
-  }
+  assert(socket_pipe.CanRead());
+
+  // Read port from the pipe -- and ignore it (see comment above).

labath wrote:

Done.

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


[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

2025-06-25 Thread Hemang Gadhavi via lldb-commits


@@ -1073,20 +1073,7 @@ const lldb_private::DWARFDataExtractor 
&DWARFUnit::GetData() const {
  : m_dwarf.GetDWARFContext().getOrLoadDebugInfoData();
 }
 
-uint32_t DWARFUnit::GetHeaderByteSize() const {
-  switch (m_header.getUnitType()) {
-  case llvm::dwarf::DW_UT_compile:
-  case llvm::dwarf::DW_UT_partial:
-return GetVersion() < 5 ? 11 : 12;
-  case llvm::dwarf::DW_UT_skeleton:
-  case llvm::dwarf::DW_UT_split_compile:
-return 20;
-  case llvm::dwarf::DW_UT_type:
-  case llvm::dwarf::DW_UT_split_type:
-return GetVersion() < 5 ? 23 : 24;
-  }
-  llvm_unreachable("invalid UnitType.");
-}
+uint32_t DWARFUnit::GetHeaderByteSize() const { return m_header.getSize(); }

HemangGadhavi wrote:

okay sure, I will create separate PR for this changes. 
Thanks for suggestion. 

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


[Lldb-commits] [lldb] [lldb] Remove child_process_inherit argument from Pipe (PR #145516)

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

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

>From 598b2f3f89fd3b09ab40f1ca0417e7158bae3488 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Sun, 20 Oct 2024 00:18:56 +0200
Subject: [PATCH] [lldb] Remove child_process_inherit argument from Pipe

It's not necessary on posix platforms as of #126935 and it's ignored on
windows as of #138896. For both platforms, we have a better way of
inheriting FDs/HANDLEs.
---
 lldb/include/lldb/Host/PipeBase.h | 10 ++
 lldb/include/lldb/Host/posix/PipePosix.h  | 10 +++---
 lldb/include/lldb/Host/windows/PipeWindows.h  | 13 +++-
 lldb/source/Host/common/Socket.cpp|  2 +-
 .../posix/ConnectionFileDescriptorPosix.cpp   |  2 +-
 lldb/source/Host/posix/MainLoopPosix.cpp  |  2 +-
 lldb/source/Host/posix/PipePosix.cpp  | 31 +++
 .../Host/posix/ProcessLauncherPosixFork.cpp   |  3 +-
 lldb/source/Host/windows/PipeWindows.cpp  | 23 ++
 lldb/source/Interpreter/ScriptInterpreter.cpp |  2 +-
 .../gdb-remote/GDBRemoteCommunication.cpp |  8 ++---
 lldb/source/Target/Process.cpp|  2 +-
 lldb/tools/lldb-server/lldb-gdbserver.cpp |  2 +-
 lldb/unittests/Core/CommunicationTest.cpp |  3 +-
 lldb/unittests/Host/HostTest.cpp  |  3 +-
 lldb/unittests/Host/PipeTest.cpp  | 25 ++-
 lldb/unittests/Host/SocketTest.cpp|  4 +--
 .../TestingSupport/Host/PipeTestUtilities.h   |  4 +--
 18 files changed, 58 insertions(+), 91 deletions(-)

diff --git a/lldb/include/lldb/Host/PipeBase.h 
b/lldb/include/lldb/Host/PipeBase.h
index ed8df6bf1e511..6a37f3f2445b0 100644
--- a/lldb/include/lldb/Host/PipeBase.h
+++ b/lldb/include/lldb/Host/PipeBase.h
@@ -21,18 +21,14 @@ class PipeBase {
 public:
   virtual ~PipeBase();
 
-  virtual Status CreateNew(bool child_process_inherit) = 0;
-  virtual Status CreateNew(llvm::StringRef name,
-   bool child_process_inherit) = 0;
+  virtual Status CreateNew() = 0;
+  virtual Status CreateNew(llvm::StringRef name) = 0;
   virtual Status CreateWithUniqueName(llvm::StringRef prefix,
-  bool child_process_inherit,
   llvm::SmallVectorImpl &name) = 0;
 
-  virtual Status OpenAsReader(llvm::StringRef name,
-  bool child_process_inherit) = 0;
+  virtual Status OpenAsReader(llvm::StringRef name) = 0;
 
   virtual llvm::Error OpenAsWriter(llvm::StringRef name,
-   bool child_process_inherit,
const Timeout &timeout) = 0;
 
   virtual bool CanRead() const = 0;
diff --git a/lldb/include/lldb/Host/posix/PipePosix.h 
b/lldb/include/lldb/Host/posix/PipePosix.h
index effd33fba7eb0..0bec2061f3164 100644
--- a/lldb/include/lldb/Host/posix/PipePosix.h
+++ b/lldb/include/lldb/Host/posix/PipePosix.h
@@ -32,14 +32,12 @@ class PipePosix : public PipeBase {
 
   ~PipePosix() override;
 
-  Status CreateNew(bool child_process_inherit) override;
-  Status CreateNew(llvm::StringRef name, bool child_process_inherit) override;
+  Status CreateNew() override;
+  Status CreateNew(llvm::StringRef name) override;
   Status CreateWithUniqueName(llvm::StringRef prefix,
-  bool child_process_inherit,
   llvm::SmallVectorImpl &name) override;
-  Status OpenAsReader(llvm::StringRef name,
-  bool child_process_inherit) override;
-  llvm::Error OpenAsWriter(llvm::StringRef name, bool child_process_inherit,
+  Status OpenAsReader(llvm::StringRef name) override;
+  llvm::Error OpenAsWriter(llvm::StringRef name,
const Timeout &timeout) override;
 
   bool CanRead() const override;
diff --git a/lldb/include/lldb/Host/windows/PipeWindows.h 
b/lldb/include/lldb/Host/windows/PipeWindows.h
index 9cf591a2d4629..a8bd3cecb9afe 100644
--- a/lldb/include/lldb/Host/windows/PipeWindows.h
+++ b/lldb/include/lldb/Host/windows/PipeWindows.h
@@ -29,16 +29,14 @@ class PipeWindows : public PipeBase {
   ~PipeWindows() override;
 
   // Create an unnamed pipe.
-  Status CreateNew(bool child_process_inherit) override;
+  Status CreateNew() override;
 
   // Create a named pipe.
-  Status CreateNew(llvm::StringRef name, bool child_process_inherit) override;
+  Status CreateNew(llvm::StringRef name) override;
   Status CreateWithUniqueName(llvm::StringRef prefix,
-  bool child_process_inherit,
   llvm::SmallVectorImpl &name) override;
-  Status OpenAsReader(llvm::StringRef name,
-  bool child_process_inherit) override;
-  llvm::Error OpenAsWriter(llvm::StringRef name, bool child_process_inherit,
+  Status OpenAsReader(llvm::StringRef name) override;
+  llvm::Error OpenAsWriter(llvm::StringRef name,
const Timeout &timeout) override;
 
   bool CanRead() con

[Lldb-commits] [lldb] [lldb-dap] Fix flaky test (PR #145231)

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

https://github.com/da-viper approved this pull request.


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


[Lldb-commits] [lldb] [lldb] Make MCP server instance global (PR #145616)

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


@@ -72,10 +80,46 @@ LLDBCommandTool::Call(const llvm::json::Value &args) {
   return text_result;
 }
 
-std::optional LLDBCommandTool::GetSchema() const {
+std::optional CommandTool::GetSchema() const {
+  llvm::json::Object id_type{{"type", "number"}};
   llvm::json::Object str_type{{"type", "string"}};
-  llvm::json::Object properties{{"arguments", std::move(str_type)}};
+  llvm::json::Object properties{{"debugger_id", std::move(id_type)},
+{"arguments", std::move(str_type)}};
+  llvm::json::Array required{"debugger_id"};
   llvm::json::Object schema{{"type", "object"},
-{"properties", std::move(properties)}};
+{"properties", std::move(properties)},
+{"required", std::move(required)}};
   return schema;
 }
+
+llvm::Expected
+DebuggerListTool::Call(const llvm::json::Value *args) {
+  llvm::json::Path::Root root;
+
+  std::string output;
+  llvm::raw_string_ostream os(output);
+
+  const size_t num_debuggers = Debugger::GetNumDebuggers();
+  for (size_t i = 0; i < num_debuggers; ++i) {
+lldb::DebuggerSP debugger_sp = Debugger::GetDebuggerAtIndex(i);
+if (!debugger_sp)
+  continue;
+
+os << "- debugger " << i << '\n';
+
+const TargetList &target_list = debugger_sp->GetTargetList();
+const size_t num_targets = target_list.GetNumTargets();
+for (size_t j = 0; j < num_targets; ++j) {
+  lldb::TargetSP target_sp = target_list.GetTargetAtIndex(i);
+  if (!target_sp)
+continue;
+  os << "- target " << j;
+  if (Module *exe_module = target_sp->GetExecutableModulePointer())
+os << " " << exe_module->GetFileSpec().GetPath();

ashgti wrote:

Do we need a newline here?

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


[Lldb-commits] [lldb] [lldb] Make MCP server instance global (PR #145616)

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


@@ -72,10 +80,46 @@ LLDBCommandTool::Call(const llvm::json::Value &args) {
   return text_result;
 }
 
-std::optional LLDBCommandTool::GetSchema() const {
+std::optional CommandTool::GetSchema() const {
+  llvm::json::Object id_type{{"type", "number"}};
   llvm::json::Object str_type{{"type", "string"}};
-  llvm::json::Object properties{{"arguments", std::move(str_type)}};
+  llvm::json::Object properties{{"debugger_id", std::move(id_type)},
+{"arguments", std::move(str_type)}};
+  llvm::json::Array required{"debugger_id"};
   llvm::json::Object schema{{"type", "object"},
-{"properties", std::move(properties)}};
+{"properties", std::move(properties)},
+{"required", std::move(required)}};
   return schema;
 }
+
+llvm::Expected
+DebuggerListTool::Call(const llvm::json::Value *args) {
+  llvm::json::Path::Root root;
+
+  std::string output;
+  llvm::raw_string_ostream os(output);
+
+  const size_t num_debuggers = Debugger::GetNumDebuggers();
+  for (size_t i = 0; i < num_debuggers; ++i) {
+lldb::DebuggerSP debugger_sp = Debugger::GetDebuggerAtIndex(i);
+if (!debugger_sp)
+  continue;
+
+os << "- debugger " << i << '\n';

ashgti wrote:

I wonder if we should document this somehow somewhere?

It looks like in the latest version of the MCP spec there is structured output 
as well, 
https://modelcontextprotocol.io/specification/2025-06-18/server/tools#structured-content


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


[Lldb-commits] [lldb] [lldb] Make MCP server instance global (PR #145616)

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


@@ -7,20 +7,23 @@
 
//===--===//
 
 #include "Tool.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 
 using namespace lldb_private::mcp;
 using namespace llvm;
 
-struct LLDBCommandToolArguments {
+struct CommandToolArguments {

ashgti wrote:

Should we put `CommandToolArguments` and its `fromJSON` in an anonymous 
namespace?

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


[Lldb-commits] [lldb] [lldb] Make MCP server instance global (PR #145616)

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


@@ -37,20 +37,26 @@ class Tool {
   std::string m_description;
 };
 
-class LLDBCommandTool : public mcp::Tool {
+class CommandTool : public mcp::Tool {
 public:
-  LLDBCommandTool(std::string name, std::string description,
-  Debugger &debugger);
-  ~LLDBCommandTool() = default;
+  using mcp::Tool::Tool;
+  ~CommandTool() = default;
 
   virtual llvm::Expected
-  Call(const llvm::json::Value &args) override;
+  Call(const llvm::json::Value *args) override;

ashgti wrote:

Do you know why this changed from `const json::Value &` to `const json::Value 
*`? Is that to support no arguments as a `nullptr`? In lldb-dap, I use a 
`std::monostate` to mark empty arguments (see 
https://github.com/llvm/llvm-project/blob/029823a84de90e3245d20e238509e13704ea5123/lldb/tools/lldb-dap/Protocol/ProtocolBase.h#L157
 and 
https://github.com/llvm/llvm-project/blob/a76448c27de2fc110c0fe2dac9120d225aee6d39/lldb/tools/lldb-dap/Handler/RequestHandler.h#L114C1-L119C1).

I wonder if that would be helpful here, but no changes required, just trying to 
understand the change.

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


[Lldb-commits] [lldb] [lldb] Make MCP server instance global (PR #145616)

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


@@ -72,10 +80,46 @@ LLDBCommandTool::Call(const llvm::json::Value &args) {
   return text_result;
 }
 
-std::optional LLDBCommandTool::GetSchema() const {
+std::optional CommandTool::GetSchema() const {
+  llvm::json::Object id_type{{"type", "number"}};
   llvm::json::Object str_type{{"type", "string"}};
-  llvm::json::Object properties{{"arguments", std::move(str_type)}};
+  llvm::json::Object properties{{"debugger_id", std::move(id_type)},
+{"arguments", std::move(str_type)}};
+  llvm::json::Array required{"debugger_id"};
   llvm::json::Object schema{{"type", "object"},
-{"properties", std::move(properties)}};
+{"properties", std::move(properties)},
+{"required", std::move(required)}};
   return schema;
 }
+
+llvm::Expected
+DebuggerListTool::Call(const llvm::json::Value *args) {
+  llvm::json::Path::Root root;
+
+  std::string output;
+  llvm::raw_string_ostream os(output);
+
+  const size_t num_debuggers = Debugger::GetNumDebuggers();
+  for (size_t i = 0; i < num_debuggers; ++i) {
+lldb::DebuggerSP debugger_sp = Debugger::GetDebuggerAtIndex(i);
+if (!debugger_sp)
+  continue;
+
+os << "- debugger " << i << '\n';

JDevlieghere wrote:

Cool, I'll add a FIXME to use that going forward.

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


[Lldb-commits] [lldb] [lldb] Make MCP server instance global (PR #145616)

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


@@ -72,10 +80,46 @@ LLDBCommandTool::Call(const llvm::json::Value &args) {
   return text_result;
 }
 
-std::optional LLDBCommandTool::GetSchema() const {
+std::optional CommandTool::GetSchema() const {
+  llvm::json::Object id_type{{"type", "number"}};
   llvm::json::Object str_type{{"type", "string"}};
-  llvm::json::Object properties{{"arguments", std::move(str_type)}};
+  llvm::json::Object properties{{"debugger_id", std::move(id_type)},
+{"arguments", std::move(str_type)}};
+  llvm::json::Array required{"debugger_id"};
   llvm::json::Object schema{{"type", "object"},
-{"properties", std::move(properties)}};
+{"properties", std::move(properties)},
+{"required", std::move(required)}};
   return schema;
 }
+
+llvm::Expected
+DebuggerListTool::Call(const llvm::json::Value *args) {
+  llvm::json::Path::Root root;
+
+  std::string output;
+  llvm::raw_string_ostream os(output);
+
+  const size_t num_debuggers = Debugger::GetNumDebuggers();
+  for (size_t i = 0; i < num_debuggers; ++i) {
+lldb::DebuggerSP debugger_sp = Debugger::GetDebuggerAtIndex(i);
+if (!debugger_sp)
+  continue;
+
+os << "- debugger " << i << '\n';
+
+const TargetList &target_list = debugger_sp->GetTargetList();
+const size_t num_targets = target_list.GetNumTargets();
+for (size_t j = 0; j < num_targets; ++j) {
+  lldb::TargetSP target_sp = target_list.GetTargetAtIndex(i);
+  if (!target_sp)
+continue;
+  os << "- target " << j;
+  if (Module *exe_module = target_sp->GetExecutableModulePointer())
+os << " " << exe_module->GetFileSpec().GetPath();

JDevlieghere wrote:

No, this is intentional to list the executable after the target.

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


[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

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

DavidSpickett wrote:

Clang only supports DWARF64 for ELF:
```
def gdwarf64 : Flag<["-"], "gdwarf64">, Group,
  Visibility<[ClangOption, CC1Option, CC1AsOption]>,
  HelpText<"Enables DWARF64 format for ELF binaries, if debug information 
emission is enabled.">,
  MarshallingInfoFlag>;
```
So the existing Linux bots could run these tests. You can check the test 
compiler being used and see if it supports the option, that's more flexible 
than requiring it to be on Linux.

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


[Lldb-commits] [lldb] [lldb] Make MCP server instance global (PR #145616)

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


@@ -37,20 +37,26 @@ class Tool {
   std::string m_description;
 };
 
-class LLDBCommandTool : public mcp::Tool {
+class CommandTool : public mcp::Tool {
 public:
-  LLDBCommandTool(std::string name, std::string description,
-  Debugger &debugger);
-  ~LLDBCommandTool() = default;
+  using mcp::Tool::Tool;
+  ~CommandTool() = default;
 
   virtual llvm::Expected
-  Call(const llvm::json::Value &args) override;
+  Call(const llvm::json::Value *args) override;

JDevlieghere wrote:

Correct, I can use a `std::variant` with `std::monostate` if you prefer.

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


[Lldb-commits] [lldb] [lldb] Make MCP server instance global (PR #145616)

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


@@ -72,10 +80,46 @@ LLDBCommandTool::Call(const llvm::json::Value &args) {
   return text_result;
 }
 
-std::optional LLDBCommandTool::GetSchema() const {
+std::optional CommandTool::GetSchema() const {
+  llvm::json::Object id_type{{"type", "number"}};
   llvm::json::Object str_type{{"type", "string"}};
-  llvm::json::Object properties{{"arguments", std::move(str_type)}};
+  llvm::json::Object properties{{"debugger_id", std::move(id_type)},
+{"arguments", std::move(str_type)}};
+  llvm::json::Array required{"debugger_id"};
   llvm::json::Object schema{{"type", "object"},
-{"properties", std::move(properties)}};
+{"properties", std::move(properties)},
+{"required", std::move(required)}};
   return schema;
 }
+
+llvm::Expected
+DebuggerListTool::Call(const llvm::json::Value *args) {
+  llvm::json::Path::Root root;
+
+  std::string output;
+  llvm::raw_string_ostream os(output);
+
+  const size_t num_debuggers = Debugger::GetNumDebuggers();
+  for (size_t i = 0; i < num_debuggers; ++i) {
+lldb::DebuggerSP debugger_sp = Debugger::GetDebuggerAtIndex(i);
+if (!debugger_sp)
+  continue;
+
+os << "- debugger " << i << '\n';
+
+const TargetList &target_list = debugger_sp->GetTargetList();
+const size_t num_targets = target_list.GetNumTargets();
+for (size_t j = 0; j < num_targets; ++j) {
+  lldb::TargetSP target_sp = target_list.GetTargetAtIndex(i);
+  if (!target_sp)
+continue;
+  os << "- target " << j;
+  if (Module *exe_module = target_sp->GetExecutableModulePointer())
+os << " " << exe_module->GetFileSpec().GetPath();

JDevlieghere wrote:

Oh, I see what you're saying, there's a missing newline after printing the 
target (executable). 

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


[Lldb-commits] [lldb] [lldb] Fix FindProcessImpl() for iOS simulators (PR #139174)

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

JDevlieghere wrote:

> I think the PR is close to finish, except the "how to make sure hello.cpp 
> builds in Windows" question.

Does this test need to build on Windows? That test should only run on Darwin, 
so if it's properly skipped, we shouldn't even try to build the inferior. The 
Windows-conditional parts will be dead code.

Besides that this LGTM



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


[Lldb-commits] [lldb] [lldb] Fix qEcho message handling. (PR #145675)

2025-06-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (eleviant)


Changes

This fixes issues found in e066f35c6981c720e3a7e5883efc40c861b3b7, which was 
later reverted. The problem was with "k" message which was sent with 
sync_on_timeout flag set to true, so lldb was waiting for response, which is 
currently not being sent by lldb-server. Not waiting for response at all seems 
to be not a solution, because on MAC OS X lldb waits for response from "k" to 
gracefully kill inferior.

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


7 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/gdbclientutils.py (+10) 
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp 
(+5-4) 
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h 
(+4-2) 
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
(+2-1) 
- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (+4-2) 
- (modified) 
lldb/test/API/commands/command/script_alias/TestCommandScriptAlias.py (+1) 
- (modified) 
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py (+72) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py 
b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
index 753de22b9cfee..b603c35c8df09 100644
--- a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
+++ b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
@@ -92,6 +92,9 @@ class MockGDBServerResponder:
 class RESPONSE_DISCONNECT:
 pass
 
+class RESPONSE_NONE:
+pass
+
 def __init__(self):
 self.packetLog = []
 
@@ -181,6 +184,8 @@ def respond(self, packet):
 return self.qQueryGDBServer()
 if packet == "qHostInfo":
 return self.qHostInfo()
+if packet.startswith("qEcho"):
+return self.qEcho(int(packet.split(":")[1]))
 if packet == "qGetWorkingDir":
 return self.qGetWorkingDir()
 if packet == "qOffsets":
@@ -237,6 +242,9 @@ def qProcessInfo(self):
 def qHostInfo(self):
 return "ptrsize:8;endian:little;"
 
+def qEcho(self):
+return "E04"
+
 def qQueryGDBServer(self):
 return "E04"
 
@@ -655,6 +663,8 @@ def _handlePacket(self, packet):
 if not isinstance(response, list):
 response = [response]
 for part in response:
+if part is MockGDBServerResponder.RESPONSE_NONE:
+continue
 if part is MockGDBServerResponder.RESPONSE_DISCONNECT:
 raise self.TerminateConnectionException()
 self._sendPacket(part)
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
index 394b62559da76..406fa06ea011a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
@@ -180,7 +180,7 @@ bool GDBRemoteClientBase::Interrupt(std::chrono::seconds 
interrupt_timeout) {
 GDBRemoteCommunication::PacketResult
 GDBRemoteClientBase::SendPacketAndWaitForResponse(
 llvm::StringRef payload, StringExtractorGDBRemote &response,
-std::chrono::seconds interrupt_timeout) {
+std::chrono::seconds interrupt_timeout, bool sync_on_timeout) {
   Lock lock(*this, interrupt_timeout);
   if (!lock) {
 if (Log *log = GetLog(GDBRLog::Process))
@@ -191,7 +191,7 @@ GDBRemoteClientBase::SendPacketAndWaitForResponse(
 return PacketResult::ErrorSendFailed;
   }
 
-  return SendPacketAndWaitForResponseNoLock(payload, response);
+  return SendPacketAndWaitForResponseNoLock(payload, response, 
sync_on_timeout);
 }
 
 GDBRemoteCommunication::PacketResult
@@ -236,14 +236,15 @@ 
GDBRemoteClientBase::SendPacketAndReceiveResponseWithOutputSupport(
 
 GDBRemoteCommunication::PacketResult
 GDBRemoteClientBase::SendPacketAndWaitForResponseNoLock(
-llvm::StringRef payload, StringExtractorGDBRemote &response) {
+llvm::StringRef payload, StringExtractorGDBRemote &response,
+bool sync_on_timeout) {
   PacketResult packet_result = SendPacketNoLock(payload);
   if (packet_result != PacketResult::Success)
 return packet_result;
 
   const size_t max_response_retries = 3;
   for (size_t i = 0; i < max_response_retries; ++i) {
-packet_result = ReadPacket(response, GetPacketTimeout(), true);
+packet_result = ReadPacket(response, GetPacketTimeout(), sync_on_timeout);
 // Make sure we received a response
 if (packet_result != PacketResult::Success)
   return packet_result;
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
index af2abdf4da5cf..9c17a8c1de057 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
@@ -61,7 +61,8 @@ class GDBRemot

[Lldb-commits] [lldb] [lldb][docs] Document qWatchpointSupportInfo (PR #145709)

2025-06-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes



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


1 Files Affected:

- (modified) lldb/docs/resources/lldbgdbremote.md (+17) 


``diff
diff --git a/lldb/docs/resources/lldbgdbremote.md 
b/lldb/docs/resources/lldbgdbremote.md
index 162815148a18b..80c68091ecd07 100644
--- a/lldb/docs/resources/lldbgdbremote.md
+++ b/lldb/docs/resources/lldbgdbremote.md
@@ -1998,6 +1998,23 @@ threads (live system debug) / cores (JTAG) in your 
program have
 stopped and allows LLDB to display and control your program
 correctly.
 
+## qWatchpointSupportInfo
+
+Get the number of hardware watchpoints available on the remote target.
+
+```
+send packet: $qWatchpointSupportInfo:#55
+read packet: $num:4;#f9
+```
+
+`num` is the number of hardware breakpoints, it will be `0` if none are
+available.
+
+**Priority to Implement:** Low. If this packet is not supported, LLDB will 
assume
+that hardware breakpoints are supported. If that is not the case, LLDB assumes
+that the debug stub will respond with an error when asked to set a hardware
+watchpoint.
+
 ## Stop reply packet extensions
 
 This section describes some of the additional information you can

``




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


[Lldb-commits] [lldb] [lldb] Fix FindProcessImpl() for iOS simulators (PR #139174)

2025-06-25 Thread via lldb-commits

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

>From d98210b81f7b49f5384e968b1a18e00e432aaf2c Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Thu, 8 May 2025 16:21:53 -0700
Subject: [PATCH 1/7] Fix macOS FindProcessImpl()

---
 lldb/source/Host/macosx/objcxx/Host.mm | 25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index e187bf98188ae..e8a1c597eea53 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -595,7 +595,9 @@ DataExtractor data(arg_data.GetBytes(), arg_data_size,
   const llvm::Triple::ArchType triple_arch = triple.getArch();
   const bool check_for_ios_simulator =
   (triple_arch == llvm::Triple::x86 ||
-   triple_arch == llvm::Triple::x86_64);
+   triple_arch == llvm::Triple::x86_64 ||
+   triple_arch == llvm::Triple::aarch64);
+
   const char *cstr = data.GetCStr(&offset);
   if (cstr) {
 process_info.GetExecutableFile().SetFile(cstr, 
FileSpec::Style::native);
@@ -621,22 +623,25 @@ DataExtractor data(arg_data.GetBytes(), arg_data_size,
   }
 
   Environment &proc_env = process_info.GetEnvironment();
+  bool is_simulator = false;
   while ((cstr = data.GetCStr(&offset))) {
 if (cstr[0] == '\0')
   break;
 
-if (check_for_ios_simulator) {
-  if (strncmp(cstr, "SIMULATOR_UDID=", strlen("SIMULATOR_UDID=")) 
==
-  0)
-process_info.GetArchitecture().GetTriple().setOS(
-llvm::Triple::IOS);
-  else
-process_info.GetArchitecture().GetTriple().setOS(
-llvm::Triple::MacOSX);
-}
+if (check_for_ios_simulator &&
+strncmp(cstr, "SIMULATOR_UDID=", strlen("SIMULATOR_UDID=")) ==
+0)
+  is_simulator = true;
 
 proc_env.insert(cstr);
   }
+  llvm::Triple &triple = process_info.GetArchitecture().GetTriple();
+  if (is_simulator) {
+triple.setOS(llvm::Triple::IOS);
+triple.setEnvironment(llvm::Triple::Simulator);
+  } else {
+triple.setOS(llvm::Triple::MacOSX);
+  }
   return true;
 }
   }

>From 8377bc3b61fb30c003d1d188d6e8d879baea58ab Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Mon, 16 Jun 2025 11:06:47 -0700
Subject: [PATCH 2/7] Add test

---
 lldb/test/API/macosx/simulator/TestSimulatorPlatform.py | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py 
b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
index 74ba0ee6c83bb..8406ee45479fd 100644
--- a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -39,7 +39,7 @@ def check_debugserver(self, log, expected_platform, 
expected_version):
 if expected_version:
 self.assertEqual(aout_info["min_version_os_sdk"], expected_version)
 
-def run_with(self, arch, os, vers, env, expected_load_command):
+def run_with(self, arch, os, vers, env, expected_load_command, 
expected_platform=None):
 env_list = [env] if env else []
 triple = "-".join([arch, "apple", os + vers] + env_list)
 sdk = lldbutil.get_xcode_sdk(os, env)
@@ -75,6 +75,11 @@ def run_with(self, arch, os, vers, env, 
expected_load_command):
 self, "break here", lldb.SBFileSpec("hello.c")
 )
 triple_re = "-".join([arch, "apple", os + vers + ".*"] + env_list)
+if expected_platform is not None:
+# The current platform should be expected
+self.expect("platform status", patterns=[r"Platform: " + 
expected_platform])
+# Should be able to list processes on the current platform
+self.expect("platform process list", patterns=[r"\d+ matching 
processes were found on \"%s\"" % expected_platform])
 self.expect("image list -b -t", patterns=[r"a\.out " + triple_re])
 self.check_debugserver(log, os + env, vers)
 
@@ -90,6 +95,7 @@ def test_ios(self):
 vers="",
 env="simulator",
 expected_load_command="LC_BUILD_VERSION",
+expected_platform="ios-simulator",
 )
 
 @skipIfAsan

>From 2c31b44d01a7a8bc0fece27fed8162c599aa8387 Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Mon, 16 Jun 2025 15:02:56 -0700
Subject: [PATCH 3/7] Fix format

---
 .../API/macosx/simulator/TestSimulatorPlatform.py | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py 
b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
index 8406ee45479fd..44a5a942ab513 100644
--- a/lldb/test/API/macosx/simula

[Lldb-commits] [lldb] [lldb] Fix race condition in Process::WaitForProcessToStop() (PR #144919)

2025-06-25 Thread via lldb-commits

athierry-oct wrote:

Thanks for the feedback and the good discussion!

> I think I understand most of what you're saying, and I think the proposed 
> solution may solve the problem you have in mind -- but I don't think it can 
> solve the problem I have in mind (and I'm not sure which of those is OP's 
> problem :P). The race I think I see is in Process::StopForDestroyOrDetach.

The race I have in mind is the one described by @labath, ie. this one:

> We first check the process state (both of them), and if it's running, we 
> install the hijack listener (and wait on it). However if the stopped event is 
> sent (enqueued to the primary listener) before the hijack listener is 
> installed, the listener will never get anything. I don't see how fiddling 
> with thread identities can help there. Even if it does, it will only help for 
> one particular thread. OP is calling Kill from the event handling thread, but 
> I don't think we require that. If Kill is called from some other thread, I 
> think it could still run into the same bug (although the race window will 
> most likely be smaller, since the event thread will be alive and pulling 
> events from the queue).

I'm not exactly sure if it's also related to what you're describing @jimingham. 
From my (limited) understanding, it looks like a separate issue: in my case I'm 
calling `Kill()` from the same thread that's handling the stop, so nobody is 
actually handling the stop (because the thread handling the stop is blocked 
inside `Kill()`).

> The race Pavel is pointing out also seems real to me, but that should be 
> fixed at the source, rather than after the fact. Process::HijackProcessEvents 
> should check the previous "primary event listener" to see if it has any 
> events and if so they should be transferred to the Hijack Listener. We should 
> also do the same thing in RestoreProcessEvents. That way we'll never drop an 
> event when shuffling primary listeners.

I can try to submit another version of the patch doing that

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


[Lldb-commits] [lldb] [lldb] Extract debug server location code (PR #145706)

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

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

LGTM.

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


[Lldb-commits] [lldb] [lldb] Make MCP server instance global (PR #145616)

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

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


[Lldb-commits] [lldb] [lldb][docs] Document qWatchpointSupportInfo (PR #145709)

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


@@ -1998,6 +1998,23 @@ threads (live system debug) / cores (JTAG) in your 
program have
 stopped and allows LLDB to display and control your program
 correctly.
 
+## qWatchpointSupportInfo
+
+Get the number of hardware watchpoints available on the remote target.
+
+```
+send packet: $qWatchpointSupportInfo:#55
+read packet: $num:4;#f9
+```
+
+`num` is the number of hardware breakpoints, it will be `0` if none are
+available.
+
+**Priority to Implement:** Low. If this packet is not supported, LLDB will 
assume

bulbazord wrote:

Suggestion: `will assume` -> `may assume`. Although it's unlikely to change, 
this documentation could become out of date if that behavior does change in the 
future.

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


[Lldb-commits] [lldb] [lldb] Fix AppleObjCDeclVendor for classes which have no methods (PR #145452)

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


@@ -552,10 +552,9 @@ bool ClassDescriptorV2::Describe(
 } else {
   std::optional base_method_list =
   GetMethodList(process, class_ro->m_baseMethods_ptr);
-  if (!base_method_list)
-return false;
-  if (!ProcessMethodList(instance_method_func, *base_method_list))
-return false;
+  if (base_method_list)
+if (!ProcessMethodList(instance_method_func, *base_method_list))

bulbazord wrote:

```suggestion
  if (base_method_list && !ProcessMethodList(instance_method_func, 
*base_method_list))
```

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


[Lldb-commits] [lldb] e8abdfc - [lldb] Make MCP server instance global (#145616)

2025-06-25 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-06-25T13:46:33-07:00
New Revision: e8abdfc88ffed632750fe0fd7deafb577e902bd6

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

LOG: [lldb] Make MCP server instance global (#145616)

Rather than having one MCP server per debugger, make the MCP server
global and pass a debugger id along with tool invocations that require
one. This PR also adds a second tool to list the available debuggers
with their targets so the model can decide which debugger instance to
use.

Added: 


Modified: 
lldb/include/lldb/Core/Debugger.h
lldb/include/lldb/Core/ProtocolServer.h
lldb/include/lldb/lldb-forward.h
lldb/include/lldb/lldb-private-interfaces.h
lldb/source/Commands/CommandObjectProtocolServer.cpp
lldb/source/Core/Debugger.cpp
lldb/source/Core/ProtocolServer.cpp
lldb/source/Plugins/Protocol/MCP/Protocol.h
lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.cpp
lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.h
lldb/source/Plugins/Protocol/MCP/Tool.cpp
lldb/source/Plugins/Protocol/MCP/Tool.h
lldb/unittests/Protocol/ProtocolMCPServerTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 9f82466a83417..2087ef2a11562 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -602,10 +602,6 @@ class Debugger : public 
std::enable_shared_from_this,
   void FlushProcessOutput(Process &process, bool flush_stdout,
   bool flush_stderr);
 
-  void AddProtocolServer(lldb::ProtocolServerSP protocol_server_sp);
-  void RemoveProtocolServer(lldb::ProtocolServerSP protocol_server_sp);
-  lldb::ProtocolServerSP GetProtocolServer(llvm::StringRef protocol) const;
-
   SourceManager::SourceFileCache &GetSourceFileCache() {
 return m_source_file_cache;
   }
@@ -776,8 +772,6 @@ class Debugger : public 
std::enable_shared_from_this,
   mutable std::mutex m_progress_reports_mutex;
   /// @}
 
-  llvm::SmallVector m_protocol_servers;
-
   std::mutex m_destroy_callback_mutex;
   lldb::callback_token_t m_destroy_callback_next_token = 0;
   struct DestroyCallbackInfo {

diff  --git a/lldb/include/lldb/Core/ProtocolServer.h 
b/lldb/include/lldb/Core/ProtocolServer.h
index fafe460904323..937256c10aec1 100644
--- a/lldb/include/lldb/Core/ProtocolServer.h
+++ b/lldb/include/lldb/Core/ProtocolServer.h
@@ -20,8 +20,9 @@ class ProtocolServer : public PluginInterface {
   ProtocolServer() = default;
   virtual ~ProtocolServer() = default;
 
-  static lldb::ProtocolServerSP Create(llvm::StringRef name,
-   Debugger &debugger);
+  static ProtocolServer *GetOrCreate(llvm::StringRef name);
+
+  static std::vector GetSupportedProtocols();
 
   struct Connection {
 Socket::SocketProtocol protocol;

diff  --git a/lldb/include/lldb/lldb-forward.h 
b/lldb/include/lldb/lldb-forward.h
index 558818e8e2309..2bc85a2d2afa6 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -391,7 +391,7 @@ typedef std::shared_ptr PlatformSP;
 typedef std::shared_ptr ProcessSP;
 typedef std::shared_ptr ProcessAttachInfoSP;
 typedef std::shared_ptr ProcessLaunchInfoSP;
-typedef std::shared_ptr ProtocolServerSP;
+typedef std::unique_ptr ProtocolServerUP;
 typedef std::weak_ptr ProcessWP;
 typedef std::shared_ptr RegisterCheckpointSP;
 typedef std::shared_ptr RegisterContextSP;

diff  --git a/lldb/include/lldb/lldb-private-interfaces.h 
b/lldb/include/lldb/lldb-private-interfaces.h
index 34eaaa8e581e9..249b25c251ac2 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -81,8 +81,7 @@ typedef lldb::PlatformSP (*PlatformCreateInstance)(bool force,
 typedef lldb::ProcessSP (*ProcessCreateInstance)(
 lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
 const FileSpec *crash_file_path, bool can_connect);
-typedef lldb::ProtocolServerSP (*ProtocolServerCreateInstance)(
-Debugger &debugger);
+typedef lldb::ProtocolServerUP (*ProtocolServerCreateInstance)();
 typedef lldb::RegisterTypeBuilderSP (*RegisterTypeBuilderCreateInstance)(
 Target &target);
 typedef lldb::ScriptInterpreterSP (*ScriptInterpreterCreateInstance)(

diff  --git a/lldb/source/Commands/CommandObjectProtocolServer.cpp 
b/lldb/source/Commands/CommandObjectProtocolServer.cpp
index 115754769f3e3..55bd42ed1a533 100644
--- a/lldb/source/Commands/CommandObjectProtocolServer.cpp
+++ b/lldb/source/Commands/CommandObjectProtocolServer.cpp
@@ -23,20 +23,6 @@ using namespace lldb_private;
 #define LLDB_OPTIONS_mcp
 #include "CommandOptions.inc"
 
-static std::vector GetSupportedProtocols() {
-  std::vector supported_protocols;
-  size_t i = 0;
-
-  for (llvm::Stri

[Lldb-commits] [lldb] [lldb] Remove child_process_inherit argument from Pipe (PR #145516)

2025-06-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

It's not necessary on posix platforms as of #126935 and it's ignored on 
windows as of #138896. For both platforms, we have a better way of 
inheriting FDs/HANDLEs.

---

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


18 Files Affected:

- (modified) lldb/include/lldb/Host/PipeBase.h (+3-7) 
- (modified) lldb/include/lldb/Host/posix/PipePosix.h (+4-6) 
- (modified) lldb/include/lldb/Host/windows/PipeWindows.h (+5-8) 
- (modified) lldb/source/Host/common/Socket.cpp (+1-1) 
- (modified) lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp (+1-1) 
- (modified) lldb/source/Host/posix/MainLoopPosix.cpp (+1-1) 
- (modified) lldb/source/Host/posix/PipePosix.cpp (+11-20) 
- (modified) lldb/source/Host/posix/ProcessLauncherPosixFork.cpp (+1-2) 
- (modified) lldb/source/Host/windows/PipeWindows.cpp (+9-14) 
- (modified) lldb/source/Interpreter/ScriptInterpreter.cpp (+1-1) 
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
(+5-4) 
- (modified) lldb/source/Target/Process.cpp (+1-1) 
- (modified) lldb/tools/lldb-server/lldb-gdbserver.cpp (+1-1) 
- (modified) lldb/unittests/Core/CommunicationTest.cpp (+1-2) 
- (modified) lldb/unittests/Host/HostTest.cpp (+1-2) 
- (modified) lldb/unittests/Host/PipeTest.cpp (+10-15) 
- (modified) lldb/unittests/Host/SocketTest.cpp (+1-3) 
- (modified) lldb/unittests/TestingSupport/Host/PipeTestUtilities.h (+2-2) 


``diff
diff --git a/lldb/include/lldb/Host/PipeBase.h 
b/lldb/include/lldb/Host/PipeBase.h
index ed8df6bf1e511..6a37f3f2445b0 100644
--- a/lldb/include/lldb/Host/PipeBase.h
+++ b/lldb/include/lldb/Host/PipeBase.h
@@ -21,18 +21,14 @@ class PipeBase {
 public:
   virtual ~PipeBase();
 
-  virtual Status CreateNew(bool child_process_inherit) = 0;
-  virtual Status CreateNew(llvm::StringRef name,
-   bool child_process_inherit) = 0;
+  virtual Status CreateNew() = 0;
+  virtual Status CreateNew(llvm::StringRef name) = 0;
   virtual Status CreateWithUniqueName(llvm::StringRef prefix,
-  bool child_process_inherit,
   llvm::SmallVectorImpl &name) = 0;
 
-  virtual Status OpenAsReader(llvm::StringRef name,
-  bool child_process_inherit) = 0;
+  virtual Status OpenAsReader(llvm::StringRef name) = 0;
 
   virtual llvm::Error OpenAsWriter(llvm::StringRef name,
-   bool child_process_inherit,
const Timeout &timeout) = 0;
 
   virtual bool CanRead() const = 0;
diff --git a/lldb/include/lldb/Host/posix/PipePosix.h 
b/lldb/include/lldb/Host/posix/PipePosix.h
index effd33fba7eb0..0bec2061f3164 100644
--- a/lldb/include/lldb/Host/posix/PipePosix.h
+++ b/lldb/include/lldb/Host/posix/PipePosix.h
@@ -32,14 +32,12 @@ class PipePosix : public PipeBase {
 
   ~PipePosix() override;
 
-  Status CreateNew(bool child_process_inherit) override;
-  Status CreateNew(llvm::StringRef name, bool child_process_inherit) override;
+  Status CreateNew() override;
+  Status CreateNew(llvm::StringRef name) override;
   Status CreateWithUniqueName(llvm::StringRef prefix,
-  bool child_process_inherit,
   llvm::SmallVectorImpl &name) override;
-  Status OpenAsReader(llvm::StringRef name,
-  bool child_process_inherit) override;
-  llvm::Error OpenAsWriter(llvm::StringRef name, bool child_process_inherit,
+  Status OpenAsReader(llvm::StringRef name) override;
+  llvm::Error OpenAsWriter(llvm::StringRef name,
const Timeout &timeout) override;
 
   bool CanRead() const override;
diff --git a/lldb/include/lldb/Host/windows/PipeWindows.h 
b/lldb/include/lldb/Host/windows/PipeWindows.h
index 9cf591a2d4629..a8bd3cecb9afe 100644
--- a/lldb/include/lldb/Host/windows/PipeWindows.h
+++ b/lldb/include/lldb/Host/windows/PipeWindows.h
@@ -29,16 +29,14 @@ class PipeWindows : public PipeBase {
   ~PipeWindows() override;
 
   // Create an unnamed pipe.
-  Status CreateNew(bool child_process_inherit) override;
+  Status CreateNew() override;
 
   // Create a named pipe.
-  Status CreateNew(llvm::StringRef name, bool child_process_inherit) override;
+  Status CreateNew(llvm::StringRef name) override;
   Status CreateWithUniqueName(llvm::StringRef prefix,
-  bool child_process_inherit,
   llvm::SmallVectorImpl &name) override;
-  Status OpenAsReader(llvm::StringRef name,
-  bool child_process_inherit) override;
-  llvm::Error OpenAsWriter(llvm::StringRef name, bool child_process_inherit,
+  Status OpenAsReader(llvm::StringRef name) override;
+  llvm::Error OpenAsWriter(llvm::StringRef name,
const Timeout &timeout) override;
 
   bool CanRead

[Lldb-commits] [lldb] [lldb] Clean up GDBRemoteCommunication::StartDebugserverProcess (PR #145021)

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

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


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


[Lldb-commits] [lldb] [lldb] Defend against infinite recursion in GetClassDescriptor (PR #145396)

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


@@ -421,6 +422,10 @@ class AppleObjCRuntimeV2 : public AppleObjCRuntime {
 
   lldb::addr_t GetISAHashTablePointer();
 
+  using ValueObjectSet = llvm::SmallSet;

adrian-prantl wrote:

`llvm::SmallPtrSet`?

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


[Lldb-commits] [lldb] [LLDB] Update DIL to handle smart pointers; add more tests. (PR #143786)

2025-06-25 Thread via lldb-commits




cmtice wrote:

I've tried to move most of the tests around as you suggested.  I have kept the 
dil smart pointer tests separate from the existing stl tests (although I moved 
them over to the data-formattter-stl/libcxx tree).  They do test functionality 
that the existing tests don't.

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


[Lldb-commits] [lldb] [lldb] Fix evaluating expressions without JIT in an object context (PR #145599)

2025-06-25 Thread Igor Kudrin via lldb-commits


@@ -321,7 +321,8 @@ IRMemoryMap::Allocation::Allocation(lldb::addr_t 
process_alloc,
 
 lldb::addr_t IRMemoryMap::Malloc(size_t size, uint8_t alignment,
  uint32_t permissions, AllocationPolicy policy,
- bool zero_memory, Status &error) {
+ bool zero_memory, Status &error,

igorkudrin wrote:

That would mean more intrusive code changes because `used_policy` would become 
a required parameter. Maybe it would make more sense to switch to using 
`llvm::Expected<>` for this method?

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


[Lldb-commits] [lldb] [lldb] Make MCP server instance global (PR #145616)

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

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


[Lldb-commits] [lldb] [LLDB] Add SI_USER and SI_KERNEL to Linux signals (PR #144800)

2025-06-25 Thread Jacob Lalonde via lldb-commits

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


[Lldb-commits] [lldb] [lldb] make PlatformAndroid/AdbClient::GetSyncService threadsafe (PR #145382)

2025-06-25 Thread Chad Smith via lldb-commits

https://github.com/cs01 edited https://github.com/llvm/llvm-project/pull/145382
___
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-25 Thread Chelsea Cassanova via lldb-commits

chelcassanova wrote:

> I'd be alright with it going in a follow-up. That being said, it would be 
> easy to kick this can down the road. Let's figure out a way to make this 
> happen without blocking this PR.

I think that this should be addressed in a follow-up PR, mainly because I think 
changes to remove this list might end up touching other parts of the SB API. 
I'd rather that the tool land and then follow up on this as it's a larger issue.

> Yes. Alternatively, let's have our internal clients move away from these so 
> we can remove it altogether 😄

Correct me if I'm wrong but we might've already done this? Either way this is 
the smallest exception list so I think I can address this still in this patch.

> Perhaps, but all of this can be done in a follow-up (unless requested by 
> another reviewer). I don't think it's essential this change right now.

Agreed.

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 evaluating expressions without JIT in an object context (PR #145599)

2025-06-25 Thread via lldb-commits

jimingham wrote:

It isn't terribly important.  We are switching to returning expected so if you 
think that looks nicer, feel free to do that.  But otherwise, this is fine as 
it.


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


[Lldb-commits] [lldb] [lldb] Fix evaluating expressions without JIT in an object context (PR #145599)

2025-06-25 Thread Igor Kudrin via lldb-commits

igorkudrin wrote:

> But we do support scalar persistent expression results in core files 
> currently:
> 
> (lldb) expr int $my_int = 5
(lldb) expr $my_int * 2
(int) $0 = 10
> 
> and that should still work after your change. I see no reason why it 
> wouldn't, but it would be good to add some use of persistent expression 
> variables in your test as well as expression result variables to make sure.

Thank you for the test. It revealed another execution path that had to be 
fixed. I've updated the patch and added your test. Please take a look.

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


[Lldb-commits] [lldb] [lldb][NFC] remove the ResolveSDKPathFromDebugInfo method (PR #145744)

2025-06-25 Thread Charles Zablit via lldb-commits

https://github.com/charles-zablit created 
https://github.com/llvm/llvm-project/pull/145744

This patch is part of an effort to remove the `ResolveSDKPathFromDebugInfo` 
method, and more specifically the variant which takes a `Module` as argument.

This PR should be merged after https://github.com/llvm/llvm-project/pull/144913.

>From e28a9e6249077c9ffca878cbf4c933b6f4f9eab8 Mon Sep 17 00:00:00 2001
From: Charles Zablit 
Date: Thu, 19 Jun 2025 16:17:33 +0100
Subject: [PATCH 1/3] [lldb][darwin] force BuiltinHeadersInSystemModules to be
 always false

---
 lldb/include/lldb/Utility/XcodeSDK.h  | 13 -
 .../Clang/ClangExpressionParser.cpp   | 50 +--
 lldb/source/Utility/XcodeSDK.cpp  | 21 
 3 files changed, 1 insertion(+), 83 deletions(-)

diff --git a/lldb/include/lldb/Utility/XcodeSDK.h 
b/lldb/include/lldb/Utility/XcodeSDK.h
index ceb8abb8c502d..a1a0ec415b90e 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -93,19 +93,6 @@ class XcodeSDK {
   static bool SDKSupportsModules(Type type, llvm::VersionTuple version);
   static bool SDKSupportsModules(Type desired_type, const FileSpec &sdk_path);
 
-  /// Returns true if the SDK for the specified triple supports
-  /// builtin modules in system headers.
-  ///
-  /// NOTE: should be kept in sync with sdkSupportsBuiltinModules in
-  /// Toolchains/Darwin.cpp
-  ///
-  /// FIXME: this function will be removed once LLDB's ClangExpressionParser
-  /// constructs the compiler instance through the driver/toolchain. See \ref
-  /// SetupImportStdModuleLangOpts
-  ///
-  static bool SDKSupportsBuiltinModules(const llvm::Triple &target_triple,
-llvm::VersionTuple sdk_version);
-
   /// Return the canonical SDK name, such as "macosx" for the macOS SDK.
   static std::string GetCanonicalName(Info info);
   /// Return the best-matching SDK type for a specific triple.
diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 7aa9cae5a5614..3caf30c5822a2 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -319,49 +319,6 @@ class ClangDiagnosticManagerAdapter : public 
clang::DiagnosticConsumer {
   StringRef m_filename;
 };
 
-/// Returns true if the SDK for the specified triple supports
-/// builtin modules in system headers. This is used to decide
-/// whether to pass -fbuiltin-headers-in-system-modules to
-/// the compiler instance when compiling the `std` module.
-static llvm::Expected
-sdkSupportsBuiltinModules(lldb_private::Target &target) {
-  auto arch_spec = target.GetArchitecture();
-  auto const &triple = arch_spec.GetTriple();
-  auto module_sp = target.GetExecutableModule();
-  if (!module_sp)
-return llvm::createStringError("Executable module not found.");
-
-  // Get SDK path that the target was compiled against.
-  auto platform_sp = target.GetPlatform();
-  if (!platform_sp)
-return llvm::createStringError("No Platform plugin found on target.");
-
-  auto sdk_or_err = platform_sp->GetSDKPathFromDebugInfo(*module_sp);
-  if (!sdk_or_err)
-return sdk_or_err.takeError();
-
-  // Use the SDK path from debug-info to find a local matching SDK directory.
-  auto sdk_path_or_err =
-  HostInfo::GetSDKRoot(HostInfo::SDKOptions{std::move(sdk_or_err->first)});
-  if (!sdk_path_or_err)
-return sdk_path_or_err.takeError();
-
-  auto VFS = FileSystem::Instance().GetVirtualFileSystem();
-  if (!VFS)
-return llvm::createStringError("No virtual filesystem available.");
-
-  // Extract SDK version from the /path/to/some.sdk/SDKSettings.json
-  auto parsed_or_err = clang::parseDarwinSDKInfo(*VFS, *sdk_path_or_err);
-  if (!parsed_or_err)
-return parsed_or_err.takeError();
-
-  auto maybe_sdk = *parsed_or_err;
-  if (!maybe_sdk)
-return llvm::createStringError("Couldn't find Darwin SDK info.");
-
-  return XcodeSDK::SDKSupportsBuiltinModules(triple, maybe_sdk->getVersion());
-}
-
 static void SetupModuleHeaderPaths(CompilerInstance *compiler,
std::vector 
include_directories,
lldb::TargetSP target_sp) {
@@ -723,12 +680,7 @@ static void SetupImportStdModuleLangOpts(CompilerInstance 
&compiler,
   lang_opts.GNUKeywords = true;
   lang_opts.CPlusPlus11 = true;
 
-  if (auto supported_or_err = sdkSupportsBuiltinModules(target))
-lang_opts.BuiltinHeadersInSystemModules = !*supported_or_err;
-  else
-LLDB_LOG_ERROR(log, supported_or_err.takeError(),
-   "Failed to determine BuiltinHeadersInSystemModules when "
-   "setting up import-std-module: {0}");
+  lang_opts.BuiltinHeadersInSystemModules = false;
 
   // The Darwin libc expects this macro to be set.
   lang_opts.GNUCVersion = 40201;
diff --g

[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

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

JDevlieghere wrote:

+1 on testing and Pavel's suggestion to use assembly/yaml for it so it can run 
everywhere.

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


[Lldb-commits] [lldb] [lldb][docs] Document qWatchpointSupportInfo (PR #145709)

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

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

None

>From f6411a087299e570db9ef4a460c2ed2048160c39 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 25 Jun 2025 14:12:37 +
Subject: [PATCH] [lldb][docs] Document qWatchpointSupportInfo

---
 lldb/docs/resources/lldbgdbremote.md | 17 +
 1 file changed, 17 insertions(+)

diff --git a/lldb/docs/resources/lldbgdbremote.md 
b/lldb/docs/resources/lldbgdbremote.md
index 162815148a18b..80c68091ecd07 100644
--- a/lldb/docs/resources/lldbgdbremote.md
+++ b/lldb/docs/resources/lldbgdbremote.md
@@ -1998,6 +1998,23 @@ threads (live system debug) / cores (JTAG) in your 
program have
 stopped and allows LLDB to display and control your program
 correctly.
 
+## qWatchpointSupportInfo
+
+Get the number of hardware watchpoints available on the remote target.
+
+```
+send packet: $qWatchpointSupportInfo:#55
+read packet: $num:4;#f9
+```
+
+`num` is the number of hardware breakpoints, it will be `0` if none are
+available.
+
+**Priority to Implement:** Low. If this packet is not supported, LLDB will 
assume
+that hardware breakpoints are supported. If that is not the case, LLDB assumes
+that the debug stub will respond with an error when asked to set a hardware
+watchpoint.
+
 ## Stop reply packet extensions
 
 This section describes some of the additional information you can

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


[Lldb-commits] [lldb] Default transcript dumping in "statistics dump" to false (PR #145436)

2025-06-25 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r HEAD~1...HEAD 
lldb/test/API/commands/statistics/basic/TestStats.py
``





View the diff from darker here.


``diff
--- TestStats.py2025-06-25 18:44:14.00 +
+++ TestStats.py2025-06-25 18:46:07.314101 +
@@ -855,24 +855,24 @@
 transcript saving is disabled.
 """
 self.build()
 exe = self.getBuildArtifact("a.out")
 target = self.createTestTarget(file_path=exe)
-
+
 # Ensure transcript saving is disabled (this is the default)
 self.runCmd("settings set interpreter.save-transcript false")
-
+
 # Request transcript in statistics dump and check for warning
 interpreter = self.dbg.GetCommandInterpreter()
 res = lldb.SBCommandReturnObject()
 interpreter.HandleCommand("statistics dump --transcript=true", res)
 self.assertTrue(res.Succeeded())
 # We should warn about transcript being requested but not saved
 self.assertIn(
 "transcript requested but none was saved. Enable with "
 "'settings set interpreter.save-transcript true'",
-res.GetError()
+res.GetError(),
 )
 
 def verify_stats(self, stats, expectation, options):
 for field_name in expectation:
 idx = field_name.find(".")

``




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


[Lldb-commits] [lldb] [lldb] Add DWARFExpressionEntry and GetExpressionEntryAtAddress() to … (PR #144238)

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


@@ -53,6 +54,29 @@ bool DWARFExpressionList::ContainsAddress(lldb::addr_t 
func_load_addr,
   return GetExpressionAtAddress(func_load_addr, addr) != nullptr;
 }
 
+llvm::Expected
+DWARFExpressionList::GetExpressionEntryAtAddress(lldb::addr_t func_load_addr,
+lldb::addr_t load_addr) const {
+  if (const DWARFExpression *always = GetAlwaysValidExpr()) {
+AddressRange full_range(m_func_file_addr, /*size=*/LLDB_INVALID_ADDRESS);
+return DWARFExpressionEntry{full_range, always};
+  }
+
+  if (func_load_addr == LLDB_INVALID_ADDRESS)
+func_load_addr = m_func_file_addr;
+  lldb::addr_t file_pc = load_addr - func_load_addr + m_func_file_addr;
+
+  uint32_t idx = m_exprs.FindEntryIndexThatContains(file_pc);

adrian-prantl wrote:

why not use
```
  const Entry *FindEntryThatContains(B addr) const {
```?

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


[Lldb-commits] [lldb] [lldb] include `LLVMTargetParser` in `LINK_COMPONENTS` (PR #145606)

2025-06-25 Thread Charles Zablit via lldb-commits

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


[Lldb-commits] [lldb] 369cbcc - [lldb] include `LLVMTargetParser` in `LINK_COMPONENTS` (#145606)

2025-06-25 Thread via lldb-commits

Author: Andrew Rogers
Date: 2025-06-25T19:30:50+01:00
New Revision: 369cbcc1a21ab07ea6ca142a3b87c75d0a1b2014

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

LOG: [lldb] include `LLVMTargetParser` in `LINK_COMPONENTS` (#145606)

## Purpose
Fix duplicate symbol definition errors when building LLDB `HostTests`
against a LLVM Windows DLL.

## Background 
When building LLDB `HostTests` against LLVM built as a Windows DLL,
compilation fails due to multiple duplicate symbol definition errors.
This is because symbols are both exported by the LLVM Windows DLL and
the `LLVMTargetParser` library.

## Overview
The issue is resolved by adding `LLVMTargetParser` (e.g. `TargetParser`)
to `LINK_COMPONENTS`, which adds it to `LLVM_LINK_COMPONENTS`, rather
than `LINK_LIBS`, which links directly against the library. This change
makes it behave correctly when linking against a static or dynamic LLVM.

Added: 


Modified: 
lldb/unittests/Host/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/Host/CMakeLists.txt 
b/lldb/unittests/Host/CMakeLists.txt
index 3b20f1d723d18..5591edda38aca 100644
--- a/lldb/unittests/Host/CMakeLists.txt
+++ b/lldb/unittests/Host/CMakeLists.txt
@@ -37,7 +37,9 @@ add_lldb_unittest(HostTests
 lldbUtilityHelpers
 lldbHostHelpers
 LLVMTestingSupport
-LLVMTargetParser
+
+  LINK_COMPONENTS
+TargetParser
   )
 
 add_subdirectory(common)



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


[Lldb-commits] [lldb] [lldb][DWARF64] Enable support for DWARF64 format handling (PR #145645)

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

https://github.com/DavidSpickett commented:

Also wondering about testing this. What tools can produce DWARF64?

Have you ran `check-lldb` with DWARF64 enabled and what results did you get?

I doubt anyone has spare capacity to add a whole new bot for this, but perhaps 
we would be ok with a few new tests that force DWARF64. Covering the main 
differences. 

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


[Lldb-commits] [lldb] [lldb] make PlatformAndroid/AdbClient::GetSyncService threadsafe (PR #145382)

2025-06-25 Thread Chad Smith via lldb-commits

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


[Lldb-commits] [lldb] Default transcript dumping in "statistics dump" to false (PR #145436)

2025-06-25 Thread via lldb-commits

https://github.com/qxy11 updated 
https://github.com/llvm/llvm-project/pull/145436

>From 1323a237d4cbe554e7f373316a041ca172168afe Mon Sep 17 00:00:00 2001
From: Janet Yang 
Date: Mon, 23 Jun 2025 14:25:12 -0700
Subject: [PATCH 1/4] Disable "transcript" in "statistics dump" by default

---
 lldb/include/lldb/Target/Statistics.h |  2 +-
 .../commands/statistics/basic/TestStats.py| 37 ++-
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index 42f03798c219e..676f3a4a118be 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -195,7 +195,7 @@ struct StatisticsOptions {
   return m_include_transcript.value();
 // `m_include_transcript` has no value set, so return a value based on
 // `m_summary_only`.
-return !GetSummaryOnly();
+return false;
   }
 
   void SetIncludePlugins(bool value) { m_include_plugins = value; }
diff --git a/lldb/test/API/commands/statistics/basic/TestStats.py 
b/lldb/test/API/commands/statistics/basic/TestStats.py
index 5281bde4c6479..890ceb1f5fd57 100644
--- a/lldb/test/API/commands/statistics/basic/TestStats.py
+++ b/lldb/test/API/commands/statistics/basic/TestStats.py
@@ -892,7 +892,7 @@ def get_test_cases_for_sections_existence(self):
 "targets.frameVariable": True,
 "targets.totalSharedLibraryEventHitCount": True,
 "modules": True,
-"transcript": True,
+"transcript": False,
 },
 },
 {  # Summary mode
@@ -979,6 +979,24 @@ def get_test_cases_for_sections_existence(self):
 "transcript": False,
 },
 },
+{  # Default mode without modules and with transcript
+"command_options": " --modules=false --transcript=true",
+"api_options": {
+"SetIncludeModules": False,
+"SetIncludeTranscript": True,
+},
+"expect": {
+"commands": True,
+"targets": True,
+"targets.moduleIdentifiers": False,
+"targets.breakpoints": True,
+"targets.expressionEvaluation": True,
+"targets.frameVariable": True,
+"targets.totalSharedLibraryEventHitCount": True,
+"modules": False,
+"transcript": True,
+},
+},
 {  # Default mode without modules
 "command_options": " --modules=false",
 "api_options": {
@@ -993,6 +1011,23 @@ def get_test_cases_for_sections_existence(self):
 "targets.frameVariable": True,
 "targets.totalSharedLibraryEventHitCount": True,
 "modules": False,
+"transcript": False,
+},
+},
+{  # Default mode with transcript
+"command_options": " --transcript=true",
+"api_options": {
+"SetIncludeTranscript": True,
+},
+"expect": {
+"commands": True,
+"targets": True,
+"targets.moduleIdentifiers": True,
+"targets.breakpoints": True,
+"targets.expressionEvaluation": True,
+"targets.frameVariable": True,
+"targets.totalSharedLibraryEventHitCount": True,
+"modules": True,
 "transcript": True,
 },
 },

>From e6fa7b17ce96bf520598d752ea00c5c9cdfb41e5 Mon Sep 17 00:00:00 2001
From: Janet Yang 
Date: Mon, 23 Jun 2025 15:46:42 -0700
Subject: [PATCH 2/4] Update some comments

---
 lldb/include/lldb/API/SBStatisticsOptions.h |  3 +--
 lldb/include/lldb/Target/Statistics.h   |  3 +--
 lldb/source/Commands/Options.td | 16 +---
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/lldb/include/lldb/API/SBStatisticsOptions.h 
b/lldb/include/lldb/API/SBStatisticsOptions.h
index 74bea03eff9c9..bfff9dc926432 100644
--- a/lldb/include/lldb/API/SBStatisticsOptions.h
+++ b/lldb/include/lldb/API/SBStatisticsOptions.h
@@ -57,8 +57,7 @@ class LLDB_API SBStatisticsOptions {
   /// a JSON array with all commands the user and/or scripts executed during a
   /// debug session.
   ///
-  /// Defaults to true, unless the `SummaryOnly` mode is enabled, in which case
-  /// this is turned off unless specified.
+  /// Defaults to false.
   void SetIncludeTranscript(bool b);
   bool GetIncludeTranscript() const;
 
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index 676f3a4a118be..68194cf216a1a 100644
--- a/lldb/include/lldb/Target/

[Lldb-commits] [lldb] [lldb][NFC] remove the ResolveSDKPathFromDebugInfo method (PR #145744)

2025-06-25 Thread Charles Zablit via lldb-commits

https://github.com/charles-zablit updated 
https://github.com/llvm/llvm-project/pull/145744

>From e28a9e6249077c9ffca878cbf4c933b6f4f9eab8 Mon Sep 17 00:00:00 2001
From: Charles Zablit 
Date: Thu, 19 Jun 2025 16:17:33 +0100
Subject: [PATCH 1/5] [lldb][darwin] force BuiltinHeadersInSystemModules to be
 always false

---
 lldb/include/lldb/Utility/XcodeSDK.h  | 13 -
 .../Clang/ClangExpressionParser.cpp   | 50 +--
 lldb/source/Utility/XcodeSDK.cpp  | 21 
 3 files changed, 1 insertion(+), 83 deletions(-)

diff --git a/lldb/include/lldb/Utility/XcodeSDK.h 
b/lldb/include/lldb/Utility/XcodeSDK.h
index ceb8abb8c502d..a1a0ec415b90e 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -93,19 +93,6 @@ class XcodeSDK {
   static bool SDKSupportsModules(Type type, llvm::VersionTuple version);
   static bool SDKSupportsModules(Type desired_type, const FileSpec &sdk_path);
 
-  /// Returns true if the SDK for the specified triple supports
-  /// builtin modules in system headers.
-  ///
-  /// NOTE: should be kept in sync with sdkSupportsBuiltinModules in
-  /// Toolchains/Darwin.cpp
-  ///
-  /// FIXME: this function will be removed once LLDB's ClangExpressionParser
-  /// constructs the compiler instance through the driver/toolchain. See \ref
-  /// SetupImportStdModuleLangOpts
-  ///
-  static bool SDKSupportsBuiltinModules(const llvm::Triple &target_triple,
-llvm::VersionTuple sdk_version);
-
   /// Return the canonical SDK name, such as "macosx" for the macOS SDK.
   static std::string GetCanonicalName(Info info);
   /// Return the best-matching SDK type for a specific triple.
diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 7aa9cae5a5614..3caf30c5822a2 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -319,49 +319,6 @@ class ClangDiagnosticManagerAdapter : public 
clang::DiagnosticConsumer {
   StringRef m_filename;
 };
 
-/// Returns true if the SDK for the specified triple supports
-/// builtin modules in system headers. This is used to decide
-/// whether to pass -fbuiltin-headers-in-system-modules to
-/// the compiler instance when compiling the `std` module.
-static llvm::Expected
-sdkSupportsBuiltinModules(lldb_private::Target &target) {
-  auto arch_spec = target.GetArchitecture();
-  auto const &triple = arch_spec.GetTriple();
-  auto module_sp = target.GetExecutableModule();
-  if (!module_sp)
-return llvm::createStringError("Executable module not found.");
-
-  // Get SDK path that the target was compiled against.
-  auto platform_sp = target.GetPlatform();
-  if (!platform_sp)
-return llvm::createStringError("No Platform plugin found on target.");
-
-  auto sdk_or_err = platform_sp->GetSDKPathFromDebugInfo(*module_sp);
-  if (!sdk_or_err)
-return sdk_or_err.takeError();
-
-  // Use the SDK path from debug-info to find a local matching SDK directory.
-  auto sdk_path_or_err =
-  HostInfo::GetSDKRoot(HostInfo::SDKOptions{std::move(sdk_or_err->first)});
-  if (!sdk_path_or_err)
-return sdk_path_or_err.takeError();
-
-  auto VFS = FileSystem::Instance().GetVirtualFileSystem();
-  if (!VFS)
-return llvm::createStringError("No virtual filesystem available.");
-
-  // Extract SDK version from the /path/to/some.sdk/SDKSettings.json
-  auto parsed_or_err = clang::parseDarwinSDKInfo(*VFS, *sdk_path_or_err);
-  if (!parsed_or_err)
-return parsed_or_err.takeError();
-
-  auto maybe_sdk = *parsed_or_err;
-  if (!maybe_sdk)
-return llvm::createStringError("Couldn't find Darwin SDK info.");
-
-  return XcodeSDK::SDKSupportsBuiltinModules(triple, maybe_sdk->getVersion());
-}
-
 static void SetupModuleHeaderPaths(CompilerInstance *compiler,
std::vector 
include_directories,
lldb::TargetSP target_sp) {
@@ -723,12 +680,7 @@ static void SetupImportStdModuleLangOpts(CompilerInstance 
&compiler,
   lang_opts.GNUKeywords = true;
   lang_opts.CPlusPlus11 = true;
 
-  if (auto supported_or_err = sdkSupportsBuiltinModules(target))
-lang_opts.BuiltinHeadersInSystemModules = !*supported_or_err;
-  else
-LLDB_LOG_ERROR(log, supported_or_err.takeError(),
-   "Failed to determine BuiltinHeadersInSystemModules when "
-   "setting up import-std-module: {0}");
+  lang_opts.BuiltinHeadersInSystemModules = false;
 
   // The Darwin libc expects this macro to be set.
   lang_opts.GNUCVersion = 40201;
diff --git a/lldb/source/Utility/XcodeSDK.cpp b/lldb/source/Utility/XcodeSDK.cpp
index 004b4717e315b..eb2047e67c326 100644
--- a/lldb/source/Utility/XcodeSDK.cpp
+++ b/lldb/source/Utility/XcodeSDK.cpp
@@ -266,27 +266,6 @@ bool XcodeSDK::SupportsS

[Lldb-commits] [lldb] [lldb][NFC] remove the ResolveSDKPathFromDebugInfo method (PR #145744)

2025-06-25 Thread Charles Zablit via lldb-commits


@@ -1130,14 +1130,33 @@ void 
PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
 
   if (target) {
 if (ModuleSP exe_module_sp = target->GetExecutableModule()) {
-  auto path_or_err = ResolveSDKPathFromDebugInfo(*exe_module_sp);
-  if (path_or_err) {
-sysroot_spec = FileSpec(*path_or_err);
+  SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
+  if (!sym_file)
+return;
+
+  XcodeSDK merged_sdk;
+  for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i) {
+if (auto cu_sp = sym_file->GetCompileUnitAtIndex(i)) {
+  auto cu_sdk = sym_file->ParseXcodeSDK(*cu_sp);
+  merged_sdk.Merge(cu_sdk);
+}
+  }
+
+  if (FileSystem::Instance().Exists(merged_sdk.GetSysroot())) {
+sysroot_spec = merged_sdk.GetSysroot();
   } else {
-LLDB_LOG_ERROR(GetLog(LLDBLog::Types | LLDBLog::Host),
-   path_or_err.takeError(),
-   "Failed to resolve SDK path: {0}");
+auto path_or_err =
+HostInfo::GetSDKRoot(HostInfo::SDKOptions{merged_sdk});
+if (path_or_err) {
+  sysroot_spec = FileSpec(*path_or_err);
+} else {
+  LLDB_LOG_ERROR(GetLog(LLDBLog::Types | LLDBLog::Host),
+ path_or_err.takeError(),
+ "Failed to resolve SDK path: {0}");
+}
   }
+  // getSDKfortriple()

charles-zablit wrote:

Initially, I did not intend to leave this here. I have now added the `TODO` 
comment you suggested.

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


[Lldb-commits] [lldb] [lldb] include `LLVMTargetParser` in `LINK_COMPONENTS` (PR #145606)

2025-06-25 Thread Charles Zablit via lldb-commits

charles-zablit wrote:

@andrurogerz do you need us to merge this for you?

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


[Lldb-commits] [lldb] [lldb] Fix evaluating expressions without JIT in an object context (PR #145599)

2025-06-25 Thread via lldb-commits


@@ -321,7 +321,8 @@ IRMemoryMap::Allocation::Allocation(lldb::addr_t 
process_alloc,
 
 lldb::addr_t IRMemoryMap::Malloc(size_t size, uint8_t alignment,
  uint32_t permissions, AllocationPolicy policy,
- bool zero_memory, Status &error) {
+ bool zero_memory, Status &error,

jimingham wrote:

Can you put error last here?  We generally put the error return last among the 
out parameters.

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


[Lldb-commits] [lldb] [lldb] Fix evaluating expressions without JIT in an object context (PR #145599)

2025-06-25 Thread via lldb-commits

jimingham wrote:

That seems like a sensible strategy.

I made one trivial comment about the ordering of parameters, but otherwise this 
LGTM.

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


[Lldb-commits] [lldb] 487581b - [lldb][darwin] force BuiltinHeadersInSystemModules to be always false (#144913)

2025-06-25 Thread via lldb-commits

Author: Charles Zablit
Date: 2025-06-25T11:18:07-07:00
New Revision: 487581b826a5339410aaf306eafedc7b806b25e3

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

LOG: [lldb][darwin] force BuiltinHeadersInSystemModules to be always false 
(#144913)

`SDKSupportsBuiltinModules` always returns true on newer versions of
Darwin based OS. The only way for this call to return `false` would be
to have a version mismatch between lldb and the SDK (recent lldb
manually installed on macOS 14 for instance).

This patch removes this check and hardcodes the value of
`BuiltinHeadersInSystemModules` to `false`.

Added: 


Modified: 
lldb/include/lldb/Utility/XcodeSDK.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Utility/XcodeSDK.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/XcodeSDK.h 
b/lldb/include/lldb/Utility/XcodeSDK.h
index ceb8abb8c502d..a1a0ec415b90e 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -93,19 +93,6 @@ class XcodeSDK {
   static bool SDKSupportsModules(Type type, llvm::VersionTuple version);
   static bool SDKSupportsModules(Type desired_type, const FileSpec &sdk_path);
 
-  /// Returns true if the SDK for the specified triple supports
-  /// builtin modules in system headers.
-  ///
-  /// NOTE: should be kept in sync with sdkSupportsBuiltinModules in
-  /// Toolchains/Darwin.cpp
-  ///
-  /// FIXME: this function will be removed once LLDB's ClangExpressionParser
-  /// constructs the compiler instance through the driver/toolchain. See \ref
-  /// SetupImportStdModuleLangOpts
-  ///
-  static bool SDKSupportsBuiltinModules(const llvm::Triple &target_triple,
-llvm::VersionTuple sdk_version);
-
   /// Return the canonical SDK name, such as "macosx" for the macOS SDK.
   static std::string GetCanonicalName(Info info);
   /// Return the best-matching SDK type for a specific triple.

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 7aa9cae5a5614..ffc76e6e93498 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -319,49 +319,6 @@ class ClangDiagnosticManagerAdapter : public 
clang::DiagnosticConsumer {
   StringRef m_filename;
 };
 
-/// Returns true if the SDK for the specified triple supports
-/// builtin modules in system headers. This is used to decide
-/// whether to pass -fbuiltin-headers-in-system-modules to
-/// the compiler instance when compiling the `std` module.
-static llvm::Expected
-sdkSupportsBuiltinModules(lldb_private::Target &target) {
-  auto arch_spec = target.GetArchitecture();
-  auto const &triple = arch_spec.GetTriple();
-  auto module_sp = target.GetExecutableModule();
-  if (!module_sp)
-return llvm::createStringError("Executable module not found.");
-
-  // Get SDK path that the target was compiled against.
-  auto platform_sp = target.GetPlatform();
-  if (!platform_sp)
-return llvm::createStringError("No Platform plugin found on target.");
-
-  auto sdk_or_err = platform_sp->GetSDKPathFromDebugInfo(*module_sp);
-  if (!sdk_or_err)
-return sdk_or_err.takeError();
-
-  // Use the SDK path from debug-info to find a local matching SDK directory.
-  auto sdk_path_or_err =
-  HostInfo::GetSDKRoot(HostInfo::SDKOptions{std::move(sdk_or_err->first)});
-  if (!sdk_path_or_err)
-return sdk_path_or_err.takeError();
-
-  auto VFS = FileSystem::Instance().GetVirtualFileSystem();
-  if (!VFS)
-return llvm::createStringError("No virtual filesystem available.");
-
-  // Extract SDK version from the /path/to/some.sdk/SDKSettings.json
-  auto parsed_or_err = clang::parseDarwinSDKInfo(*VFS, *sdk_path_or_err);
-  if (!parsed_or_err)
-return parsed_or_err.takeError();
-
-  auto maybe_sdk = *parsed_or_err;
-  if (!maybe_sdk)
-return llvm::createStringError("Couldn't find Darwin SDK info.");
-
-  return XcodeSDK::SDKSupportsBuiltinModules(triple, maybe_sdk->getVersion());
-}
-
 static void SetupModuleHeaderPaths(CompilerInstance *compiler,
std::vector 
include_directories,
lldb::TargetSP target_sp) {
@@ -705,7 +662,6 @@ static void SetupLangOpts(CompilerInstance &compiler,
 
 static void SetupImportStdModuleLangOpts(CompilerInstance &compiler,
  lldb_private::Target &target) {
-  Log *log = GetLog(LLDBLog::Expressions);
   LangOptions &lang_opts = compiler.getLangOpts();
   lang_opts.Modules = true;
   // We want to implicitly build modules.
@@ -723,12 +679,7 @@ static void S

[Lldb-commits] [lldb] [lldb] include `LLVMTargetParser` in `LINK_COMPONENTS` (PR #145606)

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

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


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


[Lldb-commits] [lldb] Default transcript dumping in "statistics dump" to false (PR #145436)

2025-06-25 Thread via lldb-commits

qxy11 wrote:

Added a unit test around the warning message as well. I'll probably need some 
help with landing this.

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


[Lldb-commits] [lldb] [lldb] include `LLVMTargetParser` in `LINK_COMPONENTS` (PR #145606)

2025-06-25 Thread Andrew Rogers via lldb-commits

andrurogerz wrote:

> do you need us to merge this for you?

@charles-zablit yes, I would appreciate it! Thank you!

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


[Lldb-commits] [lldb] [llvm] [LLDB] Warn about truncated DWARF section names on Windows (PR #145175)

2025-06-25 Thread via lldb-commits

https://github.com/Nerixyz updated 
https://github.com/llvm/llvm-project/pull/145175

>From a7e33a16dd280250df2ff2d01648bd4d5bfe000b Mon Sep 17 00:00:00 2001
From: Nerixyz 
Date: Sat, 21 Jun 2025 17:36:58 +0200
Subject: [PATCH] [LLDB] Warn about truncated DWARF section names on Windows

---
 .../ObjectFile/PECOFF/ObjectFilePECOFF.cpp| 21 
 .../Shell/ObjectFile/PECOFF/lit.local.cfg |  2 +-
 .../Shell/ObjectFile/PECOFF/truncated-dwarf.c |  7 
 lldb/test/Shell/helper/build.py   | 33 ---
 llvm/docs/ReleaseNotes.md |  2 ++
 5 files changed, 59 insertions(+), 6 deletions(-)
 create mode 100644 lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c

diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp 
b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 4984445dcbab9..61c03e25e461c 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -1036,12 +1036,23 @@ void ObjectFilePECOFF::CreateSections(SectionList 
&unified_section_list) {
 m_sections_up->AddSection(header_sp);
 unified_section_list.AddSection(header_sp);
 
+std::vector truncated_dwarf_sections;
 const uint32_t nsects = m_sect_headers.size();
 for (uint32_t idx = 0; idx < nsects; ++idx) {
   llvm::StringRef sect_name = GetSectionName(m_sect_headers[idx]);
   ConstString const_sect_name(sect_name);
   SectionType section_type = GetSectionType(sect_name, 
m_sect_headers[idx]);
 
+  // Detect unknown sections matching ".debug_*"
+  // In PECOFF files, the section name in the section header can only
+  // contain 8 bytes. If a section name doesn't fit there, it can be
+  // extended in the string table. Since, officially, executable images
+  // don't have a string table, the default link.exe truncates section 
names
+  // to fit in the section header.
+  if (section_type == eSectionTypeOther && sect_name.size() == 8 &&
+  sect_name.starts_with(".debug_"))
+truncated_dwarf_sections.emplace_back(sect_name);
+
   SectionSP section_sp(new Section(
   module_sp,   // Module to which this section belongs
   this,// Object file to which this section belongs
@@ -1071,6 +1082,16 @@ void ObjectFilePECOFF::CreateSections(SectionList 
&unified_section_list) {
   m_sections_up->AddSection(section_sp);
   unified_section_list.AddSection(section_sp);
 }
+
+if (!truncated_dwarf_sections.empty())
+  module_sp->ReportWarning(
+  "contains {} DWARF sections with truncated names ({}).\nWindows "
+  "executable (PECOFF) images produced by the default link.exe don't "
+  "include the required section names. A third party linker like "
+  "lld-link is required (compile with -fuse-ld=lld-link when using "
+  "Clang).",
+  truncated_dwarf_sections.size(),
+  llvm::join(truncated_dwarf_sections, ", "));
   }
 }
 
diff --git a/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg 
b/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg
index 9ef350be1dee2..1ae00d07fc3e6 100644
--- a/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg
+++ b/lldb/test/Shell/ObjectFile/PECOFF/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.yaml', '.test']
+config.suffixes = ['.yaml', '.test', '.c']
diff --git a/lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c 
b/lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c
new file mode 100644
index 0..43dc252739ebc
--- /dev/null
+++ b/lldb/test/Shell/ObjectFile/PECOFF/truncated-dwarf.c
@@ -0,0 +1,7 @@
+// REQUIRES: target-windows
+// RUN: %build --compiler=clang-cl --force-dwarf-symbols --force-ms-link -o 
%t.exe -- %s
+// RUN: %lldb -f %t.exe 2>&1 | FileCheck %s
+
+int main(void) {}
+
+// CHECK: warning: {{.*}} contains 4 DWARF sections with truncated names 
(.debug_{{[a-z]}}, .debug_{{[a-z]}}, .debug_{{[a-z]}}, .debug_{{[a-z]}})
diff --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index caaa14f90af1c..c73aa8a11b396 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -173,6 +173,22 @@
 help="Specify the C/C++ standard.",
 )
 
+parser.add_argument(
+"--force-dwarf-symbols",
+dest="force_dwarf_symbols",
+action="store_true",
+default=False,
+help="When compiling with clang-cl on Windows, use DWARF instead of 
CodeView",
+)
+
+parser.add_argument(
+"--force-ms-link",
+dest="force_ms_link",
+action="store_true",
+default=False,
+help="When compiling with clang-cl on Windows, always use link.exe",
+)
+
 
 args = parser.parse_args(args=sys.argv[1:])
 
@@ -379,15 +395,20 @@ def __init__(self, toolchain_type, args):
 )
 
 if self.mode == "link" or self.mode == "compile-and-link":
-self.linker = (
-self._find_linker("link")
-if t

[Lldb-commits] [lldb] [lldb][AArch64] Handle core file tag segments missing tag data (PR #145338)

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

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


[Lldb-commits] [lldb] [LLDB] Update DIL to handle smart pointers; add more tests. (PR #143786)

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

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


[Lldb-commits] [lldb] [lldb] include `LLVMTargetParser` in `LINK_COMPONENTS` (PR #145606)

2025-06-25 Thread Charles Zablit via lldb-commits

charles-zablit wrote:

Confirmed that this builds fine with the changes 👍 

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


[Lldb-commits] [lldb] [LLDB] Update DIL to handle smart pointers; add more tests. (PR #143786)

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


@@ -0,0 +1,24 @@
+#include 
+
+int main(int argc, char **argv) {
+
+  struct NodeS {
+std::shared_ptr next;
+int value;
+  };
+  auto ptr_node = std::shared_ptr(new NodeS{nullptr, 2});
+  ptr_node = std::shared_ptr(new NodeS{std::move(ptr_node), 1});
+
+  std::shared_ptr ptr_null;
+  auto ptr_int = std::make_shared(1);
+  auto ptr_float = std::make_shared(1.1f);
+
+  std::weak_ptr ptr_int_weak = ptr_int;
+
+  std::shared_ptr ptr_void = ptr_int;
+
+  // TestSharedPtr
+  // TestSharedPtrDeref
+  // TestSharedPtrCompare

labath wrote:

?

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


[Lldb-commits] [lldb] 3a3d1bf - [lldb][AArch64] Handle core file tag segments missing tag data (#145338)

2025-06-25 Thread via lldb-commits

Author: David Spickett
Date: 2025-06-25T10:31:38+01:00
New Revision: 3a3d1bf4a39bbbe1cfdc56ab9eeeb13cb438348a

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

LOG: [lldb][AArch64] Handle core file tag segments missing tag data (#145338)

In the same way that memory regions may be known from a core file but
not readable, tag segments can also have no content. For example:
```
$ readelf --segments core
<...>
Program Headers:
  Type   Offset VirtAddr   PhysAddr
 FileSizMemSiz  Flags  Align
<...>
  LOAD   0x2000 0x93899000 0x
 0x 0x1000  RW 0x1000
<...>
  LOPROC+0x2 0x8000 0x93899000 0x
 0x 0x1000 0x0
```
This happens if you have a restricted coredump filter or size limit.

The area of virtual memory this segment covers is 0x1000, or 4096 bytes
aka one tagged page. It's FileSiz would normally be 0x80. Tags are
packed 2 per byte and granules are 16 bytes. 4096 / 16 / 2 = 128 or
0x80.

But here it has no data, and in theory a corrupt file might have some
data but not all. This triggered an assert in
UnpackTagsFromCoreFileSegment and crashed lldb.

To fix this I have made UnpackTagsFromCoreFileSegment return an expected
and returned an error in this case instead of asserting. This will be
seen by the user, as shown in the added API test.

Added: 
lldb/test/API/linux/aarch64/mte_core_file/core.mte.notags

Modified: 
lldb/include/lldb/Target/MemoryTagManager.h
lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h

lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py
lldb/test/API/linux/aarch64/mte_core_file/main.c
lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/MemoryTagManager.h 
b/lldb/include/lldb/Target/MemoryTagManager.h
index 6bd4180fff703..5b7219692d77f 100644
--- a/lldb/include/lldb/Target/MemoryTagManager.h
+++ b/lldb/include/lldb/Target/MemoryTagManager.h
@@ -122,11 +122,15 @@ class MemoryTagManager {
   //
   // 'reader' will always be a wrapper around a CoreFile in real use
   // but allows testing without having to mock a CoreFile.
+  //
+  // This call will fail in the case that the core file segment does not 
contain
+  // enough data to read all the tags.
   typedef std::function CoreReaderFn;
-  std::vector virtual UnpackTagsFromCoreFileSegment(
-  CoreReaderFn reader, lldb::addr_t tag_segment_virtual_address,
-  lldb::addr_t tag_segment_data_address, lldb::addr_t addr,
-  size_t len) const = 0;
+  llvm::
+  Expected> virtual 
UnpackTagsFromCoreFileSegment(
+  CoreReaderFn reader, lldb::addr_t tag_segment_virtual_address,
+  lldb::addr_t tag_segment_data_address, lldb::addr_t addr,
+  size_t len) const = 0;
 
   // Pack uncompressed tags into their storage format (e.g. for gdb QMemTags).
   // Checks that each tag is within the expected value range.

diff  --git 
a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp 
b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
index 7e25bc4ea2a28..9f60675e51904 100644
--- a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
+++ b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
@@ -247,7 +247,7 @@ MemoryTagManagerAArch64MTE::UnpackTagsData(const 
std::vector &tags,
   return unpacked;
 }
 
-std::vector
+llvm::Expected>
 MemoryTagManagerAArch64MTE::UnpackTagsFromCoreFileSegment(
 CoreReaderFn reader, lldb::addr_t tag_segment_virtual_address,
 lldb::addr_t tag_segment_data_address, lldb::addr_t addr,
@@ -290,8 +290,12 @@ MemoryTagManagerAArch64MTE::UnpackTagsFromCoreFileSegment(
   const size_t bytes_copied =
   reader(tag_segment_data_address + file_offset_in_bytes, 
tag_bytes_to_read,
  tag_data.data());
-  UNUSED_IF_ASSERT_DISABLED(bytes_copied);
-  assert(bytes_copied == tag_bytes_to_read);
+  if (bytes_copied != tag_bytes_to_read) {
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"Could not read tags from core file segment. Segment "
+"is missing some or all tag data.");
+  }
 
   std::vector tags;
   tags.reserve(2 * tag_data.size());

diff  --git a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h 
b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h
index 365e176e5b1da..79d24ce78ecee 100644
--- a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h
+++ b/lldb/source

[Lldb-commits] [lldb] [lldb] Make MCP server instance global (PR #145616)

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

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

LGTM!

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


[Lldb-commits] [lldb] [lldb] Fix FindProcessImpl() for iOS simulators (PR #139174)

2025-06-25 Thread via lldb-commits

royitaqi wrote:

Hi @JDevlieghere and @clayborg ,

Could you kindly review when you have the chance? I think the PR is close to 
finish, except the "how to make sure hello.cpp builds in Windows" question.

TL;DR updates:
1. Called `xcrun simctl spawn -s  ` to launch 
`a.out` and verified that its name and pid appear in `platform process list`.
2. Did the small fix which @clayborg pointed out, but with a `for` loop (not a 
`while`).

Thanks,
Roy

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


[Lldb-commits] [lldb] [lldb] Fix FindProcessImpl() for iOS simulators (PR #139174)

2025-06-25 Thread via lldb-commits

royitaqi wrote:

> The Windows-conditional parts will be dead code.
Hi @JDevlieghere, I have moved the Windows related code. Should be good to go 
(re-running tests on the side).

FWIW, my bad, I overlooked the `@skipUnlessDarwin` in the test.

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


[Lldb-commits] [lldb] Support disassembling RISC-V proprietary instructions (PR #145793)

2025-06-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (tedwoodward)


Changes

RISC-V supports proprietary extensions, where the TD files don't know about 
certain instructions, and the disassembler can't disassemble them. Internal 
users want to be able to disassemble these instructions in LLDB.

With llvm-objdump, the solution is to pipe the output of the disassembly 
through a filter program. This patch modifies LLDB's disassembly to look more 
like llvm-objdump's, and includes an example python script that adds a command 
"fdis" that will disassemble, then pipe the output through a specified filter 
program. This has been tested with crustfilt, a sample filter located at 
https://github.com/quic/crustfilt .

Changes in this PR:
- Decouple "can't disassemble" with "instruction size". 
DisassemblerLLVMC::MCDisasmInstance::GetMCInst now returns a bool for valid 
disassembly, and has the size as an out paramter. Use the size even if the 
disassembly is invalid. Disassemble if disassemby is valid.

- Always print out the opcode when -b is specified. Previously it wouldn't 
print out the opcode if it couldn't disassemble.

- Print out RISC-V opcodes the way llvm-objdump does. Add DumpRISCV method 
based on RISC-V pretty printer in llvm-objdump.cpp.

- Print  for instructions that can't be disassembled, matching 
llvm-objdump, instead of printing nothing.

- Update max riscv32 and riscv64 instruction size to 8.

- Add example "fdis" command script.

Change-Id: Ie5a359d9e87a12dde79a8b5c9c7a146440a550c5

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


6 Files Affected:

- (added) lldb/examples/python/filter_disasm.py (+87) 
- (modified) lldb/include/lldb/Core/Opcode.h (+1) 
- (modified) lldb/source/Core/Disassembler.cpp (+11-3) 
- (modified) lldb/source/Core/Opcode.cpp (+38) 
- (modified) lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp 
(+21-18) 
- (modified) lldb/source/Utility/ArchSpec.cpp (+2-2) 


``diff
diff --git a/lldb/examples/python/filter_disasm.py 
b/lldb/examples/python/filter_disasm.py
new file mode 100644
index 0..adb3455209055
--- /dev/null
+++ b/lldb/examples/python/filter_disasm.py
@@ -0,0 +1,87 @@
+"""
+Defines a command, fdis, that does filtered disassembly. The command does the
+lldb disassemble command with -b and any other arguments passed in, and
+pipes that through a provided filter program.
+
+The intention is to support disassembly of RISC-V proprietary instructions.
+This is handled with llvm-objdump by piping the output of llvm-objdump through
+a filter program. This script is intended to mimic that workflow.
+"""
+
+import lldb
+import subprocess
+
+filter_program = "crustfilt"
+
+def __lldb_init_module(debugger, dict):
+debugger.HandleCommand(
+'command script add -f filter_disasm.fdis fdis')
+print("Disassembly filter command (fdis) loaded")
+print("Filter program set to %s" % filter_program)
+
+
+def fdis(debugger, args, result, dict):
+"""
+  Call the built in disassembler, then pass its output to a filter program
+  to add in disassembly for hidden opcodes.
+  Except for get and set, use the fdis command like the disassemble command.
+  By default, the filter program is crustfilt, from
+  https://github.com/quic/crustfilt . This can be changed by changing
+  the global variable filter_program.
+
+  Usage:
+fdis [[get] [set ] []]
+
+Choose one of the following:
+get
+Gets the current filter program
+
+set 
+Sets the current filter program. This can be an executable, which
+will be found on PATH, or an absolute path.
+
+
+If the first argument is not get or set, the args will be passed
+to the disassemble command as is.
+
+"""
+
+global filter_program
+args_list = args.split(' ')
+result.Clear()
+
+if len(args_list) == 1 and args_list[0] == 'get':
+result.PutCString(filter_program)
+result.SetStatus(lldb.eReturnStatusSuccessFinishResult)
+return
+
+if len(args_list) == 2 and args_list[0] == 'set':
+filter_program = args_list[1]
+result.PutCString("Filter program set to %s" % filter_program)
+result.SetStatus(lldb.eReturnStatusSuccessFinishResult)
+return
+
+res = lldb.SBCommandReturnObject()
+debugger.GetCommandInterpreter().HandleCommand('disassemble -b ' + args, 
res)
+if (len(res.GetError()) > 0):
+result.SetError(res.GetError())
+result.SetStatus(lldb.eReturnStatusFailed)
+return
+output = res.GetOutput()
+
+try:
+proc = subprocess.run([filter_program], capture_output=True, 
text=True, input=output)
+except (subprocess.SubprocessError, OSError) as e:
+result.PutCString("Error occurred. Original disassembly:\n\n" + output)
+result.SetError(str(e))
+result.SetStatus(lldb.eReturnStatusFailed)
+return
+
+print(proc.stderr)
+   

[Lldb-commits] [lldb] Support disassembling RISC-V proprietary instructions (PR #145793)

2025-06-25 Thread via lldb-commits

https://github.com/tedwoodward created 
https://github.com/llvm/llvm-project/pull/145793

RISC-V supports proprietary extensions, where the TD files don't know about 
certain instructions, and the disassembler can't disassemble them. Internal 
users want to be able to disassemble these instructions in LLDB.

With llvm-objdump, the solution is to pipe the output of the disassembly 
through a filter program. This patch modifies LLDB's disassembly to look more 
like llvm-objdump's, and includes an example python script that adds a command 
"fdis" that will disassemble, then pipe the output through a specified filter 
program. This has been tested with crustfilt, a sample filter located at 
https://github.com/quic/crustfilt .

Changes in this PR:
- Decouple "can't disassemble" with "instruction size". 
DisassemblerLLVMC::MCDisasmInstance::GetMCInst now returns a bool for valid 
disassembly, and has the size as an out paramter. Use the size even if the 
disassembly is invalid. Disassemble if disassemby is valid.

- Always print out the opcode when -b is specified. Previously it wouldn't 
print out the opcode if it couldn't disassemble.

- Print out RISC-V opcodes the way llvm-objdump does. Add DumpRISCV method 
based on RISC-V pretty printer in llvm-objdump.cpp.

- Print  for instructions that can't be disassembled, matching 
llvm-objdump, instead of printing nothing.

- Update max riscv32 and riscv64 instruction size to 8.

- Add example "fdis" command script.

Change-Id: Ie5a359d9e87a12dde79a8b5c9c7a146440a550c5

>From 1a7ee4297bb8e6b3fa08818e05cf245a2c768c2b Mon Sep 17 00:00:00 2001
From: Ted Woodward 
Date: Wed, 25 Jun 2025 14:22:28 -0700
Subject: [PATCH] Support disassembling RISC-V proprietary insns

RISC-V supports proprietary extensions, where the TD files don't know
about certain instructions, and the disassembler can't disassemble them.
Internal users want to be able to disassemble these instructions.

With llvm-objdump, the solution is to pipe the output of the disassembly
through a filter program. This patch modifies LLDB's disassembly to look
more like llvm-objdump's, and includes an example python script that adds
a command "fdis" that will disassemble, then pipe the output through a
specified filter program. This has been tested with crustfilt, a sample
filter located at https://github.com/quic/crustfilt .

Changes in this PR:
- Decouple "can't disassemble" with "instruction size".
  DisassemblerLLVMC::MCDisasmInstance::GetMCInst now returns a bool for
valid disassembly, and has the size as an out paramter.
  Use the size even if the disassembly is invalid.
  Disassemble if disassemby is valid.

- Always print out the opcode when -b is specified.
  Previously it wouldn't print out the opcode if it couldn't disassemble.

- Print out RISC-V opcodes the way llvm-objdump does.
  Add DumpRISCV method based on RISC-V pretty printer in llvm-objdump.cpp.

- Print  for instructions that can't be disassembled, matching
  llvm-objdump, instead of printing nothing.

- Update max riscv32 and riscv64 instruction size to 8.

- Add example "fdis" command script.

Change-Id: Ie5a359d9e87a12dde79a8b5c9c7a146440a550c5
---
 lldb/examples/python/filter_disasm.py | 87 +++
 lldb/include/lldb/Core/Opcode.h   |  1 +
 lldb/source/Core/Disassembler.cpp | 14 ++-
 lldb/source/Core/Opcode.cpp   | 38 
 .../Disassembler/LLVMC/DisassemblerLLVMC.cpp  | 39 +
 lldb/source/Utility/ArchSpec.cpp  |  4 +-
 6 files changed, 160 insertions(+), 23 deletions(-)
 create mode 100644 lldb/examples/python/filter_disasm.py

diff --git a/lldb/examples/python/filter_disasm.py 
b/lldb/examples/python/filter_disasm.py
new file mode 100644
index 0..adb3455209055
--- /dev/null
+++ b/lldb/examples/python/filter_disasm.py
@@ -0,0 +1,87 @@
+"""
+Defines a command, fdis, that does filtered disassembly. The command does the
+lldb disassemble command with -b and any other arguments passed in, and
+pipes that through a provided filter program.
+
+The intention is to support disassembly of RISC-V proprietary instructions.
+This is handled with llvm-objdump by piping the output of llvm-objdump through
+a filter program. This script is intended to mimic that workflow.
+"""
+
+import lldb
+import subprocess
+
+filter_program = "crustfilt"
+
+def __lldb_init_module(debugger, dict):
+debugger.HandleCommand(
+'command script add -f filter_disasm.fdis fdis')
+print("Disassembly filter command (fdis) loaded")
+print("Filter program set to %s" % filter_program)
+
+
+def fdis(debugger, args, result, dict):
+"""
+  Call the built in disassembler, then pass its output to a filter program
+  to add in disassembly for hidden opcodes.
+  Except for get and set, use the fdis command like the disassemble command.
+  By default, the filter program is crustfilt, from
+  https://github.com/quic/crustfilt . This can be changed by changing
+  the gl

[Lldb-commits] [lldb] Support disassembling RISC-V proprietary instructions (PR #145793)

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


[Lldb-commits] [lldb] [lldb][NFC] remove the ResolveSDKPathFromDebugInfo method (PR #145744)

2025-06-25 Thread Charles Zablit via lldb-commits

https://github.com/charles-zablit updated 
https://github.com/llvm/llvm-project/pull/145744

>From e28a9e6249077c9ffca878cbf4c933b6f4f9eab8 Mon Sep 17 00:00:00 2001
From: Charles Zablit 
Date: Thu, 19 Jun 2025 16:17:33 +0100
Subject: [PATCH 1/4] [lldb][darwin] force BuiltinHeadersInSystemModules to be
 always false

---
 lldb/include/lldb/Utility/XcodeSDK.h  | 13 -
 .../Clang/ClangExpressionParser.cpp   | 50 +--
 lldb/source/Utility/XcodeSDK.cpp  | 21 
 3 files changed, 1 insertion(+), 83 deletions(-)

diff --git a/lldb/include/lldb/Utility/XcodeSDK.h 
b/lldb/include/lldb/Utility/XcodeSDK.h
index ceb8abb8c502d..a1a0ec415b90e 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -93,19 +93,6 @@ class XcodeSDK {
   static bool SDKSupportsModules(Type type, llvm::VersionTuple version);
   static bool SDKSupportsModules(Type desired_type, const FileSpec &sdk_path);
 
-  /// Returns true if the SDK for the specified triple supports
-  /// builtin modules in system headers.
-  ///
-  /// NOTE: should be kept in sync with sdkSupportsBuiltinModules in
-  /// Toolchains/Darwin.cpp
-  ///
-  /// FIXME: this function will be removed once LLDB's ClangExpressionParser
-  /// constructs the compiler instance through the driver/toolchain. See \ref
-  /// SetupImportStdModuleLangOpts
-  ///
-  static bool SDKSupportsBuiltinModules(const llvm::Triple &target_triple,
-llvm::VersionTuple sdk_version);
-
   /// Return the canonical SDK name, such as "macosx" for the macOS SDK.
   static std::string GetCanonicalName(Info info);
   /// Return the best-matching SDK type for a specific triple.
diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 7aa9cae5a5614..3caf30c5822a2 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -319,49 +319,6 @@ class ClangDiagnosticManagerAdapter : public 
clang::DiagnosticConsumer {
   StringRef m_filename;
 };
 
-/// Returns true if the SDK for the specified triple supports
-/// builtin modules in system headers. This is used to decide
-/// whether to pass -fbuiltin-headers-in-system-modules to
-/// the compiler instance when compiling the `std` module.
-static llvm::Expected
-sdkSupportsBuiltinModules(lldb_private::Target &target) {
-  auto arch_spec = target.GetArchitecture();
-  auto const &triple = arch_spec.GetTriple();
-  auto module_sp = target.GetExecutableModule();
-  if (!module_sp)
-return llvm::createStringError("Executable module not found.");
-
-  // Get SDK path that the target was compiled against.
-  auto platform_sp = target.GetPlatform();
-  if (!platform_sp)
-return llvm::createStringError("No Platform plugin found on target.");
-
-  auto sdk_or_err = platform_sp->GetSDKPathFromDebugInfo(*module_sp);
-  if (!sdk_or_err)
-return sdk_or_err.takeError();
-
-  // Use the SDK path from debug-info to find a local matching SDK directory.
-  auto sdk_path_or_err =
-  HostInfo::GetSDKRoot(HostInfo::SDKOptions{std::move(sdk_or_err->first)});
-  if (!sdk_path_or_err)
-return sdk_path_or_err.takeError();
-
-  auto VFS = FileSystem::Instance().GetVirtualFileSystem();
-  if (!VFS)
-return llvm::createStringError("No virtual filesystem available.");
-
-  // Extract SDK version from the /path/to/some.sdk/SDKSettings.json
-  auto parsed_or_err = clang::parseDarwinSDKInfo(*VFS, *sdk_path_or_err);
-  if (!parsed_or_err)
-return parsed_or_err.takeError();
-
-  auto maybe_sdk = *parsed_or_err;
-  if (!maybe_sdk)
-return llvm::createStringError("Couldn't find Darwin SDK info.");
-
-  return XcodeSDK::SDKSupportsBuiltinModules(triple, maybe_sdk->getVersion());
-}
-
 static void SetupModuleHeaderPaths(CompilerInstance *compiler,
std::vector 
include_directories,
lldb::TargetSP target_sp) {
@@ -723,12 +680,7 @@ static void SetupImportStdModuleLangOpts(CompilerInstance 
&compiler,
   lang_opts.GNUKeywords = true;
   lang_opts.CPlusPlus11 = true;
 
-  if (auto supported_or_err = sdkSupportsBuiltinModules(target))
-lang_opts.BuiltinHeadersInSystemModules = !*supported_or_err;
-  else
-LLDB_LOG_ERROR(log, supported_or_err.takeError(),
-   "Failed to determine BuiltinHeadersInSystemModules when "
-   "setting up import-std-module: {0}");
+  lang_opts.BuiltinHeadersInSystemModules = false;
 
   // The Darwin libc expects this macro to be set.
   lang_opts.GNUCVersion = 40201;
diff --git a/lldb/source/Utility/XcodeSDK.cpp b/lldb/source/Utility/XcodeSDK.cpp
index 004b4717e315b..eb2047e67c326 100644
--- a/lldb/source/Utility/XcodeSDK.cpp
+++ b/lldb/source/Utility/XcodeSDK.cpp
@@ -266,27 +266,6 @@ bool XcodeSDK::SupportsS

[Lldb-commits] [lldb] Default transcript dumping in "statistics dump" to false (PR #145436)

2025-06-25 Thread via lldb-commits

https://github.com/qxy11 updated 
https://github.com/llvm/llvm-project/pull/145436

>From b7889c1f7b0be25f71c6c893bfabe0ebb26f9f52 Mon Sep 17 00:00:00 2001
From: Janet Yang 
Date: Mon, 23 Jun 2025 14:25:12 -0700
Subject: [PATCH 1/5] Disable "transcript" in "statistics dump" by default

---
 lldb/include/lldb/Target/Statistics.h |  2 +-
 .../commands/statistics/basic/TestStats.py| 37 ++-
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index 42f03798c219e..676f3a4a118be 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -195,7 +195,7 @@ struct StatisticsOptions {
   return m_include_transcript.value();
 // `m_include_transcript` has no value set, so return a value based on
 // `m_summary_only`.
-return !GetSummaryOnly();
+return false;
   }
 
   void SetIncludePlugins(bool value) { m_include_plugins = value; }
diff --git a/lldb/test/API/commands/statistics/basic/TestStats.py 
b/lldb/test/API/commands/statistics/basic/TestStats.py
index cc7410ebe018d..138844586af7f 100644
--- a/lldb/test/API/commands/statistics/basic/TestStats.py
+++ b/lldb/test/API/commands/statistics/basic/TestStats.py
@@ -896,7 +896,7 @@ def get_test_cases_for_sections_existence(self):
 "targets.frameVariable": True,
 "targets.totalSharedLibraryEventHitCount": True,
 "modules": True,
-"transcript": True,
+"transcript": False,
 },
 },
 {  # Summary mode
@@ -983,6 +983,24 @@ def get_test_cases_for_sections_existence(self):
 "transcript": False,
 },
 },
+{  # Default mode without modules and with transcript
+"command_options": " --modules=false --transcript=true",
+"api_options": {
+"SetIncludeModules": False,
+"SetIncludeTranscript": True,
+},
+"expect": {
+"commands": True,
+"targets": True,
+"targets.moduleIdentifiers": False,
+"targets.breakpoints": True,
+"targets.expressionEvaluation": True,
+"targets.frameVariable": True,
+"targets.totalSharedLibraryEventHitCount": True,
+"modules": False,
+"transcript": True,
+},
+},
 {  # Default mode without modules
 "command_options": " --modules=false",
 "api_options": {
@@ -997,6 +1015,23 @@ def get_test_cases_for_sections_existence(self):
 "targets.frameVariable": True,
 "targets.totalSharedLibraryEventHitCount": True,
 "modules": False,
+"transcript": False,
+},
+},
+{  # Default mode with transcript
+"command_options": " --transcript=true",
+"api_options": {
+"SetIncludeTranscript": True,
+},
+"expect": {
+"commands": True,
+"targets": True,
+"targets.moduleIdentifiers": True,
+"targets.breakpoints": True,
+"targets.expressionEvaluation": True,
+"targets.frameVariable": True,
+"targets.totalSharedLibraryEventHitCount": True,
+"modules": True,
 "transcript": True,
 },
 },

>From 202b69d78ec22e3e8407a103ca91300e021f23c3 Mon Sep 17 00:00:00 2001
From: Janet Yang 
Date: Mon, 23 Jun 2025 15:46:42 -0700
Subject: [PATCH 2/5] Update some comments

---
 lldb/include/lldb/API/SBStatisticsOptions.h |  3 +--
 lldb/include/lldb/Target/Statistics.h   |  3 +--
 lldb/source/Commands/Options.td | 16 +---
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/lldb/include/lldb/API/SBStatisticsOptions.h 
b/lldb/include/lldb/API/SBStatisticsOptions.h
index 74bea03eff9c9..bfff9dc926432 100644
--- a/lldb/include/lldb/API/SBStatisticsOptions.h
+++ b/lldb/include/lldb/API/SBStatisticsOptions.h
@@ -57,8 +57,7 @@ class LLDB_API SBStatisticsOptions {
   /// a JSON array with all commands the user and/or scripts executed during a
   /// debug session.
   ///
-  /// Defaults to true, unless the `SummaryOnly` mode is enabled, in which case
-  /// this is turned off unless specified.
+  /// Defaults to false.
   void SetIncludeTranscript(bool b);
   bool GetIncludeTranscript() const;
 
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index 676f3a4a118be..68194cf216a1a 100644
--- a/lldb/include/lldb/Target/

  1   2   >