[Lldb-commits] [lldb] [lldb][DataFormatter] Surface CalculateNumChildren errors in std::vector summary (PR #135944)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes When the data-formatters happen to break (e.g., due to layout changes in libc++), there's no clear indicator of them failing from a user's perspective. E.g., for `std::vector`s we would just show: ``` (std::vector) v = size=0 {} ``` which is highly misleading, especially if `v.size()` returns a non-zero size. This patch surfaces the various errors that could occur when calculating the number of children of a vector. rdar://146964266 --- Full diff: https://github.com/llvm/llvm-project/pull/135944.diff 5 Files Affected: - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp (+16-5) - (modified) lldb/source/ValueObject/ValueObject.cpp (+9-3) - (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile (+3) - (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py (+35) - (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/main.cpp (+26) ``diff diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp index d538cac9f9134..ce2261b6f03c3 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp @@ -83,19 +83,30 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd:: llvm::Expected lldb_private::formatters:: LibcxxStdVectorSyntheticFrontEnd::CalculateNumChildren() { if (!m_start || !m_finish) -return 0; +return llvm::createStringError( +"Failed to determine start/end of vector data."); + uint64_t start_val = m_start->GetValueAsUnsigned(0); uint64_t finish_val = m_finish->GetValueAsUnsigned(0); - if (start_val == 0 || finish_val == 0) + // A default-initialized empty vector. + if (start_val == 0 && finish_val == 0) return 0; - if (start_val >= finish_val) -return 0; + if (start_val == 0) +return llvm::createStringError("Invalid value for start of vector."); + + if (finish_val == 0) +return llvm::createStringError("Invalid value for end of vector."); + + if (start_val > finish_val) +return llvm::createStringError( +"Start of vector data begins after end pointer."); size_t num_children = (finish_val - start_val); if (num_children % m_element_size) -return 0; +return llvm::createStringError("Size not multiple of element size."); + return num_children / m_element_size; } diff --git a/lldb/source/ValueObject/ValueObject.cpp b/lldb/source/ValueObject/ValueObject.cpp index eac24353de90b..8741cb7343166 100644 --- a/lldb/source/ValueObject/ValueObject.cpp +++ b/lldb/source/ValueObject/ValueObject.cpp @@ -1521,10 +1521,16 @@ bool ValueObject::DumpPrintableRepresentation( str = GetLocationAsCString(); break; -case eValueObjectRepresentationStyleChildrenCount: - strm.Printf("%" PRIu64 "", (uint64_t)GetNumChildrenIgnoringErrors()); - str = strm.GetString(); +case eValueObjectRepresentationStyleChildrenCount: { + if (auto err = GetNumChildren()) { +strm.Printf("%" PRIu32, *err); +str = strm.GetString(); + } else { +strm << "error: " << toString(err.takeError()); +str = strm.GetString(); + } break; +} case eValueObjectRepresentationStyleType: str = GetTypeName().GetStringRef(); diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile new file mode 100644 index 0..38cfa81053488 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp +override CXXFLAGS_EXTRAS += -std=c++14 +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py new file mode 100644 index 0..6986d71c37a8b --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py @@ -0,0 +1,35 @@ +""" +Test we can understand various layouts of the libc++'s std::string +""" + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil +import functools + + +class LibcxxInvalidVectorDataFormatterSimulatorTestCase(TestBase): +NO_DEBUG_INFO_TEST
[Lldb-commits] [lldb] [lldb][DataFormatter] Surface CalculateNumChildren errors in std::vector summary (PR #135944)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/135944 When the data-formatters happen to break (e.g., due to layout changes in libc++), there's no clear indicator of them failing from a user's perspective. E.g., for `std::vector`s we would just show: ``` (std::vector) v = size=0 {} ``` which is highly misleading, especially if `v.size()` returns a non-zero size. This patch surfaces the various errors that could occur when calculating the number of children of a vector. rdar://146964266 >From 28ffd29ac558c8eb3ec8b3305480f237c822b4fd Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 16 Apr 2025 11:46:29 +0200 Subject: [PATCH] [lldb][DataFormatter] Surface CalculateNumChildren errors in std::vector summary When the data-formatters happen to break (e.g., due to layout changes in libc++), there's no clear indicator of them failing from a user's perspective. We just show: ``` (std::vector) v = size=0 {} ``` which is highly misleading, especially if `v.size()` returns a non-zero size. This patch surfaces the various errors that could occur when calculating the number of children of a vector. --- .../Language/CPlusPlus/LibCxxVector.cpp | 21 --- lldb/source/ValueObject/ValueObject.cpp | 12 +-- .../libcxx-simulators/invalid-vector/Makefile | 3 ++ ...taFormatterLibcxxInvalidVectorSimulator.py | 35 +++ .../libcxx-simulators/invalid-vector/main.cpp | 26 ++ 5 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/main.cpp diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp index d538cac9f9134..ce2261b6f03c3 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp @@ -83,19 +83,30 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd:: llvm::Expected lldb_private::formatters:: LibcxxStdVectorSyntheticFrontEnd::CalculateNumChildren() { if (!m_start || !m_finish) -return 0; +return llvm::createStringError( +"Failed to determine start/end of vector data."); + uint64_t start_val = m_start->GetValueAsUnsigned(0); uint64_t finish_val = m_finish->GetValueAsUnsigned(0); - if (start_val == 0 || finish_val == 0) + // A default-initialized empty vector. + if (start_val == 0 && finish_val == 0) return 0; - if (start_val >= finish_val) -return 0; + if (start_val == 0) +return llvm::createStringError("Invalid value for start of vector."); + + if (finish_val == 0) +return llvm::createStringError("Invalid value for end of vector."); + + if (start_val > finish_val) +return llvm::createStringError( +"Start of vector data begins after end pointer."); size_t num_children = (finish_val - start_val); if (num_children % m_element_size) -return 0; +return llvm::createStringError("Size not multiple of element size."); + return num_children / m_element_size; } diff --git a/lldb/source/ValueObject/ValueObject.cpp b/lldb/source/ValueObject/ValueObject.cpp index eac24353de90b..8741cb7343166 100644 --- a/lldb/source/ValueObject/ValueObject.cpp +++ b/lldb/source/ValueObject/ValueObject.cpp @@ -1521,10 +1521,16 @@ bool ValueObject::DumpPrintableRepresentation( str = GetLocationAsCString(); break; -case eValueObjectRepresentationStyleChildrenCount: - strm.Printf("%" PRIu64 "", (uint64_t)GetNumChildrenIgnoringErrors()); - str = strm.GetString(); +case eValueObjectRepresentationStyleChildrenCount: { + if (auto err = GetNumChildren()) { +strm.Printf("%" PRIu32, *err); +str = strm.GetString(); + } else { +strm << "error: " << toString(err.takeError()); +str = strm.GetString(); + } break; +} case eValueObjectRepresentationStyleType: str = GetTypeName().GetStringRef(); diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile new file mode 100644 index 0..38cfa81053488 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp +override CXXFLAGS_EXTRAS += -std=c++14 +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataForma
[Lldb-commits] [lldb] [lldb] Fix deadlock between statusline and output mutex (PR #135956)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes Fix a deadlock between the statusline mutex (in Debugger) and the output file mutex (in LockedStreamFile). The deadlock occurs when the main thread is calling the statusline callback while holding the output mutex in Editline, while the default event thread is trying to update the stausline. rdar://149251156 --- Full diff: https://github.com/llvm/llvm-project/pull/135956.diff 1 Files Affected: - (modified) lldb/source/Host/common/Editline.cpp (+4-1) ``diff diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index 29abaf7c65f28..6900da9909eb8 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/source/Host/common/Editline.cpp @@ -567,8 +567,11 @@ int Editline::GetCharacter(EditLineGetCharType *c) { m_needs_prompt_repaint = false; } - if (m_redraw_callback) + if (m_redraw_callback) { +m_locked_output.reset(); m_redraw_callback(); +m_locked_output.emplace(m_output_stream_sp->Lock()); + } if (m_multiline_enabled) { // Detect when the number of rows used for this input line changes due to `` https://github.com/llvm/llvm-project/pull/135956 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix deadlock between statusline and output mutex (PR #135956)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/135956 Fix a deadlock between the statusline mutex (in Debugger) and the output file mutex (in LockedStreamFile). The deadlock occurs when the main thread is calling the statusline callback while holding the output mutex in Editline, while the default event thread is trying to update the stausline. rdar://149251156 >From 59e80e36a07922684dba14f421bca3176a6b5a13 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 16 Apr 2025 14:29:27 +0200 Subject: [PATCH] [lldb] Fix deadlock between statusline and output mutex Fix a deadlock between the statusline mutex (in Debugger) and the output file mutex (in LockedStreamFile). The deadlock occurs when the main thread is calling the statusline callback while holding the output mutex in Editline, while the default event thread is trying to update the stausline. rdar://149251156 --- lldb/source/Host/common/Editline.cpp | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index 29abaf7c65f28..6900da9909eb8 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/source/Host/common/Editline.cpp @@ -567,8 +567,11 @@ int Editline::GetCharacter(EditLineGetCharType *c) { m_needs_prompt_repaint = false; } - if (m_redraw_callback) + if (m_redraw_callback) { +m_locked_output.reset(); m_redraw_callback(); +m_locked_output.emplace(m_output_stream_sp->Lock()); + } if (m_multiline_enabled) { // Detect when the number of rows used for this input line changes due to ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add summary for NSIndirectTaggedPointerString (PR #136025)
@@ -368,3 +373,37 @@ bool lldb_private::formatters::NSTaggedString_SummaryProvider( stream << suffix; return true; } + +bool lldb_private::formatters::NSIndirectTaggedString_SummaryProvider( +ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, +Stream &stream, const TypeSummaryOptions &summary_options) { + if (!descriptor) +return false; + + uint64_t payload = 0; + if (!descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) +return false; + + // First 47 bits are the address of the contents. + addr_t ptr = payload & 0x7fffULL; + // Next 13 bits are the string's length. + size_t size = (payload >> 47) & 0x1fff; + + Status status; + std::vector buf(size); + if (auto process_sp = valobj.GetProcessSP()) +if (process_sp->ReadMemory(ptr, buf.data(), size, status)) { + llvm::StringRef prefix, suffix; + if (auto *language = Language::FindPlugin(summary_options.GetLanguage())) +std::tie(prefix, suffix) = +language->GetFormatterPrefixSuffix("NSString"); + stream << prefix << '"'; + stream.PutCString({buf.data(), size}); kastiglione wrote: > or does it copy `size` bytes (which would be faster). It does the faster option. https://github.com/llvm/llvm-project/pull/136025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add summary for NSIndirectTaggedPointerString (PR #136025)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/136025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Mach-O corefiles] Don't init Target arch to corefile (PR #136065)
https://github.com/jasonmolenda created https://github.com/llvm/llvm-project/pull/136065 This patch is making three changes, when loading a Mach-O corefile: 1. At the start of `DoLoadCore`, if a binary was provided in addition to the corefile, initialize the Target's ArchSpec. 2. Before ProcessMachCore does its "exhaustive search" fallback, looking through the corefile contents for a userland dyld or mach kernel, we must make sure the Target has an ArchSpec, or methods that check the address word size, or initialize a DataExtractor based on the Target arch will not succeed. 3. Add logging when setting the Target's arch listing exactly what that setting was based on -- the corefile itself, or the main binary. Jonas landed a change last August (started with a patch from me) which removed the Target ArchSpec initialization at the start of DoLoadCore, in a scenario where the corefile had arch armv7 and the main binary had arch armv7em (Cortex-M), and there was python code in the main binary's dSYM which sets the operating system threads provider based on the Target arch. It did different things for armv7 or armv7em, and so it would fail. Jonas' patch removed any ArchSpec setting at the start of DoLoadCore, so we wouldn't have an incorrect arch value, but that broke the exhaustive search for kernel binaries, because we didn't have an address word size or endianness. This patch should navigate the needs of both use cases. I spent a good bit of time trying to construct a test to capture all of these requirements -- but it turns out to be a good bit difficult, encompassing both a genuine kernel corefiles and a microcontroller firmware corefiles. rdar://146821929 >From 41274f7632d13ab7ec83a420c6ad6258e6fe8c36 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Wed, 16 Apr 2025 17:18:02 -0700 Subject: [PATCH] [lldb][Mach-O corefiles] Don't init Target arch to corefile This patch is making three changes, when loading a Mach-O corefile: 1. At the start of `DoLoadCore`, if a binary was provided in addition to the corefile, initialize the Target's ArchSpec. 2. Before ProcessMachCore does its "exhaustive search" fallback, looking through the corefile contents for a userland dyld or mach kernel, we must make sure the Target has an ArchSpec, or methods that check the address word size, or initialize a DataExtractor based on the Target arch will not succeed. 3. Add logging when setting the Target's arch listing exactly what that setting was based on -- the corefile itself, or the main binary. Jonas landed a change last August (started with a patch from me) which removed the Target ArchSpec initialization at the start of DoLoadCore, in a scenario where the corefile had arch armv7 and the main binary had arch armv7em (Cortex-M), and there was python code in the main binary's dSYM which sets the operating system threads provider based on the Target arch. It did different things for armv7 or armv7em, and so it would fail. Jonas' patch removed any ArchSpec setting at the start of DoLoadCore, so we wouldn't have an incorrect arch value, but that broke the exhaustive search for kernel binaries, because we didn't have an address word size or endianness. This patch should navigate the needs of both use cases. I spent a good bit of time trying to construct a test to capture all of these requirements -- but it turns out to be a good bit difficult, encompassing both a genuine kernel corefiles and a microcontroller firmware corefiles. rdar://146821929 --- .../Process/mach-core/ProcessMachCore.cpp | 58 ++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp index 281f3a0db8f69..17362b2d2855d 100644 --- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp +++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp @@ -426,6 +426,32 @@ void ProcessMachCore::LoadBinariesViaExhaustiveSearch() { std::vector dylds_found; std::vector kernels_found; + // To do an exhaustive search, we'll need to create data extractors + // to get correctly sized/endianness fields, and if the Target still + // doesn't have an architecture set, we need to seed it from either + // the main binary (if we were given one) or the corefile cputype/cpusubtype. + if (!GetTarget().GetArchitecture().IsValid()) { +Log *log(GetLog(LLDBLog::DynamicLoader | LLDBLog::Target)); +ModuleSP exe_module_sp = GetTarget().GetExecutableModule(); +if (exe_module_sp && exe_module_sp->GetArchitecture().IsValid()) { + LLDB_LOGF(log, +"ProcessMachCore::%s: Was given binary + corefile, setting " +"target ArchSpec to binary to start", +__FUNCTION__); + GetTarget().SetArchitecture(exe_module_sp->GetArchitecture()); +} else { + // The corefile's architecture is our best starting point. + ArchSpec arch(m_c
[Lldb-commits] [lldb] 18855ec - [lldb] Add summary for NSIndirectTaggedPointerString (#136025)
Author: Dave Lee Date: 2025-04-16T17:31:01-07:00 New Revision: 18855ece3c34a0d76a2126538d60760ddeee2de8 URL: https://github.com/llvm/llvm-project/commit/18855ece3c34a0d76a2126538d60760ddeee2de8 DIFF: https://github.com/llvm/llvm-project/commit/18855ece3c34a0d76a2126538d60760ddeee2de8.diff LOG: [lldb] Add summary for NSIndirectTaggedPointerString (#136025) rdar://143164164 Added: lldb/test/API/lang/objc/foundation/tagged/strings/Makefile lldb/test/API/lang/objc/foundation/tagged/strings/TestObjCTaggedStrings.py lldb/test/API/lang/objc/foundation/tagged/strings/main.m Modified: lldb/source/Plugins/Language/ObjC/NSString.cpp lldb/source/Plugins/Language/ObjC/NSString.h lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp Removed: diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp index a99d042572bfe..2626b9a3f7b8a 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp @@ -63,12 +63,17 @@ bool lldb_private::formatters::NSStringSummaryProvider( if (class_name.empty()) return false; - bool is_tagged_ptr = class_name == "NSTaggedPointerString" && - descriptor->GetTaggedPointerInfo(); - // for a tagged pointer, the descriptor has everything we need - if (is_tagged_ptr) -return NSTaggedString_SummaryProvider(valobj, descriptor, stream, - summary_options); + // For tagged pointers, the descriptor has everything needed. + bool is_tagged = descriptor->GetTaggedPointerInfo(); + if (is_tagged) { +if (class_name == "NSTaggedPointerString") + return NSTaggedString_SummaryProvider(valobj, descriptor, stream, +summary_options); + +if (class_name == "NSIndirectTaggedPointerString") + return NSIndirectTaggedString_SummaryProvider(valobj, descriptor, stream, +summary_options); + } auto &additionals_map(NSString_Additionals::GetAdditionalSummaries()); auto iter = additionals_map.find(class_name_cs), end = additionals_map.end(); @@ -368,3 +373,37 @@ bool lldb_private::formatters::NSTaggedString_SummaryProvider( stream << suffix; return true; } + +bool lldb_private::formatters::NSIndirectTaggedString_SummaryProvider( +ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, +Stream &stream, const TypeSummaryOptions &summary_options) { + if (!descriptor) +return false; + + uint64_t payload = 0; + if (!descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) +return false; + + // First 47 bits are the address of the contents. + addr_t ptr = payload & 0x7fffULL; + // Next 13 bits are the string's length. + size_t size = (payload >> 47) & 0x1fff; + + Status status; + std::vector buf(size); + if (auto process_sp = valobj.GetProcessSP()) +if (process_sp->ReadMemory(ptr, buf.data(), size, status)) { + llvm::StringRef prefix, suffix; + if (auto *language = Language::FindPlugin(summary_options.GetLanguage())) +std::tie(prefix, suffix) = +language->GetFormatterPrefixSuffix("NSString"); + stream << prefix << '"'; + stream.PutCString({buf.data(), size}); + stream << '"' << suffix; + return true; +} + + if (status.Fail()) +stream.Format("<{0}>", status); + return false; +} diff --git a/lldb/source/Plugins/Language/ObjC/NSString.h b/lldb/source/Plugins/Language/ObjC/NSString.h index 8c9fcf955f1f8..5d405b30b6817 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.h +++ b/lldb/source/Plugins/Language/ObjC/NSString.h @@ -25,6 +25,10 @@ bool NSTaggedString_SummaryProvider( ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, Stream &stream, const TypeSummaryOptions &summary_options); +bool NSIndirectTaggedString_SummaryProvider( +ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, +Stream &stream, const TypeSummaryOptions &summary_options); + bool NSAttributedStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options); diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp index c835b439a64dd..3b8e21cbb9269 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -691,6 +691,10 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) { AddCXXSummary( objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", "NSTaggedPointerString", appkit_flags); + AddCXXSummary(objc_category_sp, +lldb_private::formatters::NSStringSummaryProvider
[Lldb-commits] [lldb] [lldb] Add summary for NSIndirectTaggedPointerString (PR #136025)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Dave Lee (kastiglione) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/136025.diff 3 Files Affected: - (modified) lldb/source/Plugins/Language/ObjC/NSString.cpp (+45-6) - (modified) lldb/source/Plugins/Language/ObjC/NSString.h (+4) - (modified) lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp (+4) ``diff diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp index a99d042572bfe..11b4c6c5df8af 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp @@ -63,12 +63,17 @@ bool lldb_private::formatters::NSStringSummaryProvider( if (class_name.empty()) return false; - bool is_tagged_ptr = class_name == "NSTaggedPointerString" && - descriptor->GetTaggedPointerInfo(); - // for a tagged pointer, the descriptor has everything we need - if (is_tagged_ptr) -return NSTaggedString_SummaryProvider(valobj, descriptor, stream, - summary_options); + // for tagged pointers, the descriptor has everything needed. + bool is_tagged = descriptor->GetTaggedPointerInfo(); + if (is_tagged) { +if (class_name == "NSTaggedPointerString") + return NSTaggedString_SummaryProvider(valobj, descriptor, stream, +summary_options); + +if (class_name == "NSIndirectTaggedPointerString") + return NSIndirectTaggedString_SummaryProvider(valobj, descriptor, stream, +summary_options); + } auto &additionals_map(NSString_Additionals::GetAdditionalSummaries()); auto iter = additionals_map.find(class_name_cs), end = additionals_map.end(); @@ -368,3 +373,37 @@ bool lldb_private::formatters::NSTaggedString_SummaryProvider( stream << suffix; return true; } + +bool lldb_private::formatters::NSIndirectTaggedString_SummaryProvider( +ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, +Stream &stream, const TypeSummaryOptions &summary_options) { + if (!descriptor) +return false; + + uint64_t payload = 0; + if (!descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) +return false; + + // First 47 bits are the address of the contents. + addr_t ptr = payload & 0x7fffULL; + // Next 13 bits are the string's length. + size_t size = (payload >> 47) & 0x1fff; + + Status status; + char buf[8192]; + if (auto process_sp = valobj.GetProcessSP()) +if (process_sp->ReadMemory(ptr, buf, size, status)) { + llvm::StringRef prefix, suffix; + if (auto *language = Language::FindPlugin(summary_options.GetLanguage())) +std::tie(prefix, suffix) = +language->GetFormatterPrefixSuffix("NSString"); + stream << prefix << '"'; + stream.PutCString({buf, size}); + stream << '"' << suffix; + return true; +} + + if (status.Fail()) +stream.Format("<{0}>", status); + return false; +} diff --git a/lldb/source/Plugins/Language/ObjC/NSString.h b/lldb/source/Plugins/Language/ObjC/NSString.h index 8c9fcf955f1f8..5d405b30b6817 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.h +++ b/lldb/source/Plugins/Language/ObjC/NSString.h @@ -25,6 +25,10 @@ bool NSTaggedString_SummaryProvider( ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, Stream &stream, const TypeSummaryOptions &summary_options); +bool NSIndirectTaggedString_SummaryProvider( +ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, +Stream &stream, const TypeSummaryOptions &summary_options); + bool NSAttributedStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options); diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp index c835b439a64dd..3b8e21cbb9269 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -691,6 +691,10 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) { AddCXXSummary( objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", "NSTaggedPointerString", appkit_flags); + AddCXXSummary(objc_category_sp, +lldb_private::formatters::NSStringSummaryProvider, +"NSString summary provider", "NSIndirectTaggedPointerString", +appkit_flags); AddCXXSummary(objc_category_sp, lldb_private::formatters::NSAttributedStringSummaryProvider, `` https://github.com/llvm/llvm-project/pull/136025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] Test "Revert "[CI] monolithic-linux improvements"" (PR #136078)
https://github.com/boomanaiden154 closed https://github.com/llvm/llvm-project/pull/136078 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] Test "Revert "[CI] monolithic-linux improvements"" (PR #136078)
boomanaiden154 wrote: Subsumed by 1fd7e4c517141ddfb527e7560e02fd5856244971. https://github.com/llvm/llvm-project/pull/136078 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [CI] monolithic-linux improvements (PR #135499)
boomanaiden154 wrote: When relanding it would probably be helpful to land individual improvements in separate patches rather than bundling them all together. https://github.com/llvm/llvm-project/pull/135499 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 183cb45 - [lldb-dap] Fixing a race during disconnect. (#135872)
Author: John Harrison Date: 2025-04-16T07:52:16-07:00 New Revision: 183cb45c1280b80a0022649d1db8a93544bb97b0 URL: https://github.com/llvm/llvm-project/commit/183cb45c1280b80a0022649d1db8a93544bb97b0 DIFF: https://github.com/llvm/llvm-project/commit/183cb45c1280b80a0022649d1db8a93544bb97b0.diff LOG: [lldb-dap] Fixing a race during disconnect. (#135872) While attempting to disconnect the DAP transport reader thread is setting `disconnecting` as soon as it sees a [disconnect request](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disconnect). However, if it is processing another request when this disconnect arrives the `DAP::Loop` handler may exit the loop without replying to the disconnect request. There has been some instability on the CI jobs due to this race, for example https://lab.llvm.org/buildbot/#/builders/59/builds/16076 To address this, ensure we only return from `DAP::Loop` once we've emptied the queue. Added: Modified: lldb/tools/lldb-dap/DAP.cpp Removed: diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index b752e9cfaeb85..597fe3a1e323b 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -921,7 +921,7 @@ llvm::Error DAP::Loop() { StopEventHandlers(); }); - while (!disconnecting) { + while (!disconnecting || !m_queue.empty()) { std::unique_lock lock(m_queue_mutex); m_queue_cv.wait(lock, [&] { return disconnecting || !m_queue.empty(); }); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Fixing a race during disconnect. (PR #135872)
https://github.com/ashgti closed https://github.com/llvm/llvm-project/pull/135872 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
charles-zablit wrote: > Is this API used for anything outside of that `PlatformSigInfoTest`? It > doesn't seem to be used anywhere (including the apple fork). Should we just > remove this API? It's not used anywhere apart from the `PlatformSigInfoTest`. It's also inside the `lldb_private` namespace so I agree, I think it's best to remove it. https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f875dd1 - [lldb][nfc] Remove redundant check in if statement (#135869)
Author: Felipe de Azevedo Piovezan Date: 2025-04-16T08:10:29-07:00 New Revision: f875dd10162dcfb8f4625cef2bfc8e6b9f73f8fc URL: https://github.com/llvm/llvm-project/commit/f875dd10162dcfb8f4625cef2bfc8e6b9f73f8fc DIFF: https://github.com/llvm/llvm-project/commit/f875dd10162dcfb8f4625cef2bfc8e6b9f73f8fc.diff LOG: [lldb][nfc] Remove redundant check in if statement (#135869) We already check this boolean in the `if` statement two lines above. Added: Modified: lldb/source/Target/ThreadPlanStepInRange.cpp Removed: diff --git a/lldb/source/Target/ThreadPlanStepInRange.cpp b/lldb/source/Target/ThreadPlanStepInRange.cpp index 8a2417e9da326..0e93691de68af 100644 --- a/lldb/source/Target/ThreadPlanStepInRange.cpp +++ b/lldb/source/Target/ThreadPlanStepInRange.cpp @@ -370,7 +370,7 @@ bool ThreadPlanStepInRange::DefaultShouldStopHereCallback( if (!should_stop_here) return false; - if (should_stop_here && current_plan->GetKind() == eKindStepInRange && + if (current_plan->GetKind() == eKindStepInRange && operation == eFrameCompareYounger) { ThreadPlanStepInRange *step_in_range_plan = static_cast(current_plan); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Remove redundant check in if statement (PR #135869)
https://github.com/felipepiovezan closed https://github.com/llvm/llvm-project/pull/135869 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Add customization flags for ThreadPlanStepOut (PR #135866)
felipepiovezan wrote: >then it would queue up a ThreadPlanStepOut that would go to that frame. To elaborate on this, today there is no constructor for StepOut that allows one to specify a target frame. This is also something we would need to create for that to work, right? https://github.com/llvm/llvm-project/pull/135866 ___ 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] Respect x86 disassembly flavor setting (PR #134722)
@@ -116,7 +116,22 @@ void DisassembleRequestHandler::operator()( const auto inst_count = GetInteger(arguments, "instructionCount").value_or(0); - lldb::SBInstructionList insts = dap.target.ReadInstructions(addr, inst_count); + + std::string flavor_string{}; + const auto target_triple = llvm::StringRef(dap.target.GetTriple()); walter-erquinigo wrote: I can't think of a clean way to unify this with the code in source/Commands/CommandObjectDisassemble.cpp, but at the very least make a comment here and in source/Commands/CommandObjectDisassemble.cpp::OptionParsingStarting mentioning that they are duplicated logic, so that future changes are done correctly https://github.com/llvm/llvm-project/pull/134722 ___ 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] Respect x86 disassembly flavor setting (PR #134722)
https://github.com/walter-erquinigo requested changes to this pull request. https://github.com/llvm/llvm-project/pull/134722 ___ 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] Respect x86 disassembly flavor setting (PR #134722)
@@ -116,7 +116,22 @@ void DisassembleRequestHandler::operator()( const auto inst_count = GetInteger(arguments, "instructionCount").value_or(0); - lldb::SBInstructionList insts = dap.target.ReadInstructions(addr, inst_count); + + std::string flavor_string{}; + const auto target_triple = llvm::StringRef(dap.target.GetTriple()); + if (target_triple.starts_with("x86_64") || target_triple.starts_with("x86")) { walter-erquinigo wrote: well, you only need that second check https://github.com/llvm/llvm-project/pull/134722 ___ 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] explicitly set the expr as an alias for expression. (PR #134562)
da-viper wrote: I am using what is the default. which is automode.  I am not sure if there is a way to change the mode from the user. https://github.com/llvm/llvm-project/pull/134562 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
felipepiovezan wrote: It's worth mentioning that the LLVM convention (as opposed to what is done in the swift fork) is to avoid force-pushing. Instead, you'd always add a new fixup commit (`git commit --fixup`) and squash them when merging (note that, for llvm, github will force you into squashing). This obviously raises the question of: "what if I want to have small, independent PRs?". No good solutions, I'm afraid, other than stacked PRs and scrips that help with that. https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment โPingโ. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
https://github.com/charles-zablit created https://github.com/llvm/llvm-project/pull/135963 This patch updates the `CompilerType::GetIndexOfFieldWithName` API to use `llvm::Expected` if no index is found instead of `UINT32_MAX`. >From aaf9c4ec3e68d78d963cdac3d3f08dc207d49cad Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Wed, 16 Apr 2025 11:28:54 +0100 Subject: [PATCH] [lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected --- lldb/include/lldb/Symbol/CompilerType.h | 11 ++- lldb/source/Symbol/CompilerType.cpp | 4 ++-- lldb/unittests/Platform/PlatformSiginfoTest.cpp | 7 --- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index 41a1676dabd76..79998922cfc93 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -433,11 +433,12 @@ class CompilerType { CompilerDecl GetStaticFieldWithName(llvm::StringRef name) const; - uint32_t GetIndexOfFieldWithName(const char *name, - CompilerType *field_compiler_type = nullptr, - uint64_t *bit_offset_ptr = nullptr, - uint32_t *bitfield_bit_size_ptr = nullptr, - bool *is_bitfield_ptr = nullptr) const; + llvm::Expected + GetIndexOfFieldWithName(const char *name, + CompilerType *field_compiler_type = nullptr, + uint64_t *bit_offset_ptr = nullptr, + uint32_t *bitfield_bit_size_ptr = nullptr, + bool *is_bitfield_ptr = nullptr) const; llvm::Expected GetChildCompilerTypeAtIndex( ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index 22fdd24fc7cd5..0a36b390a645c 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -893,7 +893,7 @@ CompilerDecl CompilerType::GetStaticFieldWithName(llvm::StringRef name) const { return CompilerDecl(); } -uint32_t CompilerType::GetIndexOfFieldWithName( +llvm::Expected CompilerType::GetIndexOfFieldWithName( const char *name, CompilerType *field_compiler_type_ptr, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const { @@ -909,7 +909,7 @@ uint32_t CompilerType::GetIndexOfFieldWithName( return index; } } - return UINT32_MAX; + return llvm::createStringError("Invalid name: Cannot find index"); } llvm::Expected CompilerType::GetChildCompilerTypeAtIndex( diff --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp index 4b2c93a68a94a..e48d8ea667ad8 100644 --- a/lldb/unittests/Platform/PlatformSiginfoTest.cpp +++ b/lldb/unittests/Platform/PlatformSiginfoTest.cpp @@ -60,9 +60,10 @@ class PlatformSiginfoTest : public ::testing::Test { uint64_t total_offset = 0; for (auto field_name : llvm::split(path, '.')) { uint64_t bit_offset; - ASSERT_NE(field_type.GetIndexOfFieldWithName(field_name.str().c_str(), - &field_type, &bit_offset), -UINT32_MAX); + ASSERT(llvm::expectedToOptional( + field_type.GetIndexOfFieldWithName(field_name.str().c_str(), +&field_type, &bit_offset)) + .has_value()); total_offset += bit_offset; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Charles Zablit (charles-zablit) Changes This patch updates the `CompilerType::GetIndexOfFieldWithName` API to use `llvm::Expected` if no index is found instead of `UINT32_MAX`. --- Full diff: https://github.com/llvm/llvm-project/pull/135963.diff 3 Files Affected: - (modified) lldb/include/lldb/Symbol/CompilerType.h (+6-5) - (modified) lldb/source/Symbol/CompilerType.cpp (+2-2) - (modified) lldb/unittests/Platform/PlatformSiginfoTest.cpp (+4-3) ``diff diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index 41a1676dabd76..79998922cfc93 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -433,11 +433,12 @@ class CompilerType { CompilerDecl GetStaticFieldWithName(llvm::StringRef name) const; - uint32_t GetIndexOfFieldWithName(const char *name, - CompilerType *field_compiler_type = nullptr, - uint64_t *bit_offset_ptr = nullptr, - uint32_t *bitfield_bit_size_ptr = nullptr, - bool *is_bitfield_ptr = nullptr) const; + llvm::Expected + GetIndexOfFieldWithName(const char *name, + CompilerType *field_compiler_type = nullptr, + uint64_t *bit_offset_ptr = nullptr, + uint32_t *bitfield_bit_size_ptr = nullptr, + bool *is_bitfield_ptr = nullptr) const; llvm::Expected GetChildCompilerTypeAtIndex( ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index 22fdd24fc7cd5..0a36b390a645c 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -893,7 +893,7 @@ CompilerDecl CompilerType::GetStaticFieldWithName(llvm::StringRef name) const { return CompilerDecl(); } -uint32_t CompilerType::GetIndexOfFieldWithName( +llvm::Expected CompilerType::GetIndexOfFieldWithName( const char *name, CompilerType *field_compiler_type_ptr, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const { @@ -909,7 +909,7 @@ uint32_t CompilerType::GetIndexOfFieldWithName( return index; } } - return UINT32_MAX; + return llvm::createStringError("Invalid name: Cannot find index"); } llvm::Expected CompilerType::GetChildCompilerTypeAtIndex( diff --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp index 4b2c93a68a94a..e48d8ea667ad8 100644 --- a/lldb/unittests/Platform/PlatformSiginfoTest.cpp +++ b/lldb/unittests/Platform/PlatformSiginfoTest.cpp @@ -60,9 +60,10 @@ class PlatformSiginfoTest : public ::testing::Test { uint64_t total_offset = 0; for (auto field_name : llvm::split(path, '.')) { uint64_t bit_offset; - ASSERT_NE(field_type.GetIndexOfFieldWithName(field_name.str().c_str(), - &field_type, &bit_offset), -UINT32_MAX); + ASSERT(llvm::expectedToOptional( + field_type.GetIndexOfFieldWithName(field_name.str().c_str(), +&field_type, &bit_offset)) + .has_value()); total_offset += bit_offset; } `` https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
https://github.com/Michael137 commented: Is this API used for anything outside of that `PlatformSigInfoTest`? It doesn't seem to be used anywhere (including the apple fork). Should we just remove this API? If we do want to keep it, we could add a test for this in `lldb/unittests/Symbol/TestTypeSystemClang.cpp`. You can create a custom `CompilerType` (search in that file for `CreateRecordType`) and then call `GetIndexOfFieldWithName` on it with some non-existent field name. https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
@@ -909,7 +909,7 @@ uint32_t CompilerType::GetIndexOfFieldWithName( return index; } } - return UINT32_MAX; + return llvm::createStringError("Invalid name: Cannot find index"); Michael137 wrote: Could we include the name of the field? This should work: ``` llvm::createStringError("Cannot find index of field '%s'", name); ``` https://github.com/llvm/llvm-project/pull/135963 ___ 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] explicitly set the expr as an alias for expression. (PR #134562)
walter-erquinigo wrote: Probably the default is Auto. I guess we should add an option in the typescript code for selecting the mode. And about `:`, I confused you because I set up my debugger to use `:` instead of a backtick. In this mode, I think it would be great to determine via a quick parsing if the input string is an actual expression or not. What would be nice would be do this: - If the input string consists of at least two words, then run some quick command parsing to see if it's valid or not. If it's valid, then execute it as a command, otherwise follow the existing code path what do you think? https://github.com/llvm/llvm-project/pull/134562 ___ 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] fix repeating commands in repl mode (PR #135008)
@@ -164,7 +164,8 @@ void EvaluateRequestHandler::operator()( dap.focus_tid = frame.GetThread().GetThreadID(); } auto result = RunLLDBCommandsVerbatim(dap.debugger, llvm::StringRef(), - {std::string(expression)}); + {std::string(expression)}, + /*echo_commands*/ false); walter-erquinigo wrote: ```suggestion /*echo_commands=*/ false); ``` https://github.com/llvm/llvm-project/pull/135008 ___ 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] fix repeating commands in repl mode (PR #135008)
https://github.com/walter-erquinigo approved this pull request. LGTM. Let's see if Jonas has more comments https://github.com/llvm/llvm-project/pull/135008 ___ 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] fix repeating commands in repl mode (PR #135008)
https://github.com/walter-erquinigo edited https://github.com/llvm/llvm-project/pull/135008 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] fix inconsistent debugAdapterHostname argument name (PR #135544)
https://github.com/walter-erquinigo approved this pull request. https://github.com/llvm/llvm-project/pull/135544 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix deadlock between statusline and output mutex (PR #135956)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/135956 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix deadlock between statusline and output mutex (PR #135956)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/135956 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix lock inversion between statusline mutex and output mutex (PR #135956)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/135956 ___ 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] explicitly set the expr as an alias for expression. (PR #134562)
walter-erquinigo wrote: @da-viper , I'm a bit surprised by this. Which mode are you using for the debug console? I remember that in Variable mode (or whichever is the default), I was able to type `:expr ` and that worked. Is your problem occurring in the Auto mode? I think that in this case, using a prefix like `:` should be enough to disambiguate. What do you think? Adding aliases is error prone because there may be people who use `expre` instead of `expr` and then this logic breaks. https://github.com/llvm/llvm-project/pull/134562 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Parallelize module loading in POSIX dyld code (PR #130912)
JDevlieghere wrote: Forgot to ask here earlier, but would you also be able to add a release note in `llvm-project/llvm/docs/ReleaseNotes.md`? Thanks! https://github.com/llvm/llvm-project/pull/130912 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix deadlock between statusline and output mutex (PR #135956)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/135956 >From 215f32820d09d215f2c1b4f4c4c0e0fbe9437264 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 16 Apr 2025 15:55:25 +0200 Subject: [PATCH] [lldb] Fix lock inversion between statusline mutex and output mutex Fix a deadlock between the statusline mutex (in Debugger) and the output file mutex (in LockedStreamFile). The deadlock occurs when the main thread is calling the statusline callback while holding the output mutex in Editline, while the default event thread is trying to update the statusline. Extend the uncritical section so we can redraw the statusline there. The loop in Editline::GetCharacter should be unnecessary. It would only loop if we had a successful read with length zero, which shouldn't be possible or when we can't convert a partial UTF-8 character, in which case we bail out. --- lldb/source/Host/common/Editline.cpp | 93 +-- .../statusline/TestStatusline.py | 17 2 files changed, 63 insertions(+), 47 deletions(-) diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index 29abaf7c65f28..ff71cd0cdb241 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/source/Host/common/Editline.cpp @@ -567,9 +567,6 @@ int Editline::GetCharacter(EditLineGetCharType *c) { m_needs_prompt_repaint = false; } - if (m_redraw_callback) -m_redraw_callback(); - if (m_multiline_enabled) { // Detect when the number of rows used for this input line changes due to // an edit @@ -585,54 +582,56 @@ int Editline::GetCharacter(EditLineGetCharType *c) { m_current_line_rows = new_line_rows; } + if (m_terminal_size_has_changed) +ApplyTerminalSizeChange(); + + // This mutex is locked by our caller (GetLine). Unlock it while we read a + // character (blocking operation), so we do not hold the mutex + // indefinitely. This gives a chance for someone to interrupt us. After + // Read returns, immediately lock the mutex again and check if we were + // interrupted. + m_locked_output.reset(); + + if (m_redraw_callback) +m_redraw_callback(); + // Read an actual character - while (true) { -lldb::ConnectionStatus status = lldb::eConnectionStatusSuccess; -char ch = 0; - -if (m_terminal_size_has_changed) - ApplyTerminalSizeChange(); - -// This mutex is locked by our caller (GetLine). Unlock it while we read a -// character (blocking operation), so we do not hold the mutex -// indefinitely. This gives a chance for someone to interrupt us. After -// Read returns, immediately lock the mutex again and check if we were -// interrupted. -m_locked_output.reset(); -int read_count = -m_input_connection.Read(&ch, 1, std::nullopt, status, nullptr); -m_locked_output.emplace(m_output_stream_sp->Lock()); -if (m_editor_status == EditorStatus::Interrupted) { - while (read_count > 0 && status == lldb::eConnectionStatusSuccess) -read_count = -m_input_connection.Read(&ch, 1, std::nullopt, status, nullptr); - lldbassert(status == lldb::eConnectionStatusInterrupted); - return 0; -} + lldb::ConnectionStatus status = lldb::eConnectionStatusSuccess; + char ch = 0; + int read_count = + m_input_connection.Read(&ch, 1, std::nullopt, status, nullptr); + + // Re-lock the output mutex to protected m_editor_status here and in the + // switch below. + m_locked_output.emplace(m_output_stream_sp->Lock()); + if (m_editor_status == EditorStatus::Interrupted) { +while (read_count > 0 && status == lldb::eConnectionStatusSuccess) + read_count = + m_input_connection.Read(&ch, 1, std::nullopt, status, nullptr); +lldbassert(status == lldb::eConnectionStatusInterrupted); +return 0; + } -if (read_count) { - if (CompleteCharacter(ch, *c)) -return 1; -} else { - switch (status) { - case lldb::eConnectionStatusSuccess: // Success -break; + if (read_count) { +if (CompleteCharacter(ch, *c)) + return 1; +return 0; + } - case lldb::eConnectionStatusInterrupted: -llvm_unreachable("Interrupts should have been handled above."); - - case lldb::eConnectionStatusError:// Check GetError() for details - case lldb::eConnectionStatusTimedOut: // Request timed out - case lldb::eConnectionStatusEndOfFile:// End-of-file encountered - case lldb::eConnectionStatusNoConnection: // No connection - case lldb::eConnectionStatusLostConnection: // Lost connection while - // connected to a valid - // connection -m_editor_status = EditorStatus::EndOfInput; -return 0; - } -} + switch (status) { + case lldb::eConnectionStatusSuccess: +llvm_unreachable("Success should have resulted in positive
[Lldb-commits] [lldb] [lldb] Fix lock inversion between statusline mutex and output mutex (PR #135956)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/135956 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DataFormatter] Surface CalculateNumChildren errors in std::vector summary (PR #135944)
https://github.com/adrian-prantl approved this pull request. Oh this is fantastic! https://github.com/llvm/llvm-project/pull/135944 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/135963 >From 6dd67fe4ad03f0ec0623717715b8cfcc9537ab3f Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Wed, 16 Apr 2025 11:28:54 +0100 Subject: [PATCH] [lldb] Remove unused API CompilerType::GetIndexOfFieldWithName --- lldb/include/lldb/Symbol/CompilerType.h | 6 -- lldb/source/Symbol/CompilerType.cpp | 19 - .../Platform/PlatformSiginfoTest.cpp | 21 --- 3 files changed, 46 deletions(-) diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index 41a1676dabd76..3561bc70887e6 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -433,12 +433,6 @@ class CompilerType { CompilerDecl GetStaticFieldWithName(llvm::StringRef name) const; - uint32_t GetIndexOfFieldWithName(const char *name, - CompilerType *field_compiler_type = nullptr, - uint64_t *bit_offset_ptr = nullptr, - uint32_t *bitfield_bit_size_ptr = nullptr, - bool *is_bitfield_ptr = nullptr) const; - llvm::Expected GetChildCompilerTypeAtIndex( ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index 22fdd24fc7cd5..8e89d006d08d3 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -893,25 +893,6 @@ CompilerDecl CompilerType::GetStaticFieldWithName(llvm::StringRef name) const { return CompilerDecl(); } -uint32_t CompilerType::GetIndexOfFieldWithName( -const char *name, CompilerType *field_compiler_type_ptr, -uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, -bool *is_bitfield_ptr) const { - unsigned count = GetNumFields(); - std::string field_name; - for (unsigned index = 0; index < count; index++) { -CompilerType field_compiler_type( -GetFieldAtIndex(index, field_name, bit_offset_ptr, -bitfield_bit_size_ptr, is_bitfield_ptr)); -if (strcmp(field_name.c_str(), name) == 0) { - if (field_compiler_type_ptr) -*field_compiler_type_ptr = field_compiler_type; - return index; -} - } - return UINT32_MAX; -} - llvm::Expected CompilerType::GetChildCompilerTypeAtIndex( ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, diff --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp index 4b2c93a68a94a..a1f55bdd926db 100644 --- a/lldb/unittests/Platform/PlatformSiginfoTest.cpp +++ b/lldb/unittests/Platform/PlatformSiginfoTest.cpp @@ -50,27 +50,6 @@ class PlatformSiginfoTest : public ::testing::Test { typedef std::tuple field_tuple; - void ExpectField(const CompilerType &siginfo_type, field_tuple field) { -const char *path; -uint64_t offset, size; -std::tie(path, offset, size) = field; - -SCOPED_TRACE(path); -CompilerType field_type = siginfo_type; -uint64_t total_offset = 0; -for (auto field_name : llvm::split(path, '.')) { - uint64_t bit_offset; - ASSERT_NE(field_type.GetIndexOfFieldWithName(field_name.str().c_str(), - &field_type, &bit_offset), -UINT32_MAX); - total_offset += bit_offset; -} - -EXPECT_EQ(total_offset, offset * 8); -EXPECT_EQ(llvm::expectedToOptional(field_type.GetByteSize(nullptr)), - std::optional(size)); - } - void ExpectFields(const CompilerType &container, std::initializer_list fields) { for (auto x : fields) ___ 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] fix repeating commands in repl mode (PR #135008)
@@ -28,15 +28,12 @@ def test_completions(self): self.set_source_breakpoints(source, [breakpoint1_line, breakpoint2_line]) -self.assertEvaluate( -"`command regex user_command s/^$/platform/", r"\(lldb\) command regex" -) -self.assertEvaluate( -"`command alias alias_command platform", r"\(lldb\) command alias" -) +# the result of the commands should return the empty string. walter-erquinigo wrote: ```suggestion # The result of the commands should return the empty string. ``` https://github.com/llvm/llvm-project/pull/135008 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 419fa1b - [lldb][DataFormatter] Surface CalculateNumChildren errors in std::vector summary (#135944)
Author: Michael Buch Date: 2025-04-16T17:57:51+02:00 New Revision: 419fa1b06a36336ad85f1c71fc72ffa719ceb659 URL: https://github.com/llvm/llvm-project/commit/419fa1b06a36336ad85f1c71fc72ffa719ceb659 DIFF: https://github.com/llvm/llvm-project/commit/419fa1b06a36336ad85f1c71fc72ffa719ceb659.diff LOG: [lldb][DataFormatter] Surface CalculateNumChildren errors in std::vector summary (#135944) When the data-formatters happen to break (e.g., due to layout changes in libc++), there's no clear indicator of them failing from a user's perspective. E.g., for `std::vector`s we would just show: ``` (std::vector) v = size=0 {} ``` which is highly misleading, especially if `v.size()` returns a non-zero size. This patch surfaces the various errors that could occur when calculating the number of children of a vector. rdar://146964266 Added: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/main.cpp Modified: lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp lldb/source/ValueObject/ValueObject.cpp Removed: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp index d538cac9f9134..ce2261b6f03c3 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp @@ -83,19 +83,30 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd:: llvm::Expected lldb_private::formatters:: LibcxxStdVectorSyntheticFrontEnd::CalculateNumChildren() { if (!m_start || !m_finish) -return 0; +return llvm::createStringError( +"Failed to determine start/end of vector data."); + uint64_t start_val = m_start->GetValueAsUnsigned(0); uint64_t finish_val = m_finish->GetValueAsUnsigned(0); - if (start_val == 0 || finish_val == 0) + // A default-initialized empty vector. + if (start_val == 0 && finish_val == 0) return 0; - if (start_val >= finish_val) -return 0; + if (start_val == 0) +return llvm::createStringError("Invalid value for start of vector."); + + if (finish_val == 0) +return llvm::createStringError("Invalid value for end of vector."); + + if (start_val > finish_val) +return llvm::createStringError( +"Start of vector data begins after end pointer."); size_t num_children = (finish_val - start_val); if (num_children % m_element_size) -return 0; +return llvm::createStringError("Size not multiple of element size."); + return num_children / m_element_size; } diff --git a/lldb/source/ValueObject/ValueObject.cpp b/lldb/source/ValueObject/ValueObject.cpp index eac24353de90b..8741cb7343166 100644 --- a/lldb/source/ValueObject/ValueObject.cpp +++ b/lldb/source/ValueObject/ValueObject.cpp @@ -1521,10 +1521,16 @@ bool ValueObject::DumpPrintableRepresentation( str = GetLocationAsCString(); break; -case eValueObjectRepresentationStyleChildrenCount: - strm.Printf("%" PRIu64 "", (uint64_t)GetNumChildrenIgnoringErrors()); - str = strm.GetString(); +case eValueObjectRepresentationStyleChildrenCount: { + if (auto err = GetNumChildren()) { +strm.Printf("%" PRIu32, *err); +str = strm.GetString(); + } else { +strm << "error: " << toString(err.takeError()); +str = strm.GetString(); + } break; +} case eValueObjectRepresentationStyleType: str = GetTypeName().GetStringRef(); diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile new file mode 100644 index 0..38cfa81053488 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp +override CXXFLAGS_EXTRAS += -std=c++14 +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py new file mode 100644 index 0..8788ea7be882d --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py @@ -0,0 +1,39 @@ +""" +Test we can understand various layouts of the libc++'s std::string +""" + + +im
[Lldb-commits] [lldb] [lldb][DataFormatter] Surface CalculateNumChildren errors in std::vector summary (PR #135944)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/135944 ___ 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] Respect x86 disassembly flavor setting (PR #134722)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/134722 >From ababee38bf0dae6c12e09225bf84ec2bf03e7982 Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Mon, 7 Apr 2025 20:43:30 +0100 Subject: [PATCH 1/2] [lldb][lldb-dap] Respect x86 disassembly flavor setting Ensure the disassembly respects the "target.x86-disassembly-flavor" setting for x86 and x86_64 targets. Depends on #134626 --- .../Handler/DisassembleRequestHandler.cpp | 17 - 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp index f0cb7be70210d..0fd9390623046 100644 --- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp @@ -116,7 +116,22 @@ void DisassembleRequestHandler::operator()( const auto inst_count = GetInteger(arguments, "instructionCount").value_or(0); - lldb::SBInstructionList insts = dap.target.ReadInstructions(addr, inst_count); + + std::string flavor_string{}; + const auto target_triple = llvm::StringRef(dap.target.GetTriple()); + if (target_triple.starts_with("x86_64") || target_triple.starts_with("x86")) { +const lldb::SBStructuredData flavor = +dap.debugger.GetSetting("target.x86-disassembly-flavor"); + +const size_t str_length = flavor.GetStringValue(nullptr, 0); +if (str_length != 0) { + flavor_string.resize(str_length + 1); + flavor.GetStringValue(flavor_string.data(), flavor_string.length()); +} + } + + lldb::SBInstructionList insts = + dap.target.ReadInstructions(addr, inst_count, flavor_string.c_str()); if (!insts.IsValid()) { response["success"] = false; >From c69872d867a6e0dc50784c8c69c75c9d5535b67b Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Wed, 16 Apr 2025 20:50:11 +0100 Subject: [PATCH 2/2] [lldb][lldb-dap] add review changes Signed-off-by: Ebuka Ezike --- lldb/source/Commands/CommandObjectDisassemble.cpp | 1 + lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp | 5 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp index 70e687e19ac6d..fa9311ad9624e 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -190,6 +190,7 @@ void CommandObjectDisassemble::CommandOptions::OptionParsingStarting( // architecture. For now GetDisassemblyFlavor is really only valid for x86 // (and for the llvm assembler plugin, but I'm papering over that since that // is the only disassembler plugin we have... +// this logic is also duplicated in `Handler/DisassembleRequestHandler` if (target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86 || target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86_64) { diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp index 0fd9390623046..7489c63a61afe 100644 --- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp @@ -119,7 +119,10 @@ void DisassembleRequestHandler::operator()( std::string flavor_string{}; const auto target_triple = llvm::StringRef(dap.target.GetTriple()); - if (target_triple.starts_with("x86_64") || target_triple.starts_with("x86")) { + // this handles both 32 and 64bit x86 architecture. + // this logic is also duplicated in + // `CommandObjectDisassemble::CommandOptions::OptionParsingStarting` + if (target_triple.starts_with("x86")) { const lldb::SBStructuredData flavor = dap.debugger.GetSetting("target.x86-disassembly-flavor"); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Add customization flags for ThreadPlanStepOut (PR #135866)
jimingham wrote: That's what QueueThreadPlanStepOutNoShouldStop is supposed to do, maybe it's not working? https://github.com/llvm/llvm-project/pull/135866 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Add customization flags for ThreadPlanStepOut (PR #135866)
jimingham wrote: That one should just do "Go where I tell you, then stop". https://github.com/llvm/llvm-project/pull/135866 ___ 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] fix repeating commands in repl mode (PR #135008)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/135008 >From 296019edb5edba4a21e040feb154b1ef83f1e64d Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Wed, 9 Apr 2025 14:35:09 +0100 Subject: [PATCH 1/6] [lldb][lldb-dap] fix repeating commands in repl mode Fixes #131589 Add a new option to the RunCommands* functions to control the echoing of commands --- .../lldb-dap/evaluate/TestDAP_evaluate.py | 2 +- .../tools/lldb-dap/launch/TestDAP_launch.py | 4 +-- .../repl-mode/TestDAP_repl_mode_detection.py | 11 +++--- lldb/tools/lldb-dap/DAP.cpp | 6 ++-- lldb/tools/lldb-dap/DAP.h | 3 +- .../Handler/EvaluateRequestHandler.cpp| 3 +- lldb/tools/lldb-dap/LLDBUtils.cpp | 35 ++- lldb/tools/lldb-dap/LLDBUtils.h | 19 +++--- 8 files changed, 54 insertions(+), 29 deletions(-) diff --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py index 251d77d79d080..e2f843bd337a6 100644 --- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py +++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py @@ -101,7 +101,7 @@ def run_test_evaluate_expressions( if context == "repl": # In the repl context expressions may be interpreted as lldb # commands since no variables have the same name as the command. -self.assertEvaluate("list", r"\(lldb\) list\n.*") +self.assertEvaluate("list", r".*") else: self.assertEvaluateFailure("list") # local variable of a_function diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py index 64c99019a1c9b..eceba2f8a13cb 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -522,11 +522,9 @@ def test_version(self): ) version_eval_output = version_eval_response["body"]["result"] -# The first line is the prompt line like "(lldb) version", so we skip it. -version_eval_output_without_prompt_line = version_eval_output.splitlines()[1:] version_string = self.dap_server.get_initialize_value("$__lldb_version") self.assertEqual( -version_eval_output_without_prompt_line, +version_eval_output.splitlines(), version_string.splitlines(), "version string does not match", ) diff --git a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py index 7c77fc8541b93..09ca725ee8883 100644 --- a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py +++ b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py @@ -28,15 +28,12 @@ def test_completions(self): self.set_source_breakpoints(source, [breakpoint1_line, breakpoint2_line]) -self.assertEvaluate( -"`command regex user_command s/^$/platform/", r"\(lldb\) command regex" -) -self.assertEvaluate( -"`command alias alias_command platform", r"\(lldb\) command alias" -) +# the result of the commands should return the empty string. +self.assertEvaluate("`command regex user_command s/^$/platform/", r"^$") +self.assertEvaluate("`command alias alias_command platform", r"^$") self.assertEvaluate( "`command alias alias_command_with_arg platform select --sysroot %1 remote-linux", -r"\(lldb\) command alias", +r"^$", ) self.continue_to_next_stop() diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index 9361ba968e9c2..03b9dc7135ef7 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -561,10 +561,12 @@ ReplMode DAP::DetectReplMode(lldb::SBFrame frame, std::string &expression, } bool DAP::RunLLDBCommands(llvm::StringRef prefix, - llvm::ArrayRef commands) { + llvm::ArrayRef commands, + bool echo_commands) { bool required_command_failed = false; std::string output = - ::RunLLDBCommands(debugger, prefix, commands, required_command_failed); + ::RunLLDBCommands(debugger, prefix, commands, required_command_failed, +/*parse_command_directives*/ true, echo_commands); SendOutput(OutputType::Console, output); return !required_command_failed; } diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h index fc43d988f3a09..cb3431cc87fd1 100644 --- a/lldb/tools/lldb-dap/DAP.h +++ b/lldb/tools/lldb-dap/DAP.h @@ -290,7 +290,8 @@ struct DAP { /// \b false if a fatal error was found while executing these commands, /// according to the rules of \a LLDBUtils::RunLLDBCommands. bool RunLL
[Lldb-commits] [lldb] [lldb][nfc] Add customization flags for ThreadPlanStepOut (PR #135866)
felipepiovezan wrote: > That's what QueueThreadPlanStepOutNoShouldStop is supposed to do, maybe it's > not working? There is only one constructor for step out, and it always skips those frames. So, yes, even in `QueueThreadPlanForStepOutNoShouldStop` we will skip over frames. https://github.com/llvm/llvm-project/pull/135866 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix lock inversion between statusline mutex and output mutex (PR #135956)
https://github.com/jasonmolenda approved this pull request. Looks good, thanks! https://github.com/llvm/llvm-project/pull/135956 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/135963 >From 6dd67fe4ad03f0ec0623717715b8cfcc9537ab3f Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Wed, 16 Apr 2025 11:28:54 +0100 Subject: [PATCH 1/2] [lldb] Remove unused API CompilerType::GetIndexOfFieldWithName --- lldb/include/lldb/Symbol/CompilerType.h | 6 -- lldb/source/Symbol/CompilerType.cpp | 19 - .../Platform/PlatformSiginfoTest.cpp | 21 --- 3 files changed, 46 deletions(-) diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index 41a1676dabd76..3561bc70887e6 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -433,12 +433,6 @@ class CompilerType { CompilerDecl GetStaticFieldWithName(llvm::StringRef name) const; - uint32_t GetIndexOfFieldWithName(const char *name, - CompilerType *field_compiler_type = nullptr, - uint64_t *bit_offset_ptr = nullptr, - uint32_t *bitfield_bit_size_ptr = nullptr, - bool *is_bitfield_ptr = nullptr) const; - llvm::Expected GetChildCompilerTypeAtIndex( ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index 22fdd24fc7cd5..8e89d006d08d3 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -893,25 +893,6 @@ CompilerDecl CompilerType::GetStaticFieldWithName(llvm::StringRef name) const { return CompilerDecl(); } -uint32_t CompilerType::GetIndexOfFieldWithName( -const char *name, CompilerType *field_compiler_type_ptr, -uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, -bool *is_bitfield_ptr) const { - unsigned count = GetNumFields(); - std::string field_name; - for (unsigned index = 0; index < count; index++) { -CompilerType field_compiler_type( -GetFieldAtIndex(index, field_name, bit_offset_ptr, -bitfield_bit_size_ptr, is_bitfield_ptr)); -if (strcmp(field_name.c_str(), name) == 0) { - if (field_compiler_type_ptr) -*field_compiler_type_ptr = field_compiler_type; - return index; -} - } - return UINT32_MAX; -} - llvm::Expected CompilerType::GetChildCompilerTypeAtIndex( ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, diff --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp index 4b2c93a68a94a..a1f55bdd926db 100644 --- a/lldb/unittests/Platform/PlatformSiginfoTest.cpp +++ b/lldb/unittests/Platform/PlatformSiginfoTest.cpp @@ -50,27 +50,6 @@ class PlatformSiginfoTest : public ::testing::Test { typedef std::tuple field_tuple; - void ExpectField(const CompilerType &siginfo_type, field_tuple field) { -const char *path; -uint64_t offset, size; -std::tie(path, offset, size) = field; - -SCOPED_TRACE(path); -CompilerType field_type = siginfo_type; -uint64_t total_offset = 0; -for (auto field_name : llvm::split(path, '.')) { - uint64_t bit_offset; - ASSERT_NE(field_type.GetIndexOfFieldWithName(field_name.str().c_str(), - &field_type, &bit_offset), -UINT32_MAX); - total_offset += bit_offset; -} - -EXPECT_EQ(total_offset, offset * 8); -EXPECT_EQ(llvm::expectedToOptional(field_type.GetByteSize(nullptr)), - std::optional(size)); - } - void ExpectFields(const CompilerType &container, std::initializer_list fields) { for (auto x : fields) >From 77faa748f436cd28ea95854296c476a1be04e5d3 Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Wed, 16 Apr 2025 19:04:56 +0100 Subject: [PATCH 2/2] fixup! [lldb] Remove unused API CompilerType::GetIndexOfFieldWithName --- lldb/unittests/Platform/CMakeLists.txt| 1 - .../Platform/PlatformSiginfoTest.cpp | 288 -- 2 files changed, 289 deletions(-) delete mode 100644 lldb/unittests/Platform/PlatformSiginfoTest.cpp diff --git a/lldb/unittests/Platform/CMakeLists.txt b/lldb/unittests/Platform/CMakeLists.txt index 5c0ef5ca6ef22..7d57f633d89c3 100644 --- a/lldb/unittests/Platform/CMakeLists.txt +++ b/lldb/unittests/Platform/CMakeLists.txt @@ -2,7 +2,6 @@ add_lldb_unittest(LLDBPlatformTests PlatformAppleSimulatorTest.cpp PlatformDarwinTest.cpp PlatformMacOSXTest.cpp - PlatformSiginfoTest.cpp PlatformTest.cpp LINK_LIBS diff --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp deleted file mode 100644 index a1f55bdd926db..0 --- a/lldb/
[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)
https://github.com/walter-erquinigo approved this pull request. https://github.com/llvm/llvm-project/pull/129728 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add summary for NSIndirectTaggedPointerString (PR #136025)
https://github.com/kastiglione converted_to_draft https://github.com/llvm/llvm-project/pull/136025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add summary for NSIndirectTaggedPointerString (PR #136025)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/136025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add summary for NSIndirectTaggedPointerString (PR #136025)
@@ -368,3 +373,37 @@ bool lldb_private::formatters::NSTaggedString_SummaryProvider( stream << suffix; return true; } + +bool lldb_private::formatters::NSIndirectTaggedString_SummaryProvider( +ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, +Stream &stream, const TypeSummaryOptions &summary_options) { + if (!descriptor) +return false; + + uint64_t payload = 0; + if (!descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) +return false; + + // First 47 bits are the address of the contents. + addr_t ptr = payload & 0x7fffULL; + // Next 13 bits are the string's length. + size_t size = (payload >> 47) & 0x1fff; + + Status status; + char buf[8192]; adrian-prantl wrote: and then you can `reserve()` exactly `size` https://github.com/llvm/llvm-project/pull/136025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] Reland [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (PR #136077)
llvmbot wrote: @llvm/pr-subscribers-hlsl Author: None (yronglin) Changes This PR reland https://github.com/llvm/llvm-project/pull/135808, fixed some missed changes in LLDB. I found this issue when I working on https://github.com/llvm/llvm-project/pull/107168. Currently we have many similiar data structures like: - std::pair. - Element type of ModuleIdPath. - IdentifierLocPair. - IdentifierLoc. This PR unify these data structures to IdentifierLoc, moved IdentifierLoc definition to SourceLocation.h, and deleted other similer data structures. --- Patch is 110.90 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/136077.diff 47 Files Affected: - (modified) clang-tools-extra/pp-trace/PPCallbacksTracker.cpp (+2-2) - (modified) clang/include/clang/AST/OpenACCClause.h (+10-10) - (modified) clang/include/clang/Basic/IdentifierTable.h (+23-3) - (modified) clang/include/clang/Lex/ModuleLoader.h (+2-1) - (modified) clang/include/clang/Lex/PPCallbacks.h (+1) - (modified) clang/include/clang/Lex/Preprocessor.h (+4-5) - (modified) clang/include/clang/Parse/LoopHint.h (+1-1) - (modified) clang/include/clang/Parse/Parser.h (+5-8) - (modified) clang/include/clang/Sema/ParsedAttr.h (-10) - (modified) clang/include/clang/Sema/Sema.h (+1-1) - (modified) clang/include/clang/Sema/SemaCodeCompletion.h (+1-2) - (modified) clang/include/clang/Sema/SemaObjC.h (+2-2) - (modified) clang/include/clang/Sema/SemaOpenACC.h (+1-1) - (modified) clang/lib/AST/OpenACCClause.cpp (+2-2) - (modified) clang/lib/AST/TextNodeDumper.cpp (+2-2) - (modified) clang/lib/Frontend/CompilerInstance.cpp (+28-25) - (modified) clang/lib/Frontend/FrontendActions.cpp (+2-2) - (modified) clang/lib/Lex/PPDirectives.cpp (+11-11) - (modified) clang/lib/Lex/PPLexerChange.cpp (+3-3) - (modified) clang/lib/Lex/Pragma.cpp (+35-38) - (modified) clang/lib/Lex/Preprocessor.cpp (+8-8) - (modified) clang/lib/Parse/ParseDecl.cpp (+14-14) - (modified) clang/lib/Parse/ParseExpr.cpp (+4-3) - (modified) clang/lib/Parse/ParseHLSL.cpp (+1-1) - (modified) clang/lib/Parse/ParseObjc.cpp (+18-20) - (modified) clang/lib/Parse/ParseOpenACC.cpp (+7-5) - (modified) clang/lib/Parse/ParsePragma.cpp (+7-8) - (modified) clang/lib/Parse/ParseStmt.cpp (+3-3) - (modified) clang/lib/Parse/Parser.cpp (+9-10) - (modified) clang/lib/Sema/ParsedAttr.cpp (-8) - (modified) clang/lib/Sema/SemaARM.cpp (+1-1) - (modified) clang/lib/Sema/SemaCodeComplete.cpp (+4-4) - (modified) clang/lib/Sema/SemaDeclAttr.cpp (+65-59) - (modified) clang/lib/Sema/SemaDeclObjC.cpp (+19-16) - (modified) clang/lib/Sema/SemaHLSL.cpp (+6-6) - (modified) clang/lib/Sema/SemaModule.cpp (+23-19) - (modified) clang/lib/Sema/SemaObjC.cpp (+23-22) - (modified) clang/lib/Sema/SemaOpenACCClause.cpp (+6-5) - (modified) clang/lib/Sema/SemaStmtAttr.cpp (+16-13) - (modified) clang/lib/Sema/SemaSwift.cpp (+12-12) - (modified) clang/lib/Sema/SemaTemplateVariadic.cpp (+5-5) - (modified) clang/lib/Sema/SemaType.cpp (+6-7) - (modified) clang/lib/Serialization/ASTReader.cpp (+1-1) - (modified) clang/lib/Serialization/ASTWriter.cpp (+4-4) - (modified) clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp (+1-1) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (+4-2) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp (+8-9) ``diff diff --git a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp index 3bb30fd15b2e1..4c916fa30685b 100644 --- a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp +++ b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp @@ -547,8 +547,8 @@ void PPCallbacksTracker::appendArgument(const char *Name, ModuleIdPath Value) { if (I) SS << ", "; SS << "{" - << "Name: " << Value[I].first->getName() << ", " - << "Loc: " << getSourceLocationString(PP, Value[I].second) << "}"; + << "Name: " << Value[I].getIdentifierInfo()->getName() << ", " + << "Loc: " << getSourceLocationString(PP, Value[I].getLoc()) << "}"; } SS << "]"; appendArgument(Name, SS.str()); diff --git a/clang/include/clang/AST/OpenACCClause.h b/clang/include/clang/AST/OpenACCClause.h index 681567228cbb0..f18a6cf62f2c5 100644 --- a/clang/include/clang/AST/OpenACCClause.h +++ b/clang/include/clang/AST/OpenACCClause.h @@ -258,7 +258,7 @@ inline bool operator!=(const OpenACCBindClause &LHS, return !(LHS == RHS); } -using DeviceTypeArgument = std::pair; +using DeviceTypeArgument = IdentifierLoc; /// A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or /// an identifier. The 'asterisk' means 'the rest'. class OpenACCDeviceTypeClause final @@ -280,16 +280,16 @@ class OpenACCDeviceTypeClause final "Invalid clause kind for device-type"); assert(!llvm::any_of(Archs, [](const DeviceTypeArgument &Arg) { - return
[Lldb-commits] [clang] [clang-tools-extra] [lldb] Reland [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (PR #136077)
https://github.com/zyn0217 approved this pull request. https://github.com/llvm/llvm-project/pull/136077 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Minidump parser] Implement a range data vector for minidump memory ranges (PR #136040)
https://github.com/Jlalond created https://github.com/llvm/llvm-project/pull/136040 Recently I was debugging a Minidump with a few thousand ranges, and came across the (now deleted) comment: ``` // I don't have a sense of how frequently this is called or how many memory // ranges a Minidump typically has, so I'm not sure if searching for the // appropriate range linearly each time is stupid. Perhaps we should build // an index for faster lookups. ``` blaming this comment, it's 9 years old! Much overdue for this simple fix with a range data vector. I had to add a default constructor to Range in order to implement the RangeDataVector, but otherwise this just a replacement of look up logic. >From 40ca59992a02a5d236263ea88d8f7c1569b5e6c2 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Wed, 16 Apr 2025 14:33:04 -0700 Subject: [PATCH] Implement a range data vector for minidump memory ranges --- .../Process/minidump/MinidumpParser.cpp | 63 ++- .../Plugins/Process/minidump/MinidumpParser.h | 19 +- 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp index 94c0a5f11e435..24c89a173944c 100644 --- a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp +++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp @@ -429,62 +429,64 @@ MinidumpParser::GetExceptionStreams() { std::optional MinidumpParser::FindMemoryRange(lldb::addr_t addr) { - Log *log = GetLog(LLDBLog::Modules); + if (m_memory_ranges.IsEmpty()) +PopulateMemoryRanges(); + + MemoryRangeVector::Entry *entry = m_memory_ranges.FindEntryThatContains(addr); + if (!entry) +return std::nullopt; + + return entry->data; +} +void MinidumpParser::PopulateMemoryRanges() { + Log *log = GetLog(LLDBLog::Modules); auto ExpectedMemory = GetMinidumpFile().getMemoryList(); - if (!ExpectedMemory) { -LLDB_LOG_ERROR(log, ExpectedMemory.takeError(), - "Failed to read memory list: {0}"); - } else { + if (ExpectedMemory) { for (const auto &memory_desc : *ExpectedMemory) { const LocationDescriptor &loc_desc = memory_desc.Memory; const lldb::addr_t range_start = memory_desc.StartOfMemoryRange; const size_t range_size = loc_desc.DataSize; - - if (loc_desc.RVA + loc_desc.DataSize > GetData().size()) -return std::nullopt; - - if (range_start <= addr && addr < range_start + range_size) { -auto ExpectedSlice = GetMinidumpFile().getRawData(loc_desc); -if (!ExpectedSlice) { - LLDB_LOG_ERROR(log, ExpectedSlice.takeError(), - "Failed to get memory slice: {0}"); - return std::nullopt; -} -return minidump::Range(range_start, *ExpectedSlice); + auto ExpectedSlice = GetMinidumpFile().getRawData(loc_desc); + if (!ExpectedSlice) { +LLDB_LOG_ERROR(log, ExpectedSlice.takeError(), + "Failed to get memory slice: {0}"); +continue; } + m_memory_ranges.Append(MemoryRangeVector::Entry( + range_start, range_size, + minidump::Range(range_start, *ExpectedSlice))); } + } else { +LLDB_LOG_ERROR(log, ExpectedMemory.takeError(), + "Failed to read memory list: {0}"); } if (!GetStream(StreamType::Memory64List).empty()) { llvm::Error err = llvm::Error::success(); -for (const auto &memory_desc : GetMinidumpFile().getMemory64List(err)) { - if (memory_desc.first.StartOfMemoryRange <= addr - && addr < memory_desc.first.StartOfMemoryRange + memory_desc.first.DataSize) { -return minidump::Range(memory_desc.first.StartOfMemoryRange, memory_desc.second); - } +for (const auto &memory_desc : GetMinidumpFile().getMemory64List(err)) { + m_memory_ranges.Append(MemoryRangeVector::Entry( + memory_desc.first.StartOfMemoryRange, memory_desc.first.DataSize, + minidump::Range(memory_desc.first.StartOfMemoryRange, + memory_desc.second))); } if (err) LLDB_LOG_ERROR(log, std::move(err), "Failed to read memory64 list: {0}"); } - return std::nullopt; + m_memory_ranges.Sort(); } llvm::ArrayRef MinidumpParser::GetMemory(lldb::addr_t addr, size_t size) { - // I don't have a sense of how frequently this is called or how many memory - // ranges a Minidump typically has, so I'm not sure if searching for the - // appropriate range linearly each time is stupid. Perhaps we should build - // an index for faster lookups. std::optional range = FindMemoryRange(addr); if (!range) return {}; // There's at least some overlap between the beginning of the desired range - // (addr) and the current range. Figure out where the overlap begins and how - // much overlap there is. + // (addr) and the current ran
[Lldb-commits] [clang] [clang-tools-extra] [lldb] Reland [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (PR #136077)
llvmbot wrote: @llvm/pr-subscribers-clang-tools-extra Author: None (yronglin) Changes This PR reland https://github.com/llvm/llvm-project/pull/135808, fixed some missed changes in LLDB. I found this issue when I working on https://github.com/llvm/llvm-project/pull/107168. Currently we have many similiar data structures like: - std::pair. - Element type of ModuleIdPath. - IdentifierLocPair. - IdentifierLoc. This PR unify these data structures to IdentifierLoc, moved IdentifierLoc definition to SourceLocation.h, and deleted other similer data structures. --- Patch is 110.90 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/136077.diff 47 Files Affected: - (modified) clang-tools-extra/pp-trace/PPCallbacksTracker.cpp (+2-2) - (modified) clang/include/clang/AST/OpenACCClause.h (+10-10) - (modified) clang/include/clang/Basic/IdentifierTable.h (+23-3) - (modified) clang/include/clang/Lex/ModuleLoader.h (+2-1) - (modified) clang/include/clang/Lex/PPCallbacks.h (+1) - (modified) clang/include/clang/Lex/Preprocessor.h (+4-5) - (modified) clang/include/clang/Parse/LoopHint.h (+1-1) - (modified) clang/include/clang/Parse/Parser.h (+5-8) - (modified) clang/include/clang/Sema/ParsedAttr.h (-10) - (modified) clang/include/clang/Sema/Sema.h (+1-1) - (modified) clang/include/clang/Sema/SemaCodeCompletion.h (+1-2) - (modified) clang/include/clang/Sema/SemaObjC.h (+2-2) - (modified) clang/include/clang/Sema/SemaOpenACC.h (+1-1) - (modified) clang/lib/AST/OpenACCClause.cpp (+2-2) - (modified) clang/lib/AST/TextNodeDumper.cpp (+2-2) - (modified) clang/lib/Frontend/CompilerInstance.cpp (+28-25) - (modified) clang/lib/Frontend/FrontendActions.cpp (+2-2) - (modified) clang/lib/Lex/PPDirectives.cpp (+11-11) - (modified) clang/lib/Lex/PPLexerChange.cpp (+3-3) - (modified) clang/lib/Lex/Pragma.cpp (+35-38) - (modified) clang/lib/Lex/Preprocessor.cpp (+8-8) - (modified) clang/lib/Parse/ParseDecl.cpp (+14-14) - (modified) clang/lib/Parse/ParseExpr.cpp (+4-3) - (modified) clang/lib/Parse/ParseHLSL.cpp (+1-1) - (modified) clang/lib/Parse/ParseObjc.cpp (+18-20) - (modified) clang/lib/Parse/ParseOpenACC.cpp (+7-5) - (modified) clang/lib/Parse/ParsePragma.cpp (+7-8) - (modified) clang/lib/Parse/ParseStmt.cpp (+3-3) - (modified) clang/lib/Parse/Parser.cpp (+9-10) - (modified) clang/lib/Sema/ParsedAttr.cpp (-8) - (modified) clang/lib/Sema/SemaARM.cpp (+1-1) - (modified) clang/lib/Sema/SemaCodeComplete.cpp (+4-4) - (modified) clang/lib/Sema/SemaDeclAttr.cpp (+65-59) - (modified) clang/lib/Sema/SemaDeclObjC.cpp (+19-16) - (modified) clang/lib/Sema/SemaHLSL.cpp (+6-6) - (modified) clang/lib/Sema/SemaModule.cpp (+23-19) - (modified) clang/lib/Sema/SemaObjC.cpp (+23-22) - (modified) clang/lib/Sema/SemaOpenACCClause.cpp (+6-5) - (modified) clang/lib/Sema/SemaStmtAttr.cpp (+16-13) - (modified) clang/lib/Sema/SemaSwift.cpp (+12-12) - (modified) clang/lib/Sema/SemaTemplateVariadic.cpp (+5-5) - (modified) clang/lib/Sema/SemaType.cpp (+6-7) - (modified) clang/lib/Serialization/ASTReader.cpp (+1-1) - (modified) clang/lib/Serialization/ASTWriter.cpp (+4-4) - (modified) clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp (+1-1) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (+4-2) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp (+8-9) ``diff diff --git a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp index 3bb30fd15b2e1..4c916fa30685b 100644 --- a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp +++ b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp @@ -547,8 +547,8 @@ void PPCallbacksTracker::appendArgument(const char *Name, ModuleIdPath Value) { if (I) SS << ", "; SS << "{" - << "Name: " << Value[I].first->getName() << ", " - << "Loc: " << getSourceLocationString(PP, Value[I].second) << "}"; + << "Name: " << Value[I].getIdentifierInfo()->getName() << ", " + << "Loc: " << getSourceLocationString(PP, Value[I].getLoc()) << "}"; } SS << "]"; appendArgument(Name, SS.str()); diff --git a/clang/include/clang/AST/OpenACCClause.h b/clang/include/clang/AST/OpenACCClause.h index 681567228cbb0..f18a6cf62f2c5 100644 --- a/clang/include/clang/AST/OpenACCClause.h +++ b/clang/include/clang/AST/OpenACCClause.h @@ -258,7 +258,7 @@ inline bool operator!=(const OpenACCBindClause &LHS, return !(LHS == RHS); } -using DeviceTypeArgument = std::pair; +using DeviceTypeArgument = IdentifierLoc; /// A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or /// an identifier. The 'asterisk' means 'the rest'. class OpenACCDeviceTypeClause final @@ -280,16 +280,16 @@ class OpenACCDeviceTypeClause final "Invalid clause kind for device-type"); assert(!llvm::any_of(Archs, [](const DeviceTypeArgument &Arg) {
[Lldb-commits] [lldb] [lldb][Mach-O corefiles] Don't init Target arch to corefile (PR #136065)
@@ -578,20 +605,47 @@ Status ProcessMachCore::DoLoadCore() { SetCanJIT(false); + // If we have an executable binary in the Target already, + // use that to set the Target's ArchSpec. + // + // Don't initialize the ArchSpec based on the corefile's cputype/cpusubtype + // here, the corefile creator may not know the correct subtype of the code + // that is executing, initialize the Target to that, and if the + // main binary has Python code which initializes based on the Target arch, + // get the wrong subtype value. + ModuleSP exe_module_sp = GetTarget().GetExecutableModule(); + if (exe_module_sp && exe_module_sp->GetArchitecture().IsValid()) { +LLDB_LOGF(log, + "ProcessMachCore::%s: Was given binary + corefile, setting " + "target ArchSpec to binary to start", + __FUNCTION__); +GetTarget().SetArchitecture(exe_module_sp->GetArchitecture()); + } + CreateMemoryRegions(); LoadBinariesAndSetDYLD(); CleanupMemoryRegionPermissions(); - ModuleSP exe_module_sp = GetTarget().GetExecutableModule(); + exe_module_sp = GetTarget().GetExecutableModule(); jimingham wrote: It seems like you've already done exactly this computation at the beginning of LoadBinariesAndSetDYLD. Why do you need to do it again here? https://github.com/llvm/llvm-project/pull/136065 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Test "Revert "[CI] monolithic-linux improvements"" (PR #136078)
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/136078 None >From e70b8283d7778568ff715f8cc400732ad92ac321 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Thu, 17 Apr 2025 11:45:52 +0800 Subject: [PATCH] Revert "[CI] monolithic-linux improvements (#135499)" This reverts commit a399c6926a8701083c767cbb041e22ff92e9d717. --- .ci/compute_projects.py | 10 ++--- .ci/compute_projects_test.py | 13 --- .ci/monolithic-linux.sh | 72 lldb/test/requirements.txt | 2 - 4 files changed, 44 insertions(+), 53 deletions(-) diff --git a/.ci/compute_projects.py b/.ci/compute_projects.py index 17a2136a270d5..ff43547c9bbe5 100644 --- a/.ci/compute_projects.py +++ b/.ci/compute_projects.py @@ -52,9 +52,6 @@ "clang": {"clang-tools-extra", "compiler-rt", "cross-project-tests"}, "clang-tools-extra": {"libc"}, "mlir": {"flang"}, -# Test everything if ci scripts are changed. -# FIXME: Figure out what is missing and add here. -".ci": {"llvm", "clang", "lld", "lldb"}, } DEPENDENT_RUNTIMES_TO_TEST = {"clang": {"libcxx", "libcxxabi", "libunwind"}} @@ -133,11 +130,12 @@ def _add_dependencies(projects: Set[str]) -> Set[str]: def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> Set[str]: projects_to_test = set() for modified_project in modified_projects: +# Skip all projects where we cannot run tests. +if modified_project not in PROJECT_CHECK_TARGETS: +continue if modified_project in RUNTIMES: continue -# Skip all projects where we cannot run tests. -if modified_project in PROJECT_CHECK_TARGETS: -projects_to_test.add(modified_project) +projects_to_test.add(modified_project) if modified_project not in DEPENDENTS_TO_TEST: continue for dependent_project in DEPENDENTS_TO_TEST[modified_project]: diff --git a/.ci/compute_projects_test.py b/.ci/compute_projects_test.py index 1ab1c82498932..e787fd8133c86 100644 --- a/.ci/compute_projects_test.py +++ b/.ci/compute_projects_test.py @@ -188,19 +188,6 @@ def test_exclude_gn(self): self.assertEqual(env_variables["runtimes_to_build"], "") self.assertEqual(env_variables["runtimes_check_targets"], "") - def test_ci(self): -env_variables = compute_projects.get_env_variables( -[".ci/compute_projects.py"], "Linux" -) -self.assertEqual(env_variables["projects_to_build"], - "clang;lld;llvm;lldb") -self.assertEqual(env_variables["project_check_targets"], "check-clang - check-lld check-llvm check-lldb") -self.assertEqual(env_variables["runtimes_to_build"], - "libcxx;libcxxabi;libunwind") -self.assertEqual(env_variables["runtimes_check_targets"], "check-cxx - check-cxxabi check-unwind") - if __name__ == "__main__": unittest.main() diff --git a/.ci/monolithic-linux.sh b/.ci/monolithic-linux.sh index f81a14cca6cb3..6461c9d40ad59 100755 --- a/.ci/monolithic-linux.sh +++ b/.ci/monolithic-linux.sh @@ -18,6 +18,7 @@ set -o pipefail MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}" BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}" +INSTALL_DIR="${BUILD_DIR}/install" rm -rf "${BUILD_DIR}" ccache --zero-stats @@ -27,14 +28,10 @@ if [[ -n "${CLEAR_CACHE:-}" ]]; then ccache --clear fi -mkdir -p artifacts/reproducers - -# Make sure any clang reproducers will end up as artifacts. -export CLANG_CRASH_DIAGNOSTICS_DIR=`realpath artifacts/reproducers` - function at-exit { retcode=$? + mkdir -p artifacts ccache --print-stats > artifacts/ccache_stats.txt cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log @@ -53,28 +50,17 @@ trap at-exit EXIT projects="${1}" targets="${2}" -runtimes="${3}" lit_args="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --use-unique-output-file-name --timeout=1200 --time-tests" echo "--- cmake" - export PIP_BREAK_SYSTEM_PACKAGES=1 pip install -q -r "${MONOREPO_ROOT}"/mlir/python/requirements.txt pip install -q -r "${MONOREPO_ROOT}"/lldb/test/requirements.txt pip install -q -r "${MONOREPO_ROOT}"/.ci/requirements.txt - -# Set the system llvm-symbolizer as preferred. -export LLVM_SYMBOLIZER_PATH=`which llvm-symbolizer` -[[ ! -f "${LLVM_SYMBOLIZER_PATH}" ]] && echo "llvm-symbolizer not found!" - -# Set up all runtimes either way. libcxx is a dependency of LLDB. -# If it ends up being unused, not much harm. cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \ -D LLVM_ENABLE_PROJECTS="${projects}" \ - -D LLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ -G Ninja \ - -D CMAKE_PREFIX_PATH="${HOME}/.local" \ -D CMAKE_BUILD_TYPE=Release \ -D LLVM_ENABLE_ASSERTIONS=ON \ -D LLVM_BUILD_EXAMPLES=ON \ @@ -83,47 +69,69 @@ cmake -S "${MONOREPO_ROOT}"/llv
[Lldb-commits] [clang] [clang-tools-extra] [lldb] Reland [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (PR #136077)
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-arm Author: None (yronglin) Changes This PR reland https://github.com/llvm/llvm-project/pull/135808, fixed some missed changes in LLDB. I found this issue when I working on https://github.com/llvm/llvm-project/pull/107168. Currently we have many similiar data structures like: - std::pair. - Element type of ModuleIdPath. - IdentifierLocPair. - IdentifierLoc. This PR unify these data structures to IdentifierLoc, moved IdentifierLoc definition to SourceLocation.h, and deleted other similer data structures. --- Patch is 110.90 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/136077.diff 47 Files Affected: - (modified) clang-tools-extra/pp-trace/PPCallbacksTracker.cpp (+2-2) - (modified) clang/include/clang/AST/OpenACCClause.h (+10-10) - (modified) clang/include/clang/Basic/IdentifierTable.h (+23-3) - (modified) clang/include/clang/Lex/ModuleLoader.h (+2-1) - (modified) clang/include/clang/Lex/PPCallbacks.h (+1) - (modified) clang/include/clang/Lex/Preprocessor.h (+4-5) - (modified) clang/include/clang/Parse/LoopHint.h (+1-1) - (modified) clang/include/clang/Parse/Parser.h (+5-8) - (modified) clang/include/clang/Sema/ParsedAttr.h (-10) - (modified) clang/include/clang/Sema/Sema.h (+1-1) - (modified) clang/include/clang/Sema/SemaCodeCompletion.h (+1-2) - (modified) clang/include/clang/Sema/SemaObjC.h (+2-2) - (modified) clang/include/clang/Sema/SemaOpenACC.h (+1-1) - (modified) clang/lib/AST/OpenACCClause.cpp (+2-2) - (modified) clang/lib/AST/TextNodeDumper.cpp (+2-2) - (modified) clang/lib/Frontend/CompilerInstance.cpp (+28-25) - (modified) clang/lib/Frontend/FrontendActions.cpp (+2-2) - (modified) clang/lib/Lex/PPDirectives.cpp (+11-11) - (modified) clang/lib/Lex/PPLexerChange.cpp (+3-3) - (modified) clang/lib/Lex/Pragma.cpp (+35-38) - (modified) clang/lib/Lex/Preprocessor.cpp (+8-8) - (modified) clang/lib/Parse/ParseDecl.cpp (+14-14) - (modified) clang/lib/Parse/ParseExpr.cpp (+4-3) - (modified) clang/lib/Parse/ParseHLSL.cpp (+1-1) - (modified) clang/lib/Parse/ParseObjc.cpp (+18-20) - (modified) clang/lib/Parse/ParseOpenACC.cpp (+7-5) - (modified) clang/lib/Parse/ParsePragma.cpp (+7-8) - (modified) clang/lib/Parse/ParseStmt.cpp (+3-3) - (modified) clang/lib/Parse/Parser.cpp (+9-10) - (modified) clang/lib/Sema/ParsedAttr.cpp (-8) - (modified) clang/lib/Sema/SemaARM.cpp (+1-1) - (modified) clang/lib/Sema/SemaCodeComplete.cpp (+4-4) - (modified) clang/lib/Sema/SemaDeclAttr.cpp (+65-59) - (modified) clang/lib/Sema/SemaDeclObjC.cpp (+19-16) - (modified) clang/lib/Sema/SemaHLSL.cpp (+6-6) - (modified) clang/lib/Sema/SemaModule.cpp (+23-19) - (modified) clang/lib/Sema/SemaObjC.cpp (+23-22) - (modified) clang/lib/Sema/SemaOpenACCClause.cpp (+6-5) - (modified) clang/lib/Sema/SemaStmtAttr.cpp (+16-13) - (modified) clang/lib/Sema/SemaSwift.cpp (+12-12) - (modified) clang/lib/Sema/SemaTemplateVariadic.cpp (+5-5) - (modified) clang/lib/Sema/SemaType.cpp (+6-7) - (modified) clang/lib/Serialization/ASTReader.cpp (+1-1) - (modified) clang/lib/Serialization/ASTWriter.cpp (+4-4) - (modified) clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp (+1-1) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (+4-2) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp (+8-9) ``diff diff --git a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp index 3bb30fd15b2e1..4c916fa30685b 100644 --- a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp +++ b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp @@ -547,8 +547,8 @@ void PPCallbacksTracker::appendArgument(const char *Name, ModuleIdPath Value) { if (I) SS << ", "; SS << "{" - << "Name: " << Value[I].first->getName() << ", " - << "Loc: " << getSourceLocationString(PP, Value[I].second) << "}"; + << "Name: " << Value[I].getIdentifierInfo()->getName() << ", " + << "Loc: " << getSourceLocationString(PP, Value[I].getLoc()) << "}"; } SS << "]"; appendArgument(Name, SS.str()); diff --git a/clang/include/clang/AST/OpenACCClause.h b/clang/include/clang/AST/OpenACCClause.h index 681567228cbb0..f18a6cf62f2c5 100644 --- a/clang/include/clang/AST/OpenACCClause.h +++ b/clang/include/clang/AST/OpenACCClause.h @@ -258,7 +258,7 @@ inline bool operator!=(const OpenACCBindClause &LHS, return !(LHS == RHS); } -using DeviceTypeArgument = std::pair; +using DeviceTypeArgument = IdentifierLoc; /// A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or /// an identifier. The 'asterisk' means 'the rest'. class OpenACCDeviceTypeClause final @@ -280,16 +280,16 @@ class OpenACCDeviceTypeClause final "Invalid clause kind for device-type"); assert(!llvm::any_of(Archs, [](const Device
[Lldb-commits] [lldb] [lldb][Mach-O corefiles] Don't init Target arch to corefile (PR #136065)
@@ -578,20 +605,47 @@ Status ProcessMachCore::DoLoadCore() { SetCanJIT(false); + // If we have an executable binary in the Target already, + // use that to set the Target's ArchSpec. + // + // Don't initialize the ArchSpec based on the corefile's cputype/cpusubtype + // here, the corefile creator may not know the correct subtype of the code + // that is executing, initialize the Target to that, and if the + // main binary has Python code which initializes based on the Target arch, + // get the wrong subtype value. + ModuleSP exe_module_sp = GetTarget().GetExecutableModule(); + if (exe_module_sp && exe_module_sp->GetArchitecture().IsValid()) { +LLDB_LOGF(log, + "ProcessMachCore::%s: Was given binary + corefile, setting " + "target ArchSpec to binary to start", + __FUNCTION__); +GetTarget().SetArchitecture(exe_module_sp->GetArchitecture()); + } + CreateMemoryRegions(); LoadBinariesAndSetDYLD(); CleanupMemoryRegionPermissions(); - ModuleSP exe_module_sp = GetTarget().GetExecutableModule(); + exe_module_sp = GetTarget().GetExecutableModule(); jimingham wrote: If there's a reason that's then that's all good, but it might be helpful to future us to say why. https://github.com/llvm/llvm-project/pull/136065 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add summary for NSIndirectTaggedPointerString (PR #136025)
@@ -368,3 +373,37 @@ bool lldb_private::formatters::NSTaggedString_SummaryProvider( stream << suffix; return true; } + +bool lldb_private::formatters::NSIndirectTaggedString_SummaryProvider( +ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, +Stream &stream, const TypeSummaryOptions &summary_options) { + if (!descriptor) +return false; + + uint64_t payload = 0; + if (!descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) +return false; + + // First 47 bits are the address of the contents. + addr_t ptr = payload & 0x7fffULL; + // Next 13 bits are the string's length. + size_t size = (payload >> 47) & 0x1fff; + + Status status; + std::vector buf(size); + if (auto process_sp = valobj.GetProcessSP()) +if (process_sp->ReadMemory(ptr, buf.data(), size, status)) { + llvm::StringRef prefix, suffix; + if (auto *language = Language::FindPlugin(summary_options.GetLanguage())) +std::tie(prefix, suffix) = +language->GetFormatterPrefixSuffix("NSString"); + stream << prefix << '"'; + stream.PutCString({buf.data(), size}); adrian-prantl wrote: Does PutCString scan through the buffer until it finds a `NUL` byte or does it copy `size` bytes (which would be faster). I doubt this affects the performance measurably. Just being curious. https://github.com/llvm/llvm-project/pull/136025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] include telemetry session-id in diagnostic msg when enabled (PR #135924)
https://github.com/oontvoo created https://github.com/llvm/llvm-project/pull/135924 If LLDB crashes, it often helpful to know what the user was doing up to the point of the crash. Reporting the session-id helps us looking up the relevant logs. (Given Telemetry is disabled upstream, this change should mostly be a no-op change) >From 77e4045f5f48fb02237af45f1a12464ae218a168 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Wed, 16 Apr 2025 03:10:01 -0400 Subject: [PATCH] include telemetry session-id in diagnostic msg when enabled --- lldb/include/lldb/Core/Telemetry.h | 2 ++ lldb/source/Core/Telemetry.cpp | 2 ++ lldb/source/Utility/Diagnostics.cpp | 3 +++ lldb/source/Utility/LLDBAssert.cpp | 10 +++--- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lldb/include/lldb/Core/Telemetry.h b/lldb/include/lldb/Core/Telemetry.h index fa01e2e4af90f..f21efe0a9c533 100644 --- a/lldb/include/lldb/Core/Telemetry.h +++ b/lldb/include/lldb/Core/Telemetry.h @@ -219,6 +219,8 @@ class TelemetryManager : public llvm::telemetry::Manager { virtual llvm::StringRef GetInstanceName() const = 0; + llvm::StringRef GetSessionId() const; + static TelemetryManager *GetInstance(); protected: diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp index 8db29889e0846..8497c4f866c18 100644 --- a/lldb/source/Core/Telemetry.cpp +++ b/lldb/source/Core/Telemetry.cpp @@ -112,6 +112,8 @@ llvm::Error TelemetryManager::preDispatch(TelemetryInfo *entry) { return llvm::Error::success(); } +llvm::StringRef TelemetryManager::GetSessionid() const { return m_id; } + class NoOpTelemetryManager : public TelemetryManager { public: llvm::Error preDispatch(llvm::telemetry::TelemetryInfo *entry) override { diff --git a/lldb/source/Utility/Diagnostics.cpp b/lldb/source/Utility/Diagnostics.cpp index b2a08165dd6ca..9c9e24bc9659f 100644 --- a/lldb/source/Utility/Diagnostics.cpp +++ b/lldb/source/Utility/Diagnostics.cpp @@ -70,6 +70,9 @@ bool Diagnostics::Dump(raw_ostream &stream) { bool Diagnostics::Dump(raw_ostream &stream, const FileSpec &dir) { stream << "LLDB diagnostics will be written to " << dir.GetPath() << "\n"; stream << "Please include the directory content when filing a bug report\n"; + TelemetryManager *manager = TelemetryManager::GetInstance(); + if (manager->GetConfig()->EnableTelemetry) +stream << "Telemetry-SessionId: " << manager->GetSessionid() << "\n"; if (Error error = Create(dir)) { stream << toString(std::move(error)) << '\n'; diff --git a/lldb/source/Utility/LLDBAssert.cpp b/lldb/source/Utility/LLDBAssert.cpp index 611ad43cd071b..dc1e4d53031cc 100644 --- a/lldb/source/Utility/LLDBAssert.cpp +++ b/lldb/source/Utility/LLDBAssert.cpp @@ -7,6 +7,7 @@ //===--===// #include "lldb/Utility/LLDBAssert.h" +#include "lldb/Core/Telemetry.h" #include "llvm/Config/llvm-config.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Signals.h" @@ -51,11 +52,14 @@ void _lldb_assert(bool expression, const char *expr_text, const char *func, std::string buffer; llvm::raw_string_ostream backtrace(buffer); llvm::sys::PrintStackTrace(backtrace); - +std::string extra_detail; +TelemetryManager *manager = TelemetryManager::GetInstance(); +if (manager->GetConfig()->EnableTelemetry) + extra_detail = ". Telemetry-SessionId:" + manager->GetSessionId(); (*g_lldb_assert_callback.load())( llvm::formatv( -"Assertion failed: ({0}), function {1}, file {2}, line {3}", -expr_text, func, file, line) +"Assertion failed: ({0}), function {1}, file {2}, line {3}{4}", +expr_text, func, file, line, extra_detail) .str(), buffer, "Please file a bug report against lldb and include the backtrace, the " ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] include telemetry session-id in diagnostic msg when enabled (PR #135924)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Vy Nguyen (oontvoo) Changes If LLDB crashes, it often helpful to know what the user was doing up to the point of the crash. Reporting the session-id helps us looking up the relevant logs. (Given Telemetry is disabled upstream, this change should mostly be a no-op change) --- Full diff: https://github.com/llvm/llvm-project/pull/135924.diff 4 Files Affected: - (modified) lldb/include/lldb/Core/Telemetry.h (+2) - (modified) lldb/source/Core/Telemetry.cpp (+2) - (modified) lldb/source/Utility/Diagnostics.cpp (+3) - (modified) lldb/source/Utility/LLDBAssert.cpp (+7-3) ``diff diff --git a/lldb/include/lldb/Core/Telemetry.h b/lldb/include/lldb/Core/Telemetry.h index fa01e2e4af90f..f21efe0a9c533 100644 --- a/lldb/include/lldb/Core/Telemetry.h +++ b/lldb/include/lldb/Core/Telemetry.h @@ -219,6 +219,8 @@ class TelemetryManager : public llvm::telemetry::Manager { virtual llvm::StringRef GetInstanceName() const = 0; + llvm::StringRef GetSessionId() const; + static TelemetryManager *GetInstance(); protected: diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp index 8db29889e0846..8497c4f866c18 100644 --- a/lldb/source/Core/Telemetry.cpp +++ b/lldb/source/Core/Telemetry.cpp @@ -112,6 +112,8 @@ llvm::Error TelemetryManager::preDispatch(TelemetryInfo *entry) { return llvm::Error::success(); } +llvm::StringRef TelemetryManager::GetSessionid() const { return m_id; } + class NoOpTelemetryManager : public TelemetryManager { public: llvm::Error preDispatch(llvm::telemetry::TelemetryInfo *entry) override { diff --git a/lldb/source/Utility/Diagnostics.cpp b/lldb/source/Utility/Diagnostics.cpp index b2a08165dd6ca..9c9e24bc9659f 100644 --- a/lldb/source/Utility/Diagnostics.cpp +++ b/lldb/source/Utility/Diagnostics.cpp @@ -70,6 +70,9 @@ bool Diagnostics::Dump(raw_ostream &stream) { bool Diagnostics::Dump(raw_ostream &stream, const FileSpec &dir) { stream << "LLDB diagnostics will be written to " << dir.GetPath() << "\n"; stream << "Please include the directory content when filing a bug report\n"; + TelemetryManager *manager = TelemetryManager::GetInstance(); + if (manager->GetConfig()->EnableTelemetry) +stream << "Telemetry-SessionId: " << manager->GetSessionid() << "\n"; if (Error error = Create(dir)) { stream << toString(std::move(error)) << '\n'; diff --git a/lldb/source/Utility/LLDBAssert.cpp b/lldb/source/Utility/LLDBAssert.cpp index 611ad43cd071b..dc1e4d53031cc 100644 --- a/lldb/source/Utility/LLDBAssert.cpp +++ b/lldb/source/Utility/LLDBAssert.cpp @@ -7,6 +7,7 @@ //===--===// #include "lldb/Utility/LLDBAssert.h" +#include "lldb/Core/Telemetry.h" #include "llvm/Config/llvm-config.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Signals.h" @@ -51,11 +52,14 @@ void _lldb_assert(bool expression, const char *expr_text, const char *func, std::string buffer; llvm::raw_string_ostream backtrace(buffer); llvm::sys::PrintStackTrace(backtrace); - +std::string extra_detail; +TelemetryManager *manager = TelemetryManager::GetInstance(); +if (manager->GetConfig()->EnableTelemetry) + extra_detail = ". Telemetry-SessionId:" + manager->GetSessionId(); (*g_lldb_assert_callback.load())( llvm::formatv( -"Assertion failed: ({0}), function {1}, file {2}, line {3}", -expr_text, func, file, line) +"Assertion failed: ({0}), function {1}, file {2}, line {3}{4}", +expr_text, func, file, line, extra_detail) .str(), buffer, "Please file a bug report against lldb and include the backtrace, the " `` https://github.com/llvm/llvm-project/pull/135924 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DataFormatter] Surface CalculateNumChildren errors in std::vector summary (PR #135944)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/135944 >From 28ffd29ac558c8eb3ec8b3305480f237c822b4fd Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 16 Apr 2025 11:46:29 +0200 Subject: [PATCH 1/2] [lldb][DataFormatter] Surface CalculateNumChildren errors in std::vector summary When the data-formatters happen to break (e.g., due to layout changes in libc++), there's no clear indicator of them failing from a user's perspective. We just show: ``` (std::vector) v = size=0 {} ``` which is highly misleading, especially if `v.size()` returns a non-zero size. This patch surfaces the various errors that could occur when calculating the number of children of a vector. --- .../Language/CPlusPlus/LibCxxVector.cpp | 21 --- lldb/source/ValueObject/ValueObject.cpp | 12 +-- .../libcxx-simulators/invalid-vector/Makefile | 3 ++ ...taFormatterLibcxxInvalidVectorSimulator.py | 35 +++ .../libcxx-simulators/invalid-vector/main.cpp | 26 ++ 5 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/main.cpp diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp index d538cac9f9134..ce2261b6f03c3 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp @@ -83,19 +83,30 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd:: llvm::Expected lldb_private::formatters:: LibcxxStdVectorSyntheticFrontEnd::CalculateNumChildren() { if (!m_start || !m_finish) -return 0; +return llvm::createStringError( +"Failed to determine start/end of vector data."); + uint64_t start_val = m_start->GetValueAsUnsigned(0); uint64_t finish_val = m_finish->GetValueAsUnsigned(0); - if (start_val == 0 || finish_val == 0) + // A default-initialized empty vector. + if (start_val == 0 && finish_val == 0) return 0; - if (start_val >= finish_val) -return 0; + if (start_val == 0) +return llvm::createStringError("Invalid value for start of vector."); + + if (finish_val == 0) +return llvm::createStringError("Invalid value for end of vector."); + + if (start_val > finish_val) +return llvm::createStringError( +"Start of vector data begins after end pointer."); size_t num_children = (finish_val - start_val); if (num_children % m_element_size) -return 0; +return llvm::createStringError("Size not multiple of element size."); + return num_children / m_element_size; } diff --git a/lldb/source/ValueObject/ValueObject.cpp b/lldb/source/ValueObject/ValueObject.cpp index eac24353de90b..8741cb7343166 100644 --- a/lldb/source/ValueObject/ValueObject.cpp +++ b/lldb/source/ValueObject/ValueObject.cpp @@ -1521,10 +1521,16 @@ bool ValueObject::DumpPrintableRepresentation( str = GetLocationAsCString(); break; -case eValueObjectRepresentationStyleChildrenCount: - strm.Printf("%" PRIu64 "", (uint64_t)GetNumChildrenIgnoringErrors()); - str = strm.GetString(); +case eValueObjectRepresentationStyleChildrenCount: { + if (auto err = GetNumChildren()) { +strm.Printf("%" PRIu32, *err); +str = strm.GetString(); + } else { +strm << "error: " << toString(err.takeError()); +str = strm.GetString(); + } break; +} case eValueObjectRepresentationStyleType: str = GetTypeName().GetStringRef(); diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile new file mode 100644 index 0..38cfa81053488 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp +override CXXFLAGS_EXTRAS += -std=c++14 +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py new file mode 100644 index 0..6986d71c37a8b --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py @@ -0,0 +1,35 @@ +""" +Test we
[Lldb-commits] [lldb] [lldb][DataFormatter] Surface CalculateNumChildren errors in std::vector summary (PR #135944)
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 -- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/main.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp lldb/source/ValueObject/ValueObject.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/main.cpp index b8f0eccf0..c9f04f60e 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/main.cpp @@ -31,7 +31,7 @@ int main() { std::__2::vector v4; char carr[] = {'a'}; - std::__3::vector v5{.__begin_=carr, .__end_=carr + 1}; + std::__3::vector v5{.__begin_ = carr, .__end_ = carr + 1}; return 0; } `` https://github.com/llvm/llvm-project/pull/135944 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] include telemetry session-id in diagnostic msg when enabled (PR #135924)
https://github.com/oontvoo edited https://github.com/llvm/llvm-project/pull/135924 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] include telemetry session-id in diagnostic msg when enabled (PR #135924)
https://github.com/oontvoo edited https://github.com/llvm/llvm-project/pull/135924 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DataFormatter] Surface CalculateNumChildren errors in std::vector summary (PR #135944)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/135944 >From 28ffd29ac558c8eb3ec8b3305480f237c822b4fd Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 16 Apr 2025 11:46:29 +0200 Subject: [PATCH 1/3] [lldb][DataFormatter] Surface CalculateNumChildren errors in std::vector summary When the data-formatters happen to break (e.g., due to layout changes in libc++), there's no clear indicator of them failing from a user's perspective. We just show: ``` (std::vector) v = size=0 {} ``` which is highly misleading, especially if `v.size()` returns a non-zero size. This patch surfaces the various errors that could occur when calculating the number of children of a vector. --- .../Language/CPlusPlus/LibCxxVector.cpp | 21 --- lldb/source/ValueObject/ValueObject.cpp | 12 +-- .../libcxx-simulators/invalid-vector/Makefile | 3 ++ ...taFormatterLibcxxInvalidVectorSimulator.py | 35 +++ .../libcxx-simulators/invalid-vector/main.cpp | 26 ++ 5 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/main.cpp diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp index d538cac9f9134..ce2261b6f03c3 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp @@ -83,19 +83,30 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd:: llvm::Expected lldb_private::formatters:: LibcxxStdVectorSyntheticFrontEnd::CalculateNumChildren() { if (!m_start || !m_finish) -return 0; +return llvm::createStringError( +"Failed to determine start/end of vector data."); + uint64_t start_val = m_start->GetValueAsUnsigned(0); uint64_t finish_val = m_finish->GetValueAsUnsigned(0); - if (start_val == 0 || finish_val == 0) + // A default-initialized empty vector. + if (start_val == 0 && finish_val == 0) return 0; - if (start_val >= finish_val) -return 0; + if (start_val == 0) +return llvm::createStringError("Invalid value for start of vector."); + + if (finish_val == 0) +return llvm::createStringError("Invalid value for end of vector."); + + if (start_val > finish_val) +return llvm::createStringError( +"Start of vector data begins after end pointer."); size_t num_children = (finish_val - start_val); if (num_children % m_element_size) -return 0; +return llvm::createStringError("Size not multiple of element size."); + return num_children / m_element_size; } diff --git a/lldb/source/ValueObject/ValueObject.cpp b/lldb/source/ValueObject/ValueObject.cpp index eac24353de90b..8741cb7343166 100644 --- a/lldb/source/ValueObject/ValueObject.cpp +++ b/lldb/source/ValueObject/ValueObject.cpp @@ -1521,10 +1521,16 @@ bool ValueObject::DumpPrintableRepresentation( str = GetLocationAsCString(); break; -case eValueObjectRepresentationStyleChildrenCount: - strm.Printf("%" PRIu64 "", (uint64_t)GetNumChildrenIgnoringErrors()); - str = strm.GetString(); +case eValueObjectRepresentationStyleChildrenCount: { + if (auto err = GetNumChildren()) { +strm.Printf("%" PRIu32, *err); +str = strm.GetString(); + } else { +strm << "error: " << toString(err.takeError()); +str = strm.GetString(); + } break; +} case eValueObjectRepresentationStyleType: str = GetTypeName().GetStringRef(); diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile new file mode 100644 index 0..38cfa81053488 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp +override CXXFLAGS_EXTRAS += -std=c++14 +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py new file mode 100644 index 0..6986d71c37a8b --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py @@ -0,0 +1,35 @@ +""" +Test we
[Lldb-commits] [lldb] [LLDB] Add unary operators Dereference and AddressOf to DIL (PR #134428)
werat wrote: > I'm sure lldb-eval had its reasons to implement this, but its use case was > very different from this, and it wasn't in a position to change lldb to make > things faster. We are. As far as I remember flow analysis was implemented because according to C rules `&*p` is equivalent to `p`, which is important if `p` is NULL or "invalid". Same goes for array dereferencing. I could see how DIL may not want to care about this and just do dereference and return error if the pointer is invalid. I had to implement it in lldb-eval because we did have some user expressions that relied on this fact :) https://github.com/llvm/llvm-project/pull/134428 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Fixing a race during disconnect. (PR #135872)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/135872 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Minidump Parser] Implement a range data vector for minidump memory ranges (PR #136040)
https://github.com/Jlalond edited https://github.com/llvm/llvm-project/pull/136040 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove CompilerType::GetIndexOfFieldWithName (PR #135963)
https://github.com/charles-zablit edited https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove CompilerType::GetIndexOfFieldWithName (PR #135963)
charles-zablit wrote: > We probably shouldnt be removing the test. Is there some way to test whatever > we used to test without the API? I see 2 options: 1. Move the body of `CompilerType::GetIndexOfFieldWithName` into the test directly. This way, we remove the API but keep the test. 2. Keep the API, use `llvm::Expected` and keep the test. I feel like `1` would be `hiding` the API, and I would therefore prefer `2`. https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
https://github.com/charles-zablit edited https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
charles-zablit wrote: > It's worth mentioning that the LLVM convention (as opposed to what is done in > the swift fork) is to avoid force-pushing. Thanks! I will avoid that for the future PRs ๐ https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Add customization flags for ThreadPlanStepOut (PR #135866)
jimingham wrote: > > then it would queue up a ThreadPlanStepOut that would go to that frame. > > To elaborate on this, today there is no constructor for StepOut that allows > one to specify a target frame. This is also something we would need to create > for that to work, right? The main constructor for ThreadStepOut is: ``` ThreadPlanStepOut(Thread &thread, SymbolContext *addr_context, bool first_insn, bool stop_others, Vote report_stop_vote, Vote report_run_vote, uint32_t frame_idx, LazyBool step_out_avoids_code_without_debug_info, bool continue_to_next_branch = false, bool gather_return_value = true); ``` The `frame_idx` parameter is the frame you step out to. We use that, for instance, to implement "stepping out to the currently selected frame": `(lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 * frame #0: 0x00010330 callem`A at callem.c:2 frame #1: 0x0001035c callem`B at callem.c:6 frame #2: 0x00010380 callem`C at callem.c:10 frame #3: 0x000103a4 callem`D at callem.c:14 frame #4: 0x000103c8 callem`main at callem.c:18 frame #5: 0x0001821e2b4c dyld`start (lldb) up frame #1: 0x0001035c callem`B at callem.c:6 3} 4 5int B (int input) { -> 6 return A(input); ^ 7} 8 9int C (int input) { (lldb) up frame #2: 0x00010380 callem`C at callem.c:10 7} 8 9int C (int input) { -> 10 return B(input); ^ 11 } 12 13 int D (int input) { (lldb) fin Process 68455 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step out Return value: (int) $0 = 500 frame #0: 0x000103a4 callem`D at callem.c:14 11 } 12 13 int D (int input) { -> 14 return C(input); ^ 15 } 16 17 int main() { Target 0: (callem) stopped. ` https://github.com/llvm/llvm-project/pull/135866 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Add customization flags for ThreadPlanStepOut (PR #135866)
felipepiovezan wrote: > The `frame_idx` parameter is the frame you step out to. I don't think this is quite true, that parameter indicates where we step out _from_. I know this distinction may look unimportant at first, but it is exactly that distinction that gives the constructor space to skip artificial/hidden frames. The frame we step out _to_ is initially computed as `frame_idx+1`, and that keeps getting incremented while the frame is artificial/hidden. https://github.com/llvm/llvm-project/pull/135866 ___ 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] fix repeating commands in repl mode (PR #135008)
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,h -- lldb/tools/lldb-dap/DAP.cpp lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp lldb/tools/lldb-dap/LLDBUtils.cpp lldb/tools/lldb-dap/LLDBUtils.h `` View the diff from clang-format here. ``diff diff --git a/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp index 88f730313..99a5e599d 100644 --- a/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/EvaluateRequestHandler.cpp @@ -165,7 +165,7 @@ void EvaluateRequestHandler::operator()( } auto result = RunLLDBCommandsVerbatim(dap.debugger, llvm::StringRef(), {std::string(expression)}, - /*echo_commands=*/ false); + /*echo_commands=*/false); EmplaceSafeString(body, "result", result); body.try_emplace("variablesReference", (int64_t)0); } else { `` https://github.com/llvm/llvm-project/pull/135008 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 9dbe107 - disable test on older compilers (#136037)
Author: Shubham Sandeep Rastogi Date: 2025-04-16T14:41:20-07:00 New Revision: 9dbe107219c7ab1c422300f9eeb9ca3f7fc87c53 URL: https://github.com/llvm/llvm-project/commit/9dbe107219c7ab1c422300f9eeb9ca3f7fc87c53 DIFF: https://github.com/llvm/llvm-project/commit/9dbe107219c7ab1c422300f9eeb9ca3f7fc87c53.diff LOG: disable test on older compilers (#136037) Added: Modified: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py Removed: diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py index 8788ea7be882d..3f58018b0fbd9 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py @@ -13,6 +13,8 @@ class LibcxxInvalidVectorDataFormatterSimulatorTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True + +@skipIf(compiler="clang", compiler_version=['<', '15.0.1']) def test(self): self.build() lldbutil.run_to_source_breakpoint(self, "return 0", lldb.SBFileSpec("main.cpp")) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] disable test on older compilers (PR #136037)
https://github.com/rastogishubham created https://github.com/llvm/llvm-project/pull/136037 None >From 58c4bcec97c984ba43a5d141d8a5bf0bb53714b5 Mon Sep 17 00:00:00 2001 From: Shubham Sandeep Rastogi Date: Wed, 16 Apr 2025 14:40:49 -0700 Subject: [PATCH] disable test on older compilers --- .../TestDataFormatterLibcxxInvalidVectorSimulator.py| 2 ++ 1 file changed, 2 insertions(+) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py index 8788ea7be882d..3f58018b0fbd9 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/TestDataFormatterLibcxxInvalidVectorSimulator.py @@ -13,6 +13,8 @@ class LibcxxInvalidVectorDataFormatterSimulatorTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True + +@skipIf(compiler="clang", compiler_version=['<', '15.0.1']) def test(self): self.build() lldbutil.run_to_source_breakpoint(self, "return 0", lldb.SBFileSpec("main.cpp")) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] disable test on older compilers (PR #136037)
https://github.com/rastogishubham closed https://github.com/llvm/llvm-project/pull/136037 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Minidump parser] Implement a range data vector for minidump memory ranges (PR #136040)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jacob Lalonde (Jlalond) Changes Recently I was debugging a Minidump with a few thousand ranges, and came across the (now deleted) comment: ``` // I don't have a sense of how frequently this is called or how many memory // ranges a Minidump typically has, so I'm not sure if searching for the // appropriate range linearly each time is stupid. Perhaps we should build // an index for faster lookups. ``` blaming this comment, it's 9 years old! Much overdue for this simple fix with a range data vector. I had to add a default constructor to Range in order to implement the RangeDataVector, but otherwise this just a replacement of look up logic. --- Full diff: https://github.com/llvm/llvm-project/pull/136040.diff 2 Files Affected: - (modified) lldb/source/Plugins/Process/minidump/MinidumpParser.cpp (+33-30) - (modified) lldb/source/Plugins/Process/minidump/MinidumpParser.h (+16-3) ``diff diff --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp index 94c0a5f11e435..24c89a173944c 100644 --- a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp +++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp @@ -429,62 +429,64 @@ MinidumpParser::GetExceptionStreams() { std::optional MinidumpParser::FindMemoryRange(lldb::addr_t addr) { - Log *log = GetLog(LLDBLog::Modules); + if (m_memory_ranges.IsEmpty()) +PopulateMemoryRanges(); + + MemoryRangeVector::Entry *entry = m_memory_ranges.FindEntryThatContains(addr); + if (!entry) +return std::nullopt; + + return entry->data; +} +void MinidumpParser::PopulateMemoryRanges() { + Log *log = GetLog(LLDBLog::Modules); auto ExpectedMemory = GetMinidumpFile().getMemoryList(); - if (!ExpectedMemory) { -LLDB_LOG_ERROR(log, ExpectedMemory.takeError(), - "Failed to read memory list: {0}"); - } else { + if (ExpectedMemory) { for (const auto &memory_desc : *ExpectedMemory) { const LocationDescriptor &loc_desc = memory_desc.Memory; const lldb::addr_t range_start = memory_desc.StartOfMemoryRange; const size_t range_size = loc_desc.DataSize; - - if (loc_desc.RVA + loc_desc.DataSize > GetData().size()) -return std::nullopt; - - if (range_start <= addr && addr < range_start + range_size) { -auto ExpectedSlice = GetMinidumpFile().getRawData(loc_desc); -if (!ExpectedSlice) { - LLDB_LOG_ERROR(log, ExpectedSlice.takeError(), - "Failed to get memory slice: {0}"); - return std::nullopt; -} -return minidump::Range(range_start, *ExpectedSlice); + auto ExpectedSlice = GetMinidumpFile().getRawData(loc_desc); + if (!ExpectedSlice) { +LLDB_LOG_ERROR(log, ExpectedSlice.takeError(), + "Failed to get memory slice: {0}"); +continue; } + m_memory_ranges.Append(MemoryRangeVector::Entry( + range_start, range_size, + minidump::Range(range_start, *ExpectedSlice))); } + } else { +LLDB_LOG_ERROR(log, ExpectedMemory.takeError(), + "Failed to read memory list: {0}"); } if (!GetStream(StreamType::Memory64List).empty()) { llvm::Error err = llvm::Error::success(); -for (const auto &memory_desc : GetMinidumpFile().getMemory64List(err)) { - if (memory_desc.first.StartOfMemoryRange <= addr - && addr < memory_desc.first.StartOfMemoryRange + memory_desc.first.DataSize) { -return minidump::Range(memory_desc.first.StartOfMemoryRange, memory_desc.second); - } +for (const auto &memory_desc : GetMinidumpFile().getMemory64List(err)) { + m_memory_ranges.Append(MemoryRangeVector::Entry( + memory_desc.first.StartOfMemoryRange, memory_desc.first.DataSize, + minidump::Range(memory_desc.first.StartOfMemoryRange, + memory_desc.second))); } if (err) LLDB_LOG_ERROR(log, std::move(err), "Failed to read memory64 list: {0}"); } - return std::nullopt; + m_memory_ranges.Sort(); } llvm::ArrayRef MinidumpParser::GetMemory(lldb::addr_t addr, size_t size) { - // I don't have a sense of how frequently this is called or how many memory - // ranges a Minidump typically has, so I'm not sure if searching for the - // appropriate range linearly each time is stupid. Perhaps we should build - // an index for faster lookups. std::optional range = FindMemoryRange(addr); if (!range) return {}; // There's at least some overlap between the beginning of the desired range - // (addr) and the current range. Figure out where the overlap begins and how - // much overlap there is. + // (addr) and the current range. Figure out where the overlap begins and + // how much overlap there is. const size_t offset = addr - range->start; @
[Lldb-commits] [lldb] [lldb] Remove CompilerType::GetIndexOfFieldWithName (PR #135963)
Michael137 wrote: > > We probably shouldnt be removing the test. Is there some way to test > > whatever we used to test without the API? > > I see 2 options: > > 1. Move the body of `CompilerType::GetIndexOfFieldWithName` into the test > directly. This way, we remove the API but keep the test. > 2. Keep the API, use `llvm::Expected` and keep the test. > > I feel like `1` would be `hiding` the API, and I would therefore prefer `2`. I think the test can just do this: ``` uint64_t bit_offset; std::string name; field_type = field_type.GetFieldAtIndex( field_type.GetIndexOfChildWithName(field_name, /*omit_empty_base_classes=*/false), name, &bit_offset, nullptr, nullptr); ASSERT_TRUE(field_type); ``` Instead of using `CompilerType::GetIndexOfFieldWithName` (though I haven't actually tried to compile/run this) Don't have a strong opinion on whether to remove or extend the API. Personally I prefer removing it just because we already have so many similarly named APIs across CompilerType/TypeSystemClang that do things slightly differently, that it would be nice to get rid of at least one of them. https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Add customization flags for ThreadPlanStepOut (PR #135866)
felipepiovezan wrote: > > That's what QueueThreadPlanStepOutNoShouldStop is supposed to do, maybe > > it's not working? > > There is only one constructor for step out, and it always skips those frames. > So, yes, even in `QueueThreadPlanForStepOutNoShouldStop` we will skip over > frames. In fact that is what the default callback uses... https://github.com/llvm/llvm-project/pull/135866 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add summary for NSIndirectTaggedPointerString (PR #136025)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/136025 >From 1f9c152dbb7a1e2d70cdf924a8109c8cdb7d0a6f Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 16 Apr 2025 13:03:23 -0700 Subject: [PATCH 1/3] [lldb] Add summary for NSIndirectTaggedPointerString --- .../source/Plugins/Language/ObjC/NSString.cpp | 51 --- lldb/source/Plugins/Language/ObjC/NSString.h | 4 ++ .../Plugins/Language/ObjC/ObjCLanguage.cpp| 4 ++ 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp index a99d042572bfe..11b4c6c5df8af 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp @@ -63,12 +63,17 @@ bool lldb_private::formatters::NSStringSummaryProvider( if (class_name.empty()) return false; - bool is_tagged_ptr = class_name == "NSTaggedPointerString" && - descriptor->GetTaggedPointerInfo(); - // for a tagged pointer, the descriptor has everything we need - if (is_tagged_ptr) -return NSTaggedString_SummaryProvider(valobj, descriptor, stream, - summary_options); + // for tagged pointers, the descriptor has everything needed. + bool is_tagged = descriptor->GetTaggedPointerInfo(); + if (is_tagged) { +if (class_name == "NSTaggedPointerString") + return NSTaggedString_SummaryProvider(valobj, descriptor, stream, +summary_options); + +if (class_name == "NSIndirectTaggedPointerString") + return NSIndirectTaggedString_SummaryProvider(valobj, descriptor, stream, +summary_options); + } auto &additionals_map(NSString_Additionals::GetAdditionalSummaries()); auto iter = additionals_map.find(class_name_cs), end = additionals_map.end(); @@ -368,3 +373,37 @@ bool lldb_private::formatters::NSTaggedString_SummaryProvider( stream << suffix; return true; } + +bool lldb_private::formatters::NSIndirectTaggedString_SummaryProvider( +ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, +Stream &stream, const TypeSummaryOptions &summary_options) { + if (!descriptor) +return false; + + uint64_t payload = 0; + if (!descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) +return false; + + // First 47 bits are the address of the contents. + addr_t ptr = payload & 0x7fffULL; + // Next 13 bits are the string's length. + size_t size = (payload >> 47) & 0x1fff; + + Status status; + char buf[8192]; + if (auto process_sp = valobj.GetProcessSP()) +if (process_sp->ReadMemory(ptr, buf, size, status)) { + llvm::StringRef prefix, suffix; + if (auto *language = Language::FindPlugin(summary_options.GetLanguage())) +std::tie(prefix, suffix) = +language->GetFormatterPrefixSuffix("NSString"); + stream << prefix << '"'; + stream.PutCString({buf, size}); + stream << '"' << suffix; + return true; +} + + if (status.Fail()) +stream.Format("<{0}>", status); + return false; +} diff --git a/lldb/source/Plugins/Language/ObjC/NSString.h b/lldb/source/Plugins/Language/ObjC/NSString.h index 8c9fcf955f1f8..5d405b30b6817 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.h +++ b/lldb/source/Plugins/Language/ObjC/NSString.h @@ -25,6 +25,10 @@ bool NSTaggedString_SummaryProvider( ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, Stream &stream, const TypeSummaryOptions &summary_options); +bool NSIndirectTaggedString_SummaryProvider( +ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, +Stream &stream, const TypeSummaryOptions &summary_options); + bool NSAttributedStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options); diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp index c835b439a64dd..3b8e21cbb9269 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -691,6 +691,10 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) { AddCXXSummary( objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", "NSTaggedPointerString", appkit_flags); + AddCXXSummary(objc_category_sp, +lldb_private::formatters::NSStringSummaryProvider, +"NSString summary provider", "NSIndirectTaggedPointerString", +appkit_flags); AddCXXSummary(objc_category_sp, lldb_private::formatters::NSAttributedStringSummaryProvider, >From e50e40d2de5a24525457da9a2185b3e8358520cf Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 16 Apr 2025 15:24:06 -0700
[Lldb-commits] [lldb] [lldb] Add summary for NSIndirectTaggedPointerString (PR #136025)
@@ -368,3 +373,37 @@ bool lldb_private::formatters::NSTaggedString_SummaryProvider( stream << suffix; return true; } + +bool lldb_private::formatters::NSIndirectTaggedString_SummaryProvider( +ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, +Stream &stream, const TypeSummaryOptions &summary_options) { + if (!descriptor) +return false; + + uint64_t payload = 0; + if (!descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) +return false; + + // First 47 bits are the address of the contents. + addr_t ptr = payload & 0x7fffULL; + // Next 13 bits are the string's length. + size_t size = (payload >> 47) & 0x1fff; + + Status status; + char buf[8192]; kastiglione wrote: good call, done https://github.com/llvm/llvm-project/pull/136025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove CompilerType::GetIndexOfFieldWithName (PR #135963)
Michael137 wrote: We probably shouldnt be removing the test. Is there some way to test whatever we used to test without the API? https://github.com/llvm/llvm-project/pull/135963 ___ 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] fix repeating commands in repl mode (PR #135008)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/135008 >From 296019edb5edba4a21e040feb154b1ef83f1e64d Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Wed, 9 Apr 2025 14:35:09 +0100 Subject: [PATCH 1/5] [lldb][lldb-dap] fix repeating commands in repl mode Fixes #131589 Add a new option to the RunCommands* functions to control the echoing of commands --- .../lldb-dap/evaluate/TestDAP_evaluate.py | 2 +- .../tools/lldb-dap/launch/TestDAP_launch.py | 4 +-- .../repl-mode/TestDAP_repl_mode_detection.py | 11 +++--- lldb/tools/lldb-dap/DAP.cpp | 6 ++-- lldb/tools/lldb-dap/DAP.h | 3 +- .../Handler/EvaluateRequestHandler.cpp| 3 +- lldb/tools/lldb-dap/LLDBUtils.cpp | 35 ++- lldb/tools/lldb-dap/LLDBUtils.h | 19 +++--- 8 files changed, 54 insertions(+), 29 deletions(-) diff --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py index 251d77d79d080..e2f843bd337a6 100644 --- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py +++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py @@ -101,7 +101,7 @@ def run_test_evaluate_expressions( if context == "repl": # In the repl context expressions may be interpreted as lldb # commands since no variables have the same name as the command. -self.assertEvaluate("list", r"\(lldb\) list\n.*") +self.assertEvaluate("list", r".*") else: self.assertEvaluateFailure("list") # local variable of a_function diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py index 64c99019a1c9b..eceba2f8a13cb 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -522,11 +522,9 @@ def test_version(self): ) version_eval_output = version_eval_response["body"]["result"] -# The first line is the prompt line like "(lldb) version", so we skip it. -version_eval_output_without_prompt_line = version_eval_output.splitlines()[1:] version_string = self.dap_server.get_initialize_value("$__lldb_version") self.assertEqual( -version_eval_output_without_prompt_line, +version_eval_output.splitlines(), version_string.splitlines(), "version string does not match", ) diff --git a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py index 7c77fc8541b93..09ca725ee8883 100644 --- a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py +++ b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py @@ -28,15 +28,12 @@ def test_completions(self): self.set_source_breakpoints(source, [breakpoint1_line, breakpoint2_line]) -self.assertEvaluate( -"`command regex user_command s/^$/platform/", r"\(lldb\) command regex" -) -self.assertEvaluate( -"`command alias alias_command platform", r"\(lldb\) command alias" -) +# the result of the commands should return the empty string. +self.assertEvaluate("`command regex user_command s/^$/platform/", r"^$") +self.assertEvaluate("`command alias alias_command platform", r"^$") self.assertEvaluate( "`command alias alias_command_with_arg platform select --sysroot %1 remote-linux", -r"\(lldb\) command alias", +r"^$", ) self.continue_to_next_stop() diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index 9361ba968e9c2..03b9dc7135ef7 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -561,10 +561,12 @@ ReplMode DAP::DetectReplMode(lldb::SBFrame frame, std::string &expression, } bool DAP::RunLLDBCommands(llvm::StringRef prefix, - llvm::ArrayRef commands) { + llvm::ArrayRef commands, + bool echo_commands) { bool required_command_failed = false; std::string output = - ::RunLLDBCommands(debugger, prefix, commands, required_command_failed); + ::RunLLDBCommands(debugger, prefix, commands, required_command_failed, +/*parse_command_directives*/ true, echo_commands); SendOutput(OutputType::Console, output); return !required_command_failed; } diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h index fc43d988f3a09..cb3431cc87fd1 100644 --- a/lldb/tools/lldb-dap/DAP.h +++ b/lldb/tools/lldb-dap/DAP.h @@ -290,7 +290,8 @@ struct DAP { /// \b false if a fatal error was found while executing these commands, /// according to the rules of \a LLDBUtils::RunLLDBCommands. bool RunLL
[Lldb-commits] [lldb] [lldb][lldb-dap] fix repeating commands in repl mode (PR #135008)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/135008 >From 296019edb5edba4a21e040feb154b1ef83f1e64d Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Wed, 9 Apr 2025 14:35:09 +0100 Subject: [PATCH 1/4] [lldb][lldb-dap] fix repeating commands in repl mode Fixes #131589 Add a new option to the RunCommands* functions to control the echoing of commands --- .../lldb-dap/evaluate/TestDAP_evaluate.py | 2 +- .../tools/lldb-dap/launch/TestDAP_launch.py | 4 +-- .../repl-mode/TestDAP_repl_mode_detection.py | 11 +++--- lldb/tools/lldb-dap/DAP.cpp | 6 ++-- lldb/tools/lldb-dap/DAP.h | 3 +- .../Handler/EvaluateRequestHandler.cpp| 3 +- lldb/tools/lldb-dap/LLDBUtils.cpp | 35 ++- lldb/tools/lldb-dap/LLDBUtils.h | 19 +++--- 8 files changed, 54 insertions(+), 29 deletions(-) diff --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py index 251d77d79d080..e2f843bd337a6 100644 --- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py +++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py @@ -101,7 +101,7 @@ def run_test_evaluate_expressions( if context == "repl": # In the repl context expressions may be interpreted as lldb # commands since no variables have the same name as the command. -self.assertEvaluate("list", r"\(lldb\) list\n.*") +self.assertEvaluate("list", r".*") else: self.assertEvaluateFailure("list") # local variable of a_function diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py index 64c99019a1c9b..eceba2f8a13cb 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -522,11 +522,9 @@ def test_version(self): ) version_eval_output = version_eval_response["body"]["result"] -# The first line is the prompt line like "(lldb) version", so we skip it. -version_eval_output_without_prompt_line = version_eval_output.splitlines()[1:] version_string = self.dap_server.get_initialize_value("$__lldb_version") self.assertEqual( -version_eval_output_without_prompt_line, +version_eval_output.splitlines(), version_string.splitlines(), "version string does not match", ) diff --git a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py index 7c77fc8541b93..09ca725ee8883 100644 --- a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py +++ b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py @@ -28,15 +28,12 @@ def test_completions(self): self.set_source_breakpoints(source, [breakpoint1_line, breakpoint2_line]) -self.assertEvaluate( -"`command regex user_command s/^$/platform/", r"\(lldb\) command regex" -) -self.assertEvaluate( -"`command alias alias_command platform", r"\(lldb\) command alias" -) +# the result of the commands should return the empty string. +self.assertEvaluate("`command regex user_command s/^$/platform/", r"^$") +self.assertEvaluate("`command alias alias_command platform", r"^$") self.assertEvaluate( "`command alias alias_command_with_arg platform select --sysroot %1 remote-linux", -r"\(lldb\) command alias", +r"^$", ) self.continue_to_next_stop() diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index 9361ba968e9c2..03b9dc7135ef7 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -561,10 +561,12 @@ ReplMode DAP::DetectReplMode(lldb::SBFrame frame, std::string &expression, } bool DAP::RunLLDBCommands(llvm::StringRef prefix, - llvm::ArrayRef commands) { + llvm::ArrayRef commands, + bool echo_commands) { bool required_command_failed = false; std::string output = - ::RunLLDBCommands(debugger, prefix, commands, required_command_failed); + ::RunLLDBCommands(debugger, prefix, commands, required_command_failed, +/*parse_command_directives*/ true, echo_commands); SendOutput(OutputType::Console, output); return !required_command_failed; } diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h index fc43d988f3a09..cb3431cc87fd1 100644 --- a/lldb/tools/lldb-dap/DAP.h +++ b/lldb/tools/lldb-dap/DAP.h @@ -290,7 +290,8 @@ struct DAP { /// \b false if a fatal error was found while executing these commands, /// according to the rules of \a LLDBUtils::RunLLDBCommands. bool RunLL
[Lldb-commits] [lldb] [lldb] Add summary for NSIndirectTaggedPointerString (PR #136025)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/136025 None >From 1f9c152dbb7a1e2d70cdf924a8109c8cdb7d0a6f Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 16 Apr 2025 13:03:23 -0700 Subject: [PATCH] [lldb] Add summary for NSIndirectTaggedPointerString --- .../source/Plugins/Language/ObjC/NSString.cpp | 51 --- lldb/source/Plugins/Language/ObjC/NSString.h | 4 ++ .../Plugins/Language/ObjC/ObjCLanguage.cpp| 4 ++ 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp index a99d042572bfe..11b4c6c5df8af 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp @@ -63,12 +63,17 @@ bool lldb_private::formatters::NSStringSummaryProvider( if (class_name.empty()) return false; - bool is_tagged_ptr = class_name == "NSTaggedPointerString" && - descriptor->GetTaggedPointerInfo(); - // for a tagged pointer, the descriptor has everything we need - if (is_tagged_ptr) -return NSTaggedString_SummaryProvider(valobj, descriptor, stream, - summary_options); + // for tagged pointers, the descriptor has everything needed. + bool is_tagged = descriptor->GetTaggedPointerInfo(); + if (is_tagged) { +if (class_name == "NSTaggedPointerString") + return NSTaggedString_SummaryProvider(valobj, descriptor, stream, +summary_options); + +if (class_name == "NSIndirectTaggedPointerString") + return NSIndirectTaggedString_SummaryProvider(valobj, descriptor, stream, +summary_options); + } auto &additionals_map(NSString_Additionals::GetAdditionalSummaries()); auto iter = additionals_map.find(class_name_cs), end = additionals_map.end(); @@ -368,3 +373,37 @@ bool lldb_private::formatters::NSTaggedString_SummaryProvider( stream << suffix; return true; } + +bool lldb_private::formatters::NSIndirectTaggedString_SummaryProvider( +ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, +Stream &stream, const TypeSummaryOptions &summary_options) { + if (!descriptor) +return false; + + uint64_t payload = 0; + if (!descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) +return false; + + // First 47 bits are the address of the contents. + addr_t ptr = payload & 0x7fffULL; + // Next 13 bits are the string's length. + size_t size = (payload >> 47) & 0x1fff; + + Status status; + char buf[8192]; + if (auto process_sp = valobj.GetProcessSP()) +if (process_sp->ReadMemory(ptr, buf, size, status)) { + llvm::StringRef prefix, suffix; + if (auto *language = Language::FindPlugin(summary_options.GetLanguage())) +std::tie(prefix, suffix) = +language->GetFormatterPrefixSuffix("NSString"); + stream << prefix << '"'; + stream.PutCString({buf, size}); + stream << '"' << suffix; + return true; +} + + if (status.Fail()) +stream.Format("<{0}>", status); + return false; +} diff --git a/lldb/source/Plugins/Language/ObjC/NSString.h b/lldb/source/Plugins/Language/ObjC/NSString.h index 8c9fcf955f1f8..5d405b30b6817 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.h +++ b/lldb/source/Plugins/Language/ObjC/NSString.h @@ -25,6 +25,10 @@ bool NSTaggedString_SummaryProvider( ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, Stream &stream, const TypeSummaryOptions &summary_options); +bool NSIndirectTaggedString_SummaryProvider( +ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, +Stream &stream, const TypeSummaryOptions &summary_options); + bool NSAttributedStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options); diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp index c835b439a64dd..3b8e21cbb9269 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -691,6 +691,10 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) { AddCXXSummary( objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", "NSTaggedPointerString", appkit_flags); + AddCXXSummary(objc_category_sp, +lldb_private::formatters::NSStringSummaryProvider, +"NSString summary provider", "NSIndirectTaggedPointerString", +appkit_flags); AddCXXSummary(objc_category_sp, lldb_private::formatters::NSAttributedStringSummaryProvider, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org
[Lldb-commits] [lldb] [lldb] Add summary for NSIndirectTaggedPointerString (PR #136025)
https://github.com/kastiglione ready_for_review https://github.com/llvm/llvm-project/pull/136025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add summary for NSIndirectTaggedPointerString (PR #136025)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/136025 >From 1f9c152dbb7a1e2d70cdf924a8109c8cdb7d0a6f Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 16 Apr 2025 13:03:23 -0700 Subject: [PATCH 1/2] [lldb] Add summary for NSIndirectTaggedPointerString --- .../source/Plugins/Language/ObjC/NSString.cpp | 51 --- lldb/source/Plugins/Language/ObjC/NSString.h | 4 ++ .../Plugins/Language/ObjC/ObjCLanguage.cpp| 4 ++ 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp index a99d042572bfe..11b4c6c5df8af 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp @@ -63,12 +63,17 @@ bool lldb_private::formatters::NSStringSummaryProvider( if (class_name.empty()) return false; - bool is_tagged_ptr = class_name == "NSTaggedPointerString" && - descriptor->GetTaggedPointerInfo(); - // for a tagged pointer, the descriptor has everything we need - if (is_tagged_ptr) -return NSTaggedString_SummaryProvider(valobj, descriptor, stream, - summary_options); + // for tagged pointers, the descriptor has everything needed. + bool is_tagged = descriptor->GetTaggedPointerInfo(); + if (is_tagged) { +if (class_name == "NSTaggedPointerString") + return NSTaggedString_SummaryProvider(valobj, descriptor, stream, +summary_options); + +if (class_name == "NSIndirectTaggedPointerString") + return NSIndirectTaggedString_SummaryProvider(valobj, descriptor, stream, +summary_options); + } auto &additionals_map(NSString_Additionals::GetAdditionalSummaries()); auto iter = additionals_map.find(class_name_cs), end = additionals_map.end(); @@ -368,3 +373,37 @@ bool lldb_private::formatters::NSTaggedString_SummaryProvider( stream << suffix; return true; } + +bool lldb_private::formatters::NSIndirectTaggedString_SummaryProvider( +ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, +Stream &stream, const TypeSummaryOptions &summary_options) { + if (!descriptor) +return false; + + uint64_t payload = 0; + if (!descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) +return false; + + // First 47 bits are the address of the contents. + addr_t ptr = payload & 0x7fffULL; + // Next 13 bits are the string's length. + size_t size = (payload >> 47) & 0x1fff; + + Status status; + char buf[8192]; + if (auto process_sp = valobj.GetProcessSP()) +if (process_sp->ReadMemory(ptr, buf, size, status)) { + llvm::StringRef prefix, suffix; + if (auto *language = Language::FindPlugin(summary_options.GetLanguage())) +std::tie(prefix, suffix) = +language->GetFormatterPrefixSuffix("NSString"); + stream << prefix << '"'; + stream.PutCString({buf, size}); + stream << '"' << suffix; + return true; +} + + if (status.Fail()) +stream.Format("<{0}>", status); + return false; +} diff --git a/lldb/source/Plugins/Language/ObjC/NSString.h b/lldb/source/Plugins/Language/ObjC/NSString.h index 8c9fcf955f1f8..5d405b30b6817 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.h +++ b/lldb/source/Plugins/Language/ObjC/NSString.h @@ -25,6 +25,10 @@ bool NSTaggedString_SummaryProvider( ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, Stream &stream, const TypeSummaryOptions &summary_options); +bool NSIndirectTaggedString_SummaryProvider( +ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor, +Stream &stream, const TypeSummaryOptions &summary_options); + bool NSAttributedStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options); diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp index c835b439a64dd..3b8e21cbb9269 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -691,6 +691,10 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) { AddCXXSummary( objc_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", "NSTaggedPointerString", appkit_flags); + AddCXXSummary(objc_category_sp, +lldb_private::formatters::NSStringSummaryProvider, +"NSString summary provider", "NSIndirectTaggedPointerString", +appkit_flags); AddCXXSummary(objc_category_sp, lldb_private::formatters::NSAttributedStringSummaryProvider, >From e50e40d2de5a24525457da9a2185b3e8358520cf Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 16 Apr 2025 15:24:06 -0700
[Lldb-commits] [lldb] [lldb] Add summary for NSIndirectTaggedPointerString (PR #136025)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/136025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add summary for NSIndirectTaggedPointerString (PR #136025)
@@ -63,12 +63,17 @@ bool lldb_private::formatters::NSStringSummaryProvider( if (class_name.empty()) return false; - bool is_tagged_ptr = class_name == "NSTaggedPointerString" && - descriptor->GetTaggedPointerInfo(); - // for a tagged pointer, the descriptor has everything we need - if (is_tagged_ptr) -return NSTaggedString_SummaryProvider(valobj, descriptor, stream, - summary_options); + // for tagged pointers, the descriptor has everything needed. adrian-prantl wrote: ```suggestion // For tagged pointers, the descriptor has everything needed. ``` https://github.com/llvm/llvm-project/pull/136025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits