[Lldb-commits] [lldb] Fix comment in TestObjcPoHint.py (PR #142306)
https://github.com/saagarjha created https://github.com/llvm/llvm-project/pull/142306 This seems to have been copied from above but not changed to match. >From 1be69ca55dddba65e1268681bb6f7ca037d7a476 Mon Sep 17 00:00:00 2001 From: Saagar Jha Date: Sun, 1 Jun 2025 02:38:51 -0700 Subject: [PATCH] Fix comment in TestObjcPoHint.py This seems to have been copied from above but not changed to match. --- lldb/test/API/lang/objc/objc-po-hint/TestObjcPoHint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/test/API/lang/objc/objc-po-hint/TestObjcPoHint.py b/lldb/test/API/lang/objc/objc-po-hint/TestObjcPoHint.py index 3073cb07e0532..ba922944f4ce2 100644 --- a/lldb/test/API/lang/objc/objc-po-hint/TestObjcPoHint.py +++ b/lldb/test/API/lang/objc/objc-po-hint/TestObjcPoHint.py @@ -37,7 +37,7 @@ def test_show_po_hint_disabled(self): self, "Set breakpoint here", lldb.SBFileSpec("main.m") ) self.runCmd("setting set show-dont-use-po-hint false") -# Make sure the hint is printed the first time +# Make sure the hint is not printed self.expect( "dwim-print -O -- foo", substrs=["note: object description"], ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Avoid creating a temporary instance of std::string (NFC) (PR #142294)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/142294 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] faea938 - [lldb] Avoid creating a temporary instance of std::string (NFC) (#142294)
Author: Kazu Hirata Date: 2025-06-01T23:23:34-07:00 New Revision: faea938248ccb8fda37d8ac04fc11b25b8f31869 URL: https://github.com/llvm/llvm-project/commit/faea938248ccb8fda37d8ac04fc11b25b8f31869 DIFF: https://github.com/llvm/llvm-project/commit/faea938248ccb8fda37d8ac04fc11b25b8f31869.diff LOG: [lldb] Avoid creating a temporary instance of std::string (NFC) (#142294) GetExceptionBreakpoint takes StringRef to look for a matching breakpoint, so we don't need to create a temporary instance of std::string on our own. Added: Modified: lldb/tools/lldb-dap/Handler/SetExceptionBreakpointsRequestHandler.cpp Removed: diff --git a/lldb/tools/lldb-dap/Handler/SetExceptionBreakpointsRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/SetExceptionBreakpointsRequestHandler.cpp index 09d4fea2a9a22..2214833f8a770 100644 --- a/lldb/tools/lldb-dap/Handler/SetExceptionBreakpointsRequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/SetExceptionBreakpointsRequestHandler.cpp @@ -76,7 +76,7 @@ void SetExceptionBreakpointsRequestHandler::operator()( for (const auto &value : *filters) { const auto filter = GetAsString(value); -auto *exc_bp = dap.GetExceptionBreakpoint(std::string(filter)); +auto *exc_bp = dap.GetExceptionBreakpoint(filter); if (exc_bp) { exc_bp->SetBreakpoint(); unset_filters.erase(std::string(filter)); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Avoid creating a temporary instance of std::string (NFC) (PR #142294)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/142294 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a2e093f - [NFC][lldb-dap] Avoid unnecessary copy in setBreakpoint (#142179)
Author: Ebuka Ezike Date: 2025-06-01T10:13:39+01:00 New Revision: a2e093f4b5a97704aeed5af0d0185da54eaf326f URL: https://github.com/llvm/llvm-project/commit/a2e093f4b5a97704aeed5af0d0185da54eaf326f DIFF: https://github.com/llvm/llvm-project/commit/a2e093f4b5a97704aeed5af0d0185da54eaf326f.diff LOG: [NFC][lldb-dap] Avoid unnecessary copy in setBreakpoint (#142179) Added: Modified: lldb/tools/lldb-dap/Handler/SetBreakpointsRequestHandler.cpp Removed: diff --git a/lldb/tools/lldb-dap/Handler/SetBreakpointsRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/SetBreakpointsRequestHandler.cpp index 0ff88f62f8f51..5d336af740c99 100644 --- a/lldb/tools/lldb-dap/Handler/SetBreakpointsRequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/SetBreakpointsRequestHandler.cpp @@ -7,8 +7,6 @@ //===--===// #include "DAP.h" -#include "EventHelper.h" -#include "JSONUtils.h" #include "Protocol/ProtocolRequests.h" #include "RequestHandler.h" #include @@ -22,7 +20,7 @@ namespace lldb_dap { llvm::Expected SetBreakpointsRequestHandler::Run( const protocol::SetBreakpointsArguments &args) const { - const auto response_breakpoints = + std::vector response_breakpoints = dap.SetSourceBreakpoints(args.source, args.breakpoints); return protocol::SetBreakpointsResponseBody{std::move(response_breakpoints)}; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb-dap] Avoid unnecessary copy in setBreakpoint (PR #142179)
https://github.com/da-viper closed https://github.com/llvm/llvm-project/pull/142179 ___ 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)
@@ -141,76 +127,75 @@ 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 the `promise` and `coro_frame` member. We intentionally add them as + // pointer types instead of a value type, and don't automatically dereference + // those pointers. We do so to avoid potential very deep recursion in case + // there is a cycle formed between `std::coroutine_handle`s and their + // promises. + ValueObjectSP promise_ptr_sp = CreateValueObjectFromAddress( + "promise", frame_ptr_addr + 2 * ptr_size, exe_ctx, + promise_type.GetPointerType(), /*do_deref=*/false); + m_children.push_back(std::move(promise_ptr_sp)); + ValueObjectSP coro
[Lldb-commits] [lldb] [lldb] Show coro_frame in `std::coroutine_handle` pretty printer (PR #141516)
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] Fix comment in TestObjcPoHint.py (PR #142306)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Saagar Jha (saagarjha) Changes This seems to have been copied from above but not changed to match. --- Full diff: https://github.com/llvm/llvm-project/pull/142306.diff 1 Files Affected: - (modified) lldb/test/API/lang/objc/objc-po-hint/TestObjcPoHint.py (+1-1) ``diff diff --git a/lldb/test/API/lang/objc/objc-po-hint/TestObjcPoHint.py b/lldb/test/API/lang/objc/objc-po-hint/TestObjcPoHint.py index 3073cb07e0532..ba922944f4ce2 100644 --- a/lldb/test/API/lang/objc/objc-po-hint/TestObjcPoHint.py +++ b/lldb/test/API/lang/objc/objc-po-hint/TestObjcPoHint.py @@ -37,7 +37,7 @@ def test_show_po_hint_disabled(self): self, "Set breakpoint here", lldb.SBFileSpec("main.m") ) self.runCmd("setting set show-dont-use-po-hint false") -# Make sure the hint is printed the first time +# Make sure the hint is not printed self.expect( "dwim-print -O -- foo", substrs=["note: object description"], `` https://github.com/llvm/llvm-project/pull/142306 ___ 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)
https://github.com/vogelsgesang updated https://github.com/llvm/llvm-project/pull/141516 >From 25e1d6769bda37a5920e56a464c64af702a5652d 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 | 139 -- .../Plugins/Language/CPlusPlus/Coroutines.h | 4 +- .../coroutine_handle/TestCoroutineHandle.py | 46 +++--- 5 files changed, 97 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..34e554ca1ae29 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