[Lldb-commits] [lldb] [lldb] Remove a redundant control flow statement (NFC) (PR #144284)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Kazu Hirata (kazutakahirata) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/144284.diff 1 Files Affected: - (modified) lldb/tools/debugserver/source/RNBRemote.cpp (-1) ``diff diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index 391d1c50168ea..8be384c6d24af 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -1476,7 +1476,6 @@ bool RNBRemote::InitializeRegisters(bool force) { void RNBRemote::NotifyThatProcessStopped(void) { RNBRemote::HandlePacket_last_signal(NULL); - return; } /* 'A arglen,argnum,arg,...' `` https://github.com/llvm/llvm-project/pull/144284 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove a redundant control flow statement (NFC) (PR #144284)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/144284 None >From 7763d82df4c8d050598fac2b6347ce3ba0e3518d Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 15 Jun 2025 10:48:33 -0700 Subject: [PATCH] [lldb] Remove a redundant control flow statement (NFC) --- lldb/tools/debugserver/source/RNBRemote.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index 391d1c50168ea..8be384c6d24af 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -1476,7 +1476,6 @@ bool RNBRemote::InitializeRegisters(bool force) { void RNBRemote::NotifyThatProcessStopped(void) { RNBRemote::HandlePacket_last_signal(NULL); - return; } /* 'A arglen,argnum,arg,...' ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Update DIL to handle smart pointers; add more tests. (PR #143786)
https://github.com/cmtice updated https://github.com/llvm/llvm-project/pull/143786 >From 837e8dd36446104b207248c9dbf372a6da6ffbf1 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Wed, 11 Jun 2025 14:24:17 -0700 Subject: [PATCH 1/2] [LLDB] Update DIL to handle smart pointers; add more tests. This updates the DIL implementation to handle smart pointers (accessing field members and dereferencing) in the same way the current 'frame variable' implementation does. It also adds tests for handling smart pointers, as well as some additional DIL tests. --- lldb/source/ValueObject/DILEval.cpp | 9 +++- .../frame/var-dil/basics/BitField/Makefile| 3 ++ .../BitField/TestFrameVarDILBitField.py | 38 .../frame/var-dil/basics/BitField/main.cpp| 44 +++ .../frame/var-dil/basics/Indirection/Makefile | 3 ++ .../Indirection/TestFrameVarDILIndirection.py | 36 +++ .../frame/var-dil/basics/Indirection/main.cpp | 14 ++ .../basics/PointerDereference/Makefile| 3 ++ .../TestFrameVarDILPointerDereference.py | 30 + .../basics/PointerDereference/main.cpp| 32 ++ .../frame/var-dil/basics/QualifiedId/Makefile | 3 ++ .../QualifiedId/TestFrameVarDILQualifiedId.py | 29 .../frame/var-dil/basics/QualifiedId/main.cpp | 18 .../frame/var-dil/basics/SharedPtr/Makefile | 6 +++ .../SharedPtr/TestFrameVarDILSharedPtr.py | 36 +++ .../TestFrameVarDILSharedPtrDeref.py | 29 .../frame/var-dil/basics/SharedPtr/main.cpp | 26 +++ .../frame/var-dil/basics/UniquePtr/Makefile | 6 +++ .../UniquePtr/TestFrameVarDILUniquePtr.py | 28 .../TestFrameVarDILUniquePtrDeref.py | 29 .../frame/var-dil/basics/UniquePtr/main.cpp | 25 +++ 21 files changed, 446 insertions(+), 1 deletion(-) create mode 100644 lldb/test/API/commands/frame/var-dil/basics/BitField/Makefile create mode 100644 lldb/test/API/commands/frame/var-dil/basics/BitField/TestFrameVarDILBitField.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/BitField/main.cpp create mode 100644 lldb/test/API/commands/frame/var-dil/basics/Indirection/Makefile create mode 100644 lldb/test/API/commands/frame/var-dil/basics/Indirection/TestFrameVarDILIndirection.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/Indirection/main.cpp create mode 100644 lldb/test/API/commands/frame/var-dil/basics/PointerDereference/Makefile create mode 100644 lldb/test/API/commands/frame/var-dil/basics/PointerDereference/TestFrameVarDILPointerDereference.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/PointerDereference/main.cpp create mode 100644 lldb/test/API/commands/frame/var-dil/basics/QualifiedId/Makefile create mode 100644 lldb/test/API/commands/frame/var-dil/basics/QualifiedId/TestFrameVarDILQualifiedId.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/QualifiedId/main.cpp create mode 100644 lldb/test/API/commands/frame/var-dil/basics/SharedPtr/Makefile create mode 100644 lldb/test/API/commands/frame/var-dil/basics/SharedPtr/TestFrameVarDILSharedPtr.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/SharedPtr/TestFrameVarDILSharedPtrDeref.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/SharedPtr/main.cpp create mode 100644 lldb/test/API/commands/frame/var-dil/basics/UniquePtr/Makefile create mode 100644 lldb/test/API/commands/frame/var-dil/basics/UniquePtr/TestFrameVarDILUniquePtr.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/UniquePtr/TestFrameVarDILUniquePtrDeref.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/UniquePtr/main.cpp diff --git a/lldb/source/ValueObject/DILEval.cpp b/lldb/source/ValueObject/DILEval.cpp index c8cb54aa18a93..adc34e25766b3 100644 --- a/lldb/source/ValueObject/DILEval.cpp +++ b/lldb/source/ValueObject/DILEval.cpp @@ -253,6 +253,12 @@ Interpreter::Visit(const UnaryOpNode *node) { rhs = dynamic_rhs; lldb::ValueObjectSP child_sp = rhs->Dereference(error); +if (!child_sp && m_use_synthetic) { + if (lldb::ValueObjectSP synth_obj_sp = rhs->GetSyntheticValue()) { +error.Clear(); +child_sp = synth_obj_sp->Dereference(error); + } +} if (error.Fail()) return llvm::make_error(m_expr, error.AsCString(), node->GetLocation()); @@ -280,6 +286,7 @@ Interpreter::Visit(const MemberOfNode *node) { auto base_or_err = Evaluate(node->GetBase()); if (!base_or_err) return base_or_err; + bool expr_is_ptr = node->GetIsArrow(); lldb::ValueObjectSP base = *base_or_err; // Perform some basic type & correctness checking. @@ -319,11 +326,11 @@ Interpreter::Visit(const MemberOfNode *node) { return llvm::make_error( m_expr, errMsg, node->GetLocation(
[Lldb-commits] [lldb] [LLDB] Update DIL to handle smart pointers; add more tests. (PR #143786)
https://github.com/cmtice updated https://github.com/llvm/llvm-project/pull/143786 >From 837e8dd36446104b207248c9dbf372a6da6ffbf1 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Wed, 11 Jun 2025 14:24:17 -0700 Subject: [PATCH 1/3] [LLDB] Update DIL to handle smart pointers; add more tests. This updates the DIL implementation to handle smart pointers (accessing field members and dereferencing) in the same way the current 'frame variable' implementation does. It also adds tests for handling smart pointers, as well as some additional DIL tests. --- lldb/source/ValueObject/DILEval.cpp | 9 +++- .../frame/var-dil/basics/BitField/Makefile| 3 ++ .../BitField/TestFrameVarDILBitField.py | 38 .../frame/var-dil/basics/BitField/main.cpp| 44 +++ .../frame/var-dil/basics/Indirection/Makefile | 3 ++ .../Indirection/TestFrameVarDILIndirection.py | 36 +++ .../frame/var-dil/basics/Indirection/main.cpp | 14 ++ .../basics/PointerDereference/Makefile| 3 ++ .../TestFrameVarDILPointerDereference.py | 30 + .../basics/PointerDereference/main.cpp| 32 ++ .../frame/var-dil/basics/QualifiedId/Makefile | 3 ++ .../QualifiedId/TestFrameVarDILQualifiedId.py | 29 .../frame/var-dil/basics/QualifiedId/main.cpp | 18 .../frame/var-dil/basics/SharedPtr/Makefile | 6 +++ .../SharedPtr/TestFrameVarDILSharedPtr.py | 36 +++ .../TestFrameVarDILSharedPtrDeref.py | 29 .../frame/var-dil/basics/SharedPtr/main.cpp | 26 +++ .../frame/var-dil/basics/UniquePtr/Makefile | 6 +++ .../UniquePtr/TestFrameVarDILUniquePtr.py | 28 .../TestFrameVarDILUniquePtrDeref.py | 29 .../frame/var-dil/basics/UniquePtr/main.cpp | 25 +++ 21 files changed, 446 insertions(+), 1 deletion(-) create mode 100644 lldb/test/API/commands/frame/var-dil/basics/BitField/Makefile create mode 100644 lldb/test/API/commands/frame/var-dil/basics/BitField/TestFrameVarDILBitField.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/BitField/main.cpp create mode 100644 lldb/test/API/commands/frame/var-dil/basics/Indirection/Makefile create mode 100644 lldb/test/API/commands/frame/var-dil/basics/Indirection/TestFrameVarDILIndirection.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/Indirection/main.cpp create mode 100644 lldb/test/API/commands/frame/var-dil/basics/PointerDereference/Makefile create mode 100644 lldb/test/API/commands/frame/var-dil/basics/PointerDereference/TestFrameVarDILPointerDereference.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/PointerDereference/main.cpp create mode 100644 lldb/test/API/commands/frame/var-dil/basics/QualifiedId/Makefile create mode 100644 lldb/test/API/commands/frame/var-dil/basics/QualifiedId/TestFrameVarDILQualifiedId.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/QualifiedId/main.cpp create mode 100644 lldb/test/API/commands/frame/var-dil/basics/SharedPtr/Makefile create mode 100644 lldb/test/API/commands/frame/var-dil/basics/SharedPtr/TestFrameVarDILSharedPtr.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/SharedPtr/TestFrameVarDILSharedPtrDeref.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/SharedPtr/main.cpp create mode 100644 lldb/test/API/commands/frame/var-dil/basics/UniquePtr/Makefile create mode 100644 lldb/test/API/commands/frame/var-dil/basics/UniquePtr/TestFrameVarDILUniquePtr.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/UniquePtr/TestFrameVarDILUniquePtrDeref.py create mode 100644 lldb/test/API/commands/frame/var-dil/basics/UniquePtr/main.cpp diff --git a/lldb/source/ValueObject/DILEval.cpp b/lldb/source/ValueObject/DILEval.cpp index c8cb54aa18a93..adc34e25766b3 100644 --- a/lldb/source/ValueObject/DILEval.cpp +++ b/lldb/source/ValueObject/DILEval.cpp @@ -253,6 +253,12 @@ Interpreter::Visit(const UnaryOpNode *node) { rhs = dynamic_rhs; lldb::ValueObjectSP child_sp = rhs->Dereference(error); +if (!child_sp && m_use_synthetic) { + if (lldb::ValueObjectSP synth_obj_sp = rhs->GetSyntheticValue()) { +error.Clear(); +child_sp = synth_obj_sp->Dereference(error); + } +} if (error.Fail()) return llvm::make_error(m_expr, error.AsCString(), node->GetLocation()); @@ -280,6 +286,7 @@ Interpreter::Visit(const MemberOfNode *node) { auto base_or_err = Evaluate(node->GetBase()); if (!base_or_err) return base_or_err; + bool expr_is_ptr = node->GetIsArrow(); lldb::ValueObjectSP base = *base_or_err; // Perform some basic type & correctness checking. @@ -319,11 +326,11 @@ Interpreter::Visit(const MemberOfNode *node) { return llvm::make_error( m_expr, errMsg, node->GetLocation(
[Lldb-commits] [lldb] [LLDB] Consolidate C++ string buffer summaries (PR #144258)
https://github.com/Nerixyz created https://github.com/llvm/llvm-project/pull/144258 As part of https://github.com/llvm/llvm-project/pull/143177, I moved the non-libc++ specific formatting of `std::string`s out to `CxxStringTypes` as MSVC's STL `std::string` can also be thought of a pointer+size pair. I named this kind of string "string buffer". This PR picks that change, so the MSVC PR can be smaller. Unfortunately, libstdc++'s `std::string` does not fit this (it also uses a different string printer function). This resolves two FIXMEs in the libc++ tests, where empty u16 and u32 strings didn't have any prefix (u/U). >From 1d74dd1c8d8d768b7ddc22a368be164450362e5e Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Sun, 15 Jun 2025 12:23:27 +0200 Subject: [PATCH] [LLDB] Consolidate C++ string buffer summaries --- .../Language/CPlusPlus/CxxStringTypes.cpp | 105 ++--- .../Language/CPlusPlus/CxxStringTypes.h | 12 ++ .../Plugins/Language/CPlusPlus/LibCxx.cpp | 147 -- .../string/TestDataFormatterLibcxxString.py | 8 +- .../TestDataFormatterLibcxxStringView.py | 8 +- 5 files changed, 134 insertions(+), 146 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp index fc17b76804d9f..4e7569cd8a388 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp @@ -116,15 +116,7 @@ bool lldb_private::formatters::WCharStringSummaryProvider( return false; // Get a wchar_t basic type from the current type system - CompilerType wchar_compiler_type = - valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar); - - if (!wchar_compiler_type) -return false; - - // Safe to pass nullptr for exe_scope here. - std::optional size = - llvm::expectedToOptional(wchar_compiler_type.GetBitSize(nullptr)); + std::optional size = GetWCharByteSize(*valobj.GetTargetSP()); if (!size) return false; const uint32_t wchar_size = *size; @@ -136,13 +128,13 @@ bool lldb_private::formatters::WCharStringSummaryProvider( options.SetPrefixToken("L"); switch (wchar_size) { - case 8: + case 1: return StringPrinter::ReadStringAndDumpToStream( options); - case 16: + case 2: return StringPrinter::ReadStringAndDumpToStream( options); - case 32: + case 4: return StringPrinter::ReadStringAndDumpToStream( options); default: @@ -177,15 +169,7 @@ bool lldb_private::formatters::WCharSummaryProvider( return false; // Get a wchar_t basic type from the current type system - CompilerType wchar_compiler_type = - valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar); - - if (!wchar_compiler_type) -return false; - -// Safe to pass nullptr for exe_scope here. - std::optional size = - llvm::expectedToOptional(wchar_compiler_type.GetBitSize(nullptr)); + std::optional size = GetWCharByteSize(*valobj.GetTargetSP()); if (!size) return false; const uint32_t wchar_size = *size; @@ -199,13 +183,13 @@ bool lldb_private::formatters::WCharSummaryProvider( options.SetBinaryZeroIsTerminator(false); switch (wchar_size) { - case 8: + case 1: return StringPrinter::ReadBufferAndDumpToStream( options); - case 16: + case 2: return StringPrinter::ReadBufferAndDumpToStream( options); - case 32: + case 4: return StringPrinter::ReadBufferAndDumpToStream( options); default: @@ -214,3 +198,76 @@ bool lldb_private::formatters::WCharSummaryProvider( } return true; } + +std::optional +lldb_private::formatters::GetWCharByteSize(Target &target) { + TypeSystemClangSP scratch_ts_sp = + ScratchTypeSystemClang::GetForTarget(target); + if (!scratch_ts_sp) +return {}; + + return llvm::expectedToOptional( + scratch_ts_sp->GetBasicType(lldb::eBasicTypeWChar).GetByteSize(nullptr)); +} + +template +bool lldb_private::formatters::StringBufferSummaryProvider( +Stream &stream, const TypeSummaryOptions &summary_options, +lldb::ValueObjectSP location_sp, uint64_t size, std::string prefix_token) { + + if (size == 0) { +stream.PutCString(prefix_token); +stream.PutCString("\"\""); +return true; + } + + if (!location_sp) +return false; + + StringPrinter::ReadBufferAndDumpToStreamOptions options(*location_sp); + + if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) { +const auto max_size = +location_sp->GetTargetSP()->GetMaximumSizeOfStringSummary(); +if (size > max_size) { + size = max_size; + options.SetIsTruncated(true); +} + } + + { +DataExtractor extractor; +const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size); +if (bytes_read < size) + return false; + +options.SetData(std::move(extractor)); + } + options.SetStream(&stream);
[Lldb-commits] [lldb] [LLDB] Consolidate C++ string buffer summaries (PR #144258)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: nerix (Nerixyz) Changes As part of https://github.com/llvm/llvm-project/pull/143177, I moved the non-libc++ specific formatting of `std::string`s out to `CxxStringTypes` as MSVC's STL `std::string` can also be thought of a pointer+size pair. I named this kind of string "string buffer". This PR picks that change, so the MSVC PR can be smaller. Unfortunately, libstdc++'s `std::string` does not fit this (it also uses a different string printer function). This resolves two FIXMEs in the libc++ tests, where empty u16 and u32 strings didn't have any prefix (u/U). --- Full diff: https://github.com/llvm/llvm-project/pull/144258.diff 5 Files Affected: - (modified) lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp (+81-24) - (modified) lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.h (+12) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp (+34-113) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py (+3-5) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py (+4-4) ``diff diff --git a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp index fc17b76804d9f..4e7569cd8a388 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp @@ -116,15 +116,7 @@ bool lldb_private::formatters::WCharStringSummaryProvider( return false; // Get a wchar_t basic type from the current type system - CompilerType wchar_compiler_type = - valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar); - - if (!wchar_compiler_type) -return false; - - // Safe to pass nullptr for exe_scope here. - std::optional size = - llvm::expectedToOptional(wchar_compiler_type.GetBitSize(nullptr)); + std::optional size = GetWCharByteSize(*valobj.GetTargetSP()); if (!size) return false; const uint32_t wchar_size = *size; @@ -136,13 +128,13 @@ bool lldb_private::formatters::WCharStringSummaryProvider( options.SetPrefixToken("L"); switch (wchar_size) { - case 8: + case 1: return StringPrinter::ReadStringAndDumpToStream( options); - case 16: + case 2: return StringPrinter::ReadStringAndDumpToStream( options); - case 32: + case 4: return StringPrinter::ReadStringAndDumpToStream( options); default: @@ -177,15 +169,7 @@ bool lldb_private::formatters::WCharSummaryProvider( return false; // Get a wchar_t basic type from the current type system - CompilerType wchar_compiler_type = - valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar); - - if (!wchar_compiler_type) -return false; - -// Safe to pass nullptr for exe_scope here. - std::optional size = - llvm::expectedToOptional(wchar_compiler_type.GetBitSize(nullptr)); + std::optional size = GetWCharByteSize(*valobj.GetTargetSP()); if (!size) return false; const uint32_t wchar_size = *size; @@ -199,13 +183,13 @@ bool lldb_private::formatters::WCharSummaryProvider( options.SetBinaryZeroIsTerminator(false); switch (wchar_size) { - case 8: + case 1: return StringPrinter::ReadBufferAndDumpToStream( options); - case 16: + case 2: return StringPrinter::ReadBufferAndDumpToStream( options); - case 32: + case 4: return StringPrinter::ReadBufferAndDumpToStream( options); default: @@ -214,3 +198,76 @@ bool lldb_private::formatters::WCharSummaryProvider( } return true; } + +std::optional +lldb_private::formatters::GetWCharByteSize(Target &target) { + TypeSystemClangSP scratch_ts_sp = + ScratchTypeSystemClang::GetForTarget(target); + if (!scratch_ts_sp) +return {}; + + return llvm::expectedToOptional( + scratch_ts_sp->GetBasicType(lldb::eBasicTypeWChar).GetByteSize(nullptr)); +} + +template +bool lldb_private::formatters::StringBufferSummaryProvider( +Stream &stream, const TypeSummaryOptions &summary_options, +lldb::ValueObjectSP location_sp, uint64_t size, std::string prefix_token) { + + if (size == 0) { +stream.PutCString(prefix_token); +stream.PutCString("\"\""); +return true; + } + + if (!location_sp) +return false; + + StringPrinter::ReadBufferAndDumpToStreamOptions options(*location_sp); + + if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) { +const auto max_size = +location_sp->GetTargetSP()->GetMaximumSizeOfStringSummary(); +if (size > max_size) { + size = max_size; + options.SetIsTruncated(true); +} + } + + { +DataExtractor extractor; +const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size); +if (bytes_read < size) + return false; + +options.SetData(std:
[Lldb-commits] [lldb] [lldb] add plugin names to process save-core error output. (PR #143126)
da-viper wrote: >How about you remove the completion parts from this PR and tackle that topic >in another PR. Dropped all completion related changes. https://github.com/llvm/llvm-project/pull/143126 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add plugin names to process save-core error output. (PR #143126)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/143126 >From fc849bd4e831f9dc6f53be3a8508e1eb33f4151c Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Fri, 6 Jun 2025 13:15:41 +0100 Subject: [PATCH] [lldb] add plugin names to process save-core error output. show the plugin names in when running `help plugin save-core` --- lldb/include/lldb/Core/PluginManager.h| 2 ++ lldb/source/Commands/CommandObjectProcess.cpp | 24 - lldb/source/Core/PluginManager.cpp| 27 +++ lldb/source/Symbol/SaveCoreOptions.cpp| 17 +--- .../process_save_core/TestProcessSaveCore.py | 7 + ...ommand-process-save-core-not-a-plugin.test | 2 +- 6 files changed, 69 insertions(+), 10 deletions(-) diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h index e7b169103..0e917025ba41e 100644 --- a/lldb/include/lldb/Core/PluginManager.h +++ b/lldb/include/lldb/Core/PluginManager.h @@ -270,6 +270,8 @@ class PluginManager { static Status SaveCore(const lldb::ProcessSP &process_sp, lldb_private::SaveCoreOptions &core_options); + static std::vector GetSaveCorePluginNames(); + // ObjectContainer static bool RegisterPlugin( llvm::StringRef name, llvm::StringRef description, diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index b1f243c9e2777..0a1744277d7dc 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -1281,7 +1281,27 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed { ~CommandOptions() override = default; llvm::ArrayRef GetDefinitions() override { - return llvm::ArrayRef(g_process_save_core_options); + if (!m_opt_def.empty()) +return llvm::ArrayRef(m_opt_def); + + auto orig = llvm::ArrayRef(g_process_save_core_options); + m_opt_def.resize(orig.size()); + llvm::copy(g_process_save_core_options, m_opt_def.data()); + for (OptionDefinition &value : m_opt_def) { +llvm::StringRef opt_name = value.long_option; +if (opt_name != "plugin-name") + continue; + +std::vector plugin_names = +PluginManager::GetSaveCorePluginNames(); +m_plugin_enums.resize(plugin_names.size()); +for (auto [num, val] : llvm::zip(plugin_names, m_plugin_enums)) { + val.string_value = num.data(); +} +value.enum_values = llvm::ArrayRef(m_plugin_enums); +break; + } + return llvm::ArrayRef(m_opt_def); } Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, @@ -1312,6 +1332,8 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed { // Instance variables to hold the values for command options. SaveCoreOptions m_core_dump_options; +llvm::SmallVector m_plugin_enums; +std::vector m_opt_def; }; protected: diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp index 5d44434033c55..94d66f0f929cd 100644 --- a/lldb/source/Core/PluginManager.cpp +++ b/lldb/source/Core/PluginManager.cpp @@ -843,11 +843,28 @@ Status PluginManager::SaveCore(const lldb::ProcessSP &process_sp, } // Check to see if any of the object file plugins tried and failed to save. - // If none ran, set the error message. - if (error.Success()) -error = Status::FromErrorString( -"no ObjectFile plugins were able to save a core for this process"); - return error; + // if any failure, return the error message. + if (error.Fail()) +return error; + + // Report only for the plugin that was specified. + if (!plugin_name.empty()) +return Status::FromErrorStringWithFormatv( +"The \"{}\" plugin is not able to save a core for this process.", +plugin_name); + + return Status::FromErrorString( + "no ObjectFile plugins were able to save a core for this process"); +} + +std::vector PluginManager::GetSaveCorePluginNames() { + std::vector plugin_names; + auto instances = GetObjectFileInstances().GetSnapshot(); + for (auto &instance : instances) { +if (instance.save_core) + plugin_names.emplace_back(instance.name); + } + return plugin_names; } #pragma mark ObjectContainer diff --git a/lldb/source/Symbol/SaveCoreOptions.cpp b/lldb/source/Symbol/SaveCoreOptions.cpp index d884b00a47b00..0f9dbb73c1721 100644 --- a/lldb/source/Symbol/SaveCoreOptions.cpp +++ b/lldb/source/Symbol/SaveCoreOptions.cpp @@ -21,9 +21,20 @@ Status SaveCoreOptions::SetPluginName(const char *name) { return error; } - if (!PluginManager::IsRegisteredObjectFilePluginName(name)) { -return Status::FromErrorStringWithFormat( -"plugin name '%s' is not a valid ObjectFile plugin name", name); + std::vector plugin_names = + PluginManager::GetSaveCorePluginNames(); + if (llvm::find(plugin_names, na