[Lldb-commits] [lldb] [lldb][NFCI] Simplify ProcessElfCore::GetAuxvData() (PR #102263)
https://github.com/igorkudrin created https://github.com/llvm/llvm-project/pull/102263 There is no need to clone the content and set extraction properties because `m_auxv` is already in the required form. >From d3a72694e444cf19e62bceab3234b8a338aec7b1 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Tue, 6 Aug 2024 18:33:01 -0700 Subject: [PATCH] [lldb][NFCI] Simplify ProcessElfCore::GetAuxvData() There is no need to create a new `DataExtractor` and clone the content, because `m_auxv` already has the required form. --- lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp index 30af9345999c41..e73e31ca78d19f 100644 --- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -1077,10 +1077,10 @@ ArchSpec ProcessElfCore::GetArchitecture() { } DataExtractor ProcessElfCore::GetAuxvData() { - const uint8_t *start = m_auxv.GetDataStart(); - size_t len = m_auxv.GetByteSize(); - lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(start, len)); - return DataExtractor(buffer, GetByteOrder(), GetAddressByteSize()); + assert(m_auxv.GetByteSize() == 0 || + (m_auxv.GetByteOrder() == GetByteOrder() && + m_auxv.GetAddressByteSize() == GetAddressByteSize())); + return DataExtractor(m_auxv); } bool ProcessElfCore::GetProcessInfo(ProcessInstanceInfo &info) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFCI] Simplify ProcessElfCore::GetAuxvData() (PR #102263)
@@ -1077,10 +1077,10 @@ ArchSpec ProcessElfCore::GetArchitecture() { } DataExtractor ProcessElfCore::GetAuxvData() { - const uint8_t *start = m_auxv.GetDataStart(); - size_t len = m_auxv.GetByteSize(); - lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(start, len)); - return DataExtractor(buffer, GetByteOrder(), GetAddressByteSize()); + assert(m_auxv.GetByteSize() == 0 || + (m_auxv.GetByteOrder() == GetByteOrder() && + m_auxv.GetAddressByteSize() == GetAddressByteSize())); igorkudrin wrote: I added the `assert` to be on the safe side. It shows that the change is eligible, and if I overlooked some exotic execution path, it will trigger and point directly to the problem. If you believe it's excessive, I'll remove it. The copy constructor for `DataExtractor` should be called explicitly, see [the comment](https://github.com/llvm/llvm-project/blob/03841e7ab847b279d65be707a8e0f2799fd69f50/lldb/include/lldb/Utility/DataExtractor.h#L137). And `GetAuxvData()` cannot return a reference to a data member because in some classes it returns a temporary object. https://github.com/llvm/llvm-project/pull/102263 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFCI] Simplify ProcessElfCore::GetAuxvData() (PR #102263)
https://github.com/igorkudrin edited https://github.com/llvm/llvm-project/pull/102263 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFCI] Simplify ProcessElfCore::GetAuxvData() (PR #102263)
@@ -1077,10 +1077,10 @@ ArchSpec ProcessElfCore::GetArchitecture() { } DataExtractor ProcessElfCore::GetAuxvData() { - const uint8_t *start = m_auxv.GetDataStart(); - size_t len = m_auxv.GetByteSize(); - lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(start, len)); - return DataExtractor(buffer, GetByteOrder(), GetAddressByteSize()); + assert(m_auxv.GetByteSize() == 0 || + (m_auxv.GetByteOrder() == GetByteOrder() && + m_auxv.GetAddressByteSize() == GetAddressByteSize())); igorkudrin wrote: I'd also prefer to return a constant reference, but there are other implementations of this virtual function that can't do that, for example, `ProcessGDBRemote::GetAuxvData()`. https://github.com/llvm/llvm-project/pull/102263 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFCI] Simplify ProcessElfCore::GetAuxvData() (PR #102263)
https://github.com/igorkudrin closed https://github.com/llvm/llvm-project/pull/102263 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AArch64] Do not crash if NT_ARM_TLS is missing (PR #106478)
https://github.com/igorkudrin created https://github.com/llvm/llvm-project/pull/106478 [D156118](https://reviews.llvm.org/D156118) states that this note is always present, but it is better to check it explicitly, as otherwise `lldb` may crash when trying to read registers. >From e588c3c3053239bd089a06749ecd99bf187290be Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Wed, 28 Aug 2024 17:57:38 -0700 Subject: [PATCH] [lldb][AArch64] Do not crash if NT_ARM_TLS is missing [D156118](https://reviews.llvm.org/D156118) states that this note is always present, but it is better to check it explicitly, as otherwise `lldb` may crash when trying to read registers. --- .../Utility/RegisterInfoPOSIX_arm64.cpp | 7 ++-- .../elf-core/aarch64-no-NT_ARM_TLS.yaml | 34 +++ .../test/Shell/Process/elf-core/lit.local.cfg | 1 + 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml create mode 100644 lldb/test/Shell/Process/elf-core/lit.local.cfg diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp index 054b7d9b2ec575..8ebdd214458c45 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp @@ -254,9 +254,10 @@ RegisterInfoPOSIX_arm64::RegisterInfoPOSIX_arm64( if (m_opt_regsets.AllSet(eRegsetMaskMTE)) AddRegSetMTE(); - // The TLS set always contains tpidr but only has tpidr2 when SME is - // present. - AddRegSetTLS(m_opt_regsets.AllSet(eRegsetMaskSSVE)); + if (m_opt_regsets.AllSet(eRegsetMaskTLS)) +// The TLS set always contains tpidr but only has tpidr2 when SME is +// present. +AddRegSetTLS(m_opt_regsets.AllSet(eRegsetMaskSSVE)); if (m_opt_regsets.AnySet(eRegsetMaskSSVE)) AddRegSetSME(m_opt_regsets.AnySet(eRegsetMaskZT)); diff --git a/lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml b/lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml new file mode 100644 index 00..bd8ce225c9e071 --- /dev/null +++ b/lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml @@ -0,0 +1,34 @@ +# REQUIRES: aarch64 + +## Check that lldb does not crash if a core file does not contain an NT_ARM_TLS +## note while there are notes for other dynamic register sets. + +# RUN: yaml2obj %s -o %t +# RUN: %lldb -c %t -o "re r -a" | FileCheck %s + +# CHECK: Pointer Authentication Registers: +# CHECK-NEXT: data_mask = +# CHECK-NEXT: code_mask = +# CHECK-NOT: Thread Local Storage Registers: + +--- !ELF +FileHeader: + Class:ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_CORE + Machine: EM_AARCH64 +ProgramHeaders: + - Type: PT_NOTE +FirstSec: .note +LastSec:.note +Sections: + - Name: .note +Type: SHT_NOTE +Notes: + - Name: CORE +Desc: 0b000b0038931b9338931b93e02e11915ee12f00400162e258014000200162e224014100 +Type: NT_PRSTATUS + - Name: LINUX +Desc: 7f007f00 +Type: NT_ARM_PAC_MASK +... diff --git a/lldb/test/Shell/Process/elf-core/lit.local.cfg b/lldb/test/Shell/Process/elf-core/lit.local.cfg new file mode 100644 index 00..8169b9f95e118c --- /dev/null +++ b/lldb/test/Shell/Process/elf-core/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.yaml'] ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AArch64] Do not crash if NT_ARM_TLS is missing (PR #106478)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/106478 >From 6854730d45a2c119d2b8f71df6e22ead1c7ad5a8 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Wed, 28 Aug 2024 17:57:38 -0700 Subject: [PATCH] [lldb][AArch64] Do not crash if NT_ARM_TLS is missing [D156118](https://reviews.llvm.org/D156118) states that this note is always present, but it is better to check it explicitly, as otherwise `lldb` may crash when trying to read registers. --- .../Utility/RegisterInfoPOSIX_arm64.cpp | 7 ++-- .../elf-core/aarch64-no-NT_ARM_TLS.yaml | 34 +++ .../test/Shell/Process/elf-core/lit.local.cfg | 1 + 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml create mode 100644 lldb/test/Shell/Process/elf-core/lit.local.cfg diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp index 054b7d9b2ec575..8ebdd214458c45 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp @@ -254,9 +254,10 @@ RegisterInfoPOSIX_arm64::RegisterInfoPOSIX_arm64( if (m_opt_regsets.AllSet(eRegsetMaskMTE)) AddRegSetMTE(); - // The TLS set always contains tpidr but only has tpidr2 when SME is - // present. - AddRegSetTLS(m_opt_regsets.AllSet(eRegsetMaskSSVE)); + if (m_opt_regsets.AllSet(eRegsetMaskTLS)) +// The TLS set always contains tpidr but only has tpidr2 when SME is +// present. +AddRegSetTLS(m_opt_regsets.AllSet(eRegsetMaskSSVE)); if (m_opt_regsets.AnySet(eRegsetMaskSSVE)) AddRegSetSME(m_opt_regsets.AnySet(eRegsetMaskZT)); diff --git a/lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml b/lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml new file mode 100644 index 00..bd8ce225c9e071 --- /dev/null +++ b/lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml @@ -0,0 +1,34 @@ +# REQUIRES: aarch64 + +## Check that lldb does not crash if a core file does not contain an NT_ARM_TLS +## note while there are notes for other dynamic register sets. + +# RUN: yaml2obj %s -o %t +# RUN: %lldb -c %t -o "re r -a" | FileCheck %s + +# CHECK: Pointer Authentication Registers: +# CHECK-NEXT: data_mask = +# CHECK-NEXT: code_mask = +# CHECK-NOT: Thread Local Storage Registers: + +--- !ELF +FileHeader: + Class:ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_CORE + Machine: EM_AARCH64 +ProgramHeaders: + - Type: PT_NOTE +FirstSec: .note +LastSec:.note +Sections: + - Name: .note +Type: SHT_NOTE +Notes: + - Name: CORE +Desc: 0b000b0038931b9338931b93e02e11915ee12f00400162e258014000200162e224014100 +Type: NT_PRSTATUS + - Name: LINUX +Desc: 7f007f00 +Type: NT_ARM_PAC_MASK +... diff --git a/lldb/test/Shell/Process/elf-core/lit.local.cfg b/lldb/test/Shell/Process/elf-core/lit.local.cfg new file mode 100644 index 00..8169b9f95e118c --- /dev/null +++ b/lldb/test/Shell/Process/elf-core/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.yaml'] ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AArch64] Do not crash if NT_ARM_TLS is missing (PR #106478)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/106478 >From 6854730d45a2c119d2b8f71df6e22ead1c7ad5a8 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Wed, 28 Aug 2024 17:57:38 -0700 Subject: [PATCH 1/2] [lldb][AArch64] Do not crash if NT_ARM_TLS is missing [D156118](https://reviews.llvm.org/D156118) states that this note is always present, but it is better to check it explicitly, as otherwise `lldb` may crash when trying to read registers. --- .../Utility/RegisterInfoPOSIX_arm64.cpp | 7 ++-- .../elf-core/aarch64-no-NT_ARM_TLS.yaml | 34 +++ .../test/Shell/Process/elf-core/lit.local.cfg | 1 + 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml create mode 100644 lldb/test/Shell/Process/elf-core/lit.local.cfg diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp index 054b7d9b2ec575..8ebdd214458c45 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp @@ -254,9 +254,10 @@ RegisterInfoPOSIX_arm64::RegisterInfoPOSIX_arm64( if (m_opt_regsets.AllSet(eRegsetMaskMTE)) AddRegSetMTE(); - // The TLS set always contains tpidr but only has tpidr2 when SME is - // present. - AddRegSetTLS(m_opt_regsets.AllSet(eRegsetMaskSSVE)); + if (m_opt_regsets.AllSet(eRegsetMaskTLS)) +// The TLS set always contains tpidr but only has tpidr2 when SME is +// present. +AddRegSetTLS(m_opt_regsets.AllSet(eRegsetMaskSSVE)); if (m_opt_regsets.AnySet(eRegsetMaskSSVE)) AddRegSetSME(m_opt_regsets.AnySet(eRegsetMaskZT)); diff --git a/lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml b/lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml new file mode 100644 index 00..bd8ce225c9e071 --- /dev/null +++ b/lldb/test/Shell/Process/elf-core/aarch64-no-NT_ARM_TLS.yaml @@ -0,0 +1,34 @@ +# REQUIRES: aarch64 + +## Check that lldb does not crash if a core file does not contain an NT_ARM_TLS +## note while there are notes for other dynamic register sets. + +# RUN: yaml2obj %s -o %t +# RUN: %lldb -c %t -o "re r -a" | FileCheck %s + +# CHECK: Pointer Authentication Registers: +# CHECK-NEXT: data_mask = +# CHECK-NEXT: code_mask = +# CHECK-NOT: Thread Local Storage Registers: + +--- !ELF +FileHeader: + Class:ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_CORE + Machine: EM_AARCH64 +ProgramHeaders: + - Type: PT_NOTE +FirstSec: .note +LastSec:.note +Sections: + - Name: .note +Type: SHT_NOTE +Notes: + - Name: CORE +Desc: 0b000b0038931b9338931b93e02e11915ee12f00400162e258014000200162e224014100 +Type: NT_PRSTATUS + - Name: LINUX +Desc: 7f007f00 +Type: NT_ARM_PAC_MASK +... diff --git a/lldb/test/Shell/Process/elf-core/lit.local.cfg b/lldb/test/Shell/Process/elf-core/lit.local.cfg new file mode 100644 index 00..8169b9f95e118c --- /dev/null +++ b/lldb/test/Shell/Process/elf-core/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.yaml'] >From 90366705c6bce931a279940c5f9ee43f232f00f2 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Thu, 29 Aug 2024 12:20:42 -0700 Subject: [PATCH 2/2] fixup: add braces --- .../source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp index 8ebdd214458c45..9f5872e5de7e9f 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp @@ -254,10 +254,11 @@ RegisterInfoPOSIX_arm64::RegisterInfoPOSIX_arm64( if (m_opt_regsets.AllSet(eRegsetMaskMTE)) AddRegSetMTE(); - if (m_opt_regsets.AllSet(eRegsetMaskTLS)) + if (m_opt_regsets.AllSet(eRegsetMaskTLS)) { // The TLS set always contains tpidr but only has tpidr2 when SME is
[Lldb-commits] [lld] [lldb] [flang] [libcxx] [compiler-rt] [clang-tools-extra] [llvm] [clang] [YAMLParser] Unfold multi-line scalar values (PR #70898)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/70898 >From 113c03bbf773c71d329ab2afd063753365e4ac68 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Thu, 26 Oct 2023 13:19:08 -0700 Subject: [PATCH] [YAMLParser] Unfold multi-line scalar values Long scalar values can be split into multiple lines to improve readability. The rules are described in Section 6.5. "Line Folding", https://yaml.org/spec/1.2.2/#65-line-folding. In addition, for flow scalar styles, the Spec states that "All leading and trailing white space characters on each line are excluded from the content", https://yaml.org/spec/1.2.2/#73-flow-scalar-styles. The patch implements these unfolding rules for double-quoted, single-quoted, and plain scalars. --- llvm/include/llvm/Support/YAMLParser.h | 9 +- llvm/lib/Support/YAMLParser.cpp | 364 +--- llvm/test/YAMLParser/spec-09-01.test| 11 +- llvm/test/YAMLParser/spec-09-02.test| 31 +- llvm/test/YAMLParser/spec-09-03.test| 7 +- llvm/test/YAMLParser/spec-09-04.test| 3 +- llvm/test/YAMLParser/spec-09-05.test| 7 +- llvm/test/YAMLParser/spec-09-06.test| 3 +- llvm/test/YAMLParser/spec-09-07.test| 11 +- llvm/test/YAMLParser/spec-09-08.test| 15 +- llvm/test/YAMLParser/spec-09-09.test| 7 +- llvm/test/YAMLParser/spec-09-10.test| 3 +- llvm/test/YAMLParser/spec-09-11.test| 6 +- llvm/test/YAMLParser/spec-09-13.test| 11 +- llvm/test/YAMLParser/spec-09-16.test| 17 +- llvm/test/YAMLParser/spec-09-17.test| 3 +- llvm/test/YAMLParser/spec1.2-07-05.test | 8 + llvm/test/YAMLParser/spec1.2-07-06.test | 7 + llvm/test/YAMLParser/spec1.2-07-09.test | 7 + llvm/test/YAMLParser/spec1.2-07-12.test | 7 + llvm/test/YAMLParser/spec1.2-07-14.test | 23 ++ 21 files changed, 367 insertions(+), 193 deletions(-) create mode 100644 llvm/test/YAMLParser/spec1.2-07-05.test create mode 100644 llvm/test/YAMLParser/spec1.2-07-06.test create mode 100644 llvm/test/YAMLParser/spec1.2-07-09.test create mode 100644 llvm/test/YAMLParser/spec1.2-07-12.test create mode 100644 llvm/test/YAMLParser/spec1.2-07-14.test diff --git a/llvm/include/llvm/Support/YAMLParser.h b/llvm/include/llvm/Support/YAMLParser.h index f4767641647c217..9d95a1e13a0dff4 100644 --- a/llvm/include/llvm/Support/YAMLParser.h +++ b/llvm/include/llvm/Support/YAMLParser.h @@ -240,9 +240,14 @@ class ScalarNode final : public Node { private: StringRef Value; - StringRef unescapeDoubleQuoted(StringRef UnquotedValue, - StringRef::size_type Start, + StringRef getDoubleQuotedValue(StringRef UnquotedValue, SmallVectorImpl &Storage) const; + + static StringRef getSingleQuotedValue(StringRef RawValue, +SmallVectorImpl &Storage); + + static StringRef getPlainValue(StringRef RawValue, + SmallVectorImpl &Storage); }; /// A block scalar node is an opaque datum that can be presented as a diff --git a/llvm/lib/Support/YAMLParser.cpp b/llvm/lib/Support/YAMLParser.cpp index 1422e40f91944ae..96b9aa95a96b3a6 100644 --- a/llvm/lib/Support/YAMLParser.cpp +++ b/llvm/lib/Support/YAMLParser.cpp @@ -2030,187 +2030,219 @@ bool Node::failed() const { } StringRef ScalarNode::getValue(SmallVectorImpl &Storage) const { - // TODO: Handle newlines properly. We need to remove leading whitespace. - if (Value[0] == '"') { // Double quoted. -// Pull off the leading and trailing "s. -StringRef UnquotedValue = Value.substr(1, Value.size() - 2); -// Search for characters that would require unescaping the value. -StringRef::size_type i = UnquotedValue.find_first_of("\\\r\n"); -if (i != StringRef::npos) - return unescapeDoubleQuoted(UnquotedValue, i, Storage); + if (Value[0] == '"') +return getDoubleQuotedValue(Value, Storage); + if (Value[0] == '\'') +return getSingleQuotedValue(Value, Storage); + return getPlainValue(Value, Storage); +} + +static StringRef +parseScalarValue(StringRef UnquotedValue, SmallVectorImpl &Storage, + StringRef LookupChars, + std::function &)> + UnescapeCallback) { + size_t I = UnquotedValue.find_first_of(LookupChars); + if (I == StringRef::npos) return UnquotedValue; - } else if (Value[0] == '\'') { // Single quoted. -// Pull off the leading and trailing 's. -StringRef UnquotedValue = Value.substr(1, Value.size() - 2); -StringRef::size_type i = UnquotedValue.find('\''); -if (i != StringRef::npos) { - // We're going to need Storage. - Storage.clear(); - Storage.reserve(UnquotedValue.size()); - for (; i != StringRef::npos; i = UnquotedValue.find('\'')) { -StringRef Valid(UnquotedValue.begin(), i); -llvm::append_range(Storage, Valid); -Storage.push_back('\''); -UnquotedValue = UnquotedValue.substr(i + 2
[Lldb-commits] [clang-tools-extra] [llvm] [clang] [compiler-rt] [flang] [lldb] [lld] [libcxx] [YAMLParser] Unfold multi-line scalar values (PR #70898)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/70898 >From 113c03bbf773c71d329ab2afd063753365e4ac68 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Thu, 26 Oct 2023 13:19:08 -0700 Subject: [PATCH] [YAMLParser] Unfold multi-line scalar values Long scalar values can be split into multiple lines to improve readability. The rules are described in Section 6.5. "Line Folding", https://yaml.org/spec/1.2.2/#65-line-folding. In addition, for flow scalar styles, the Spec states that "All leading and trailing white space characters on each line are excluded from the content", https://yaml.org/spec/1.2.2/#73-flow-scalar-styles. The patch implements these unfolding rules for double-quoted, single-quoted, and plain scalars. --- llvm/include/llvm/Support/YAMLParser.h | 9 +- llvm/lib/Support/YAMLParser.cpp | 364 +--- llvm/test/YAMLParser/spec-09-01.test| 11 +- llvm/test/YAMLParser/spec-09-02.test| 31 +- llvm/test/YAMLParser/spec-09-03.test| 7 +- llvm/test/YAMLParser/spec-09-04.test| 3 +- llvm/test/YAMLParser/spec-09-05.test| 7 +- llvm/test/YAMLParser/spec-09-06.test| 3 +- llvm/test/YAMLParser/spec-09-07.test| 11 +- llvm/test/YAMLParser/spec-09-08.test| 15 +- llvm/test/YAMLParser/spec-09-09.test| 7 +- llvm/test/YAMLParser/spec-09-10.test| 3 +- llvm/test/YAMLParser/spec-09-11.test| 6 +- llvm/test/YAMLParser/spec-09-13.test| 11 +- llvm/test/YAMLParser/spec-09-16.test| 17 +- llvm/test/YAMLParser/spec-09-17.test| 3 +- llvm/test/YAMLParser/spec1.2-07-05.test | 8 + llvm/test/YAMLParser/spec1.2-07-06.test | 7 + llvm/test/YAMLParser/spec1.2-07-09.test | 7 + llvm/test/YAMLParser/spec1.2-07-12.test | 7 + llvm/test/YAMLParser/spec1.2-07-14.test | 23 ++ 21 files changed, 367 insertions(+), 193 deletions(-) create mode 100644 llvm/test/YAMLParser/spec1.2-07-05.test create mode 100644 llvm/test/YAMLParser/spec1.2-07-06.test create mode 100644 llvm/test/YAMLParser/spec1.2-07-09.test create mode 100644 llvm/test/YAMLParser/spec1.2-07-12.test create mode 100644 llvm/test/YAMLParser/spec1.2-07-14.test diff --git a/llvm/include/llvm/Support/YAMLParser.h b/llvm/include/llvm/Support/YAMLParser.h index f4767641647c217..9d95a1e13a0dff4 100644 --- a/llvm/include/llvm/Support/YAMLParser.h +++ b/llvm/include/llvm/Support/YAMLParser.h @@ -240,9 +240,14 @@ class ScalarNode final : public Node { private: StringRef Value; - StringRef unescapeDoubleQuoted(StringRef UnquotedValue, - StringRef::size_type Start, + StringRef getDoubleQuotedValue(StringRef UnquotedValue, SmallVectorImpl &Storage) const; + + static StringRef getSingleQuotedValue(StringRef RawValue, +SmallVectorImpl &Storage); + + static StringRef getPlainValue(StringRef RawValue, + SmallVectorImpl &Storage); }; /// A block scalar node is an opaque datum that can be presented as a diff --git a/llvm/lib/Support/YAMLParser.cpp b/llvm/lib/Support/YAMLParser.cpp index 1422e40f91944ae..96b9aa95a96b3a6 100644 --- a/llvm/lib/Support/YAMLParser.cpp +++ b/llvm/lib/Support/YAMLParser.cpp @@ -2030,187 +2030,219 @@ bool Node::failed() const { } StringRef ScalarNode::getValue(SmallVectorImpl &Storage) const { - // TODO: Handle newlines properly. We need to remove leading whitespace. - if (Value[0] == '"') { // Double quoted. -// Pull off the leading and trailing "s. -StringRef UnquotedValue = Value.substr(1, Value.size() - 2); -// Search for characters that would require unescaping the value. -StringRef::size_type i = UnquotedValue.find_first_of("\\\r\n"); -if (i != StringRef::npos) - return unescapeDoubleQuoted(UnquotedValue, i, Storage); + if (Value[0] == '"') +return getDoubleQuotedValue(Value, Storage); + if (Value[0] == '\'') +return getSingleQuotedValue(Value, Storage); + return getPlainValue(Value, Storage); +} + +static StringRef +parseScalarValue(StringRef UnquotedValue, SmallVectorImpl &Storage, + StringRef LookupChars, + std::function &)> + UnescapeCallback) { + size_t I = UnquotedValue.find_first_of(LookupChars); + if (I == StringRef::npos) return UnquotedValue; - } else if (Value[0] == '\'') { // Single quoted. -// Pull off the leading and trailing 's. -StringRef UnquotedValue = Value.substr(1, Value.size() - 2); -StringRef::size_type i = UnquotedValue.find('\''); -if (i != StringRef::npos) { - // We're going to need Storage. - Storage.clear(); - Storage.reserve(UnquotedValue.size()); - for (; i != StringRef::npos; i = UnquotedValue.find('\'')) { -StringRef Valid(UnquotedValue.begin(), i); -llvm::append_range(Storage, Valid); -Storage.push_back('\''); -UnquotedValue = UnquotedValue.substr(i + 2
[Lldb-commits] [lldb] f13ce15 - [DebugInfo] Rename getOffset() to getContribution(). NFC.
Author: Igor Kudrin Date: 2020-04-03T14:15:53+07:00 New Revision: f13ce15d441095493030404ab31eddb0fc08ca42 URL: https://github.com/llvm/llvm-project/commit/f13ce15d441095493030404ab31eddb0fc08ca42 DIFF: https://github.com/llvm/llvm-project/commit/f13ce15d441095493030404ab31eddb0fc08ca42.diff LOG: [DebugInfo] Rename getOffset() to getContribution(). NFC. The old name was a bit misleading because the functions actually return contributions to the corresponding sections. Differential revision: https://reviews.llvm.org/D77302 Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp llvm/tools/llvm-dwp/llvm-dwp.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp index 0198a10645c2..8447d4fcea4c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -263,7 +263,8 @@ void DWARFUnit::SetDwoStrOffsetsBase() { lldb::offset_t baseOffset = 0; if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) { -if (const auto *contribution = entry->getOffset(llvm::DW_SECT_STR_OFFSETS)) +if (const auto *contribution = +entry->getContribution(llvm::DW_SECT_STR_OFFSETS)) baseOffset = contribution->Offset; else return; @@ -479,7 +480,7 @@ DWARFDataExtractor DWARFUnit::GetLocationData() const { const DWARFDataExtractor &data = GetVersion() >= 5 ? Ctx.getOrLoadLocListsData() : Ctx.getOrLoadLocData(); if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) { -if (const auto *contribution = entry->getOffset(llvm::DW_SECT_LOC)) +if (const auto *contribution = entry->getContribution(llvm::DW_SECT_LOC)) return DWARFDataExtractor(data, contribution->Offset, contribution->Length); return DWARFDataExtractor(); @@ -815,12 +816,13 @@ DWARFUnitHeader::extract(const DWARFDataExtractor &data, llvm::inconvertibleErrorCode(), "Package unit with a non-zero abbreviation offset"); } -auto *unit_contrib = header.m_index_entry->getOffset(); +auto *unit_contrib = header.m_index_entry->getContribution(); if (!unit_contrib || unit_contrib->Length != header.m_length + 4) { return llvm::createStringError(llvm::inconvertibleErrorCode(), "Inconsistent DWARF package unit index"); } -auto *abbr_entry = header.m_index_entry->getOffset(llvm::DW_SECT_ABBREV); +auto *abbr_entry = +header.m_index_entry->getContribution(llvm::DW_SECT_ABBREV); if (!abbr_entry) { return llvm::createStringError( llvm::inconvertibleErrorCode(), diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp index da8fec46dba7..9bf3206f1c61 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp @@ -38,7 +38,7 @@ SymbolFileDWARFDwo::SymbolFileDWARFDwo(SymbolFileDWARF &base_symbol_file, DWARFCompileUnit *SymbolFileDWARFDwo::GetDWOCompileUnitForHash(uint64_t hash) { if (const llvm::DWARFUnitIndex &index = m_context.GetAsLLVM().getCUIndex()) { if (const llvm::DWARFUnitIndex::Entry *entry = index.getFromHash(hash)) { - if (auto *unit_contrib = entry->getOffset()) + if (auto *unit_contrib = entry->getContribution()) return llvm::dyn_cast_or_null( DebugInfo().GetUnitAtOffset(DIERef::Section::DebugInfo, unit_contrib->Offset)); diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h index 1d313a3cca24..635c437fff10 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h @@ -487,7 +487,7 @@ class DWARFUnit { uint32_t getLineTableOffset() const { if (auto IndexEntry = Header.getIndexEntry()) - if (const auto *Contrib = IndexEntry->getOffset(DW_SECT_LINE)) + if (const auto *Contrib = IndexEntry->getContribution(DW_SECT_LINE)) return Contrib->Offset; return 0; } diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h index 684103aac2fc..d6b5e72cf16c 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h @@ -56,10 +56,10 @@ class DWARFUnitIndex { friend class DWARFUnitIndex; public: -const
[Lldb-commits] [lldb] a0249fe - [DebugInfo] Rename section identifiers which are deprecated in DWARFv5. NFC.
Author: Igor Kudrin Date: 2020-04-06T13:28:06+07:00 New Revision: a0249fe91c7ba0dabf0e8789171fb4aea5fca1cb URL: https://github.com/llvm/llvm-project/commit/a0249fe91c7ba0dabf0e8789171fb4aea5fca1cb DIFF: https://github.com/llvm/llvm-project/commit/a0249fe91c7ba0dabf0e8789171fb4aea5fca1cb.diff LOG: [DebugInfo] Rename section identifiers which are deprecated in DWARFv5. NFC. This is a preparation for an upcoming patch which adds support for DWARFv5 unit index sections. The patch adds tag "_EXT_" to identifiers which reference sections that are deprecated in the DWARFv5 standard. See D75929 for the discussion. Differential Revision: https://reviews.llvm.org/D77141 Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h llvm/lib/DebugInfo/DWARF/DWARFContext.cpp llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp llvm/tools/llvm-dwp/llvm-dwp.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index 941a547ddbf9..874978bf1398 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -76,7 +76,7 @@ void DWARFDebugInfo::ParseUnitsFor(DIERef::Section section) { if (m_context.isDwo()) index = &llvm::getDWARFUnitIndex(m_context.GetAsLLVM(), section == DIERef::Section::DebugTypes - ? llvm::DW_SECT_TYPES + ? llvm::DW_SECT_EXT_TYPES : llvm::DW_SECT_INFO); lldb::offset_t offset = 0; while (data.ValidOffset(offset)) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp index 8447d4fcea4c..b8d16758246f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -480,7 +480,7 @@ DWARFDataExtractor DWARFUnit::GetLocationData() const { const DWARFDataExtractor &data = GetVersion() >= 5 ? Ctx.getOrLoadLocListsData() : Ctx.getOrLoadLocData(); if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) { -if (const auto *contribution = entry->getContribution(llvm::DW_SECT_LOC)) +if (const auto *contribution = entry->getContribution(llvm::DW_SECT_EXT_LOC)) return DWARFDataExtractor(data, contribution->Offset, contribution->Length); return DWARFDataExtractor(); diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h index d6b5e72cf16c..018962c0bd50 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h @@ -21,12 +21,12 @@ class raw_ostream; enum DWARFSectionKind { DW_SECT_INFO = 1, - DW_SECT_TYPES, + DW_SECT_EXT_TYPES, DW_SECT_ABBREV, DW_SECT_LINE, - DW_SECT_LOC, + DW_SECT_EXT_LOC, DW_SECT_STR_OFFSETS, - DW_SECT_MACINFO, + DW_SECT_EXT_MACINFO, DW_SECT_MACRO, }; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 2150df411f42..bdd2a7240df6 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -763,7 +763,7 @@ const DWARFUnitIndex &DWARFContext::getTUIndex() { DataExtractor TUIndexData(DObj->getTUIndexSection(), isLittleEndian(), 0); - TUIndex = std::make_unique(DW_SECT_TYPES); + TUIndex = std::make_unique(DW_SECT_EXT_TYPES); TUIndex->parse(TUIndexData); return *TUIndex; } @@ -959,7 +959,7 @@ void DWARFContext::parseNormalUnits() { }); NormalUnits.finishedInfoUnits(); DObj->forEachTypesSections([&](const DWARFSection &S) { -NormalUnits.addUnitsForSection(*this, S, DW_SECT_TYPES); +NormalUnits.addUnitsForSection(*this, S, DW_SECT_EXT_TYPES); }); } @@ -971,7 +971,7 @@ void DWARFContext::parseDWOUnits(bool Lazy) { }); DWOUnits.finishedInfoUnits(); DObj->forEachTypesDWOSections([&](const DWARFSection &S) { -DWOUnits.addUnitsForDWOSection(*this, S, DW_SECT_TYPES, Lazy); +DWOUnits.addUnitsForDWOSection(*this, S, DW_SECT_EXT_TYPES, Lazy); }); } diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index 80f09dbd4c18..a42185b8015c 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -183,7 +183,7 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section, // data based on the index entries. StringRef Data = LocSection->Data; if (auto *Index
[Lldb-commits] [lldb] r368033 - Update LLDB to follow changes in llvm::DWARFDebugNames::NameIndex (4/5)
Author: ikudrin Date: Tue Aug 6 06:38:27 2019 New Revision: 368033 URL: http://llvm.org/viewvc/llvm-project?rev=368033&view=rev Log: Update LLDB to follow changes in llvm::DWARFDebugNames::NameIndex (4/5) Differential Revision: https://reviews.llvm.org/D65640 Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp?rev=368033&r1=368032&r2=368033&view=diff == --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp Tue Aug 6 06:38:27 2019 @@ -105,7 +105,7 @@ void DebugNamesDWARFIndex::GetGlobalVari if (!regex.Execute(nte.getString())) continue; - uint32_t entry_offset = nte.getEntryOffset(); + uint64_t entry_offset = nte.getEntryOffset(); llvm::Expected entry_or = ni.getEntry(&entry_offset); for (; entry_or; entry_or = ni.getEntry(&entry_offset)) { if (entry_or->tag() != DW_TAG_variable) @@ -125,7 +125,7 @@ void DebugNamesDWARFIndex::GetGlobalVari uint64_t cu_offset = cu.GetOffset(); for (const DebugNames::NameIndex &ni: *m_debug_names_up) { for (DebugNames::NameTableEntry nte: ni) { - uint32_t entry_offset = nte.getEntryOffset(); + uint64_t entry_offset = nte.getEntryOffset(); llvm::Expected entry_or = ni.getEntry(&entry_offset); for (; entry_or; entry_or = ni.getEntry(&entry_offset)) { if (entry_or->tag() != DW_TAG_variable) @@ -248,7 +248,7 @@ void DebugNamesDWARFIndex::GetFunctions( if (!regex.Execute(nte.getString())) continue; - uint32_t entry_offset = nte.getEntryOffset(); + uint64_t entry_offset = nte.getEntryOffset(); llvm::Expected entry_or = ni.getEntry(&entry_offset); for (; entry_or; entry_or = ni.getEntry(&entry_offset)) { Tag tag = entry_or->tag(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 9a952fd - [LLDB] Fix build failures after removing Version from DWARFExpression.
Author: Igor Kudrin Date: 2020-01-27T19:33:34+07:00 New Revision: 9a952fd462774e79d8dc514d71bf43ea0ca7f429 URL: https://github.com/llvm/llvm-project/commit/9a952fd462774e79d8dc514d71bf43ea0ca7f429 DIFF: https://github.com/llvm/llvm-project/commit/9a952fd462774e79d8dc514d71bf43ea0ca7f429.diff LOG: [LLDB] Fix build failures after removing Version from DWARFExpression. Added: Modified: lldb/source/Expression/DWARFExpression.cpp Removed: diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index 9b927085ca2e..849c96d9b455 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -88,8 +88,7 @@ void DWARFExpression::UpdateValue(uint64_t const_value, void DWARFExpression::DumpLocation(Stream *s, const DataExtractor &data, lldb::DescriptionLevel level, ABI *abi) const { - llvm::DWARFExpression(data.GetAsLLVM(), llvm::dwarf::DWARF_VERSION, -data.GetAddressByteSize()) + llvm::DWARFExpression(data.GetAsLLVM(), data.GetAddressByteSize()) .print(s->AsRawOstream(), abi ? &abi->GetMCRegisterInfo() : nullptr, nullptr); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)
igorkudrin wrote: > To make the test more representative, I suggeest replacing the `removeFile()` > method with the following: Thanks! I've updated the test as you suggested. https://github.com/llvm/llvm-project/pull/111237 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/111237 >From 6756842b1c78ac6f41fa467f112aa7632f260582 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Fri, 4 Oct 2024 23:27:04 -0700 Subject: [PATCH 1/2] [lldb] Fix and re-enable TestUseSourceCache.py The decorators caused the main test, i.e. `test_set_use_source_cache_true()`, to be skipped in most scenarios. In fact, it was only run on a Windows host targeting a non-Windows remote platform, and it failed in this case because the source file is opened with the `FILE_SHARE_DELETE` share mode, which allows the file to be removed, see `llvm::sys::fs::openNativeFileInternal()` in `llvm/lib/Support/Windows/Path.inc`. This patch changes the test to check that the content can still be displayed even after deleting the file when caching is enabled. The updated test is expected to work on any platform, so the decorators are removed. --- .../settings/use_source_cache/TestUseSourceCache.py | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py index 421599080a9e51..421b13f253f05b 100644 --- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py +++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py @@ -17,8 +17,6 @@ def test_set_use_source_cache_false(self): """Test that after 'set use-source-cache false', files are not locked.""" self.set_use_source_cache_and_test(False) -@skipIf(hostoslist=no_match(["windows"])) -@skipIf(oslist=["windows"]) # Fails on windows 11 def test_set_use_source_cache_true(self): """Test that after 'set use-source-cache false', files are locked.""" self.set_use_source_cache_and_test(True) @@ -43,16 +41,15 @@ def set_use_source_cache_and_test(self, is_cache_enabled): self, "calc" ) -# Show the source file contents to make sure LLDB loads src file. -self.runCmd("source list") +# Ensure that the source file is loaded. +self.expect("step", patterns=["-> .+ int x4 ="]) # Try deleting the source file. is_file_removed = self.removeFile(src) if is_cache_enabled: -self.assertFalse( -is_file_removed, "Source cache is enabled, but delete file succeeded" -) +# Regardless of whether the file is removed, its contents should be displayed. +self.expect("step", patterns=["-> .+ int x5 ="]) if not is_cache_enabled: self.assertTrue( >From 433f6efa4657494c9b9a5581f3fa2b5b2299ff24 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Tue, 8 Oct 2024 22:16:23 -0700 Subject: [PATCH 2/2] `removeFile()` -> `overwriteFile()` --- .../use_source_cache/TestUseSourceCache.py | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py index 421b13f253f05b..3e9cfcf2fba27d 100644 --- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py +++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py @@ -44,22 +44,24 @@ def set_use_source_cache_and_test(self, is_cache_enabled): # Ensure that the source file is loaded. self.expect("step", patterns=["-> .+ int x4 ="]) -# Try deleting the source file. -is_file_removed = self.removeFile(src) +# Try overwriting the source file. +is_file_overwritten = self.overwriteFile(src) if is_cache_enabled: -# Regardless of whether the file is removed, its contents should be displayed. +# Regardless of whether the file is changed, its original contents should be displayed. self.expect("step", patterns=["-> .+ int x5 ="]) if not is_cache_enabled: self.assertTrue( -is_file_removed, "Source cache is disabled, but delete file failed" +is_file_overwritten, "Source cache is disabled, but writing to file failed" ) -def removeFile(self, src): -"""Remove file and return true iff file was successfully removed.""" +def overwriteFile(self, src): +"""Write to file and return true iff file was successfully written.""" try: -os.remove(src) +f = open(src, "w") +f.writelines(["// hello world\n"]) +f.close() return True except Exception: return False ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix TestGlobalModuleCache.py for remote debugging (PR #111483)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/111483 >From bb594335d05a4c8cb2949556f5b338242a9b5280 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Mon, 7 Oct 2024 22:07:02 -0700 Subject: [PATCH 1/2] [lldb] Fix TestGlobalModuleCache.py for remote debugging `SBDebugger().Create()` returns a debugger with only the host platform in its platform list. If the test suite is running for a remote platform, it should be explicitly added and selected in the new debugger created within the test, otherwise, the test will fail because the host platform may not be able to launch the built binary. --- .../API/python_api/global_module_cache/TestGlobalModuleCache.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py index ccefc28946e062..16bc86bd4fc44d 100644 --- a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py +++ b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py @@ -111,6 +111,8 @@ def do_test(self, one_target, one_debugger): else: if one_target: new_debugger = lldb.SBDebugger().Create() +if lldb.selected_platform is not None: +new_debugger.SetSelectedPlatform(lldb.selected_platform) new_debugger.SetAsync(False) self.old_debugger = self.dbg self.dbg = new_debugger >From 22e342662c066b2d1d8a689acb69dd72a4a80bcb Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Tue, 8 Oct 2024 21:34:48 -0700 Subject: [PATCH 2/2] Update lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py Co-authored-by: Pavel Labath --- .../python_api/global_module_cache/TestGlobalModuleCache.py| 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py index 16bc86bd4fc44d..5dd268be4cb05f 100644 --- a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py +++ b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py @@ -111,8 +111,7 @@ def do_test(self, one_target, one_debugger): else: if one_target: new_debugger = lldb.SBDebugger().Create() -if lldb.selected_platform is not None: -new_debugger.SetSelectedPlatform(lldb.selected_platform) +new_debugger.SetSelectedPlatform(lldb.selected_platform) new_debugger.SetAsync(False) self.old_debugger = self.dbg self.dbg = new_debugger ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix TestGlobalModuleCache.py for remote debugging (PR #111483)
@@ -111,6 +111,8 @@ def do_test(self, one_target, one_debugger): else: if one_target: new_debugger = lldb.SBDebugger().Create() +if lldb.selected_platform is not None: +new_debugger.SetSelectedPlatform(lldb.selected_platform) igorkudrin wrote: Thanks! I copied the code from `Base.setUp()` (`lldbtest.py`) because I thought the condition was there for a reason. https://github.com/llvm/llvm-project/pull/111483 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix TestGlobalModuleCache.py for remote debugging (PR #111483)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/111483 >From bb594335d05a4c8cb2949556f5b338242a9b5280 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Mon, 7 Oct 2024 22:07:02 -0700 Subject: [PATCH 1/2] [lldb] Fix TestGlobalModuleCache.py for remote debugging `SBDebugger().Create()` returns a debugger with only the host platform in its platform list. If the test suite is running for a remote platform, it should be explicitly added and selected in the new debugger created within the test, otherwise, the test will fail because the host platform may not be able to launch the built binary. --- .../API/python_api/global_module_cache/TestGlobalModuleCache.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py index ccefc28946e062..16bc86bd4fc44d 100644 --- a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py +++ b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py @@ -111,6 +111,8 @@ def do_test(self, one_target, one_debugger): else: if one_target: new_debugger = lldb.SBDebugger().Create() +if lldb.selected_platform is not None: +new_debugger.SetSelectedPlatform(lldb.selected_platform) new_debugger.SetAsync(False) self.old_debugger = self.dbg self.dbg = new_debugger >From 22e342662c066b2d1d8a689acb69dd72a4a80bcb Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Tue, 8 Oct 2024 21:34:48 -0700 Subject: [PATCH 2/2] Update lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py Co-authored-by: Pavel Labath --- .../python_api/global_module_cache/TestGlobalModuleCache.py| 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py index 16bc86bd4fc44d..5dd268be4cb05f 100644 --- a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py +++ b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py @@ -111,8 +111,7 @@ def do_test(self, one_target, one_debugger): else: if one_target: new_debugger = lldb.SBDebugger().Create() -if lldb.selected_platform is not None: -new_debugger.SetSelectedPlatform(lldb.selected_platform) +new_debugger.SetSelectedPlatform(lldb.selected_platform) new_debugger.SetAsync(False) self.old_debugger = self.dbg self.dbg = new_debugger ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/111237 >From 6756842b1c78ac6f41fa467f112aa7632f260582 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Fri, 4 Oct 2024 23:27:04 -0700 Subject: [PATCH] [lldb] Fix and re-enable TestUseSourceCache.py The decorators caused the main test, i.e. `test_set_use_source_cache_true()`, to be skipped in most scenarios. In fact, it was only run on a Windows host targeting a non-Windows remote platform, and it failed in this case because the source file is opened with the `FILE_SHARE_DELETE` share mode, which allows the file to be removed, see `llvm::sys::fs::openNativeFileInternal()` in `llvm/lib/Support/Windows/Path.inc`. This patch changes the test to check that the content can still be displayed even after deleting the file when caching is enabled. The updated test is expected to work on any platform, so the decorators are removed. --- .../settings/use_source_cache/TestUseSourceCache.py | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py index 421599080a9e51..421b13f253f05b 100644 --- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py +++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py @@ -17,8 +17,6 @@ def test_set_use_source_cache_false(self): """Test that after 'set use-source-cache false', files are not locked.""" self.set_use_source_cache_and_test(False) -@skipIf(hostoslist=no_match(["windows"])) -@skipIf(oslist=["windows"]) # Fails on windows 11 def test_set_use_source_cache_true(self): """Test that after 'set use-source-cache false', files are locked.""" self.set_use_source_cache_and_test(True) @@ -43,16 +41,15 @@ def set_use_source_cache_and_test(self, is_cache_enabled): self, "calc" ) -# Show the source file contents to make sure LLDB loads src file. -self.runCmd("source list") +# Ensure that the source file is loaded. +self.expect("step", patterns=["-> .+ int x4 ="]) # Try deleting the source file. is_file_removed = self.removeFile(src) if is_cache_enabled: -self.assertFalse( -is_file_removed, "Source cache is enabled, but delete file succeeded" -) +# Regardless of whether the file is removed, its contents should be displayed. +self.expect("step", patterns=["-> .+ int x5 ="]) if not is_cache_enabled: self.assertTrue( ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Speed up FindInMemory tests (PR #111951)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/111951 >From e027444340be4020002126da0d2c8a705c2c7e3f Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Thu, 10 Oct 2024 20:27:10 -0700 Subject: [PATCH 1/2] [lldb] Speed up FindInMemory tests A memory region can be relatively large. Searching for a value in the entire region is time-consuming, especially when running tests against a remote target, because the memory data is transferred in small chunks over a relatively slow GDB Remote Protocol. The patch limits the address range to be searched to 2K, which seems sufficient for these tests. In my setup, for local runs, these tests now take half the time they did before the patch. For a remote target, the improvement is even more significant. --- .../find_in_memory/TestFindInMemory.py| 10 ++-- .../find_in_memory/TestFindRangesInMemory.py | 16 +++--- .../find_in_memory/address_ranges_helper.py | 50 --- 3 files changed, 45 insertions(+), 31 deletions(-) diff --git a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py index 9ab4619b1f8f4f..04e807c5c6201d 100644 --- a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py +++ b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py @@ -55,7 +55,7 @@ def test_find_in_memory_ok(self): error = lldb.SBError() addr = self.process.FindInMemory( SINGLE_INSTANCE_PATTERN_STACK, -GetStackRange(self), +GetStackRange(self, True), 1, error, ) @@ -70,7 +70,7 @@ def test_find_in_memory_double_instance_ok(self): error = lldb.SBError() addr = self.process.FindInMemory( DOUBLE_INSTANCE_PATTERN_HEAP, -GetHeapRanges(self)[0], +GetHeapRanges(self, True)[0], 1, error, ) @@ -86,7 +86,7 @@ def test_find_in_memory_invalid_alignment(self): error = lldb.SBError() addr = self.process.FindInMemory( SINGLE_INSTANCE_PATTERN_STACK, -GetStackRange(self), +GetStackRange(self, True), 0, error, ) @@ -118,7 +118,7 @@ def test_find_in_memory_invalid_buffer(self): error = lldb.SBError() addr = self.process.FindInMemory( "", -GetStackRange(self), +GetStackRange(self, True), 1, error, ) @@ -131,7 +131,7 @@ def test_find_in_memory_unaligned(self): self.assertTrue(self.process, PROCESS_IS_VALID) self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) error = lldb.SBError() -range = GetAlignedRange(self) +range = GetAlignedRange(self, True) # First we make sure the pattern is found with alignment 1 addr = self.process.FindInMemory( diff --git a/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py b/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py index 31bc0e99f4914f..895c527430f218 100644 --- a/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py +++ b/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py @@ -30,7 +30,7 @@ def test_find_ranges_in_memory_two_matches(self): self.assertTrue(self.process, PROCESS_IS_VALID) self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) -addr_ranges = GetHeapRanges(self) +addr_ranges = GetHeapRanges(self, True) error = lldb.SBError() matches = self.process.FindRangesInMemory( DOUBLE_INSTANCE_PATTERN_HEAP, @@ -48,7 +48,7 @@ def test_find_ranges_in_memory_one_match(self): self.assertTrue(self.process, PROCESS_IS_VALID) self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) -addr_ranges = GetStackRanges(self) +addr_ranges = GetStackRanges(self, True) error = lldb.SBError() matches = self.process.FindRangesInMemory( SINGLE_INSTANCE_PATTERN_STACK, @@ -66,7 +66,7 @@ def test_find_ranges_in_memory_one_match_multiple_ranges(self): self.assertTrue(self.process, PROCESS_IS_VALID) self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) -addr_ranges = GetRanges(self) +addr_ranges = GetRanges(self, True) addr_ranges.Append(lldb.SBAddressRange()) self.assertGreater(addr_ranges.GetSize(), 2) error = lldb.SBError() @@ -86,7 +86,7 @@ def test_find_ranges_in_memory_one_match_max(self): self.assertTrue(self.process, PROCESS_IS_VALID) self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) -addr_ranges = GetHeapRanges(self) +addr_ranges = GetHeapRanges(self, True) error = lldb.SBError() matches = self.proces
[Lldb-commits] [lldb] [lldb] Speed up FindInMemory tests (PR #111951)
https://github.com/igorkudrin created https://github.com/llvm/llvm-project/pull/111951 A memory region can be relatively large. Searching for a value in the entire region is time-consuming, especially when running tests against a remote target, because the memory data is transferred in small chunks over a relatively slow GDB remote protocol. The patch limits the address range to be searched to 2K, which seems sufficient for these tests. In my setup, for local runs, these tests now take half the time they did before the patch. For a remote target, the improvement is even more significant. >From 6ea11737a9edbf1a1be413c2eaa7075438effb05 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Thu, 10 Oct 2024 20:27:10 -0700 Subject: [PATCH] [lldb] Speed up FindInMemory tests A memory region can be relatively large. Searching for a value in the entire region is time-consuming, especially when running tests against a remote target, because the memory data is transferred in small chunks over a relatively slow GDBRemote protocol. The patch limits the address range to be searched to 2K, which seems sufficient for these tests. In my setup, for local runs, these tests now take half the time they did before the patch. For a remote target, the improvement is even more significant. --- .../find_in_memory/TestFindInMemory.py| 10 ++-- .../find_in_memory/TestFindRangesInMemory.py | 16 +++--- .../find_in_memory/address_ranges_helper.py | 50 --- 3 files changed, 45 insertions(+), 31 deletions(-) diff --git a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py index 9ab4619b1f8f4f..04e807c5c6201d 100644 --- a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py +++ b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py @@ -55,7 +55,7 @@ def test_find_in_memory_ok(self): error = lldb.SBError() addr = self.process.FindInMemory( SINGLE_INSTANCE_PATTERN_STACK, -GetStackRange(self), +GetStackRange(self, True), 1, error, ) @@ -70,7 +70,7 @@ def test_find_in_memory_double_instance_ok(self): error = lldb.SBError() addr = self.process.FindInMemory( DOUBLE_INSTANCE_PATTERN_HEAP, -GetHeapRanges(self)[0], +GetHeapRanges(self, True)[0], 1, error, ) @@ -86,7 +86,7 @@ def test_find_in_memory_invalid_alignment(self): error = lldb.SBError() addr = self.process.FindInMemory( SINGLE_INSTANCE_PATTERN_STACK, -GetStackRange(self), +GetStackRange(self, True), 0, error, ) @@ -118,7 +118,7 @@ def test_find_in_memory_invalid_buffer(self): error = lldb.SBError() addr = self.process.FindInMemory( "", -GetStackRange(self), +GetStackRange(self, True), 1, error, ) @@ -131,7 +131,7 @@ def test_find_in_memory_unaligned(self): self.assertTrue(self.process, PROCESS_IS_VALID) self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) error = lldb.SBError() -range = GetAlignedRange(self) +range = GetAlignedRange(self, True) # First we make sure the pattern is found with alignment 1 addr = self.process.FindInMemory( diff --git a/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py b/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py index 31bc0e99f4914f..895c527430f218 100644 --- a/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py +++ b/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py @@ -30,7 +30,7 @@ def test_find_ranges_in_memory_two_matches(self): self.assertTrue(self.process, PROCESS_IS_VALID) self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) -addr_ranges = GetHeapRanges(self) +addr_ranges = GetHeapRanges(self, True) error = lldb.SBError() matches = self.process.FindRangesInMemory( DOUBLE_INSTANCE_PATTERN_HEAP, @@ -48,7 +48,7 @@ def test_find_ranges_in_memory_one_match(self): self.assertTrue(self.process, PROCESS_IS_VALID) self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) -addr_ranges = GetStackRanges(self) +addr_ranges = GetStackRanges(self, True) error = lldb.SBError() matches = self.process.FindRangesInMemory( SINGLE_INSTANCE_PATTERN_STACK, @@ -66,7 +66,7 @@ def test_find_ranges_in_memory_one_match_multiple_ranges(self): self.assertTrue(self.process, PROCESS_IS_VALID) self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) -addr_ranges = GetRanges(self) +addr_ranges = GetRanges(self, True)
[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)
igorkudrin wrote: So the test basically shows that it makes sense to set `use-source-cache` to `false` on Windows, otherwise the source file will be locked for editing. Windows 11 seems to allow deleting mmaped files, so we need to try opening the file for writing to re-enable the test. Thanks, @emrekultursay. https://github.com/llvm/llvm-project/pull/111237 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)
https://github.com/igorkudrin edited https://github.com/llvm/llvm-project/pull/111237 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/111237 >From 6756842b1c78ac6f41fa467f112aa7632f260582 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Fri, 4 Oct 2024 23:27:04 -0700 Subject: [PATCH 1/2] [lldb] Fix and re-enable TestUseSourceCache.py The decorators caused the main test, i.e. `test_set_use_source_cache_true()`, to be skipped in most scenarios. In fact, it was only run on a Windows host targeting a non-Windows remote platform, and it failed in this case because the source file is opened with the `FILE_SHARE_DELETE` share mode, which allows the file to be removed, see `llvm::sys::fs::openNativeFileInternal()` in `llvm/lib/Support/Windows/Path.inc`. This patch changes the test to check that the content can still be displayed even after deleting the file when caching is enabled. The updated test is expected to work on any platform, so the decorators are removed. --- .../settings/use_source_cache/TestUseSourceCache.py | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py index 421599080a9e51..421b13f253f05b 100644 --- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py +++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py @@ -17,8 +17,6 @@ def test_set_use_source_cache_false(self): """Test that after 'set use-source-cache false', files are not locked.""" self.set_use_source_cache_and_test(False) -@skipIf(hostoslist=no_match(["windows"])) -@skipIf(oslist=["windows"]) # Fails on windows 11 def test_set_use_source_cache_true(self): """Test that after 'set use-source-cache false', files are locked.""" self.set_use_source_cache_and_test(True) @@ -43,16 +41,15 @@ def set_use_source_cache_and_test(self, is_cache_enabled): self, "calc" ) -# Show the source file contents to make sure LLDB loads src file. -self.runCmd("source list") +# Ensure that the source file is loaded. +self.expect("step", patterns=["-> .+ int x4 ="]) # Try deleting the source file. is_file_removed = self.removeFile(src) if is_cache_enabled: -self.assertFalse( -is_file_removed, "Source cache is enabled, but delete file succeeded" -) +# Regardless of whether the file is removed, its contents should be displayed. +self.expect("step", patterns=["-> .+ int x5 ="]) if not is_cache_enabled: self.assertTrue( >From ef848fd2c7de9483cfe2cb0286a20df0a2005f97 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Tue, 8 Oct 2024 22:16:23 -0700 Subject: [PATCH 2/2] `removeFile()` -> `overwriteFile()` --- .../use_source_cache/TestUseSourceCache.py| 26 +++ 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py index 421b13f253f05b..0c005ff3ab21b1 100644 --- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py +++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py @@ -17,8 +17,9 @@ def test_set_use_source_cache_false(self): """Test that after 'set use-source-cache false', files are not locked.""" self.set_use_source_cache_and_test(False) +@skipIf(hostoslist=no_match(["windows"])) def test_set_use_source_cache_true(self): -"""Test that after 'set use-source-cache false', files are locked.""" +"""Test that after 'set use-source-cache true', files are locked.""" self.set_use_source_cache_and_test(True) def set_use_source_cache_and_test(self, is_cache_enabled): @@ -41,25 +42,28 @@ def set_use_source_cache_and_test(self, is_cache_enabled): self, "calc" ) -# Ensure that the source file is loaded. -self.expect("step", patterns=["-> .+ int x4 ="]) +# Show the source file contents to make sure LLDB loads src file. +self.runCmd("source list") -# Try deleting the source file. -is_file_removed = self.removeFile(src) +# Try overwriting the source file. +is_file_overwritten = self.overwriteFile(src) if is_cache_enabled: -# Regardless of whether the file is removed, its contents should be displayed. -self.expect("step", patterns=["-> .+ int x5 ="]) +self.assertFalse( +is_file_overwritten, "Source cache is enabled, but writing to file succeeded" +) if not is_cache_enabled: self.assertTrue( -is_file_removed, "Source cache is disabled, but delete file failed" +is_file_overwritten, "Source cache is
[Lldb-commits] [lldb] [lldb] Speed up FindInMemory tests (PR #111951)
https://github.com/igorkudrin edited https://github.com/llvm/llvm-project/pull/111951 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Speed up FindInMemory tests (PR #111951)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/111951 >From e027444340be4020002126da0d2c8a705c2c7e3f Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Thu, 10 Oct 2024 20:27:10 -0700 Subject: [PATCH] [lldb] Speed up FindInMemory tests A memory region can be relatively large. Searching for a value in the entire region is time-consuming, especially when running tests against a remote target, because the memory data is transferred in small chunks over a relatively slow GDB Remote Protocol. The patch limits the address range to be searched to 2K, which seems sufficient for these tests. In my setup, for local runs, these tests now take half the time they did before the patch. For a remote target, the improvement is even more significant. --- .../find_in_memory/TestFindInMemory.py| 10 ++-- .../find_in_memory/TestFindRangesInMemory.py | 16 +++--- .../find_in_memory/address_ranges_helper.py | 50 --- 3 files changed, 45 insertions(+), 31 deletions(-) diff --git a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py index 9ab4619b1f8f4f..04e807c5c6201d 100644 --- a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py +++ b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py @@ -55,7 +55,7 @@ def test_find_in_memory_ok(self): error = lldb.SBError() addr = self.process.FindInMemory( SINGLE_INSTANCE_PATTERN_STACK, -GetStackRange(self), +GetStackRange(self, True), 1, error, ) @@ -70,7 +70,7 @@ def test_find_in_memory_double_instance_ok(self): error = lldb.SBError() addr = self.process.FindInMemory( DOUBLE_INSTANCE_PATTERN_HEAP, -GetHeapRanges(self)[0], +GetHeapRanges(self, True)[0], 1, error, ) @@ -86,7 +86,7 @@ def test_find_in_memory_invalid_alignment(self): error = lldb.SBError() addr = self.process.FindInMemory( SINGLE_INSTANCE_PATTERN_STACK, -GetStackRange(self), +GetStackRange(self, True), 0, error, ) @@ -118,7 +118,7 @@ def test_find_in_memory_invalid_buffer(self): error = lldb.SBError() addr = self.process.FindInMemory( "", -GetStackRange(self), +GetStackRange(self, True), 1, error, ) @@ -131,7 +131,7 @@ def test_find_in_memory_unaligned(self): self.assertTrue(self.process, PROCESS_IS_VALID) self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) error = lldb.SBError() -range = GetAlignedRange(self) +range = GetAlignedRange(self, True) # First we make sure the pattern is found with alignment 1 addr = self.process.FindInMemory( diff --git a/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py b/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py index 31bc0e99f4914f..895c527430f218 100644 --- a/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py +++ b/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py @@ -30,7 +30,7 @@ def test_find_ranges_in_memory_two_matches(self): self.assertTrue(self.process, PROCESS_IS_VALID) self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) -addr_ranges = GetHeapRanges(self) +addr_ranges = GetHeapRanges(self, True) error = lldb.SBError() matches = self.process.FindRangesInMemory( DOUBLE_INSTANCE_PATTERN_HEAP, @@ -48,7 +48,7 @@ def test_find_ranges_in_memory_one_match(self): self.assertTrue(self.process, PROCESS_IS_VALID) self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) -addr_ranges = GetStackRanges(self) +addr_ranges = GetStackRanges(self, True) error = lldb.SBError() matches = self.process.FindRangesInMemory( SINGLE_INSTANCE_PATTERN_STACK, @@ -66,7 +66,7 @@ def test_find_ranges_in_memory_one_match_multiple_ranges(self): self.assertTrue(self.process, PROCESS_IS_VALID) self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) -addr_ranges = GetRanges(self) +addr_ranges = GetRanges(self, True) addr_ranges.Append(lldb.SBAddressRange()) self.assertGreater(addr_ranges.GetSize(), 2) error = lldb.SBError() @@ -86,7 +86,7 @@ def test_find_ranges_in_memory_one_match_max(self): self.assertTrue(self.process, PROCESS_IS_VALID) self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) -addr_ranges = GetHeapRanges(self) +addr_ranges = GetHeapRanges(self, True) error = lldb.SBError() matches = self.process.Fi
[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/111237 >From 6756842b1c78ac6f41fa467f112aa7632f260582 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Fri, 4 Oct 2024 23:27:04 -0700 Subject: [PATCH 1/3] [lldb] Fix and re-enable TestUseSourceCache.py The decorators caused the main test, i.e. `test_set_use_source_cache_true()`, to be skipped in most scenarios. In fact, it was only run on a Windows host targeting a non-Windows remote platform, and it failed in this case because the source file is opened with the `FILE_SHARE_DELETE` share mode, which allows the file to be removed, see `llvm::sys::fs::openNativeFileInternal()` in `llvm/lib/Support/Windows/Path.inc`. This patch changes the test to check that the content can still be displayed even after deleting the file when caching is enabled. The updated test is expected to work on any platform, so the decorators are removed. --- .../settings/use_source_cache/TestUseSourceCache.py | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py index 421599080a9e51..421b13f253f05b 100644 --- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py +++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py @@ -17,8 +17,6 @@ def test_set_use_source_cache_false(self): """Test that after 'set use-source-cache false', files are not locked.""" self.set_use_source_cache_and_test(False) -@skipIf(hostoslist=no_match(["windows"])) -@skipIf(oslist=["windows"]) # Fails on windows 11 def test_set_use_source_cache_true(self): """Test that after 'set use-source-cache false', files are locked.""" self.set_use_source_cache_and_test(True) @@ -43,16 +41,15 @@ def set_use_source_cache_and_test(self, is_cache_enabled): self, "calc" ) -# Show the source file contents to make sure LLDB loads src file. -self.runCmd("source list") +# Ensure that the source file is loaded. +self.expect("step", patterns=["-> .+ int x4 ="]) # Try deleting the source file. is_file_removed = self.removeFile(src) if is_cache_enabled: -self.assertFalse( -is_file_removed, "Source cache is enabled, but delete file succeeded" -) +# Regardless of whether the file is removed, its contents should be displayed. +self.expect("step", patterns=["-> .+ int x5 ="]) if not is_cache_enabled: self.assertTrue( >From ef848fd2c7de9483cfe2cb0286a20df0a2005f97 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Tue, 8 Oct 2024 22:16:23 -0700 Subject: [PATCH 2/3] `removeFile()` -> `overwriteFile()` --- .../use_source_cache/TestUseSourceCache.py| 26 +++ 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py index 421b13f253f05b..0c005ff3ab21b1 100644 --- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py +++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py @@ -17,8 +17,9 @@ def test_set_use_source_cache_false(self): """Test that after 'set use-source-cache false', files are not locked.""" self.set_use_source_cache_and_test(False) +@skipIf(hostoslist=no_match(["windows"])) def test_set_use_source_cache_true(self): -"""Test that after 'set use-source-cache false', files are locked.""" +"""Test that after 'set use-source-cache true', files are locked.""" self.set_use_source_cache_and_test(True) def set_use_source_cache_and_test(self, is_cache_enabled): @@ -41,25 +42,28 @@ def set_use_source_cache_and_test(self, is_cache_enabled): self, "calc" ) -# Ensure that the source file is loaded. -self.expect("step", patterns=["-> .+ int x4 ="]) +# Show the source file contents to make sure LLDB loads src file. +self.runCmd("source list") -# Try deleting the source file. -is_file_removed = self.removeFile(src) +# Try overwriting the source file. +is_file_overwritten = self.overwriteFile(src) if is_cache_enabled: -# Regardless of whether the file is removed, its contents should be displayed. -self.expect("step", patterns=["-> .+ int x5 ="]) +self.assertFalse( +is_file_overwritten, "Source cache is enabled, but writing to file succeeded" +) if not is_cache_enabled: self.assertTrue( -is_file_removed, "Source cache is disabled, but delete file failed" +is_file_overwritten, "Source cache is
[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/111237 >From 6756842b1c78ac6f41fa467f112aa7632f260582 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Fri, 4 Oct 2024 23:27:04 -0700 Subject: [PATCH 1/3] [lldb] Fix and re-enable TestUseSourceCache.py The decorators caused the main test, i.e. `test_set_use_source_cache_true()`, to be skipped in most scenarios. In fact, it was only run on a Windows host targeting a non-Windows remote platform, and it failed in this case because the source file is opened with the `FILE_SHARE_DELETE` share mode, which allows the file to be removed, see `llvm::sys::fs::openNativeFileInternal()` in `llvm/lib/Support/Windows/Path.inc`. This patch changes the test to check that the content can still be displayed even after deleting the file when caching is enabled. The updated test is expected to work on any platform, so the decorators are removed. --- .../settings/use_source_cache/TestUseSourceCache.py | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py index 421599080a9e51..421b13f253f05b 100644 --- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py +++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py @@ -17,8 +17,6 @@ def test_set_use_source_cache_false(self): """Test that after 'set use-source-cache false', files are not locked.""" self.set_use_source_cache_and_test(False) -@skipIf(hostoslist=no_match(["windows"])) -@skipIf(oslist=["windows"]) # Fails on windows 11 def test_set_use_source_cache_true(self): """Test that after 'set use-source-cache false', files are locked.""" self.set_use_source_cache_and_test(True) @@ -43,16 +41,15 @@ def set_use_source_cache_and_test(self, is_cache_enabled): self, "calc" ) -# Show the source file contents to make sure LLDB loads src file. -self.runCmd("source list") +# Ensure that the source file is loaded. +self.expect("step", patterns=["-> .+ int x4 ="]) # Try deleting the source file. is_file_removed = self.removeFile(src) if is_cache_enabled: -self.assertFalse( -is_file_removed, "Source cache is enabled, but delete file succeeded" -) +# Regardless of whether the file is removed, its contents should be displayed. +self.expect("step", patterns=["-> .+ int x5 ="]) if not is_cache_enabled: self.assertTrue( >From ef848fd2c7de9483cfe2cb0286a20df0a2005f97 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Tue, 8 Oct 2024 22:16:23 -0700 Subject: [PATCH 2/3] `removeFile()` -> `overwriteFile()` --- .../use_source_cache/TestUseSourceCache.py| 26 +++ 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py index 421b13f253f05b..0c005ff3ab21b1 100644 --- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py +++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py @@ -17,8 +17,9 @@ def test_set_use_source_cache_false(self): """Test that after 'set use-source-cache false', files are not locked.""" self.set_use_source_cache_and_test(False) +@skipIf(hostoslist=no_match(["windows"])) def test_set_use_source_cache_true(self): -"""Test that after 'set use-source-cache false', files are locked.""" +"""Test that after 'set use-source-cache true', files are locked.""" self.set_use_source_cache_and_test(True) def set_use_source_cache_and_test(self, is_cache_enabled): @@ -41,25 +42,28 @@ def set_use_source_cache_and_test(self, is_cache_enabled): self, "calc" ) -# Ensure that the source file is loaded. -self.expect("step", patterns=["-> .+ int x4 ="]) +# Show the source file contents to make sure LLDB loads src file. +self.runCmd("source list") -# Try deleting the source file. -is_file_removed = self.removeFile(src) +# Try overwriting the source file. +is_file_overwritten = self.overwriteFile(src) if is_cache_enabled: -# Regardless of whether the file is removed, its contents should be displayed. -self.expect("step", patterns=["-> .+ int x5 ="]) +self.assertFalse( +is_file_overwritten, "Source cache is enabled, but writing to file succeeded" +) if not is_cache_enabled: self.assertTrue( -is_file_removed, "Source cache is disabled, but delete file failed" +is_file_overwritten, "Source cache is
[Lldb-commits] [lldb] [lldb][NFC] Fix a build failure with MSVC (PR #111231)
https://github.com/igorkudrin closed https://github.com/llvm/llvm-project/pull/111231 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Speed up FindInMemory tests (PR #111951)
@@ -6,27 +6,30 @@ UNALIGNED_INSTANCE_PATTERN_HEAP = ALIGNED_INSTANCE_PATTERN_HEAP[1:] -def GetAlignedRange(test_base): +def GetAlignedRange(test_base, shrink=False): frame = test_base.thread.GetSelectedFrame() ex = frame.EvaluateExpression("aligned_string_ptr") test_base.assertTrue(ex.IsValid()) -return GetRangeFromAddrValue(test_base, ex) +return GetRangeFromAddrValue(test_base, ex, shrink) -def GetStackRange(test_base): +def GetStackRange(test_base, shrink=False): frame = test_base.thread.GetSelectedFrame() ex = frame.EvaluateExpression("&stack_pointer") test_base.assertTrue(ex.IsValid()) -return GetRangeFromAddrValue(test_base, ex) +return GetRangeFromAddrValue(test_base, ex, shrink) -def GetStackRanges(test_base): +def GetStackRanges(test_base, shrink=False): addr_ranges = lldb.SBAddressRangeList() addr_ranges.Append(GetStackRange(test_base)) return addr_ranges -def GetRangeFromAddrValue(test_base, addr): +def GetRangeFromAddrValue(test_base, addr, shrink=False): igorkudrin wrote: Not all tests do actual searches. For example, `test_check_stack_pointer()` in `TestFindInMemory.py` checks that ranges for two different stack pointers are the same. https://github.com/llvm/llvm-project/pull/111951 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)
https://github.com/igorkudrin created https://github.com/llvm/llvm-project/pull/111237 The decorators caused the main test, i.e. `test_set_use_source_cache_true()`, to be skipped in most scenarios. It was only run on a Windows host targeting a non-Windows remote platform, and it failed in this case because the source file is opened with the `FILE_SHARE_DELETE` share mode, which allows the file to be removed, see `llvm::sys::fs::openNativeFileInternal()` in `llvm/lib/Support/Windows/Path.inc`. This patch changes the test to check that the content can still be displayed, even after deleting the file, when the source cache is enabled. The updated test is expected to pass on any platform, so the decorators are removed. >From 6756842b1c78ac6f41fa467f112aa7632f260582 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Fri, 4 Oct 2024 23:27:04 -0700 Subject: [PATCH] [lldb] Fix and re-enable TestUseSourceCache.py The decorators caused the main test, i.e. `test_set_use_source_cache_true()`, to be skipped in most scenarios. In fact, it was only run on a Windows host targeting a non-Windows remote platform, and it failed in this case because the source file is opened with the `FILE_SHARE_DELETE` share mode, which allows the file to be removed, see `llvm::sys::fs::openNativeFileInternal()` in `llvm/lib/Support/Windows/Path.inc`. This patch changes the test to check that the content can still be displayed even after deleting the file when caching is enabled. The updated test is expected to work on any platform, so the decorators are removed. --- .../settings/use_source_cache/TestUseSourceCache.py | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py index 421599080a9e51..421b13f253f05b 100644 --- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py +++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py @@ -17,8 +17,6 @@ def test_set_use_source_cache_false(self): """Test that after 'set use-source-cache false', files are not locked.""" self.set_use_source_cache_and_test(False) -@skipIf(hostoslist=no_match(["windows"])) -@skipIf(oslist=["windows"]) # Fails on windows 11 def test_set_use_source_cache_true(self): """Test that after 'set use-source-cache false', files are locked.""" self.set_use_source_cache_and_test(True) @@ -43,16 +41,15 @@ def set_use_source_cache_and_test(self, is_cache_enabled): self, "calc" ) -# Show the source file contents to make sure LLDB loads src file. -self.runCmd("source list") +# Ensure that the source file is loaded. +self.expect("step", patterns=["-> .+ int x4 ="]) # Try deleting the source file. is_file_removed = self.removeFile(src) if is_cache_enabled: -self.assertFalse( -is_file_removed, "Source cache is enabled, but delete file succeeded" -) +# Regardless of whether the file is removed, its contents should be displayed. +self.expect("step", patterns=["-> .+ int x5 ="]) if not is_cache_enabled: self.assertTrue( ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Fix a build failure with MSVC (PR #111231)
igorkudrin wrote: > Looks good, I guess. Is that constructor even necessary, given that it just > forwards the argument to the base class, and we already have the forwarding > `using` declaration? The constructor looks redundant at the moment, perhaps it is just a legacy from the early stages of patch #106442. Maybe some other constructors can also be reduced, for example, `Win32Error::Win32Error()`. However, I may not fully understand the intentions of the author of the original patch, so I'd prefer @adrian-prantl to do the cleanup if necessary. My patch is only intended to fix the immediate problem. https://github.com/llvm/llvm-project/pull/111231 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)
igorkudrin wrote: > As I understand it, Android Studio was setting `use-source-cache:=false` so > that users can continue to edit files on windows while lldb has them open. > > Judging by this patch, that may no longer be necessary. Or does that only > apply for certain situations (certain windows versions, files which are not > large enough to be mmapped, etc.)? Based on the change history of `TestUseSourceCache.py`, the test probably passes on Windows 10 in its original form, so the opened file is probably locked there, despite the `FILE_SHARE_DELETE` mode. I don't have this system to properly debug the case, though. https://github.com/llvm/llvm-project/pull/111237 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)
igorkudrin wrote: > I don't see any relevant changes on those files, so I don't know the where > `openNativeFileInternal()` comes into the picture. `getFileAux()` calls `openNativeFileForRead()` first and then passes the file descriptor to `getOpenFileImpl()`. `openNativeFileForRead()` eventually calls `openNativeFileInternal()`, which passes `FILE_SHARE_DELETE` to `::CreateFileW()`, and that was already like that in times of [D76806](https://reviews.llvm.org/D76806) `Remove m_last_file_sp from SourceManager`, so I don't know why the opened file was locked for deletion back then. The only change in the sequence I can see was replacing `WritableMemoryBuffer` with `MemoryBuffer`, caused by [D122856](https://reviews.llvm.org/D122856), `[lldb] Refactor DataBuffer so we can map files as read-only`, but the file was still opened with the `FILE_SHARE_DELETE` mode. https://github.com/llvm/llvm-project/pull/111237 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix TestUseSourceCache for readonly source trees (PR #113251)
https://github.com/igorkudrin edited https://github.com/llvm/llvm-project/pull/113251 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix TestUseSourceCache for readonly source trees (PR #113251)
@@ -6,3 +6,6 @@ include Makefile.rules # Copy file into the build folder to enable the test to modify it. main-copy.cpp: main.cpp cp -f $< $@ +ifneq "$(OS)" "Windows_NT" # chmod is not available on Windows igorkudrin wrote: If I understand correctly, we rely on some Unix-like tools on Windows anyway; otherwise, `cp` would not be available. Such toolsets, e.g., MSYS2, provide `chmod`, so you can drop the conditions. https://github.com/llvm/llvm-project/pull/113251 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix TestGlobalModuleCache.py for remote debugging (PR #111483)
https://github.com/igorkudrin closed https://github.com/llvm/llvm-project/pull/111483 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix TestGlobalModuleCache.py for remote debugging (PR #111483)
https://github.com/igorkudrin created https://github.com/llvm/llvm-project/pull/111483 `SBDebugger().Create()` returns a debugger with only the host platform in its platform list. If the test suite is running for a remote platform, it should be explicitly added and selected in the new debugger created within the test, otherwise, the test will fail because the host platform may not be able to launch the built binary. >From bb594335d05a4c8cb2949556f5b338242a9b5280 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Mon, 7 Oct 2024 22:07:02 -0700 Subject: [PATCH] [lldb] Fix TestGlobalModuleCache.py for remote debugging `SBDebugger().Create()` returns a debugger with only the host platform in its platform list. If the test suite is running for a remote platform, it should be explicitly added and selected in the new debugger created within the test, otherwise, the test will fail because the host platform may not be able to launch the built binary. --- .../API/python_api/global_module_cache/TestGlobalModuleCache.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py index ccefc28946e062..16bc86bd4fc44d 100644 --- a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py +++ b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py @@ -111,6 +111,8 @@ def do_test(self, one_target, one_debugger): else: if one_target: new_debugger = lldb.SBDebugger().Create() +if lldb.selected_platform is not None: +new_debugger.SetSelectedPlatform(lldb.selected_platform) new_debugger.SetAsync(False) self.old_debugger = self.dbg self.dbg = new_debugger ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Fix a build failure with MSVC (PR #111231)
https://github.com/igorkudrin created https://github.com/llvm/llvm-project/pull/111231 This fixes a build error with msvc for code introduced in #106442: ``` ...\lldb\source\Expression\DiagnosticManager.cpp(37): error C2668: 'llvm::ErrorInfo::ErrorInfo': ambiguous call to overloaded function ...\llvm\include\llvm/Support/Error.h(357): note: could be 'llvm::ErrorInfo::ErrorInfo(std::error_code)', which inherits 'lldb_private::CloneableECError::CloneableECError(std::error_code)' via base class 'lldb_private::ExpressionErrorBase' ...\llvm\include\llvm/Support/Error.h(357): note: or 'llvm::ErrorInfo::ErrorInfo(std::error_code,std::string)', which inherits 'lldb_private::ExpressionErrorBase::ExpressionErrorBase(std::error_code,std::string)' via base class 'lldb_private::ExpressionErrorBase' ...\lldb\source\Expression\DiagnosticManager.cpp(37): note: while trying to match the argument list '(std::error_code)' ``` >From 2a8ae2cdca39184cc862e3ceee13c1c1275953c9 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Fri, 4 Oct 2024 22:02:23 -0700 Subject: [PATCH] [lldb][NFC] Fix a build failure with MSVC Building the original code failed with an error: ``` ...\lldb\source\Expression\DiagnosticManager.cpp(37): error C2668: 'llvm::ErrorInfo::ErrorInfo': ambiguous call to overloaded function ...\llvm\include\llvm/Support/Error.h(357): note: could be 'llvm::ErrorInfo::ErrorInfo(std::error_code)', which inherits 'lldb_private::CloneableECError::CloneableECError(std::error_code)' via base class 'lldb_private::ExpressionErrorBase' ...\llvm\include\llvm/Support/Error.h(357): note: or 'llvm::ErrorInfo::ErrorInfo(std::error_code,std::string)', which inherits 'lldb_private::ExpressionErrorBase::ExpressionErrorBase(std::error_code,std::string)' via base class 'lldb_private::ExpressionErrorBase' ...\lldb\source\Expression\DiagnosticManager.cpp(37): note: while trying to match the argument list '(std::error_code)' ``` --- lldb/include/lldb/Utility/Status.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lldb/include/lldb/Utility/Status.h b/lldb/include/lldb/Utility/Status.h index 3910c26d115a09..2911ffb804c6fb 100644 --- a/lldb/include/lldb/Utility/Status.h +++ b/lldb/include/lldb/Utility/Status.h @@ -83,8 +83,7 @@ class ExpressionErrorBase : public llvm::ErrorInfo { public: using llvm::ErrorInfo::ErrorInfo; - ExpressionErrorBase(std::error_code ec, std::string msg = {}) - : ErrorInfo(ec) {} + ExpressionErrorBase(std::error_code ec) : ErrorInfo(ec) {} lldb::ErrorType GetErrorType() const override; static char ID; }; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix TestUseSourceCache for readonly source trees (PR #113251)
https://github.com/igorkudrin approved this pull request. LGTM. Thanks! https://github.com/llvm/llvm-project/pull/113251 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Always emit diagnostic events to the system log (PR #90913)
igorkudrin wrote: Hi @JDevlieghere, This change causes diagnostic messages to be duplicated on Windows. For example: ``` > yaml2obj.exe lldb\test\Shell\ObjectFile\ELF\minidebuginfo-no-lzma.yaml -o > t.obj > lldb-new.exe (lldb) target create t.obj (x86_64) C:\tmp\t.obj No LZMA support found for reading .gnu_debugdata warning: (x86_64) C:\tmp\t.obj No LZMA support found for reading .gnu_debugdata section (lldb) Current executable set to 'C:\tmp\t.obj' (x86_64). (lldb) q ``` Could you fix this? https://github.com/llvm/llvm-project/pull/90913 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/platform-gdb] Do not assume a persistent connection (PR #131736)
https://github.com/igorkudrin closed https://github.com/llvm/llvm-project/pull/131736 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/platform-gdb] Do not assume a persistent connection (PR #131736)
https://github.com/igorkudrin created https://github.com/llvm/llvm-project/pull/131736 After https://reviews.llvm.org/D116539, when `m_gdb_client_up` in `PlatformRemoteGDBServer` is not null, the connection to a server is expected to exist. However, `PlatformRemoteGDBServer::DisconnectRemote()` is not the only way to close the connection; `GDBRemoteCommunication::WaitForPacketNoLock()` can disconnect if the server stops responding, and in this case `m_gdb_client_up` is not cleared. The patch removes this assumption and checks the connection status directly. >From 3de79119222a87709709934702d1de51ab805994 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Mon, 17 Mar 2025 23:02:07 -0700 Subject: [PATCH] [lldb/platform-gdb] Avoid an assertion failure when the connection is severed After https://reviews.llvm.org/D116539, when `m_gdb_client_up` in `PlatformRemoteGDBServer` is not null, the connection to a server is expected to exist. However, `PlatformRemoteGDBServer::DisconnectRemote()` is not the only way to close the connection; `GDBRemoteCommunication::WaitForPacketNoLock()` can disconnect if the server stops responding, and in this case `m_gdb_client_up` is not cleared. The patch removes this assumption and checks the connection status directly. --- .../gdb-server/PlatformRemoteGDBServer.cpp| 6 +- lldb/unittests/Platform/CMakeLists.txt| 1 + .../Platform/gdb-server/CMakeLists.txt| 7 ++ .../PlatformRemoteGDBServerTest.cpp | 68 +++ 4 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 lldb/unittests/Platform/gdb-server/CMakeLists.txt create mode 100644 lldb/unittests/Platform/gdb-server/PlatformRemoteGDBServerTest.cpp diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index 58d2ecd94836d..26ca6ed128972 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -206,11 +206,7 @@ bool PlatformRemoteGDBServer::SetRemoteWorkingDirectory( } bool PlatformRemoteGDBServer::IsConnected() const { - if (m_gdb_client_up) { -assert(m_gdb_client_up->IsConnected()); -return true; - } - return false; + return m_gdb_client_up && m_gdb_client_up->IsConnected(); } Status PlatformRemoteGDBServer::ConnectRemote(Args &args) { diff --git a/lldb/unittests/Platform/CMakeLists.txt b/lldb/unittests/Platform/CMakeLists.txt index 963975602d671..5c0ef5ca6ef22 100644 --- a/lldb/unittests/Platform/CMakeLists.txt +++ b/lldb/unittests/Platform/CMakeLists.txt @@ -15,3 +15,4 @@ add_lldb_unittest(LLDBPlatformTests ) add_subdirectory(Android) +add_subdirectory(gdb-server) diff --git a/lldb/unittests/Platform/gdb-server/CMakeLists.txt b/lldb/unittests/Platform/gdb-server/CMakeLists.txt new file mode 100644 index 0..41f94b06f6f2c --- /dev/null +++ b/lldb/unittests/Platform/gdb-server/CMakeLists.txt @@ -0,0 +1,7 @@ +add_lldb_unittest(PlatformGdbRemoteTests + PlatformRemoteGDBServerTest.cpp + + LINK_LIBS +lldbPluginPlatformGDB +LLVMTestingSupport + ) diff --git a/lldb/unittests/Platform/gdb-server/PlatformRemoteGDBServerTest.cpp b/lldb/unittests/Platform/gdb-server/PlatformRemoteGDBServerTest.cpp new file mode 100644 index 0..2ea4dac006cd8 --- /dev/null +++ b/lldb/unittests/Platform/gdb-server/PlatformRemoteGDBServerTest.cpp @@ -0,0 +1,68 @@ +//===-- PlatformRemoteGDBServerTest.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h" +#include "lldb/Utility/Connection.h" +#include "gmock/gmock.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::platform_gdb_server; +using namespace lldb_private::process_gdb_remote; +using namespace testing; + +namespace { + +class PlatformRemoteGDBServerHack : public PlatformRemoteGDBServer { +public: + void + SetGDBClient(std::unique_ptr gdb_client_up) { +m_gdb_client_up = std::move(gdb_client_up); + } +}; + +class MockConnection : public lldb_private::Connection { +public: + MOCK_METHOD(lldb::ConnectionStatus, Connect, + (llvm::StringRef url, Status *error_ptr), (override)); + MOCK_METHOD(lldb::ConnectionStatus, Disconnect, (Status * error_ptr), + (override)); + MOCK_METHOD(bool, IsConnected, (), (const, override)); + MOCK_METHOD(size_t, Read, + (void *dst, size_t dst_len, const Timeout &timeout, + lldb::ConnectionStatus &status, Status *error_ptr), + (override)); + MOCK_METHOD(size_t, Write, + (const
[Lldb-commits] [lldb] [lldb/gdb-remote] Do not crash on an invalid server response (PR #131979)
https://github.com/igorkudrin created https://github.com/llvm/llvm-project/pull/131979 An invalid RLE sequence in the received packet could result in an out-of-bounds reading that could cause a crash. >From 239aeaa5686350681dc79cad63d5aae5a5f2310a Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Tue, 18 Mar 2025 23:24:55 -0700 Subject: [PATCH] [lldb/gdb-remote] Do not crash on an invalid server response An invalid RLE sequence in the received packet could result in an out-of-bounds reading that could cause a crash. --- .../gdb-remote/GDBRemoteCommunication.cpp | 22 ++ .../gdb-remote/GDBRemoteCommunication.h | 2 +- .../gdb-remote/GDBRemoteCommunicationTest.cpp | 23 +++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index dad72a176b5fa..77eadfc8c9f6c 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -788,9 +788,14 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len, // Copy the packet from m_bytes to packet_str expanding the run-length // encoding in the process. - std ::string packet_str = + auto maybe_packet_str = ExpandRLE(m_bytes.substr(content_start, content_end - content_start)); - packet = StringExtractorGDBRemote(packet_str); + if (!maybe_packet_str) { +m_bytes.erase(0, total_length); +packet.Clear(); +return GDBRemoteCommunication::PacketType::Invalid; + } + packet = StringExtractorGDBRemote(*maybe_packet_str); if (m_bytes[0] == '$' || m_bytes[0] == '%') { assert(checksum_idx < m_bytes.size()); @@ -1311,17 +1316,22 @@ void llvm::format_provider::format( } } -std::string GDBRemoteCommunication::ExpandRLE(std::string packet) { +std::optional +GDBRemoteCommunication::ExpandRLE(std::string packet) { // Reserve enough byte for the most common case (no RLE used). std::string decoded; decoded.reserve(packet.size()); for (std::string::const_iterator c = packet.begin(); c != packet.end(); ++c) { if (*c == '*') { + if (decoded.empty()) +return std::nullopt; // '*' indicates RLE. Next character will give us the repeat count and // previous character is what is to be repeated. char char_to_repeat = decoded.back(); // Number of time the previous character is repeated. - int repeat_count = *++c + 3 - ' '; + if (++c == packet.end()) +return std::nullopt; + int repeat_count = *c + 3 - ' '; // We have the char_to_repeat and repeat_count. Now push it in the // packet. for (int i = 0; i < repeat_count; ++i) @@ -1329,7 +1339,9 @@ std::string GDBRemoteCommunication::ExpandRLE(std::string packet) { } else if (*c == 0x7d) { // 0x7d is the escape character. The next character is to be XOR'd with // 0x20. - char escapee = *++c ^ 0x20; + if (++c == packet.end()) +return std::nullopt; + char escapee = *c ^ 0x20; decoded.push_back(escapee); } else { decoded.push_back(*c); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h index 754797ba7f504..107c0896c4e61 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h @@ -168,7 +168,7 @@ class GDBRemoteCommunication : public Communication { GDBRemoteCommunication &server); /// Expand GDB run-length encoding. - static std::string ExpandRLE(std::string); + static std::optional ExpandRLE(std::string); protected: std::chrono::seconds m_packet_timeout; diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp index 425f6cfcd5bc9..3da1f0a718fc5 100644 --- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp @@ -68,3 +68,26 @@ TEST_F(GDBRemoteCommunicationTest, ReadPacket) { ASSERT_EQ(PacketResult::Success, server.GetAck()); } } + +// Test that packets with incorrect RLE sequences do not cause a crash and +// reported as invalid. +TEST_F(GDBRemoteCommunicationTest, CheckForPacket) { + using PacketType = GDBRemoteCommunication::PacketType; + struct TestCase { +llvm::StringLiteral Packet; +PacketType Result; + }; + static constexpr TestCase Tests[] = { + {{"$#00"}, PacketType::Standard}, + {{"$xx*#00"}, PacketType::Invalid}, // '*' without a count + {{"$*#00"}, PacketType::Invalid}, // '*' without a preceding character + {{"$xx}#00"}, PacketType::Invalid
[Lldb-commits] [lldb] [lldb/gdb-remote] Do not crash on an invalid server response (PR #131979)
https://github.com/igorkudrin closed https://github.com/llvm/llvm-project/pull/131979 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][core] Fix getting summary of a variable pointing to r/o memory (PR #139196)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/139196 >From 499f723c3f974ff53deb8f354d879e0baaa7a9e8 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Wed, 7 May 2025 19:55:07 -0700 Subject: [PATCH 1/4] [lldb][core] Fix getting summary of a variable pointing to r/o memory Motivation example: ``` > lldb -c altmain2.core ... (lldb) var F (const char *) F = 0x0804a000 "" ``` The variable `F` points to a read-only memory page not dumped to the core file, so `Process::ReadMemory()` cannot read the data. The patch switches to `Target::ReadMemory()`, which can read data both from the process memory and the application binary. --- lldb/source/ValueObject/ValueObject.cpp | 13 - .../postmortem/elf-core/TestLinuxCore.py | 27 ++ .../postmortem/elf-core/altmain2.core | Bin 0 -> 40960 bytes .../postmortem/elf-core/altmain2.out | Bin 0 -> 9776 bytes 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100755 lldb/test/API/functionalities/postmortem/elf-core/altmain2.core create mode 100755 lldb/test/API/functionalities/postmortem/elf-core/altmain2.out diff --git a/lldb/source/ValueObject/ValueObject.cpp b/lldb/source/ValueObject/ValueObject.cpp index e1c66763ff0b8..aab78428d9103 100644 --- a/lldb/source/ValueObject/ValueObject.cpp +++ b/lldb/source/ValueObject/ValueObject.cpp @@ -735,7 +735,7 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx, case eAddressTypeLoad: { ExecutionContext exe_ctx(GetExecutionContextRef()); Process *process = exe_ctx.GetProcessPtr(); - if (process) { + if (process && process->IsLiveDebugSession()) { heap_buf_ptr->SetByteSize(bytes); size_t bytes_read = process->ReadMemory( addr + offset, heap_buf_ptr->GetBytes(), bytes, error); @@ -743,6 +743,17 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx, data.SetData(data_sp); return bytes_read; } + } else if (Target *target = exe_ctx.GetTargetPtr()) { +Address target_addr; +target_addr.SetLoadAddress(addr + offset, target); +heap_buf_ptr->SetByteSize(bytes); +size_t bytes_read = +target->ReadMemory(target_addr, heap_buf_ptr->GetBytes(), bytes, + error, /*force_live_memory=*/true); +if (error.Success() || bytes_read > 0) { + data.SetData(data_sp); + return bytes_read; +} } } break; case eAddressTypeHost: { diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py index a287fd19ba352..d1e065a32efdc 100644 --- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -977,6 +977,33 @@ def test_get_core_file_api(self): self.assertEqual(process.GetCoreFile().GetFilename(), core_file_name) self.dbg.DeleteTarget(target) +@skipIfLLVMTargetMissing("X86") +def test_ro_cstring(self): +""" +Test that we can show the summary for a cstring variable that points +to a r/o memory page which is not dumped to a core file. +""" +target = self.dbg.CreateTarget("altmain2.out") +process = target.LoadCore("altmain2.core") +self.assertTrue(process, PROCESS_IS_VALID) + +frame = process.GetSelectedThread().GetFrameAtIndex(0) +self.assertEqual(frame.GetFunctionName(), "_start") + +var = frame.FindVariable("F") + +# The variable points to a RO segment that is not dumped to the core +# file and thus process.ReadCStringFromMemory() cannot get the value. +error = lldb.SBError() +cstr = process.ReadCStringFromMemory(var.GetValueAsUnsigned(), 256, error) +self.assertFailure(error, error_str="core file does not contain 0x804a000") +self.assertEqual(cstr, "") + +# Nevertheless, when getting the summary, the value can be read from the +# application binary. +cstr = var.GetSummary() +self.assertEqual(cstr, '"_start"') + def check_memory_regions(self, process, region_count): region_list = process.GetMemoryRegions() self.assertEqual(region_list.GetSize(), region_count) diff --git a/lldb/test/API/functionalities/postmortem/elf-core/altmain2.core b/lldb/test/API/functionalities/postmortem/elf-core/altmain2.core new file mode 100755 index ..b9dd8de08b813442037fcb5bedd08e8bbabfdc0b GIT binary patch literal 40960 zcmeHQ4^&jwnSa9!I!%cK#cib0IB9HSqA(1g2@tXp8Ij5$Wtd=M$vDi6Fme86<_(|; z6+_tg`VJeLbo*!1-R7KixAr7yY1h*llO~{6F(sCWr_zMokd!oo(v~!T)FyTI_ucp2 z%tOtlZMJ8(-FH3T-0yz(yZ3(gcfb4H_udT89k#l)I-QPFl7Z86N~u&4A}{64oKY?t zsH`Y~&;E#9A!n>A8-*T&)P#5twWFNXo5Amv>t%VSoTus^om+oN`+>Rj^Db^b`}?yb z;#NyEr~PK
[Lldb-commits] [lldb] [lldb][NFC] Avoid an assertion failure in dwim-print (PR #139197)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/139197 >From 3faf0c0a4a19d7e1d503c31a684d79295e414be4 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Thu, 8 May 2025 18:37:34 -0700 Subject: [PATCH 1/2] [lldb][NFC] Avoid an assertion failure in dwim-print In a Debug build on Windows, printing inline diagnostics resulted in an error, for example: ``` > cd llvm-project\lldb\test\API\functionalities\postmortem\elf-core > lldb.exe -c altmain.core > p dummy LLDB diagnostics will be written to ... Please include the directory content when filing a bug report Exception Code: 0x8003 0x7FF8FD6633EC, C:\llvm\build\bin\liblldb.dll(0x7FF8FC2C) + 0x13A33EC byte(s), std::_Vector_const_iterator > >::_Compat() + 0x6C byte(s), C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\vector, line 202 + 0x5D byte(s) 0x7FF8FD662ABE, C:\llvm\build\bin\liblldb.dll(0x7FF8FC2C) + 0x13A2ABE byte(s), std::_Vector_const_iterator > >::operator==() + 0x1E byte(s), C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\vector, line 166 + 0x0 byte(s) 0x7FF8FD662B2E, C:\llvm\build\\bin\liblldb.dll(0x7FF8FC2C) + 0x13A2B2E byte(s), std::_Vector_const_iterator > >::operator!=() + 0x1E byte(s), C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\vector, line 176 + 0xF byte(s) 0x7FF8FD65EE1C, C:\llvm\build\\bin\liblldb.dll(0x7FF8FC2C) + 0x139EE1C byte(s), std::operator!= > >,std::_Vector_iterator > > >() + 0x3C byte(s), C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\xutility, line 1947 + 0x0 byte(s) 0x7FF8FD65D4E5, C:\llvm\build\\bin\liblldb.dll(0x7FF8FC2C) + 0x139D4E5 byte(s), lldb_private::RenderDiagnosticDetails() + 0x8F5 byte(s), C:\llvm\src\llvm-project\lldb\source\Utility\DiagnosticsRendering.cpp, line 189 + 0x25 byte(s) ... ``` The comparison operator of the iterators checks that they belong to the same container, but `remaining_details.pop_back()` invalidates `detail` making it incompatible with `remaining_details.rend()`. --- lldb/source/Utility/DiagnosticsRendering.cpp | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lldb/source/Utility/DiagnosticsRendering.cpp b/lldb/source/Utility/DiagnosticsRendering.cpp index 368e2199b749f..c43b39b6b8fe9 100644 --- a/lldb/source/Utility/DiagnosticsRendering.cpp +++ b/lldb/source/Utility/DiagnosticsRendering.cpp @@ -185,9 +185,8 @@ void RenderDiagnosticDetails(Stream &stream, // Work through each detail in reverse order using the vector/stack. bool did_print = false; - for (auto detail = remaining_details.rbegin(); - detail != remaining_details.rend(); - ++detail, remaining_details.pop_back()) { + for (; !remaining_details.empty(); remaining_details.pop_back()) { +auto &detail = remaining_details.back(); // Get the information to print this detail and remove it from the stack. // Print all the lines for all the other messages first. stream << std::string(padding, ' '); @@ -196,7 +195,7 @@ void RenderDiagnosticDetails(Stream &stream, llvm::ArrayRef(remaining_details).drop_back(1)) { uint16_t column = remaining_detail.source_location->column; // Is this a note with the same column as another diagnostic? - if (column == detail->source_location->column) + if (column == detail.source_location->column) continue; if (column >= x_pos) { @@ -205,16 +204,16 @@ void RenderDiagnosticDetails(Stream &stream, } } -uint16_t column = detail->source_location->column; +uint16_t column = detail.source_location->column; // Print the line connecting the ^ with the error message. if (column >= x_pos) stream << std::string(column - x_pos, ' ') << joint << hbar << spacer; // Print a colorized string based on the message's severity type. -PrintSeverity(stream, detail->severity); +PrintSeverity(stream, detail.severity); // Finally, print the message and start a new line. -stream << detail->message << '\n'; +stream << detail.message << '\n'; did_print = true; } >From 169c3401717ccff0d28c18318a9b433165076d4b Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Fri, 9 May 2025 13:36:20 -0700 Subject: [PATCH 2/2] Update lldb/source/Utility/DiagnosticsRendering.cpp Co-authored-by: Michael Buch --- lldb/source/Utility/DiagnosticsRendering.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Utility/DiagnosticsRendering.cpp b/lldb/source/Utility/DiagnosticsRendering.cpp index c43b39b6b8fe9..e73d688bb4be5 100644 --- a/lldb/source/Utility/DiagnosticsRendering.cpp +++ b/lldb/source/Utility/DiagnosticsRendering.cpp @@ -186,7 +186,7 @@ void RenderDiagnosticDetails(Stream &stream, // Work through each detail in re
[Lldb-commits] [lldb] [lldb][NFC] Avoid an assertion failure in dwim-print (PR #139197)
https://github.com/igorkudrin closed https://github.com/llvm/llvm-project/pull/139197 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][core] Fix getting summary of a variable pointing to r/o memory (PR #139196)
@@ -735,14 +735,25 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx, case eAddressTypeLoad: { ExecutionContext exe_ctx(GetExecutionContextRef()); Process *process = exe_ctx.GetProcessPtr(); - if (process) { + if (process && process->IsLiveDebugSession()) { heap_buf_ptr->SetByteSize(bytes); size_t bytes_read = process->ReadMemory( addr + offset, heap_buf_ptr->GetBytes(), bytes, error); if (error.Success() || bytes_read > 0) { data.SetData(data_sp); return bytes_read; } + } else if (Target *target = exe_ctx.GetTargetPtr()) { +Address target_addr; +target_addr.SetLoadAddress(addr + offset, target); +heap_buf_ptr->SetByteSize(bytes); +size_t bytes_read = +target->ReadMemory(target_addr, heap_buf_ptr->GetBytes(), bytes, + error, /*force_live_memory=*/true); igorkudrin wrote: The difference is that with `force_live_memory==true`, `Target::ReadMemory()` tries to get the data from the process first, and resorts to reading from the file cache if that fails. With `force_live_memory==false` and if the data is in a read-only section, it reads from the file cache into a temporary buffer, and then calls `Process::ReadMemory()` anyway. So, with either setting, it prefers the data from the process, but `force_live_memory==true` seems to be just a bit more efficient. https://github.com/llvm/llvm-project/pull/139196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][core] Fix getting summary of a variable pointing to r/o memory (PR #139196)
@@ -735,14 +735,25 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx, case eAddressTypeLoad: { ExecutionContext exe_ctx(GetExecutionContextRef()); Process *process = exe_ctx.GetProcessPtr(); - if (process) { + if (process && process->IsLiveDebugSession()) { heap_buf_ptr->SetByteSize(bytes); size_t bytes_read = process->ReadMemory( addr + offset, heap_buf_ptr->GetBytes(), bytes, error); if (error.Success() || bytes_read > 0) { data.SetData(data_sp); return bytes_read; } + } else if (Target *target = exe_ctx.GetTargetPtr()) { +Address target_addr; +target_addr.SetLoadAddress(addr + offset, target); +heap_buf_ptr->SetByteSize(bytes); +size_t bytes_read = +target->ReadMemory(target_addr, heap_buf_ptr->GetBytes(), bytes, + error, /*force_live_memory=*/true); +if (error.Success() || bytes_read > 0) { + data.SetData(data_sp); + return bytes_read; +} igorkudrin wrote: I think it can still be factored out, even without the `else` branch. The only difference will be that `data` will be updated if we don't have a target, and that seems negligible. Thanks for the idea. https://github.com/llvm/llvm-project/pull/139196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][core] Fix getting summary of a variable pointing to r/o memory (PR #139196)
https://github.com/igorkudrin updated https://github.com/llvm/llvm-project/pull/139196 >From 499f723c3f974ff53deb8f354d879e0baaa7a9e8 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Wed, 7 May 2025 19:55:07 -0700 Subject: [PATCH 1/3] [lldb][core] Fix getting summary of a variable pointing to r/o memory Motivation example: ``` > lldb -c altmain2.core ... (lldb) var F (const char *) F = 0x0804a000 "" ``` The variable `F` points to a read-only memory page not dumped to the core file, so `Process::ReadMemory()` cannot read the data. The patch switches to `Target::ReadMemory()`, which can read data both from the process memory and the application binary. --- lldb/source/ValueObject/ValueObject.cpp | 13 - .../postmortem/elf-core/TestLinuxCore.py | 27 ++ .../postmortem/elf-core/altmain2.core | Bin 0 -> 40960 bytes .../postmortem/elf-core/altmain2.out | Bin 0 -> 9776 bytes 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100755 lldb/test/API/functionalities/postmortem/elf-core/altmain2.core create mode 100755 lldb/test/API/functionalities/postmortem/elf-core/altmain2.out diff --git a/lldb/source/ValueObject/ValueObject.cpp b/lldb/source/ValueObject/ValueObject.cpp index e1c66763ff0b8..aab78428d9103 100644 --- a/lldb/source/ValueObject/ValueObject.cpp +++ b/lldb/source/ValueObject/ValueObject.cpp @@ -735,7 +735,7 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx, case eAddressTypeLoad: { ExecutionContext exe_ctx(GetExecutionContextRef()); Process *process = exe_ctx.GetProcessPtr(); - if (process) { + if (process && process->IsLiveDebugSession()) { heap_buf_ptr->SetByteSize(bytes); size_t bytes_read = process->ReadMemory( addr + offset, heap_buf_ptr->GetBytes(), bytes, error); @@ -743,6 +743,17 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx, data.SetData(data_sp); return bytes_read; } + } else if (Target *target = exe_ctx.GetTargetPtr()) { +Address target_addr; +target_addr.SetLoadAddress(addr + offset, target); +heap_buf_ptr->SetByteSize(bytes); +size_t bytes_read = +target->ReadMemory(target_addr, heap_buf_ptr->GetBytes(), bytes, + error, /*force_live_memory=*/true); +if (error.Success() || bytes_read > 0) { + data.SetData(data_sp); + return bytes_read; +} } } break; case eAddressTypeHost: { diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py index a287fd19ba352..d1e065a32efdc 100644 --- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -977,6 +977,33 @@ def test_get_core_file_api(self): self.assertEqual(process.GetCoreFile().GetFilename(), core_file_name) self.dbg.DeleteTarget(target) +@skipIfLLVMTargetMissing("X86") +def test_ro_cstring(self): +""" +Test that we can show the summary for a cstring variable that points +to a r/o memory page which is not dumped to a core file. +""" +target = self.dbg.CreateTarget("altmain2.out") +process = target.LoadCore("altmain2.core") +self.assertTrue(process, PROCESS_IS_VALID) + +frame = process.GetSelectedThread().GetFrameAtIndex(0) +self.assertEqual(frame.GetFunctionName(), "_start") + +var = frame.FindVariable("F") + +# The variable points to a RO segment that is not dumped to the core +# file and thus process.ReadCStringFromMemory() cannot get the value. +error = lldb.SBError() +cstr = process.ReadCStringFromMemory(var.GetValueAsUnsigned(), 256, error) +self.assertFailure(error, error_str="core file does not contain 0x804a000") +self.assertEqual(cstr, "") + +# Nevertheless, when getting the summary, the value can be read from the +# application binary. +cstr = var.GetSummary() +self.assertEqual(cstr, '"_start"') + def check_memory_regions(self, process, region_count): region_list = process.GetMemoryRegions() self.assertEqual(region_list.GetSize(), region_count) diff --git a/lldb/test/API/functionalities/postmortem/elf-core/altmain2.core b/lldb/test/API/functionalities/postmortem/elf-core/altmain2.core new file mode 100755 index ..b9dd8de08b813442037fcb5bedd08e8bbabfdc0b GIT binary patch literal 40960 zcmeHQ4^&jwnSa9!I!%cK#cib0IB9HSqA(1g2@tXp8Ij5$Wtd=M$vDi6Fme86<_(|; z6+_tg`VJeLbo*!1-R7KixAr7yY1h*llO~{6F(sCWr_zMokd!oo(v~!T)FyTI_ucp2 z%tOtlZMJ8(-FH3T-0yz(yZ3(gcfb4H_udT89k#l)I-QPFl7Z86N~u&4A}{64oKY?t zsH`Y~&;E#9A!n>A8-*T&)P#5twWFNXo5Amv>t%VSoTus^om+oN`+>Rj^Db^b`}?yb z;#NyEr~PK
[Lldb-commits] [lldb] [lldb][core] Fix getting summary of a variable pointing to r/o memory (PR #139196)
igorkudrin wrote: Yes, the program file contains the debug information and the read-only section with the data, so both the core and program files are required. And there are no core files with the same properties already committed. The program is built from the existing `altmain.c`. https://github.com/llvm/llvm-project/pull/139196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][core] Fix getting summary of a variable pointing to r/o memory (PR #139196)
https://github.com/igorkudrin created https://github.com/llvm/llvm-project/pull/139196 Motivation example: ``` > lldb -c altmain2.core ... (lldb) var F (const char *) F = 0x0804a000 "" ``` The variable `F` points to a read-only memory page not dumped to the core file, so `Process::ReadMemory()` cannot read the data. The patch switches to `Target::ReadMemory()`, which can read data both from the process memory and the application binary. >From 499f723c3f974ff53deb8f354d879e0baaa7a9e8 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Wed, 7 May 2025 19:55:07 -0700 Subject: [PATCH] [lldb][core] Fix getting summary of a variable pointing to r/o memory Motivation example: ``` > lldb -c altmain2.core ... (lldb) var F (const char *) F = 0x0804a000 "" ``` The variable `F` points to a read-only memory page not dumped to the core file, so `Process::ReadMemory()` cannot read the data. The patch switches to `Target::ReadMemory()`, which can read data both from the process memory and the application binary. --- lldb/source/ValueObject/ValueObject.cpp | 13 - .../postmortem/elf-core/TestLinuxCore.py | 27 ++ .../postmortem/elf-core/altmain2.core | Bin 0 -> 40960 bytes .../postmortem/elf-core/altmain2.out | Bin 0 -> 9776 bytes 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100755 lldb/test/API/functionalities/postmortem/elf-core/altmain2.core create mode 100755 lldb/test/API/functionalities/postmortem/elf-core/altmain2.out diff --git a/lldb/source/ValueObject/ValueObject.cpp b/lldb/source/ValueObject/ValueObject.cpp index e1c66763ff0b8..aab78428d9103 100644 --- a/lldb/source/ValueObject/ValueObject.cpp +++ b/lldb/source/ValueObject/ValueObject.cpp @@ -735,7 +735,7 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx, case eAddressTypeLoad: { ExecutionContext exe_ctx(GetExecutionContextRef()); Process *process = exe_ctx.GetProcessPtr(); - if (process) { + if (process && process->IsLiveDebugSession()) { heap_buf_ptr->SetByteSize(bytes); size_t bytes_read = process->ReadMemory( addr + offset, heap_buf_ptr->GetBytes(), bytes, error); @@ -743,6 +743,17 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx, data.SetData(data_sp); return bytes_read; } + } else if (Target *target = exe_ctx.GetTargetPtr()) { +Address target_addr; +target_addr.SetLoadAddress(addr + offset, target); +heap_buf_ptr->SetByteSize(bytes); +size_t bytes_read = +target->ReadMemory(target_addr, heap_buf_ptr->GetBytes(), bytes, + error, /*force_live_memory=*/true); +if (error.Success() || bytes_read > 0) { + data.SetData(data_sp); + return bytes_read; +} } } break; case eAddressTypeHost: { diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py index a287fd19ba352..d1e065a32efdc 100644 --- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -977,6 +977,33 @@ def test_get_core_file_api(self): self.assertEqual(process.GetCoreFile().GetFilename(), core_file_name) self.dbg.DeleteTarget(target) +@skipIfLLVMTargetMissing("X86") +def test_ro_cstring(self): +""" +Test that we can show the summary for a cstring variable that points +to a r/o memory page which is not dumped to a core file. +""" +target = self.dbg.CreateTarget("altmain2.out") +process = target.LoadCore("altmain2.core") +self.assertTrue(process, PROCESS_IS_VALID) + +frame = process.GetSelectedThread().GetFrameAtIndex(0) +self.assertEqual(frame.GetFunctionName(), "_start") + +var = frame.FindVariable("F") + +# The variable points to a RO segment that is not dumped to the core +# file and thus process.ReadCStringFromMemory() cannot get the value. +error = lldb.SBError() +cstr = process.ReadCStringFromMemory(var.GetValueAsUnsigned(), 256, error) +self.assertFailure(error, error_str="core file does not contain 0x804a000") +self.assertEqual(cstr, "") + +# Nevertheless, when getting the summary, the value can be read from the +# application binary. +cstr = var.GetSummary() +self.assertEqual(cstr, '"_start"') + def check_memory_regions(self, process, region_count): region_list = process.GetMemoryRegions() self.assertEqual(region_list.GetSize(), region_count) diff --git a/lldb/test/API/functionalities/postmortem/elf-core/altmain2.core b/lldb/test/API/functionalities/postmortem/elf-core/altmain2.core new file mode 100755 index
[Lldb-commits] [lldb] [lldb][NFC] Avoid an assertion failure in dwim-print (PR #139197)
https://github.com/igorkudrin created https://github.com/llvm/llvm-project/pull/139197 In a Debug build on Windows, printing inline diagnostics resulted in an error, for example: ``` > cd llvm-project\lldb\test\API\functionalities\postmortem\elf-core > lldb.exe -c altmain.core > p dummy LLDB diagnostics will be written to ... Please include the directory content when filing a bug report Exception Code: 0x8003 0x7FF8FD6633EC, C:\llvm\build\bin\liblldb.dll(0x7FF8FC2C) + 0x13A33EC byte(s), std::_Vector_const_iterator > >::_Compat() + 0x6C byte(s), C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\vector, line 202 + 0x5D byte(s) 0x7FF8FD662ABE, C:\llvm\build\bin\liblldb.dll(0x7FF8FC2C) + 0x13A2ABE byte(s), std::_Vector_const_iterator > >::operator==() + 0x1E byte(s), C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\vector, line 166 + 0x0 byte(s) 0x7FF8FD662B2E, C:\llvm\build\\bin\liblldb.dll(0x7FF8FC2C) + 0x13A2B2E byte(s), std::_Vector_const_iterator > >::operator!=() + 0x1E byte(s), C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\vector, line 176 + 0xF byte(s) 0x7FF8FD65EE1C, C:\llvm\build\\bin\liblldb.dll(0x7FF8FC2C) + 0x139EE1C byte(s), std::operator!= > >,std::_Vector_iterator > > >() + 0x3C byte(s), C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\xutility, line 1947 + 0x0 byte(s) 0x7FF8FD65D4E5, C:\llvm\build\\bin\liblldb.dll(0x7FF8FC2C) + 0x139D4E5 byte(s), lldb_private::RenderDiagnosticDetails() + 0x8F5 byte(s), C:\llvm\src\llvm-project\lldb\source\Utility\DiagnosticsRendering.cpp, line 189 + 0x25 byte(s) ... ``` The comparison operator of the iterators checks that they belong to the same container, but `remaining_details.pop_back()` invalidates `detail` making it incompatible with `remaining_details.rend()`. >From 3faf0c0a4a19d7e1d503c31a684d79295e414be4 Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Thu, 8 May 2025 18:37:34 -0700 Subject: [PATCH] [lldb][NFC] Avoid an assertion failure in dwim-print In a Debug build on Windows, printing inline diagnostics resulted in an error, for example: ``` > cd llvm-project\lldb\test\API\functionalities\postmortem\elf-core > lldb.exe -c altmain.core > p dummy LLDB diagnostics will be written to ... Please include the directory content when filing a bug report Exception Code: 0x8003 0x7FF8FD6633EC, C:\llvm\build\bin\liblldb.dll(0x7FF8FC2C) + 0x13A33EC byte(s), std::_Vector_const_iterator > >::_Compat() + 0x6C byte(s), C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\vector, line 202 + 0x5D byte(s) 0x7FF8FD662ABE, C:\llvm\build\bin\liblldb.dll(0x7FF8FC2C) + 0x13A2ABE byte(s), std::_Vector_const_iterator > >::operator==() + 0x1E byte(s), C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\vector, line 166 + 0x0 byte(s) 0x7FF8FD662B2E, C:\llvm\build\\bin\liblldb.dll(0x7FF8FC2C) + 0x13A2B2E byte(s), std::_Vector_const_iterator > >::operator!=() + 0x1E byte(s), C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\vector, line 176 + 0xF byte(s) 0x7FF8FD65EE1C, C:\llvm\build\\bin\liblldb.dll(0x7FF8FC2C) + 0x139EE1C byte(s), std::operator!= > >,std::_Vector_iterator > > >() + 0x3C byte(s), C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\xutility, line 1947 + 0x0 byte(s) 0x7FF8FD65D4E5, C:\llvm\build\\bin\liblldb.dll(0x7FF8FC2C) + 0x139D4E5 byte(s), lldb_private::RenderDiagnosticDetails() + 0x8F5 byte(s), C:\llvm\src\llvm-project\lldb\source\Utility\DiagnosticsRendering.cpp, line 189 + 0x25 byte(s) ... ``` The comparison operator of the iterators checks that they belong to the same container, but `remaining_details.pop_back()` invalidates `detail` making it incompatible with `remaining_details.rend()`. --- lldb/source/Utility/DiagnosticsRendering.cpp | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lldb/source/Utility/DiagnosticsRendering.cpp b/lldb/source/Utility/DiagnosticsRendering.cpp index 368e2199b749f..c43b39b6b8fe9 100644 --- a/lldb/source/Utility/DiagnosticsRendering.cpp +++ b/lldb/source/Utility/DiagnosticsRendering.cpp @@ -185,9 +185,8 @@ void RenderDiagnosticDetails(Stream &stream, // Work through each detail in reverse order using the vector/stack. bool did_print = false; - for (auto detail = remaining_details.rbegin(); - detail != remaining_details.rend(); - ++detail, remaining_details.pop_back()) { + for (; !remaining_details.empty(); remaining_details.pop_back()) { +auto &detail = remaining_details.back(); // Get the information to print this detail and remove it
[Lldb-commits] [lldb] [lldb][core] Fix getting summary of a variable pointing to r/o memory (PR #139196)
https://github.com/igorkudrin closed https://github.com/llvm/llvm-project/pull/139196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][core] Fix getting summary of a variable pointing to r/o memory (PR #139196)
igorkudrin wrote: Ping. https://github.com/llvm/llvm-project/pull/139196 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits