[Lldb-commits] [lldb] [lldb] Use llvm::any_of (NFC) (PR #141443)

2025-05-26 Thread Matt Arsenault via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] DisassembleRequestHandler: use a better invalid instruction (PR #141463)

2025-05-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ely Ronnen (eronnen)


Changes

DisassembleRequestHandler: use a better invalid instruction value that fits 
VSCode client

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


2 Files Affected:

- (modified) lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp (+1) 
- (modified) lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp (+9-2) 


``diff
diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index c9061ef19f17a..1d110eac18126 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -27,6 +27,7 @@ namespace lldb_dap {
 
 static protocol::DisassembledInstruction GetInvalidInstruction() {
   DisassembledInstruction invalid_inst;
+  invalid_inst.address = LLDB_INVALID_ADDRESS;
   invalid_inst.presentationHint =
   DisassembledInstruction::eDisassembledInstructionPresentationHintInvalid;
   return invalid_inst;
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
index 8d4fbd18fee7c..2af919265b1c9 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
@@ -847,8 +847,15 @@ bool fromJSON(const llvm::json::Value &Params, 
DisassembledInstruction &DI,
 }
 
 llvm::json::Value toJSON(const DisassembledInstruction &DI) {
-  llvm::json::Object result{{"address", "0x" + llvm::utohexstr(DI.address)},
-{"instruction", DI.instruction}};
+  llvm::json::Object result{{"instruction", DI.instruction}};
+  if (DI.address == LLDB_INVALID_ADDRESS) {
+// VSCode has explicit comparisons to the string "-1" in order to check for
+// invalid instructions. See
+// 
https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/debug/browser/disassemblyView.ts
+result.insert({"address", "-1"});
+  } else {
+result.insert({"address", "0x" + llvm::utohexstr(DI.address)});
+  }
 
   if (DI.instructionBytes)
 result.insert({"instructionBytes", *DI.instructionBytes});

``




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


[Lldb-commits] [lldb] [lldb][lldb-dap] Use the default disassembly flavour if none is provided. (PR #141424)

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


@@ -2039,7 +2039,17 @@ lldb::SBInstructionList 
SBTarget::ReadInstructions(lldb::SBAddress base_addr,
   const size_t bytes_read =
   target_sp->ReadMemory(*addr_ptr, data.GetBytes(), data.GetByteSize(),
 error, force_live_memory, &load_addr);
+
   const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
+  if (!flavor_string || flavor_string[0] == '\0') {

da-viper wrote:

The other function that creates a `DisassemblerSP` 
`Disassembler::DisassembleRange` uses an address range. I would not be able to 
use that since some architecture the instructions do not map one to one to an 
address. 

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


[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)

2025-05-26 Thread A. Jiang via lldb-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/141543
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)

2025-05-26 Thread A. Jiang via lldb-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/141543
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)

2025-05-26 Thread A. Jiang via lldb-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/141543
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Initialize field to appease msan (PR #141537)

2025-05-26 Thread Aiden Grossman via lldb-commits

https://github.com/boomanaiden154 commented:

Do we want to do the initialization here or inside the struct definition in 
`ProtocolTypes.h`?

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


[Lldb-commits] [lldb] Initialize field to appease msan (PR #141537)

2025-05-26 Thread Walter Lee via lldb-commits

https://github.com/googlewalt created 
https://github.com/llvm/llvm-project/pull/141537

Tested with lldb and lldb-dap test suites.

>From d1d4ea56e970caf92ed1e5dd5848c974e6d0b795 Mon Sep 17 00:00:00 2001
From: Walter Lee 
Date: Mon, 26 May 2025 21:15:07 -0400
Subject: [PATCH] Initialize field to appease msan

Tested with lldb and lldb-dap test suites.
---
 lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index c9061ef19f17a..8825c5c6413b8 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -27,6 +27,7 @@ namespace lldb_dap {
 
 static protocol::DisassembledInstruction GetInvalidInstruction() {
   DisassembledInstruction invalid_inst;
+  invalid_inst.address = 0;
   invalid_inst.presentationHint =
   DisassembledInstruction::eDisassembledInstructionPresentationHintInvalid;
   return invalid_inst;

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


[Lldb-commits] [lldb] Initialize field to appease msan (PR #141537)

2025-05-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Walter Lee (googlewalt)


Changes

Tested with lldb and lldb-dap test suites.

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


1 Files Affected:

- (modified) lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp (+1) 


``diff
diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index c9061ef19f17a..8825c5c6413b8 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -27,6 +27,7 @@ namespace lldb_dap {
 
 static protocol::DisassembledInstruction GetInvalidInstruction() {
   DisassembledInstruction invalid_inst;
+  invalid_inst.address = 0;
   invalid_inst.presentationHint =
   DisassembledInstruction::eDisassembledInstructionPresentationHintInvalid;
   return invalid_inst;

``




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


[Lldb-commits] [lldb] Initialize field to appease msan (PR #141537)

2025-05-26 Thread Walter Lee via lldb-commits

googlewalt wrote:

I can do that.  It's probably better, though currently nothing in the struct is 
initialized.

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


[Lldb-commits] [lldb] Initialize field to appease msan (PR #141537)

2025-05-26 Thread Walter Lee via lldb-commits

googlewalt wrote:

> Do we want to do the initialization here or inside the struct definition in 
> `ProtocolTypes.h`?

Done.

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


[Lldb-commits] [lldb] [lldb] add missing cmake build type argument (PR #141427)

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

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


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


[Lldb-commits] [lldb] Initialize field to appease msan (PR #141537)

2025-05-26 Thread Walter Lee via lldb-commits

https://github.com/googlewalt updated 
https://github.com/llvm/llvm-project/pull/141537

>From d1d4ea56e970caf92ed1e5dd5848c974e6d0b795 Mon Sep 17 00:00:00 2001
From: Walter Lee 
Date: Mon, 26 May 2025 21:15:07 -0400
Subject: [PATCH 1/2] Initialize field to appease msan

Tested with lldb and lldb-dap test suites.
---
 lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index c9061ef19f17a..8825c5c6413b8 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -27,6 +27,7 @@ namespace lldb_dap {
 
 static protocol::DisassembledInstruction GetInvalidInstruction() {
   DisassembledInstruction invalid_inst;
+  invalid_inst.address = 0;
   invalid_inst.presentationHint =
   DisassembledInstruction::eDisassembledInstructionPresentationHintInvalid;
   return invalid_inst;

>From 2bb1851dd3d0be63461b7dc9429b568cbb8d062c Mon Sep 17 00:00:00 2001
From: Walter Lee 
Date: Mon, 26 May 2025 23:40:46 -0400
Subject: [PATCH 2/2] Move the initializion to the constructor

---
 lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp | 1 -
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index 8825c5c6413b8..c9061ef19f17a 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -27,7 +27,6 @@ namespace lldb_dap {
 
 static protocol::DisassembledInstruction GetInvalidInstruction() {
   DisassembledInstruction invalid_inst;
-  invalid_inst.address = 0;
   invalid_inst.presentationHint =
   DisassembledInstruction::eDisassembledInstructionPresentationHintInvalid;
   return invalid_inst;
diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h 
b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
index 5bac62adcdd38..f5e21c96fe17f 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
@@ -677,6 +677,8 @@ struct DisassembledInstruction {
   /// addresses may be presented is 'invalid.'
   /// Values: 'normal', 'invalid'
   std::optional presentationHint;
+
+  DisassembledInstruction() : address(0) {}
 };
 bool fromJSON(const llvm::json::Value &,
   DisassembledInstruction::PresentationHint &, llvm::json::Path);

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


[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)

2025-05-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: A. Jiang (frederick-vs-ja)


Changes

It seem that #140107 changed the default argument of `disableASLR` of 
related functions from `False` to `True`. libc++ CI has been stably failing for 
`TestDAP_subtleFrames.py` (in bootstrapping-build) since then. The error 
message "personality set failed: Operation not permitted" seems related to ASLR.

This PR attempts to fix the CI failure.

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


2 Files Affected:

- (modified) libcxx/include/__config (+2) 
- (modified) 
lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py 
(+1-1) 


``diff
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 57223e4f1db18..49abe17a4da76 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1219,3 +1219,5 @@ typedef __char32_t char32_t;
 #endif // __cplusplus
 
 #endif // _LIBCPP___CONFIG
+
+// Just for CI, will be reverted.
diff --git 
a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
index 1e41e841e39bc..1751c52072aac 100644
--- 
a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
+++ 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
@@ -17,7 +17,7 @@ def test_subtleFrames(self):
 Internal stack frames (such as the ones used by `std::function`) are 
marked as "subtle".
 """
 program = self.getBuildArtifact("a.out")
-self.build_and_launch(program)
+self.build_and_launch(program, disableASLR=False)
 source = "main.cpp"
 self.set_source_breakpoints(source, [line_number(source, "BREAK 
HERE")])
 self.continue_to_next_stop()

``




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


[Lldb-commits] [libcxx] [lldb] [libc++][lldb-dap][test] Fix CI for bootstrapping-build (PR #141543)

2025-05-26 Thread A. Jiang via lldb-commits

https://github.com/frederick-vs-ja created 
https://github.com/llvm/llvm-project/pull/141543

It seem that #140107 changed the default argument of `disableASLR` of related 
functions from `False` to `True`. libc++ CI has been stably failing for 
`TestDAP_subtleFrames.py` (in bootstrapping-build) since then. The error 
message "personality set failed: Operation not permitted" seems related to ASLR.

This PR attempts to fix the CI failure.

>From 75f0f1463c7bcabb5ffef34c0f1e1c0b4ca91b04 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Tue, 27 May 2025 12:10:36 +0800
Subject: [PATCH] [libc++][lldb-dap][test] Fix CI for bootstrapping-build

---
 libcxx/include/__config | 2 ++
 .../lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py| 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libcxx/include/__config b/libcxx/include/__config
index 57223e4f1db18..49abe17a4da76 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1219,3 +1219,5 @@ typedef __char32_t char32_t;
 #endif // __cplusplus
 
 #endif // _LIBCPP___CONFIG
+
+// Just for CI, will be reverted.
diff --git 
a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
index 1e41e841e39bc..1751c52072aac 100644
--- 
a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
+++ 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/TestDAP_subtleFrames.py
@@ -17,7 +17,7 @@ def test_subtleFrames(self):
 Internal stack frames (such as the ones used by `std::function`) are 
marked as "subtle".
 """
 program = self.getBuildArtifact("a.out")
-self.build_and_launch(program)
+self.build_and_launch(program, disableASLR=False)
 source = "main.cpp"
 self.set_source_breakpoints(source, [line_number(source, "BREAK 
HERE")])
 self.continue_to_next_stop()

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


[Lldb-commits] [lldb] Initialize field to appease msan (PR #141537)

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

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


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


[Lldb-commits] [lldb] Initialize field to appease msan (PR #141537)

2025-05-26 Thread Walter Lee via lldb-commits

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


[Lldb-commits] [lldb] b75d8bd - Initialize field to appease msan (#141537)

2025-05-26 Thread via lldb-commits

Author: Walter Lee
Date: 2025-05-27T00:18:40-04:00
New Revision: b75d8bdd4eb242e3936357beaf7f9407ba71d9f1

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

LOG: Initialize field to appease msan (#141537)

Tested with lldb and lldb-dap test suites.

Added: 


Modified: 
lldb/tools/lldb-dap/Protocol/ProtocolTypes.h

Removed: 




diff  --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h 
b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
index 5bac62adcdd38..f5e21c96fe17f 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
@@ -677,6 +677,8 @@ struct DisassembledInstruction {
   /// addresses may be presented is 'invalid.'
   /// Values: 'normal', 'invalid'
   std::optional presentationHint;
+
+  DisassembledInstruction() : address(0) {}
 };
 bool fromJSON(const llvm::json::Value &,
   DisassembledInstruction::PresentationHint &, llvm::json::Path);



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


[Lldb-commits] [lldb] 85cbf74 - [lldb] Use llvm::any_of (NFC) (#141443)

2025-05-26 Thread via lldb-commits

Author: Kazu Hirata
Date: 2025-05-26T09:13:17-07:00
New Revision: 85cbf742f9dab78808c0093ca85031acbf55e250

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

LOG: [lldb] Use llvm::any_of (NFC) (#141443)

Added: 


Modified: 
lldb/source/Breakpoint/WatchpointResource.cpp
lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp

Removed: 




diff  --git a/lldb/source/Breakpoint/WatchpointResource.cpp 
b/lldb/source/Breakpoint/WatchpointResource.cpp
index fa0442997b528..49d9d12aadfc3 100644
--- a/lldb/source/Breakpoint/WatchpointResource.cpp
+++ b/lldb/source/Breakpoint/WatchpointResource.cpp
@@ -73,10 +73,8 @@ bool WatchpointResource::ConstituentsContains(const 
WatchpointSP &wp_sp) {
 
 bool WatchpointResource::ConstituentsContains(const Watchpoint *wp) {
   std::lock_guard guard(m_constituents_mutex);
-  WatchpointCollection::const_iterator match =
-  std::find_if(m_constituents.begin(), m_constituents.end(),
-   [&wp](const WatchpointSP &x) { return x.get() == wp; });
-  return match != m_constituents.end();
+  return llvm::any_of(m_constituents,
+  [&wp](const WatchpointSP &x) { return x.get() == wp; });
 }
 
 WatchpointSP WatchpointResource::GetConstituentAtIndex(size_t idx) {

diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
index 3bafb21f7c33a..b9e7c698cdec0 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -177,8 +177,8 @@ void ABIAArch64::AugmentRegisterInfo(
   lldb::eFormatHex);
 
   auto bool_predicate = [](const auto ®_num) { return bool(reg_num); };
-  bool saw_v_regs = std::any_of(v_regs.begin(), v_regs.end(), bool_predicate);
-  bool saw_z_regs = std::any_of(z_regs.begin(), z_regs.end(), bool_predicate);
+  bool saw_v_regs = llvm::any_of(v_regs, bool_predicate);
+  bool saw_z_regs = llvm::any_of(z_regs, bool_predicate);
 
   // Sn/Dn for Vn.
   if (saw_v_regs) {



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


[Lldb-commits] [lldb] [lldb] Use llvm::any_of (NFC) (PR #141443)

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

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


[Lldb-commits] [lldb] [lldb] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)

2025-05-26 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang created 
https://github.com/llvm/llvm-project/pull/141516

This commit adjusts the pretty printer for `std::corotoutine_handle` based on 
recent personal experiences with debugging C++20 coroutines:

1. It adds the `coro_frame` member. This member exposes the complete coroutine 
frame contents, including the suspension point id and all internal variables 
which the compiler decided to persist into the coroutine frame. While this data 
is highly compiler-specific, inspecting it can help identify the internal state 
of suspended coroutines.
2. It includes the `promise` and `coro_frame` members, even if devirtualization 
failed and we could not infer the promise type / the coro_frame type. Having 
them available as `void*` pointers can still be useful to identify, e.g., which 
two coroutines have the same frame / promise pointers.

>From 1068b3e8d0c59336900bfb52906b3b7b81cb43e6 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Fri, 23 May 2025 01:20:46 +
Subject: [PATCH] [lldb] Show coro_frame in `std::coroutine_handle` pretty
 printer

This commit adjusts the pretty printer for `std::corotoutine_handle`
based on recent personal experiences with debugging C++20 coroutines:

1. It adds the `coro_frame` member. This member exposes the complete
   coroutine frame contents, including the suspension point id and all
   internal variables which the compiler decided to persist into the
   coroutine frame. While this data is highly compiler-specific,
   inspecting it can help identify the internal state of suspended
   coroutines.
2. It includes the `promise` and `coro_frame` members, even if
   devirtualization failed and we could not infer the promise type / the
   coro_frame type. Having them available as `void*` pointers can still
   be useful to identify, e.g., which two coroutines have the same frame
   / promise pointers.
---
 .../lldb/DataFormatters/TypeSynthetic.h   |   2 +-
 lldb/source/DataFormatters/TypeSynthetic.cpp  |   4 +-
 .../Plugins/Language/CPlusPlus/Coroutines.cpp | 148 --
 .../Plugins/Language/CPlusPlus/Coroutines.h   |   4 +-
 .../coroutine_handle/TestCoroutineHandle.py   |  46 --
 5 files changed, 100 insertions(+), 104 deletions(-)

diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h 
b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index c8d7d15588065..138d297305b53 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -92,7 +92,7 @@ class SyntheticChildrenFrontEnd {
   lldb::ValueObjectSP
   CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address,
const ExecutionContext &exe_ctx,
-   CompilerType type);
+   CompilerType type, bool do_deref = true);
 
   lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name,
 const DataExtractor &data,
diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp 
b/lldb/source/DataFormatters/TypeSynthetic.cpp
index 57009b07dc553..e8440d07f9593 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -138,9 +138,9 @@ lldb::ValueObjectSP 
SyntheticChildrenFrontEnd::CreateValueObjectFromExpression(
 
 lldb::ValueObjectSP SyntheticChildrenFrontEnd::CreateValueObjectFromAddress(
 llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx,
-CompilerType type) {
+CompilerType type, bool do_deref) {
   ValueObjectSP valobj_sp(
-  ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, type));
+  ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, type, 
do_deref));
   if (valobj_sp)
 valobj_sp->SetSyntheticChildrenGenerated(true);
   return valobj_sp;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index 376555936e89d..903b5f7cc9203 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -11,22 +11,20 @@
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/VariableList.h"
-#include "lldb/Utility/LLDBLog.h"
-#include "lldb/Utility/Log.h"
 
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::formatters;
 
-static lldb::addr_t GetCoroFramePtrFromHandle(ValueObjectSP valobj_sp) {
-  if (!valobj_sp)
+static lldb::addr_t GetCoroFramePtrFromHandle(ValueObjectSP corohandle_sp) {
+  if (!corohandle_sp)
 return LLDB_INVALID_ADDRESS;
 
   // We expect a single pointer in the `coroutine_handle` class.
   // We don't care about its name.
-  if (valobj_sp->GetNumChildrenIgnoringErrors() != 1)
+  if (corohandle_sp->GetNumChildrenIgnoringErrors() != 1)
 return LLDB_INVALID_ADDRESS;
-  ValueObjectSP ptr_sp(valobj_sp->GetChi

[Lldb-commits] [lldb] [lldb] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)

2025-05-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Vogelsgesang (vogelsgesang)


Changes

This commit adjusts the pretty printer for `std::corotoutine_handle` based on 
recent personal experiences with debugging C++20 coroutines:

1. It adds the `coro_frame` member. This member exposes the complete coroutine 
frame contents, including the suspension point id and all internal variables 
which the compiler decided to persist into the coroutine frame. While this data 
is highly compiler-specific, inspecting it can help identify the internal state 
of suspended coroutines.
2. It includes the `promise` and `coro_frame` members, even if devirtualization 
failed and we could not infer the promise type / the coro_frame type. Having 
them available as `void*` pointers can still be useful to identify, e.g., which 
two coroutines have the same frame / promise pointers.

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


5 Files Affected:

- (modified) lldb/include/lldb/DataFormatters/TypeSynthetic.h (+1-1) 
- (modified) lldb/source/DataFormatters/TypeSynthetic.cpp (+2-2) 
- (modified) lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp (+67-81) 
- (modified) lldb/source/Plugins/Language/CPlusPlus/Coroutines.h (+1-3) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
 (+29-17) 


``diff
diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h 
b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index c8d7d15588065..138d297305b53 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -92,7 +92,7 @@ class SyntheticChildrenFrontEnd {
   lldb::ValueObjectSP
   CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address,
const ExecutionContext &exe_ctx,
-   CompilerType type);
+   CompilerType type, bool do_deref = true);
 
   lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name,
 const DataExtractor &data,
diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp 
b/lldb/source/DataFormatters/TypeSynthetic.cpp
index 57009b07dc553..e8440d07f9593 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -138,9 +138,9 @@ lldb::ValueObjectSP 
SyntheticChildrenFrontEnd::CreateValueObjectFromExpression(
 
 lldb::ValueObjectSP SyntheticChildrenFrontEnd::CreateValueObjectFromAddress(
 llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx,
-CompilerType type) {
+CompilerType type, bool do_deref) {
   ValueObjectSP valobj_sp(
-  ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, type));
+  ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, type, 
do_deref));
   if (valobj_sp)
 valobj_sp->SetSyntheticChildrenGenerated(true);
   return valobj_sp;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index 376555936e89d..903b5f7cc9203 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -11,22 +11,20 @@
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/VariableList.h"
-#include "lldb/Utility/LLDBLog.h"
-#include "lldb/Utility/Log.h"
 
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::formatters;
 
-static lldb::addr_t GetCoroFramePtrFromHandle(ValueObjectSP valobj_sp) {
-  if (!valobj_sp)
+static lldb::addr_t GetCoroFramePtrFromHandle(ValueObjectSP corohandle_sp) {
+  if (!corohandle_sp)
 return LLDB_INVALID_ADDRESS;
 
   // We expect a single pointer in the `coroutine_handle` class.
   // We don't care about its name.
-  if (valobj_sp->GetNumChildrenIgnoringErrors() != 1)
+  if (corohandle_sp->GetNumChildrenIgnoringErrors() != 1)
 return LLDB_INVALID_ADDRESS;
-  ValueObjectSP ptr_sp(valobj_sp->GetChildAtIndex(0));
+  ValueObjectSP ptr_sp(corohandle_sp->GetChildAtIndex(0));
   if (!ptr_sp)
 return LLDB_INVALID_ADDRESS;
   if (!ptr_sp->GetCompilerType().IsPointerType())
@@ -62,19 +60,20 @@ static Function *ExtractDestroyFunction(lldb::TargetSP 
target_sp,
   return destroy_func_address.CalculateSymbolContextFunction();
 }
 
-static CompilerType InferPromiseType(Function &destroy_func) {
+// clang generates aritifical `__promise` and `__coro_frame` variables inside
+// the destroy function. Look for those variables and extract their type.
+static CompilerType InferArtificialCoroType(Function &destroy_func,
+ConstString var_name) {
   Block &block = destroy_func.GetBlock(true);
   auto variable_list = block.GetBlockVariableList(true);
 
-  // clang generates an artificial `__promis

[Lldb-commits] [lldb] [lldb] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)

2025-05-26 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/141516

>From 733f6321bc7020281ea33dd6dad0a2409e248ccd Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Fri, 23 May 2025 01:20:46 +
Subject: [PATCH] [lldb] Show coro_frame in `std::coroutine_handle` pretty
 printer

This commit adjusts the pretty printer for `std::corotoutine_handle`
based on recent personal experiences with debugging C++20 coroutines:

1. It adds the `coro_frame` member. This member exposes the complete
   coroutine frame contents, including the suspension point id and all
   internal variables which the compiler decided to persist into the
   coroutine frame. While this data is highly compiler-specific,
   inspecting it can help identify the internal state of suspended
   coroutines.
2. It includes the `promise` and `coro_frame` members, even if
   devirtualization failed and we could not infer the promise type / the
   coro_frame type. Having them available as `void*` pointers can still
   be useful to identify, e.g., which two coroutines have the same frame
   / promise pointers.
---
 .../lldb/DataFormatters/TypeSynthetic.h   |   2 +-
 lldb/source/DataFormatters/TypeSynthetic.cpp  |   4 +-
 .../Plugins/Language/CPlusPlus/Coroutines.cpp | 146 --
 .../Plugins/Language/CPlusPlus/Coroutines.h   |   4 +-
 .../coroutine_handle/TestCoroutineHandle.py   |  46 --
 5 files changed, 99 insertions(+), 103 deletions(-)

diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h 
b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index c8d7d15588065..138d297305b53 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -92,7 +92,7 @@ class SyntheticChildrenFrontEnd {
   lldb::ValueObjectSP
   CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address,
const ExecutionContext &exe_ctx,
-   CompilerType type);
+   CompilerType type, bool do_deref = true);
 
   lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name,
 const DataExtractor &data,
diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp 
b/lldb/source/DataFormatters/TypeSynthetic.cpp
index 57009b07dc553..e8440d07f9593 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -138,9 +138,9 @@ lldb::ValueObjectSP 
SyntheticChildrenFrontEnd::CreateValueObjectFromExpression(
 
 lldb::ValueObjectSP SyntheticChildrenFrontEnd::CreateValueObjectFromAddress(
 llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx,
-CompilerType type) {
+CompilerType type, bool do_deref) {
   ValueObjectSP valobj_sp(
-  ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, type));
+  ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, type, 
do_deref));
   if (valobj_sp)
 valobj_sp->SetSyntheticChildrenGenerated(true);
   return valobj_sp;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index d3cdb231fbb01..53eca89f64edd 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -11,22 +11,20 @@
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/VariableList.h"
-#include "lldb/Utility/LLDBLog.h"
-#include "lldb/Utility/Log.h"
 
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::formatters;
 
-static lldb::addr_t GetCoroFramePtrFromHandle(ValueObjectSP valobj_sp) {
-  if (!valobj_sp)
+static lldb::addr_t GetCoroFramePtrFromHandle(ValueObjectSP corohandle_sp) {
+  if (!corohandle_sp)
 return LLDB_INVALID_ADDRESS;
 
   // We expect a single pointer in the `coroutine_handle` class.
   // We don't care about its name.
-  if (valobj_sp->GetNumChildrenIgnoringErrors() != 1)
+  if (corohandle_sp->GetNumChildrenIgnoringErrors() != 1)
 return LLDB_INVALID_ADDRESS;
-  ValueObjectSP ptr_sp(valobj_sp->GetChildAtIndex(0));
+  ValueObjectSP ptr_sp(corohandle_sp->GetChildAtIndex(0));
   if (!ptr_sp)
 return LLDB_INVALID_ADDRESS;
   if (!ptr_sp->GetCompilerType().IsPointerType())
@@ -62,19 +60,20 @@ static Function *ExtractDestroyFunction(lldb::TargetSP 
target_sp,
   return destroy_func_address.CalculateSymbolContextFunction();
 }
 
-static CompilerType InferPromiseType(Function &destroy_func) {
+// clang generates aritifical `__promise` and `__coro_frame` variables inside
+// the destroy function. Look for those variables and extract their type.
+static CompilerType InferArtificialCoroType(Function &destroy_func,
+ConstString var_name) {
   Block &block = destroy_func.GetBlock(true);
   auto variable_list = block.GetBlockVariableL

[Lldb-commits] [lldb] [lldb] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)

2025-05-26 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- 
lldb/include/lldb/DataFormatters/TypeSynthetic.h 
lldb/source/DataFormatters/TypeSynthetic.cpp 
lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
lldb/source/Plugins/Language/CPlusPlus/Coroutines.h
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp 
b/lldb/source/DataFormatters/TypeSynthetic.cpp
index e8440d07f..33af0ad63 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -139,8 +139,8 @@ lldb::ValueObjectSP 
SyntheticChildrenFrontEnd::CreateValueObjectFromExpression(
 lldb::ValueObjectSP SyntheticChildrenFrontEnd::CreateValueObjectFromAddress(
 llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx,
 CompilerType type, bool do_deref) {
-  ValueObjectSP valobj_sp(
-  ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, type, 
do_deref));
+  ValueObjectSP valobj_sp(ValueObject::CreateValueObjectFromAddress(
+  name, address, exe_ctx, type, do_deref));
   if (valobj_sp)
 valobj_sp->SetSyntheticChildrenGenerated(true);
   return valobj_sp;

``




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


[Lldb-commits] [lldb] [lldb] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)

2025-05-26 Thread Adrian Vogelsgesang via lldb-commits

vogelsgesang wrote:

CC @ChuanqiXu9 @hokein, since I know that the both of you also looked into 
debuggability of C++20 coroutines earlier
CC @labath @adrian-prantl as reviewers of the latest significant changes in 
this area (https://reviews.llvm.org/D132624, https://reviews.llvm.org/D132735, 
https://reviews.llvm.org/D132815)

Would appreciate your reviews on this pull request :)

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


[Lldb-commits] [lldb] [lldb] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)

2025-05-26 Thread Adrian Vogelsgesang via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)

2025-05-26 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/141516

>From 4132dcd234438ec710061b498b7c5778637026d5 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Fri, 23 May 2025 01:20:46 +
Subject: [PATCH] [lldb] Show coro_frame in `std::coroutine_handle` pretty
 printer

This commit adjusts the pretty printer for `std::corotoutine_handle`
based on recent personal experiences with debugging C++20 coroutines:

1. It adds the `coro_frame` member. This member exposes the complete
   coroutine frame contents, including the suspension point id and all
   internal variables which the compiler decided to persist into the
   coroutine frame. While this data is highly compiler-specific,
   inspecting it can help identify the internal state of suspended
   coroutines.
2. It includes the `promise` and `coro_frame` members, even if
   devirtualization failed and we could not infer the promise type / the
   coro_frame type. Having them available as `void*` pointers can still
   be useful to identify, e.g., which two coroutines have the same frame
   / promise pointers.
---
 .../lldb/DataFormatters/TypeSynthetic.h   |   2 +-
 lldb/source/DataFormatters/TypeSynthetic.cpp  |   4 +-
 .../Plugins/Language/CPlusPlus/Coroutines.cpp | 138 --
 .../Plugins/Language/CPlusPlus/Coroutines.h   |   4 +-
 .../coroutine_handle/TestCoroutineHandle.py   |  46 +++---
 5 files changed, 95 insertions(+), 99 deletions(-)

diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h 
b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index c8d7d15588065..138d297305b53 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -92,7 +92,7 @@ class SyntheticChildrenFrontEnd {
   lldb::ValueObjectSP
   CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address,
const ExecutionContext &exe_ctx,
-   CompilerType type);
+   CompilerType type, bool do_deref = true);
 
   lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name,
 const DataExtractor &data,
diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp 
b/lldb/source/DataFormatters/TypeSynthetic.cpp
index 57009b07dc553..e8440d07f9593 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -138,9 +138,9 @@ lldb::ValueObjectSP 
SyntheticChildrenFrontEnd::CreateValueObjectFromExpression(
 
 lldb::ValueObjectSP SyntheticChildrenFrontEnd::CreateValueObjectFromAddress(
 llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx,
-CompilerType type) {
+CompilerType type, bool do_deref) {
   ValueObjectSP valobj_sp(
-  ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, type));
+  ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, type, 
do_deref));
   if (valobj_sp)
 valobj_sp->SetSyntheticChildrenGenerated(true);
   return valobj_sp;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index d3cdb231fbb01..f9fd770705d8b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -11,8 +11,6 @@
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/VariableList.h"
-#include "lldb/Utility/LLDBLog.h"
-#include "lldb/Utility/Log.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -62,19 +60,20 @@ static Function *ExtractDestroyFunction(lldb::TargetSP 
target_sp,
   return destroy_func_address.CalculateSymbolContextFunction();
 }
 
-static CompilerType InferPromiseType(Function &destroy_func) {
+// clang generates aritifical `__promise` and `__coro_frame` variables inside
+// the destroy function. Look for those variables and extract their type.
+static CompilerType InferArtificialCoroType(Function &destroy_func,
+ConstString var_name) {
   Block &block = destroy_func.GetBlock(true);
   auto variable_list = block.GetBlockVariableList(true);
 
-  // clang generates an artificial `__promise` variable inside the
-  // `destroy` function. Look for it.
-  auto promise_var = variable_list->FindVariable(ConstString("__promise"));
-  if (!promise_var)
+  auto var = variable_list->FindVariable(var_name);
+  if (!var)
 return {};
-  if (!promise_var->IsArtificial())
+  if (!var->IsArtificial())
 return {};
 
-  Type *promise_type = promise_var->GetType();
+  Type *promise_type = var->GetType();
   if (!promise_type)
 return {};
   return promise_type->GetForwardCompilerType();
@@ -108,30 +107,17 @@ 
lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::
 
 llvm::Expected lldb_private::formatters::
 StdlibCoroutineHandleSyntheticFrontEnd::Calcu

[Lldb-commits] [lldb] [lldb] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)

2025-05-26 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/141516

>From 35e18fc22abfb1daff2b08413f34f258e922fd5f Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Fri, 23 May 2025 01:20:46 +
Subject: [PATCH] [lldb] Show coro_frame in `std::coroutine_handle` pretty
 printer

This commit adjusts the pretty printer for `std::corotoutine_handle`
based on recent personal experiences with debugging C++20 coroutines:

1. It adds the `coro_frame` member. This member exposes the complete
   coroutine frame contents, including the suspension point id and all
   internal variables which the compiler decided to persist into the
   coroutine frame. While this data is highly compiler-specific,
   inspecting it can help identify the internal state of suspended
   coroutines.
2. It includes the `promise` and `coro_frame` members, even if
   devirtualization failed and we could not infer the promise type / the
   coro_frame type. Having them available as `void*` pointers can still
   be useful to identify, e.g., which two coroutines have the same frame
   / promise pointers.
---
 .../lldb/DataFormatters/TypeSynthetic.h   |   2 +-
 lldb/source/DataFormatters/TypeSynthetic.cpp  |   6 +-
 .../Plugins/Language/CPlusPlus/Coroutines.cpp | 138 --
 .../Plugins/Language/CPlusPlus/Coroutines.h   |   4 +-
 .../coroutine_handle/TestCoroutineHandle.py   |  46 +++---
 5 files changed, 96 insertions(+), 100 deletions(-)

diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h 
b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index c8d7d15588065..138d297305b53 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -92,7 +92,7 @@ class SyntheticChildrenFrontEnd {
   lldb::ValueObjectSP
   CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address,
const ExecutionContext &exe_ctx,
-   CompilerType type);
+   CompilerType type, bool do_deref = true);
 
   lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name,
 const DataExtractor &data,
diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp 
b/lldb/source/DataFormatters/TypeSynthetic.cpp
index 57009b07dc553..33af0ad63077f 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -138,9 +138,9 @@ lldb::ValueObjectSP 
SyntheticChildrenFrontEnd::CreateValueObjectFromExpression(
 
 lldb::ValueObjectSP SyntheticChildrenFrontEnd::CreateValueObjectFromAddress(
 llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx,
-CompilerType type) {
-  ValueObjectSP valobj_sp(
-  ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, type));
+CompilerType type, bool do_deref) {
+  ValueObjectSP valobj_sp(ValueObject::CreateValueObjectFromAddress(
+  name, address, exe_ctx, type, do_deref));
   if (valobj_sp)
 valobj_sp->SetSyntheticChildrenGenerated(true);
   return valobj_sp;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index d3cdb231fbb01..f9fd770705d8b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -11,8 +11,6 @@
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/VariableList.h"
-#include "lldb/Utility/LLDBLog.h"
-#include "lldb/Utility/Log.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -62,19 +60,20 @@ static Function *ExtractDestroyFunction(lldb::TargetSP 
target_sp,
   return destroy_func_address.CalculateSymbolContextFunction();
 }
 
-static CompilerType InferPromiseType(Function &destroy_func) {
+// clang generates aritifical `__promise` and `__coro_frame` variables inside
+// the destroy function. Look for those variables and extract their type.
+static CompilerType InferArtificialCoroType(Function &destroy_func,
+ConstString var_name) {
   Block &block = destroy_func.GetBlock(true);
   auto variable_list = block.GetBlockVariableList(true);
 
-  // clang generates an artificial `__promise` variable inside the
-  // `destroy` function. Look for it.
-  auto promise_var = variable_list->FindVariable(ConstString("__promise"));
-  if (!promise_var)
+  auto var = variable_list->FindVariable(var_name);
+  if (!var)
 return {};
-  if (!promise_var->IsArtificial())
+  if (!var->IsArtificial())
 return {};
 
-  Type *promise_type = promise_var->GetType();
+  Type *promise_type = var->GetType();
   if (!promise_type)
 return {};
   return promise_type->GetForwardCompilerType();
@@ -108,30 +107,17 @@ 
lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::
 
 llvm::Expected lldb_private::formatters::
 StdlibCoroutineHa

[Lldb-commits] [lldb] [lldb-dap] Treat empty thread names as unset (PR #141529)

2025-05-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: nerix (Nerixyz)


Changes

When a target thread returned an empty but not `nullptr` string as its name, 
the thread would show up with an empty name in lldb-dap.

I don't know how this works on macOS and Linux, but on Windows, 
[`TargetThreadWindows::GetName`](https://github.com/llvm/llvm-project/blob/deedc8a181b9598d188b2175357bce990a271d5d/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp#L178-L204)
 returns a non-null pointer to an empty string, because on MSVC's STL, 
`std::string{}.c_str()` returns a pointer to inside the object (the SSO 
storage).

This changes the check in `CreateThread`, when no custom thread formatter is 
set, to check for the length of the thread and queue name instead of it being 
`nullptr`.

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


1 Files Affected:

- (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+5-5) 


``diff
diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index c9c6f4554c325..f0b3dfb595717 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -764,12 +764,12 @@ llvm::json::Value CreateThread(lldb::SBThread &thread, 
lldb::SBFormat &format) {
   if (format && thread.GetDescriptionWithFormat(format, stream).Success()) {
 thread_str = stream.GetData();
   } else {
-const char *thread_name = thread.GetName();
-const char *queue_name = thread.GetQueueName();
+llvm::StringRef thread_name(thread.GetName());
+llvm::StringRef queue_name(thread.GetQueueName());
 
-if (thread_name) {
-  thread_str = std::string(thread_name);
-} else if (queue_name) {
+if (!thread_name.empty()) {
+  thread_str = thread_name.str();
+} else if (!queue_name.empty()) {
   auto kind = thread.GetQueue().GetKind();
   std::string queue_kind_label = "";
   if (kind == lldb::eQueueKindSerial) {

``




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


[Lldb-commits] [lldb] [lldb-dap] Treat empty thread names as unset (PR #141529)

2025-05-26 Thread via lldb-commits

https://github.com/Nerixyz created 
https://github.com/llvm/llvm-project/pull/141529

When a target thread returned an empty but not `nullptr` string as its name, 
the thread would show up with an empty name in lldb-dap.

I don't know how this works on macOS and Linux, but on Windows, 
[`TargetThreadWindows::GetName`](https://github.com/llvm/llvm-project/blob/deedc8a181b9598d188b2175357bce990a271d5d/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp#L178-L204)
 returns a non-null pointer to an empty string, because on MSVC's STL, 
`std::string{}.c_str()` returns a pointer to inside the object (the SSO 
storage).

This changes the check in `CreateThread`, when no custom thread formatter is 
set, to check for the length of the thread and queue name instead of it being 
`nullptr`.

>From 331742fc3d9f01c6f5f6755b6ec94c69bf8a2ac8 Mon Sep 17 00:00:00 2001
From: Nerixyz 
Date: Mon, 26 May 2025 22:25:05 +0200
Subject: [PATCH] [lldb-dap] Treat empty thread names as unset

---
 lldb/tools/lldb-dap/JSONUtils.cpp | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index c9c6f4554c325..f0b3dfb595717 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -764,12 +764,12 @@ llvm::json::Value CreateThread(lldb::SBThread &thread, 
lldb::SBFormat &format) {
   if (format && thread.GetDescriptionWithFormat(format, stream).Success()) {
 thread_str = stream.GetData();
   } else {
-const char *thread_name = thread.GetName();
-const char *queue_name = thread.GetQueueName();
+llvm::StringRef thread_name(thread.GetName());
+llvm::StringRef queue_name(thread.GetQueueName());
 
-if (thread_name) {
-  thread_str = std::string(thread_name);
-} else if (queue_name) {
+if (!thread_name.empty()) {
+  thread_str = thread_name.str();
+} else if (!queue_name.empty()) {
   auto kind = thread.GetQueue().GetKind();
   std::string queue_kind_label = "";
   if (kind == lldb::eQueueKindSerial) {

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


[Lldb-commits] [lldb] [lldb] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)

2025-05-26 Thread Jan Finis via lldb-commits


@@ -141,76 +127,76 @@ 
lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::Update() {
   if (frame_ptr_addr == 0 || frame_ptr_addr == LLDB_INVALID_ADDRESS)
 return lldb::ChildCacheState::eRefetch;
 
-  auto ast_ctx = valobj_sp->GetCompilerType().GetTypeSystem();
-  if (!ast_ctx)
-return lldb::ChildCacheState::eRefetch;
-
-  // Create the `resume` and `destroy` children.
   lldb::TargetSP target_sp = m_backend.GetTargetSP();
   auto &exe_ctx = m_backend.GetExecutionContextRef();
   lldb::ProcessSP process_sp = target_sp->GetProcessSP();
   auto ptr_size = process_sp->GetAddressByteSize();
-  CompilerType void_type = ast_ctx->GetBasicType(lldb::eBasicTypeVoid);
-  CompilerType coro_func_type = ast_ctx->CreateFunctionType(
-  /*result_type=*/void_type, /*args=*/&void_type, /*num_args=*/1,
-  /*is_variadic=*/false, /*qualifiers=*/0);
-  CompilerType coro_func_ptr_type = coro_func_type.GetPointerType();
-  m_resume_ptr_sp = CreateValueObjectFromAddress(
-  "resume", frame_ptr_addr + 0 * ptr_size, exe_ctx, coro_func_ptr_type);
-  lldbassert(m_resume_ptr_sp);
-  m_destroy_ptr_sp = CreateValueObjectFromAddress(
-  "destroy", frame_ptr_addr + 1 * ptr_size, exe_ctx, coro_func_ptr_type);
-  lldbassert(m_destroy_ptr_sp);
-
-  // Get the `promise_type` from the template argument
-  CompilerType promise_type(
-  valobj_sp->GetCompilerType().GetTypeTemplateArgument(0));
-  if (!promise_type)
+  auto ast_ctx = valobj_sp->GetCompilerType().GetTypeSystem();
+  if (!ast_ctx)
 return lldb::ChildCacheState::eRefetch;
 
-  // Try to infer the promise_type if it was type-erased
+  // Determine the coroutine frame type and the promise type. Fall back
+  // to `void`, since even the pointer itself might be useful, even if the
+  // type inference failed.
+  Function *destroy_func = ExtractDestroyFunction(target_sp, frame_ptr_addr);
+  CompilerType void_type = ast_ctx->GetBasicType(lldb::eBasicTypeVoid);
+  CompilerType promise_type;
+  if (CompilerType template_argt =
+  valobj_sp->GetCompilerType().GetTypeTemplateArgument(0))
+promise_type = std::move(template_argt);
   if (promise_type.IsVoidType()) {
-if (Function *destroy_func =
-ExtractDestroyFunction(target_sp, frame_ptr_addr)) {
-  if (CompilerType inferred_type = InferPromiseType(*destroy_func)) {
+// Try to infer the promise_type if it was type-erased
+if (destroy_func) {
+  if (CompilerType inferred_type = InferArtificialCoroType(
+  *destroy_func, ConstString("__promise"))) {
 promise_type = inferred_type;
   }
 }
   }
+  CompilerType coro_frame_type =
+  InferArtificialCoroType(*destroy_func, ConstString("__coro_frame"));
+  if (!coro_frame_type)
+coro_frame_type = void_type;
 
-  // If we don't know the promise type, we don't display the `promise` member.
-  // `CreateValueObjectFromAddress` below would fail for `void` types.
-  if (promise_type.IsVoidType()) {
-return lldb::ChildCacheState::eRefetch;
-  }
-
-  // Add the `promise` member. We intentionally add `promise` as a pointer type
-  // instead of a value type, and don't automatically dereference this pointer.
-  // We do so to avoid potential very deep recursion in case there is a cycle
-  // formed between `std::coroutine_handle`s and their promises.
-  lldb::ValueObjectSP promise = CreateValueObjectFromAddress(
-  "promise", frame_ptr_addr + 2 * ptr_size, exe_ctx, promise_type);
-  Status error;
-  lldb::ValueObjectSP promisePtr = promise->AddressOf(error);
-  if (error.Success())
-m_promise_ptr_sp = promisePtr->Clone(ConstString("promise"));
+  // Create the `resume` and `destroy` children.
+  CompilerType coro_func_type = ast_ctx->CreateFunctionType(
+  /*result_type=*/void_type, /*args=*/&coro_frame_type, /*num_args=*/1,
+  /*is_variadic=*/false, /*qualifiers=*/0);
+  CompilerType coro_func_ptr_type = coro_func_type.GetPointerType();
+  ValueObjectSP resume_ptr_sp = CreateValueObjectFromAddress(
+  "resume", frame_ptr_addr + 0 * ptr_size, exe_ctx, coro_func_ptr_type);
+  lldbassert(resume_ptr_sp);
+  m_children.push_back(std::move(resume_ptr_sp));
+  ValueObjectSP destroy_ptr_sp = CreateValueObjectFromAddress(
+  "destroy", frame_ptr_addr + 1 * ptr_size, exe_ctx, coro_func_ptr_type);
+  lldbassert(destroy_ptr_sp);
+  m_children.push_back(std::move(destroy_ptr_sp));
+
+  // Add promise and coro_frame

JFinis wrote:

```suggestion
```
Duplicate comment

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


[Lldb-commits] [lldb] [lldb] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)

2025-05-26 Thread Jan Finis via lldb-commits


@@ -43,11 +43,17 @@ def do_test(self, stdlib_type):
 ValueCheck(name="current_value", value="-1"),
 ],
 ),
+# We don not check any members inside the `coro_frame`,

JFinis wrote:

```suggestion
# We do not check any members inside the `coro_frame`,
```

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


[Lldb-commits] [lldb] [lldb] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)

2025-05-26 Thread Adrian Vogelsgesang via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)

2025-05-26 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/141516

>From 35e18fc22abfb1daff2b08413f34f258e922fd5f Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Fri, 23 May 2025 01:20:46 +
Subject: [PATCH 1/2] [lldb] Show coro_frame in `std::coroutine_handle` pretty
 printer

This commit adjusts the pretty printer for `std::corotoutine_handle`
based on recent personal experiences with debugging C++20 coroutines:

1. It adds the `coro_frame` member. This member exposes the complete
   coroutine frame contents, including the suspension point id and all
   internal variables which the compiler decided to persist into the
   coroutine frame. While this data is highly compiler-specific,
   inspecting it can help identify the internal state of suspended
   coroutines.
2. It includes the `promise` and `coro_frame` members, even if
   devirtualization failed and we could not infer the promise type / the
   coro_frame type. Having them available as `void*` pointers can still
   be useful to identify, e.g., which two coroutines have the same frame
   / promise pointers.
---
 .../lldb/DataFormatters/TypeSynthetic.h   |   2 +-
 lldb/source/DataFormatters/TypeSynthetic.cpp  |   6 +-
 .../Plugins/Language/CPlusPlus/Coroutines.cpp | 138 --
 .../Plugins/Language/CPlusPlus/Coroutines.h   |   4 +-
 .../coroutine_handle/TestCoroutineHandle.py   |  46 +++---
 5 files changed, 96 insertions(+), 100 deletions(-)

diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h 
b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index c8d7d15588065..138d297305b53 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -92,7 +92,7 @@ class SyntheticChildrenFrontEnd {
   lldb::ValueObjectSP
   CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address,
const ExecutionContext &exe_ctx,
-   CompilerType type);
+   CompilerType type, bool do_deref = true);
 
   lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name,
 const DataExtractor &data,
diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp 
b/lldb/source/DataFormatters/TypeSynthetic.cpp
index 57009b07dc553..33af0ad63077f 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -138,9 +138,9 @@ lldb::ValueObjectSP 
SyntheticChildrenFrontEnd::CreateValueObjectFromExpression(
 
 lldb::ValueObjectSP SyntheticChildrenFrontEnd::CreateValueObjectFromAddress(
 llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx,
-CompilerType type) {
-  ValueObjectSP valobj_sp(
-  ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, type));
+CompilerType type, bool do_deref) {
+  ValueObjectSP valobj_sp(ValueObject::CreateValueObjectFromAddress(
+  name, address, exe_ctx, type, do_deref));
   if (valobj_sp)
 valobj_sp->SetSyntheticChildrenGenerated(true);
   return valobj_sp;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index d3cdb231fbb01..f9fd770705d8b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -11,8 +11,6 @@
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/VariableList.h"
-#include "lldb/Utility/LLDBLog.h"
-#include "lldb/Utility/Log.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -62,19 +60,20 @@ static Function *ExtractDestroyFunction(lldb::TargetSP 
target_sp,
   return destroy_func_address.CalculateSymbolContextFunction();
 }
 
-static CompilerType InferPromiseType(Function &destroy_func) {
+// clang generates aritifical `__promise` and `__coro_frame` variables inside
+// the destroy function. Look for those variables and extract their type.
+static CompilerType InferArtificialCoroType(Function &destroy_func,
+ConstString var_name) {
   Block &block = destroy_func.GetBlock(true);
   auto variable_list = block.GetBlockVariableList(true);
 
-  // clang generates an artificial `__promise` variable inside the
-  // `destroy` function. Look for it.
-  auto promise_var = variable_list->FindVariable(ConstString("__promise"));
-  if (!promise_var)
+  auto var = variable_list->FindVariable(var_name);
+  if (!var)
 return {};
-  if (!promise_var->IsArtificial())
+  if (!var->IsArtificial())
 return {};
 
-  Type *promise_type = promise_var->GetType();
+  Type *promise_type = var->GetType();
   if (!promise_type)
 return {};
   return promise_type->GetForwardCompilerType();
@@ -108,30 +107,17 @@ 
lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::
 
 llvm::Expected lldb_private::formatters::
 StdlibCorouti

[Lldb-commits] [clang] [compiler-rt] [lldb] [LLDB] [NFC] - Remove duplicate #include headers from the files of lldb dir & few other files (PR #141478)

2025-05-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Akash Agrawal (akashagrwl)


Changes

A few files of lldb dir & few other files had duplicate headers included. 
This patch removes those redundancies.

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


15 Files Affected:

- (modified) clang/lib/InstallAPI/FileList.cpp (+1-1) 
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp (-1) 
- (modified) lldb/source/API/SBInstruction.cpp (+1-1) 
- (modified) lldb/source/API/SBPlatform.cpp (+1-1) 
- (modified) lldb/source/Core/Telemetry.cpp (+1-1) 
- (modified) lldb/source/Interpreter/CommandObject.cpp (-1) 
- (modified) 
lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp (-3) 
- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (-2) 
- (modified) lldb/source/Plugins/Process/FreeBSDKernel/ThreadFreeBSDKernel.cpp 
(-1) 
- (modified) lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp (-1) 
- (modified) lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp (-1) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (-1) 
- (modified) lldb/source/Target/ScriptedThreadPlan.cpp (-1) 
- (modified) lldb/source/ValueObject/ValueObject.cpp (-1) 
- (modified) lldb/tools/debugserver/source/RNBRemote.cpp (-1) 


``diff
diff --git a/clang/lib/InstallAPI/FileList.cpp 
b/clang/lib/InstallAPI/FileList.cpp
index 65610903840af..27e8a2c5b2556 100644
--- a/clang/lib/InstallAPI/FileList.cpp
+++ b/clang/lib/InstallAPI/FileList.cpp
@@ -7,8 +7,8 @@
 
//===--===//
 
 #include "clang/InstallAPI/FileList.h"
+
 #include "clang/Basic/DiagnosticFrontend.h"
-#include "clang/InstallAPI/FileList.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/JSON.h"
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp
index ca37df348580a..7566d438d60df 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp
@@ -13,7 +13,6 @@
 #include "sanitizer_flag_parser.h"
 
 #include "sanitizer_common.h"
-#include "sanitizer_flag_parser.h"
 #include "sanitizer_flags.h"
 #include "sanitizer_libc.h"
 
diff --git a/lldb/source/API/SBInstruction.cpp 
b/lldb/source/API/SBInstruction.cpp
index 30703eea6fa6c..5d21b92b3607e 100644
--- a/lldb/source/API/SBInstruction.cpp
+++ b/lldb/source/API/SBInstruction.cpp
@@ -7,13 +7,13 @@
 
//===--===//
 
 #include "lldb/API/SBInstruction.h"
+
 #include "lldb/Utility/Instrumentation.h"
 
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBFrame.h"
 #include "lldb/API/SBFile.h"
 
-#include "lldb/API/SBInstruction.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/API/SBTarget.h"
 #include "lldb/Core/Disassembler.h"
diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index 394268b77aa21..95d5fa5b14d0e 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -7,13 +7,13 @@
 
//===--===//
 
 #include "lldb/API/SBPlatform.h"
+
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEnvironment.h"
 #include "lldb/API/SBError.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBLaunchInfo.h"
 #include "lldb/API/SBModuleSpec.h"
-#include "lldb/API/SBPlatform.h"
 #include "lldb/API/SBProcessInfoList.h"
 #include "lldb/API/SBTarget.h"
 #include "lldb/API/SBUnixSignals.h"
diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp
index a819d5366cedc..c87581761c45e 100644
--- a/lldb/source/Core/Telemetry.cpp
+++ b/lldb/source/Core/Telemetry.cpp
@@ -6,8 +6,8 @@
 //
 
//===--===//
 #include "lldb/Core/Telemetry.h"
+
 #include "lldb/Core/Debugger.h"
-#include "lldb/Core/Telemetry.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/UUID.h"
diff --git a/lldb/source/Interpreter/CommandObject.cpp 
b/lldb/source/Interpreter/CommandObject.cpp
index 72dd546dd6523..129646ebddb94 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -32,7 +32,6 @@
 #include "lldb/Target/Language.h"
 
 #include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Interpreter/CommandOptionArgumentTable.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 
 using namespace lldb;
diff --git 
a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp 
b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
index d2bf2586cd82b..07f70f45985f7 100644
--- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DY

[Lldb-commits] [clang] [compiler-rt] [lldb] [LLDB] [NFC] - Remove duplicate #include headers from the files of lldb dir & few other files (PR #141478)

2025-05-26 Thread Akash Agrawal via lldb-commits

https://github.com/akashagrwl created 
https://github.com/llvm/llvm-project/pull/141478

A few files of lldb dir & few other files had duplicate headers included. This 
patch removes those redundancies.

>From 72ce442847fe03dd489938eff0eee06c65f53e90 Mon Sep 17 00:00:00 2001
From: Akash Agrawal 
Date: Mon, 26 May 2025 16:54:21 +0530
Subject: [PATCH] [LLVM] [NFC] - Remove duplicate #include headers from the
 files of lldb dir & few other files

Change-Id: I50d7df02e2dc4f493c46c4044a4e7a4ca7e03355
---
 clang/lib/InstallAPI/FileList.cpp  | 2 +-
 compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp | 1 -
 lldb/source/API/SBInstruction.cpp  | 2 +-
 lldb/source/API/SBPlatform.cpp | 2 +-
 lldb/source/Core/Telemetry.cpp | 2 +-
 lldb/source/Interpreter/CommandObject.cpp  | 1 -
 .../DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp   | 3 ---
 .../Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp   | 2 --
 .../Plugins/Process/FreeBSDKernel/ThreadFreeBSDKernel.cpp  | 1 -
 lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp  | 1 -
 lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp  | 1 -
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp   | 1 -
 lldb/source/Target/ScriptedThreadPlan.cpp  | 1 -
 lldb/source/ValueObject/ValueObject.cpp| 1 -
 lldb/tools/debugserver/source/RNBRemote.cpp| 1 -
 15 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/clang/lib/InstallAPI/FileList.cpp 
b/clang/lib/InstallAPI/FileList.cpp
index 65610903840af..27e8a2c5b2556 100644
--- a/clang/lib/InstallAPI/FileList.cpp
+++ b/clang/lib/InstallAPI/FileList.cpp
@@ -7,8 +7,8 @@
 
//===--===//
 
 #include "clang/InstallAPI/FileList.h"
+
 #include "clang/Basic/DiagnosticFrontend.h"
-#include "clang/InstallAPI/FileList.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/JSON.h"
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp
index ca37df348580a..7566d438d60df 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp
@@ -13,7 +13,6 @@
 #include "sanitizer_flag_parser.h"
 
 #include "sanitizer_common.h"
-#include "sanitizer_flag_parser.h"
 #include "sanitizer_flags.h"
 #include "sanitizer_libc.h"
 
diff --git a/lldb/source/API/SBInstruction.cpp 
b/lldb/source/API/SBInstruction.cpp
index 30703eea6fa6c..5d21b92b3607e 100644
--- a/lldb/source/API/SBInstruction.cpp
+++ b/lldb/source/API/SBInstruction.cpp
@@ -7,13 +7,13 @@
 
//===--===//
 
 #include "lldb/API/SBInstruction.h"
+
 #include "lldb/Utility/Instrumentation.h"
 
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBFrame.h"
 #include "lldb/API/SBFile.h"
 
-#include "lldb/API/SBInstruction.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/API/SBTarget.h"
 #include "lldb/Core/Disassembler.h"
diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index 394268b77aa21..95d5fa5b14d0e 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -7,13 +7,13 @@
 
//===--===//
 
 #include "lldb/API/SBPlatform.h"
+
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEnvironment.h"
 #include "lldb/API/SBError.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBLaunchInfo.h"
 #include "lldb/API/SBModuleSpec.h"
-#include "lldb/API/SBPlatform.h"
 #include "lldb/API/SBProcessInfoList.h"
 #include "lldb/API/SBTarget.h"
 #include "lldb/API/SBUnixSignals.h"
diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp
index a819d5366cedc..c87581761c45e 100644
--- a/lldb/source/Core/Telemetry.cpp
+++ b/lldb/source/Core/Telemetry.cpp
@@ -6,8 +6,8 @@
 //
 
//===--===//
 #include "lldb/Core/Telemetry.h"
+
 #include "lldb/Core/Debugger.h"
-#include "lldb/Core/Telemetry.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/UUID.h"
diff --git a/lldb/source/Interpreter/CommandObject.cpp 
b/lldb/source/Interpreter/CommandObject.cpp
index 72dd546dd6523..129646ebddb94 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -32,7 +32,6 @@
 #include "lldb/Target/Language.h"
 
 #include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Interpreter/CommandOptionArgumentTable.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 
 using namespace lldb;
diff --git 
a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDR

[Lldb-commits] [clang] [compiler-rt] [lldb] [LLDB] [NFC] - Remove duplicate #include headers from the files of lldb dir & few other files (PR #141478)

2025-05-26 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- 
clang/lib/InstallAPI/FileList.cpp 
compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp 
lldb/source/API/SBInstruction.cpp lldb/source/API/SBPlatform.cpp 
lldb/source/Core/Telemetry.cpp lldb/source/Interpreter/CommandObject.cpp 
lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
lldb/source/Plugins/Process/FreeBSDKernel/ThreadFreeBSDKernel.cpp 
lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp 
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
lldb/source/Target/ScriptedThreadPlan.cpp 
lldb/source/ValueObject/ValueObject.cpp 
lldb/tools/debugserver/source/RNBRemote.cpp
``





View the diff from clang-format here.


``diff
diff --git 
a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp 
b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
index 07f70f459..62c0fb0ff 100644
--- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
@@ -7,13 +7,13 @@
 
//===--===//
 
 #include "lldb/Core/Module.h"
+#include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/Status.h"
-#include "lldb/Symbol/ObjectFile.h"
 
 #include "HexagonDYLDRendezvous.h"
 

``




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


[Lldb-commits] [clang] [compiler-rt] [lldb] [LLDB] [NFC] - Remove duplicate #include headers from the files of lldb dir & few other files (PR #141478)

2025-05-26 Thread Akash Agrawal via lldb-commits

https://github.com/akashagrwl updated 
https://github.com/llvm/llvm-project/pull/141478

>From 72ce442847fe03dd489938eff0eee06c65f53e90 Mon Sep 17 00:00:00 2001
From: Akash Agrawal 
Date: Mon, 26 May 2025 16:54:21 +0530
Subject: [PATCH 1/2] [LLVM] [NFC] - Remove duplicate #include headers from the
 files of lldb dir & few other files

Change-Id: I50d7df02e2dc4f493c46c4044a4e7a4ca7e03355
---
 clang/lib/InstallAPI/FileList.cpp  | 2 +-
 compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp | 1 -
 lldb/source/API/SBInstruction.cpp  | 2 +-
 lldb/source/API/SBPlatform.cpp | 2 +-
 lldb/source/Core/Telemetry.cpp | 2 +-
 lldb/source/Interpreter/CommandObject.cpp  | 1 -
 .../DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp   | 3 ---
 .../Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp   | 2 --
 .../Plugins/Process/FreeBSDKernel/ThreadFreeBSDKernel.cpp  | 1 -
 lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp  | 1 -
 lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp  | 1 -
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp   | 1 -
 lldb/source/Target/ScriptedThreadPlan.cpp  | 1 -
 lldb/source/ValueObject/ValueObject.cpp| 1 -
 lldb/tools/debugserver/source/RNBRemote.cpp| 1 -
 15 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/clang/lib/InstallAPI/FileList.cpp 
b/clang/lib/InstallAPI/FileList.cpp
index 65610903840af..27e8a2c5b2556 100644
--- a/clang/lib/InstallAPI/FileList.cpp
+++ b/clang/lib/InstallAPI/FileList.cpp
@@ -7,8 +7,8 @@
 
//===--===//
 
 #include "clang/InstallAPI/FileList.h"
+
 #include "clang/Basic/DiagnosticFrontend.h"
-#include "clang/InstallAPI/FileList.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/JSON.h"
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp
index ca37df348580a..7566d438d60df 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp
@@ -13,7 +13,6 @@
 #include "sanitizer_flag_parser.h"
 
 #include "sanitizer_common.h"
-#include "sanitizer_flag_parser.h"
 #include "sanitizer_flags.h"
 #include "sanitizer_libc.h"
 
diff --git a/lldb/source/API/SBInstruction.cpp 
b/lldb/source/API/SBInstruction.cpp
index 30703eea6fa6c..5d21b92b3607e 100644
--- a/lldb/source/API/SBInstruction.cpp
+++ b/lldb/source/API/SBInstruction.cpp
@@ -7,13 +7,13 @@
 
//===--===//
 
 #include "lldb/API/SBInstruction.h"
+
 #include "lldb/Utility/Instrumentation.h"
 
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBFrame.h"
 #include "lldb/API/SBFile.h"
 
-#include "lldb/API/SBInstruction.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/API/SBTarget.h"
 #include "lldb/Core/Disassembler.h"
diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index 394268b77aa21..95d5fa5b14d0e 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -7,13 +7,13 @@
 
//===--===//
 
 #include "lldb/API/SBPlatform.h"
+
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEnvironment.h"
 #include "lldb/API/SBError.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBLaunchInfo.h"
 #include "lldb/API/SBModuleSpec.h"
-#include "lldb/API/SBPlatform.h"
 #include "lldb/API/SBProcessInfoList.h"
 #include "lldb/API/SBTarget.h"
 #include "lldb/API/SBUnixSignals.h"
diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp
index a819d5366cedc..c87581761c45e 100644
--- a/lldb/source/Core/Telemetry.cpp
+++ b/lldb/source/Core/Telemetry.cpp
@@ -6,8 +6,8 @@
 //
 
//===--===//
 #include "lldb/Core/Telemetry.h"
+
 #include "lldb/Core/Debugger.h"
-#include "lldb/Core/Telemetry.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/UUID.h"
diff --git a/lldb/source/Interpreter/CommandObject.cpp 
b/lldb/source/Interpreter/CommandObject.cpp
index 72dd546dd6523..129646ebddb94 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -32,7 +32,6 @@
 #include "lldb/Target/Language.h"
 
 #include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Interpreter/CommandOptionArgumentTable.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 
 using namespace lldb;
diff --git 
a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp 
b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
index d2bf2586cd82b..

[Lldb-commits] [clang] [compiler-rt] [lldb] [LLDB] [NFC] - Remove duplicate #include headers from the files of lldb dir & few other files (PR #141478)

2025-05-26 Thread Akash Agrawal via lldb-commits

akashagrwl wrote:

Adding @iajbar @androm3da @svs-quic for review.

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