[Lldb-commits] [lldb] [lldb/dwarf] Fix DW_IDX_parent processing for split dwarf (PR #92745)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/92745 >From ae72d530c723a8d0fb2eac38224e8cf74cc43e70 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 20 May 2024 12:30:46 + Subject: [PATCH] [lldb/dwarf] Fix DW_IDX_parent processing for split dwarf DWARFDebugInfo only knows how to resolve references in its own file, but in split dwarf, the index entries will refer to DIEs in the separate (DWO) file. To resolve the DIERef correctly we'd either need to go through the SymbolFileDWARF to get the full logic for resolving a DIERef, or use the fact that ToDIERef already looks up the correct unit while computing its result. This patch does the latter. This bug manifested itself in not being able to find type definitions for types in namespaces, so I've modified one of our type resolving test cases to run with debug_names, and added a namespaced class into it (it originally contained only a top-level class). --- .../SymbolFile/DWARF/DWARFDebugInfo.cpp | 6 --- .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h | 5 --- .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 28 +++-- .../SymbolFile/DWARF/DebugNamesDWARFIndex.h | 2 +- .../API/lang/cpp/limit-debug-info/Makefile| 2 - .../TestWithLimitDebugInfo.py | 40 +++ .../API/lang/cpp/limit-debug-info/base.cpp| 9 ++--- .../test/API/lang/cpp/limit-debug-info/base.h | 22 +++--- .../API/lang/cpp/limit-debug-info/derived.cpp | 11 +++-- .../API/lang/cpp/limit-debug-info/derived.h | 37 - .../API/lang/cpp/limit-debug-info/main.cpp| 6 +-- .../SymbolFile/DWARF/DWARFDIETest.cpp | 24 +-- 12 files changed, 106 insertions(+), 86 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index 44febcfac3b00..d28da728728e5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -259,9 +259,3 @@ DWARFDebugInfo::GetDIE(const DIERef _ref) { return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset()); return DWARFDIE(); // Not found } - -llvm::StringRef DWARFDebugInfo::PeekDIEName(const DIERef _ref) { - if (DWARFUnit *cu = GetUnit(die_ref)) -return cu->GetNonSkeletonUnit().PeekDIEName(die_ref.die_offset()); - return llvm::StringRef(); -} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index c1f0cb0203fb7..456ebd908ccb2 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -44,11 +44,6 @@ class DWARFDebugInfo { bool ContainsTypeUnits(); DWARFDIE GetDIE(const DIERef _ref); - /// Returns the AT_Name of this DIE, if it exists, without parsing the entire - /// compile unit. An empty is string is returned upon error or if the - /// attribute is not present. - llvm::StringRef PeekDIEName(const DIERef _ref); - enum { eDumpFlag_Verbose = (1 << 0), // Verbose dumping eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index 4da0d56fdcacb..79400e36e04f3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -9,7 +9,7 @@ #include "Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h" #include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h" #include "Plugins/SymbolFile/DWARF/DWARFDeclContext.h" -#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h" +#include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h" #include "lldb/Core/Module.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" @@ -48,26 +48,30 @@ DebugNamesDWARFIndex::GetUnits(const DebugNames _names) { return result; } -std::optional -DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry ) const { +DWARFUnit * +DebugNamesDWARFIndex::GetNonSkeletonUnit(const DebugNames::Entry ) const { // Look for a DWARF unit offset (CU offset or local TU offset) as they are // both offsets into the .debug_info section. std::optional unit_offset = entry.getCUOffset(); if (!unit_offset) { unit_offset = entry.getLocalTUOffset(); if (!unit_offset) - return std::nullopt; + return nullptr; } DWARFUnit *cu = m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, *unit_offset); - if (!cu) -return std::nullopt; + return cu ? >GetNonSkeletonUnit() : nullptr; +} - cu = >GetNonSkeletonUnit(); +std::optional +DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry ) const { + DWARFUnit *unit = GetNonSkeletonUnit(entry); + if (!unit) +return std::nullopt; if (std::optional die_offset = entry.getDIEUnitOffset()) -return
[Lldb-commits] [lldb] [lldb/dwarf] Fix DW_IDX_parent processing for split dwarf (PR #92745)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff da6a0b7af29a222b2e16a10155b49d4fafe967f3 1c36a0c63f2c7c69048de36ab524cc8df7056704 -- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h lldb/test/API/lang/cpp/limit-debug-info/base.cpp lldb/test/API/lang/cpp/limit-debug-info/base.h lldb/test/API/lang/cpp/limit-debug-info/derived.cpp lldb/test/API/lang/cpp/limit-debug-info/derived.h lldb/test/API/lang/cpp/limit-debug-info/main.cpp lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index 7fff5f52df..79400e36e0 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -48,7 +48,8 @@ DebugNamesDWARFIndex::GetUnits(const DebugNames _names) { return result; } -DWARFUnit *DebugNamesDWARFIndex::GetNonSkeletonUnit(const DebugNames::Entry ) const { +DWARFUnit * +DebugNamesDWARFIndex::GetNonSkeletonUnit(const DebugNames::Entry ) const { // Look for a DWARF unit offset (CU offset or local TU offset) as they are // both offsets into the .debug_info section. std::optional unit_offset = entry.getCUOffset(); `` https://github.com/llvm/llvm-project/pull/92745 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/dwarf] Fix DW_IDX_parent processing for split dwarf (PR #92745)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r da6a0b7af29a222b2e16a10155b49d4fafe967f3...1c36a0c63f2c7c69048de36ab524cc8df7056704 lldb/test/API/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py `` View the diff from darker here. ``diff --- TestWithLimitDebugInfo.py 2024-05-20 12:56:24.00 + +++ TestWithLimitDebugInfo.py 2024-05-20 13:07:51.177002 + @@ -14,12 +14,16 @@ # Load the executable target = self.dbg.CreateTarget(exe_path) self.assertTrue(target.IsValid(), VALID_TARGET) # Break on main function -lldbutil.run_break_set_by_file_and_line(self, "derived.h", line_number("derived.h", "// break1")) -lldbutil.run_break_set_by_file_and_line(self, "derived.h", line_number("derived.h", "// break2")) +lldbutil.run_break_set_by_file_and_line( +self, "derived.h", line_number("derived.h", "// break1") +) +lldbutil.run_break_set_by_file_and_line( +self, "derived.h", line_number("derived.h", "// break2") +) # Launch the process process = target.LaunchSimple(None, None, self.get_process_working_directory()) self.assertTrue(process.IsValid(), PROCESS_IS_VALID) @@ -40,6 +44,8 @@ def test_default(self): self._run_test(dict(CFLAGS_EXTRAS="$(LIMIT_DEBUG_INFO_FLAGS)")) @add_test_categories(["dwarf", "dwo"]) def test_debug_names(self): -self._run_test(dict(CFLAGS_EXTRAS="$(LIMIT_DEBUG_INFO_FLAGS) -gdwarf-5 -gpubnames")) +self._run_test( +dict(CFLAGS_EXTRAS="$(LIMIT_DEBUG_INFO_FLAGS) -gdwarf-5 -gpubnames") +) `` https://github.com/llvm/llvm-project/pull/92745 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/dwarf] Fix DW_IDX_parent processing for split dwarf (PR #92745)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Pavel Labath (labath) Changes DWARFDebugInfo only knows how to resolve references in its own file, but in split dwarf, the index entries will refer to DIEs in the separate (DWO) file. To resolve the DIERef correctly we'd either need to go through the SymbolFileDWARF to get the full logic for resolving a DIERef, or use the fact that ToDIERef already looks up the correct unit while computing its result. This patch does the latter. This bug manifested itself in not being able to find type definitions for types in namespaces, so I've modified one of our type resolving test cases to run with debug_names, and added a namespaced class into it (it originally contained only a top-level class). --- Full diff: https://github.com/llvm/llvm-project/pull/92745.diff 12 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (-6) - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h (-5) - (modified) lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp (+15-12) - (modified) lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h (+1-1) - (modified) lldb/test/API/lang/cpp/limit-debug-info/Makefile (-2) - (modified) lldb/test/API/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py (+18-18) - (modified) lldb/test/API/lang/cpp/limit-debug-info/base.cpp (+4-5) - (modified) lldb/test/API/lang/cpp/limit-debug-info/base.h (+16-6) - (modified) lldb/test/API/lang/cpp/limit-debug-info/derived.cpp (+5-6) - (modified) lldb/test/API/lang/cpp/limit-debug-info/derived.h (+27-10) - (modified) lldb/test/API/lang/cpp/limit-debug-info/main.cpp (+2-4) - (modified) lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp (+12-12) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index 44febcfac3b00..d28da728728e5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -259,9 +259,3 @@ DWARFDebugInfo::GetDIE(const DIERef _ref) { return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset()); return DWARFDIE(); // Not found } - -llvm::StringRef DWARFDebugInfo::PeekDIEName(const DIERef _ref) { - if (DWARFUnit *cu = GetUnit(die_ref)) -return cu->GetNonSkeletonUnit().PeekDIEName(die_ref.die_offset()); - return llvm::StringRef(); -} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index c1f0cb0203fb7..456ebd908ccb2 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -44,11 +44,6 @@ class DWARFDebugInfo { bool ContainsTypeUnits(); DWARFDIE GetDIE(const DIERef _ref); - /// Returns the AT_Name of this DIE, if it exists, without parsing the entire - /// compile unit. An empty is string is returned upon error or if the - /// attribute is not present. - llvm::StringRef PeekDIEName(const DIERef _ref); - enum { eDumpFlag_Verbose = (1 << 0), // Verbose dumping eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index 4da0d56fdcacb..7fff5f52dfd79 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -9,7 +9,7 @@ #include "Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h" #include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h" #include "Plugins/SymbolFile/DWARF/DWARFDeclContext.h" -#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h" +#include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h" #include "lldb/Core/Module.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" @@ -48,26 +48,29 @@ DebugNamesDWARFIndex::GetUnits(const DebugNames _names) { return result; } -std::optional -DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry ) const { +DWARFUnit *DebugNamesDWARFIndex::GetNonSkeletonUnit(const DebugNames::Entry ) const { // Look for a DWARF unit offset (CU offset or local TU offset) as they are // both offsets into the .debug_info section. std::optional unit_offset = entry.getCUOffset(); if (!unit_offset) { unit_offset = entry.getLocalTUOffset(); if (!unit_offset) - return std::nullopt; + return nullptr; } DWARFUnit *cu = m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, *unit_offset); - if (!cu) -return std::nullopt; + return cu ? >GetNonSkeletonUnit() : nullptr; +} - cu = >GetNonSkeletonUnit(); +std::optional +DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry ) const { + DWARFUnit *unit = GetNonSkeletonUnit(entry); + if (!unit) +return std::nullopt; if (std::optional die_offset = entry.getDIEUnitOffset()) -return
[Lldb-commits] [lldb] [lldb/dwarf] Fix DW_IDX_parent processing for split dwarf (PR #92745)
https://github.com/labath created https://github.com/llvm/llvm-project/pull/92745 DWARFDebugInfo only knows how to resolve references in its own file, but in split dwarf, the index entries will refer to DIEs in the separate (DWO) file. To resolve the DIERef correctly we'd either need to go through the SymbolFileDWARF to get the full logic for resolving a DIERef, or use the fact that ToDIERef already looks up the correct unit while computing its result. This patch does the latter. This bug manifested itself in not being able to find type definitions for types in namespaces, so I've modified one of our type resolving test cases to run with debug_names, and added a namespaced class into it (it originally contained only a top-level class). >From 1c36a0c63f2c7c69048de36ab524cc8df7056704 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 20 May 2024 12:30:46 + Subject: [PATCH] [lldb/dwarf] Fix DW_IDX_parent processing for split dwarf DWARFDebugInfo only knows how to resolve references in its own file, but in split dwarf, the index entries will refer to DIEs in the separate (DWO) file. To resolve the DIERef correctly we'd either need to go through the SymbolFileDWARF to get the full logic for resolving a DIERef, or use the fact that ToDIERef already looks up the correct unit while computing its result. This patch does the latter. This bug manifested itself in not being able to find type definitions for types in namespaces, so I've modified one of our type resolving test cases to run with debug_names, and added a namespaced class into it (it originally contained only a top-level class). --- .../SymbolFile/DWARF/DWARFDebugInfo.cpp | 6 --- .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h | 5 --- .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 27 -- .../SymbolFile/DWARF/DebugNamesDWARFIndex.h | 2 +- .../API/lang/cpp/limit-debug-info/Makefile| 2 - .../TestWithLimitDebugInfo.py | 36 +- .../API/lang/cpp/limit-debug-info/base.cpp| 9 ++--- .../test/API/lang/cpp/limit-debug-info/base.h | 22 --- .../API/lang/cpp/limit-debug-info/derived.cpp | 11 +++--- .../API/lang/cpp/limit-debug-info/derived.h | 37 ++- .../API/lang/cpp/limit-debug-info/main.cpp| 6 +-- .../SymbolFile/DWARF/DWARFDIETest.cpp | 24 ++-- 12 files changed, 100 insertions(+), 87 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index 44febcfac3b00..d28da728728e5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -259,9 +259,3 @@ DWARFDebugInfo::GetDIE(const DIERef _ref) { return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset()); return DWARFDIE(); // Not found } - -llvm::StringRef DWARFDebugInfo::PeekDIEName(const DIERef _ref) { - if (DWARFUnit *cu = GetUnit(die_ref)) -return cu->GetNonSkeletonUnit().PeekDIEName(die_ref.die_offset()); - return llvm::StringRef(); -} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index c1f0cb0203fb7..456ebd908ccb2 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -44,11 +44,6 @@ class DWARFDebugInfo { bool ContainsTypeUnits(); DWARFDIE GetDIE(const DIERef _ref); - /// Returns the AT_Name of this DIE, if it exists, without parsing the entire - /// compile unit. An empty is string is returned upon error or if the - /// attribute is not present. - llvm::StringRef PeekDIEName(const DIERef _ref); - enum { eDumpFlag_Verbose = (1 << 0), // Verbose dumping eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index 4da0d56fdcacb..7fff5f52dfd79 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -9,7 +9,7 @@ #include "Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h" #include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h" #include "Plugins/SymbolFile/DWARF/DWARFDeclContext.h" -#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h" +#include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h" #include "lldb/Core/Module.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" @@ -48,26 +48,29 @@ DebugNamesDWARFIndex::GetUnits(const DebugNames _names) { return result; } -std::optional -DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry ) const { +DWARFUnit *DebugNamesDWARFIndex::GetNonSkeletonUnit(const DebugNames::Entry ) const { // Look for a DWARF unit offset (CU offset or local TU offset) as they are // both offsets into the .debug_info section.
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
labath wrote: > I attached to clang and printed an expression. That resulted in 16801 calls > to `Progress::Increment`, all of which I'm guessing translate to event > broadcasts. I collected some timing numbers: Thanks for doing this. What do these numbers include? Is it just the operation it self, or everything leading up to it as well. For example, is "expr var" just the timing of the "expr" command, or attach command as well. If the latter, then what's the baseline? https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)
@@ -2306,6 +2345,11 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE , if (!die) return false; + ParsedDWARFTypeAttributes attrs(die); labath wrote: > > How exactly do we get here in that case? > > From [#90663 > (comment)](https://github.com/llvm/llvm-project/pull/90663#issuecomment-2105194128), > .debug_names somehow contains entries that are declarations. This causes > `SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext` to return a type > created from declaration when searching for definition. I've re-read that. The debug names situation is troubling, but the thing I don't understand now why is this even specific to debug_names. After this patch, it should be fairly easy to trigger a situation where we're asked to complete a type, and we don't have the definition of that type. Why don't those cases lead to a crash? For example, what would happen if the name was simply not in the index? If I ignored this entire discussion, I would say that this check makes perfect sense: since we're delaying the search for the definition, it can happen that the we don't have the definition die at the point when we're asked to complete the type. So it seems perfectly reasonable to have this check _somewhere_. I just want to check whether this is the right place. > > A simple idea I have in mind is to make the > `GetForwardDeclCompilerTypeToDIE`'s value type to a pair `{DIERef, bool}`, > and the bool indicate if this is a definition or not. So we know that info > without extra attribute parsing. How do you think? Given that this extra bool is going to cause us to use eight more bytes per type, this doesn't necessarily seem like. This would use more memory, the previous implementation would use more time. Hard to say which one is better without some very precise measurements. Choosing blindly, I would stick with the current implementation, as it's easier to optimize the cpu time than it is to reclaim that memory (the real problem here is that `ParsedDWARFTypeAttributes` was optimized for the use case where one is going to use most of the attributes it has parsed (which is what happens in ParseTypeFromDWARF). Using it to essentially just check for the presence of DW_AT_declaration is wasteful, and you could write a much faster implementation if you were writing it for this use case specifically (but it's also not clear whether it's worthwhile to have a brand new implementation for this use case). https://github.com/llvm/llvm-project/pull/92328 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Windows] Skip the TestDataFormatterLibcxxChrono test to avoid python crash (PR #92575)
https://github.com/slydiman closed https://github.com/llvm/llvm-project/pull/92575 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Windows] Fixed LibcxxChronoTimePointSecondsSummaryProvider() (PR #92701)
https://github.com/slydiman closed https://github.com/llvm/llvm-project/pull/92701 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 2217d17 - [lldb][Windows] Fixed LibcxxChronoTimePointSecondsSummaryProvider() (#92701)
Author: Dmitry Vasilyev Date: 2024-05-20T13:44:52+04:00 New Revision: 2217d1706a76d3f298899f824354ca9d96c45813 URL: https://github.com/llvm/llvm-project/commit/2217d1706a76d3f298899f824354ca9d96c45813 DIFF: https://github.com/llvm/llvm-project/commit/2217d1706a76d3f298899f824354ca9d96c45813.diff LOG: [lldb][Windows] Fixed LibcxxChronoTimePointSecondsSummaryProvider() (#92701) This patch fixes #92574. It is a replacement for #92575. Added: Modified: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py Removed: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index e160fd0763939..b0e6fb7d6f5af 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -1098,6 +1098,7 @@ LibcxxChronoTimePointSecondsSummaryProvider(ValueObject , Stream , if (!ptr_sp) return false; +#ifndef _WIN32 // The date time in the chrono library is valid in the range // [-32767-01-01T00:00:00Z, 32767-12-31T23:59:59Z]. A 64-bit time_t has a // larger range, the function strftime is not able to format the entire range @@ -1107,6 +1108,11 @@ LibcxxChronoTimePointSecondsSummaryProvider(ValueObject , Stream , -1'096'193'779'200; // -32767-01-01T00:00:00Z const std::time_t chrono_timestamp_max = 971'890'963'199; // 32767-12-31T23:59:59Z +#else + const std::time_t chrono_timestamp_min = -43'200; // 1969-12-31T12:00:00Z + const std::time_t chrono_timestamp_max = + 32'536'850'399; // 3001-01-19T21:59:59 +#endif const std::time_t seconds = ptr_sp->GetValueAsSigned(0); if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max) @@ -1148,12 +1154,17 @@ LibcxxChronoTimepointDaysSummaryProvider(ValueObject , Stream , if (!ptr_sp) return false; +#ifndef _WIN32 // The date time in the chrono library is valid in the range // [-32767-01-01Z, 32767-12-31Z]. A 32-bit time_t has a larger range, the // function strftime is not able to format the entire range of time_t. The // exact point has not been investigated; it's limited to chrono's range. const int chrono_timestamp_min = -12'687'428; // -32767-01-01Z const int chrono_timestamp_max = 11'248'737; // 32767-12-31Z +#else + const int chrono_timestamp_min = 0; // 1970-01-01Z + const int chrono_timestamp_max = 376'583; // 3001-01-19Z +#endif const int days = ptr_sp->GetValueAsSigned(0); if (days < chrono_timestamp_min || days > chrono_timestamp_max) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py index fb35481d55514..0737a5bc7e6eb 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py @@ -14,6 +14,7 @@ class LibcxxChronoDataFormatterTestCase(TestBase): @skipIf(compiler="clang", compiler_version=["<", "17.0"]) def test_with_run_command(self): """Test that that file and class static variables display correctly.""" +isNotWindowsHost = lldbplatformutil.getHostPlatform() != "windows" self.build() (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "break here", lldb.SBFileSpec("main.cpp", False) @@ -57,7 +58,11 @@ def test_with_run_command(self): self.expect( "frame variable ss_neg_date_time", substrs=[ -"ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s" +( +"ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s" +if isNotWindowsHost +else "ss_neg_date_time = timestamp=-1096193779200 s" +) ], ) self.expect( @@ -68,7 +73,11 @@ def test_with_run_command(self): self.expect( "frame variable ss_pos_date_time", substrs=[ -"ss_pos_date_time = date/time=32767-12-31T23:59:59Z timestamp=971890963199 s" +( +"ss_pos_date_time = date/time=32767-12-31T23:59:59Z timestamp=971890963199 s" +if isNotWindowsHost +else "ss_pos_date_time = timestamp=971890963199 s" +) ], ) self.expect( @@ -103,7 +112,13 @@ def test_with_run_command(self): ) self.expect( "frame variable sd_neg_date", -
[Lldb-commits] [lldb] [lldb-dap] Don't send expanded descriptions for "hover" expressions (PR #92726)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Pavel Labath (labath) Changes VSCode will automatically ask for the children (in structured form) so there's no point in sending the textual representation. This can make displaying hover popups for complex variables with complicated data formatters much faster. See discussion on #77026 for context. --- Full diff: https://github.com/llvm/llvm-project/pull/92726.diff 3 Files Affected: - (modified) lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py (+1-1) - (modified) lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py (+6-23) - (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+3-3) ``diff diff --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py index 57cabf5b7f411..68c57ad775544 100644 --- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py +++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py @@ -27,7 +27,7 @@ def assertEvaluateFailure(self, expression): ) def isResultExpandedDescription(self): -return self.context == "repl" or self.context == "hover" +return self.context == "repl" def isExpressionParsedExpected(self): return self.context != "hover" diff --git a/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py index 07ab6d5a63eb6..57c17e5ea9d3d 100644 --- a/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py +++ b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py @@ -502,29 +502,12 @@ def do_test_scopes_and_evaluate_expansion(self, enableAutoVariableSummaries: boo }, "hover": { "equals": {"type": "PointType"}, -"equals": { -"result": """(PointType) pt = { - x = 11 - y = 22 - buffer = { -[0] = 0 -[1] = 1 -[2] = 2 -[3] = 3 -[4] = 4 -[5] = 5 -[6] = 6 -[7] = 7 -[8] = 8 -[9] = 9 -[10] = 10 -[11] = 11 -[12] = 12 -[13] = 13 -[14] = 14 -[15] = 15 - } -}""" +"startswith": { +"result": ( +"{x:11, y:22, buffer:{...}}" +if enableAutoVariableSummaries +else "PointType @ 0x" +) }, "missing": ["indexedVariables"], "hasVariablesReference": True, diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp index bec277332bcf0..069877dbab339 100644 --- a/lldb/tools/lldb-dap/JSONUtils.cpp +++ b/lldb/tools/lldb-dap/JSONUtils.cpp @@ -1065,9 +1065,9 @@ llvm::json::Object VariableDescription::GetVariableExtensionsJSON() { } std::string VariableDescription::GetResult(llvm::StringRef context) { - // In repl and hover context, the results can be displayed as multiple lines - // so more detailed descriptions can be returned. - if (context != "repl" && context != "hover") + // In repl context, the results can be displayed as multiple lines so more + // detailed descriptions can be returned. + if (context != "repl") return display_value; if (!v.IsValid()) `` https://github.com/llvm/llvm-project/pull/92726 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Don't send expanded descriptions for "hover" expressions (PR #92726)
https://github.com/labath created https://github.com/llvm/llvm-project/pull/92726 VSCode will automatically ask for the children (in structured form) so there's no point in sending the textual representation. This can make displaying hover popups for complex variables with complicated data formatters much faster. See discussion on #77026 for context. >From 9d126afa09c7c2f73852da3ba943e1a74498cba4 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 20 May 2024 08:18:07 + Subject: [PATCH] [lldb-dap] Don't send expanded descriptions for "hover" expressions VSCode will automatically ask for the children (in structured form) so there's no point in sending the textual representation. This can make displaying hover popups for complex variables with complicated data formatters much faster. See discussion on #77026 for context. --- .../lldb-dap/evaluate/TestDAP_evaluate.py | 2 +- .../lldb-dap/variables/TestDAP_variables.py | 29 --- lldb/tools/lldb-dap/JSONUtils.cpp | 6 ++-- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py index 57cabf5b7f411..68c57ad775544 100644 --- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py +++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py @@ -27,7 +27,7 @@ def assertEvaluateFailure(self, expression): ) def isResultExpandedDescription(self): -return self.context == "repl" or self.context == "hover" +return self.context == "repl" def isExpressionParsedExpected(self): return self.context != "hover" diff --git a/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py index 07ab6d5a63eb6..57c17e5ea9d3d 100644 --- a/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py +++ b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py @@ -502,29 +502,12 @@ def do_test_scopes_and_evaluate_expansion(self, enableAutoVariableSummaries: boo }, "hover": { "equals": {"type": "PointType"}, -"equals": { -"result": """(PointType) pt = { - x = 11 - y = 22 - buffer = { -[0] = 0 -[1] = 1 -[2] = 2 -[3] = 3 -[4] = 4 -[5] = 5 -[6] = 6 -[7] = 7 -[8] = 8 -[9] = 9 -[10] = 10 -[11] = 11 -[12] = 12 -[13] = 13 -[14] = 14 -[15] = 15 - } -}""" +"startswith": { +"result": ( +"{x:11, y:22, buffer:{...}}" +if enableAutoVariableSummaries +else "PointType @ 0x" +) }, "missing": ["indexedVariables"], "hasVariablesReference": True, diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp index bec277332bcf0..069877dbab339 100644 --- a/lldb/tools/lldb-dap/JSONUtils.cpp +++ b/lldb/tools/lldb-dap/JSONUtils.cpp @@ -1065,9 +1065,9 @@ llvm::json::Object VariableDescription::GetVariableExtensionsJSON() { } std::string VariableDescription::GetResult(llvm::StringRef context) { - // In repl and hover context, the results can be displayed as multiple lines - // so more detailed descriptions can be returned. - if (context != "repl" && context != "hover") + // In repl context, the results can be displayed as multiple lines so more + // detailed descriptions can be returned. + if (context != "repl") return display_value; if (!v.IsValid()) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Windows] Fixed LibcxxChronoTimePointSecondsSummaryProvider() (PR #92701)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/92701 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for updating string during debug process (PR #67782)
kpdev wrote: @jimingham Please take a look: https://github.com/llvm/llvm-project/pull/67782#issuecomment-2047369473 https://github.com/llvm/llvm-project/pull/67782 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)
https://github.com/felipepiovezan approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/92618 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)
https://github.com/cmtice updated https://github.com/llvm/llvm-project/pull/87197 >From 68cb68d3f93aed6b3479fb305131b99ec599c9d8 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Sun, 31 Mar 2024 10:59:38 -0700 Subject: [PATCH 1/3] [LLDB] Add more helper functions to ValueObject class. Create additional helper functions for the ValueObject class, for: - returning the value as an APSInt or APFloat - additional type casting options - additional ways to create ValueObjects from various types of data - dereferencing a ValueObject These helper functions are needed for implementing the Data Inspection Language, described in https://discourse.llvm.org/t/rfc-data-inspection-language/69893 --- lldb/include/lldb/Core/ValueObject.h | 61 lldb/source/Core/ValueObject.cpp | 405 +++ 2 files changed, 466 insertions(+) diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index e7e35e2b2bffc..0c8dbf384a326 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -441,6 +441,19 @@ class ValueObject { virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success = nullptr); + llvm::APSInt GetValueAsAPSInt(); + + llvm::APFloat GetValueAsFloat(); + + bool GetValueAsBool(); + + /// Update the value of the current object to be the integer in the 'value' + /// parameter. + void UpdateIntegerValue(const llvm::APInt ); + + /// Assign the integer value 'new_val_sp' to the current object. + void UpdateIntegerValue(lldb::ValueObjectSP new_val_sp); + virtual bool SetValueFromCString(const char *value_str, Status ); /// Return the module associated with this value object in case the value is @@ -618,6 +631,24 @@ class ValueObject { virtual lldb::ValueObjectSP CastPointerType(const char *name, lldb::TypeSP _sp); + /// Return the target load address assocaited with this value object. + lldb::addr_t GetLoadAddress(); + + lldb::ValueObjectSP CastDerivedToBaseType(CompilerType type, +const std::vector ); + + lldb::ValueObjectSP CastBaseToDerivedType(CompilerType type, uint64_t offset); + + lldb::ValueObjectSP CastScalarToBasicType(CompilerType type, Status ); + + lldb::ValueObjectSP CastEnumToBasicType(CompilerType type); + + lldb::ValueObjectSP CastPointerToBasicType(CompilerType type); + + lldb::ValueObjectSP CastIntegerOrEnumToEnumType(CompilerType type); + + lldb::ValueObjectSP CastFloatToEnumType(CompilerType type, Status ); + /// If this object represents a C++ class with a vtable, return an object /// that represents the virtual function table. If the object isn't a class /// with a vtable, return a valid ValueObject with the error set correctly. @@ -668,6 +699,32 @@ class ValueObject { CreateValueObjectFromData(llvm::StringRef name, const DataExtractor , const ExecutionContext _ctx, CompilerType type); + static lldb::ValueObjectSP + CreateValueObjectFromBytes(lldb::TargetSP target_sp, const void *bytes, + CompilerType type); + + static lldb::ValueObjectSP CreateValueObjectFromBytes(lldb::TargetSP target, +const void *bytes, +lldb::BasicType type); + + static lldb::ValueObjectSP CreateValueObjectFromAPInt(lldb::TargetSP target, +const llvm::APInt , +CompilerType type); + + static lldb::ValueObjectSP + CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat , + CompilerType type); + + static lldb::ValueObjectSP CreateValueObjectFromPointer(lldb::TargetSP target, + uintptr_t addr, + CompilerType type); + + static lldb::ValueObjectSP CreateValueObjectFromBool(lldb::TargetSP target, + bool value); + + static lldb::ValueObjectSP CreateValueObjectFromNullptr(lldb::TargetSP target, + CompilerType type); + lldb::ValueObjectSP Persist(); /// Returns true if this is a char* or a char[] if it is a char* and @@ -719,6 +776,10 @@ class ValueObject { ClearUserVisibleData(eClearUserVisibleDataItemsSummary); } + void SetDerefValobj(ValueObject *deref) { m_deref_valobj = deref; } + + ValueObject *GetDerefValobj() { return m_deref_valobj; } + void SetValueFormat(lldb::TypeFormatImplSP format) { m_type_format_sp = std::move(format); ClearUserVisibleData(eClearUserVisibleDataItemsValue); diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index
[Lldb-commits] [lldb] [lldb][Windows] Fixed LibcxxChronoTimePointSecondsSummaryProvider() (PR #92701)
https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/92701 >From 7d455ee2dabe3adc851b0c7989e9cef53eb24e6e Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Sun, 19 May 2024 21:50:21 +0400 Subject: [PATCH] [lldb][Windows] Fixed LibcxxChronoTimePointSecondsSummaryProvider() This patch fixes #92574. It is a replacement for #92575. --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 11 .../chrono/TestDataFormatterLibcxxChrono.py | 57 --- 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index e160fd0763939..b0e6fb7d6f5af 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -1098,6 +1098,7 @@ LibcxxChronoTimePointSecondsSummaryProvider(ValueObject , Stream , if (!ptr_sp) return false; +#ifndef _WIN32 // The date time in the chrono library is valid in the range // [-32767-01-01T00:00:00Z, 32767-12-31T23:59:59Z]. A 64-bit time_t has a // larger range, the function strftime is not able to format the entire range @@ -1107,6 +1108,11 @@ LibcxxChronoTimePointSecondsSummaryProvider(ValueObject , Stream , -1'096'193'779'200; // -32767-01-01T00:00:00Z const std::time_t chrono_timestamp_max = 971'890'963'199; // 32767-12-31T23:59:59Z +#else + const std::time_t chrono_timestamp_min = -43'200; // 1969-12-31T12:00:00Z + const std::time_t chrono_timestamp_max = + 32'536'850'399; // 3001-01-19T21:59:59 +#endif const std::time_t seconds = ptr_sp->GetValueAsSigned(0); if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max) @@ -1148,12 +1154,17 @@ LibcxxChronoTimepointDaysSummaryProvider(ValueObject , Stream , if (!ptr_sp) return false; +#ifndef _WIN32 // The date time in the chrono library is valid in the range // [-32767-01-01Z, 32767-12-31Z]. A 32-bit time_t has a larger range, the // function strftime is not able to format the entire range of time_t. The // exact point has not been investigated; it's limited to chrono's range. const int chrono_timestamp_min = -12'687'428; // -32767-01-01Z const int chrono_timestamp_max = 11'248'737; // 32767-12-31Z +#else + const int chrono_timestamp_min = 0; // 1970-01-01Z + const int chrono_timestamp_max = 376'583; // 3001-01-19Z +#endif const int days = ptr_sp->GetValueAsSigned(0); if (days < chrono_timestamp_min || days > chrono_timestamp_max) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py index fb35481d55514..0737a5bc7e6eb 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py @@ -14,6 +14,7 @@ class LibcxxChronoDataFormatterTestCase(TestBase): @skipIf(compiler="clang", compiler_version=["<", "17.0"]) def test_with_run_command(self): """Test that that file and class static variables display correctly.""" +isNotWindowsHost = lldbplatformutil.getHostPlatform() != "windows" self.build() (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "break here", lldb.SBFileSpec("main.cpp", False) @@ -57,7 +58,11 @@ def test_with_run_command(self): self.expect( "frame variable ss_neg_date_time", substrs=[ -"ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s" +( +"ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s" +if isNotWindowsHost +else "ss_neg_date_time = timestamp=-1096193779200 s" +) ], ) self.expect( @@ -68,7 +73,11 @@ def test_with_run_command(self): self.expect( "frame variable ss_pos_date_time", substrs=[ -"ss_pos_date_time = date/time=32767-12-31T23:59:59Z timestamp=971890963199 s" +( +"ss_pos_date_time = date/time=32767-12-31T23:59:59Z timestamp=971890963199 s" +if isNotWindowsHost +else "ss_pos_date_time = timestamp=971890963199 s" +) ], ) self.expect( @@ -103,7 +112,13 @@ def test_with_run_command(self): ) self.expect( "frame variable sd_neg_date", -substrs=["sd_neg_date = date=-32767-01-01Z timestamp=-12687428 days"], +substrs=[ +( +"sd_neg_date = date=-32767-01-01Z
[Lldb-commits] [lldb] [lldb][Windows] Fixed LibcxxChronoTimePointSecondsSummaryProvider() (PR #92701)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 3c3f6d877623d0d821f59f4ec6038b27f27ee01d 2dfbb8663a4661255cd90269b9f527dfac8fb21b -- lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index da05ba7b40..b0e6fb7d6f 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -1162,7 +1162,7 @@ LibcxxChronoTimepointDaysSummaryProvider(ValueObject , Stream , const int chrono_timestamp_min = -12'687'428; // -32767-01-01Z const int chrono_timestamp_max = 11'248'737; // 32767-12-31Z #else - const int chrono_timestamp_min = 0; // 1970-01-01Z + const int chrono_timestamp_min = 0; // 1970-01-01Z const int chrono_timestamp_max = 376'583; // 3001-01-19Z #endif `` https://github.com/llvm/llvm-project/pull/92701 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Windows] Skip the TestDataFormatterLibcxxChrono test to avoid python crash (PR #92575)
slydiman wrote: @Michael137 > I think we should just fix #92574 since it seems pretty trivial Please look at #92701. https://github.com/llvm/llvm-project/pull/92575 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Windows] Fixed LibcxxChronoTimePointSecondsSummaryProvider() (PR #92701)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Dmitry Vasilyev (slydiman) Changes This patch fixes #92574. It is a replacement for #92575. --- Full diff: https://github.com/llvm/llvm-project/pull/92701.diff 2 Files Affected: - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp (+11) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py (+49-8) ``diff diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index e160fd0763939..da05ba7b40d32 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -1098,6 +1098,7 @@ LibcxxChronoTimePointSecondsSummaryProvider(ValueObject , Stream , if (!ptr_sp) return false; +#ifndef _WIN32 // The date time in the chrono library is valid in the range // [-32767-01-01T00:00:00Z, 32767-12-31T23:59:59Z]. A 64-bit time_t has a // larger range, the function strftime is not able to format the entire range @@ -1107,6 +1108,11 @@ LibcxxChronoTimePointSecondsSummaryProvider(ValueObject , Stream , -1'096'193'779'200; // -32767-01-01T00:00:00Z const std::time_t chrono_timestamp_max = 971'890'963'199; // 32767-12-31T23:59:59Z +#else + const std::time_t chrono_timestamp_min = -43'200; // 1969-12-31T12:00:00Z + const std::time_t chrono_timestamp_max = + 32'536'850'399; // 3001-01-19T21:59:59 +#endif const std::time_t seconds = ptr_sp->GetValueAsSigned(0); if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max) @@ -1148,12 +1154,17 @@ LibcxxChronoTimepointDaysSummaryProvider(ValueObject , Stream , if (!ptr_sp) return false; +#ifndef _WIN32 // The date time in the chrono library is valid in the range // [-32767-01-01Z, 32767-12-31Z]. A 32-bit time_t has a larger range, the // function strftime is not able to format the entire range of time_t. The // exact point has not been investigated; it's limited to chrono's range. const int chrono_timestamp_min = -12'687'428; // -32767-01-01Z const int chrono_timestamp_max = 11'248'737; // 32767-12-31Z +#else + const int chrono_timestamp_min = 0; // 1970-01-01Z + const int chrono_timestamp_max = 376'583; // 3001-01-19Z +#endif const int days = ptr_sp->GetValueAsSigned(0); if (days < chrono_timestamp_min || days > chrono_timestamp_max) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py index fb35481d55514..0737a5bc7e6eb 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py @@ -14,6 +14,7 @@ class LibcxxChronoDataFormatterTestCase(TestBase): @skipIf(compiler="clang", compiler_version=["<", "17.0"]) def test_with_run_command(self): """Test that that file and class static variables display correctly.""" +isNotWindowsHost = lldbplatformutil.getHostPlatform() != "windows" self.build() (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "break here", lldb.SBFileSpec("main.cpp", False) @@ -57,7 +58,11 @@ def test_with_run_command(self): self.expect( "frame variable ss_neg_date_time", substrs=[ -"ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s" +( +"ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s" +if isNotWindowsHost +else "ss_neg_date_time = timestamp=-1096193779200 s" +) ], ) self.expect( @@ -68,7 +73,11 @@ def test_with_run_command(self): self.expect( "frame variable ss_pos_date_time", substrs=[ -"ss_pos_date_time = date/time=32767-12-31T23:59:59Z timestamp=971890963199 s" +( +"ss_pos_date_time = date/time=32767-12-31T23:59:59Z timestamp=971890963199 s" +if isNotWindowsHost +else "ss_pos_date_time = timestamp=971890963199 s" +) ], ) self.expect( @@ -103,7 +112,13 @@ def test_with_run_command(self): ) self.expect( "frame variable sd_neg_date", -substrs=["sd_neg_date = date=-32767-01-01Z timestamp=-12687428 days"], +substrs=[ +( +"sd_neg_date = date=-32767-01-01Z timestamp=-12687428 days" +if isNotWindowsHost +else "sd_neg_date =
[Lldb-commits] [lldb] [lldb][Windows] Fixed LibcxxChronoTimePointSecondsSummaryProvider() (PR #92701)
https://github.com/slydiman created https://github.com/llvm/llvm-project/pull/92701 This patch fixes #92574. It is a replacement for #92575. >From 2dfbb8663a4661255cd90269b9f527dfac8fb21b Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Sun, 19 May 2024 21:50:21 +0400 Subject: [PATCH] [lldb][Windows] Fixed LibcxxChronoTimePointSecondsSummaryProvider() This patch fixes #92574. It is a replacement for #92575. --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 11 .../chrono/TestDataFormatterLibcxxChrono.py | 57 --- 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index e160fd0763939..da05ba7b40d32 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -1098,6 +1098,7 @@ LibcxxChronoTimePointSecondsSummaryProvider(ValueObject , Stream , if (!ptr_sp) return false; +#ifndef _WIN32 // The date time in the chrono library is valid in the range // [-32767-01-01T00:00:00Z, 32767-12-31T23:59:59Z]. A 64-bit time_t has a // larger range, the function strftime is not able to format the entire range @@ -1107,6 +1108,11 @@ LibcxxChronoTimePointSecondsSummaryProvider(ValueObject , Stream , -1'096'193'779'200; // -32767-01-01T00:00:00Z const std::time_t chrono_timestamp_max = 971'890'963'199; // 32767-12-31T23:59:59Z +#else + const std::time_t chrono_timestamp_min = -43'200; // 1969-12-31T12:00:00Z + const std::time_t chrono_timestamp_max = + 32'536'850'399; // 3001-01-19T21:59:59 +#endif const std::time_t seconds = ptr_sp->GetValueAsSigned(0); if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max) @@ -1148,12 +1154,17 @@ LibcxxChronoTimepointDaysSummaryProvider(ValueObject , Stream , if (!ptr_sp) return false; +#ifndef _WIN32 // The date time in the chrono library is valid in the range // [-32767-01-01Z, 32767-12-31Z]. A 32-bit time_t has a larger range, the // function strftime is not able to format the entire range of time_t. The // exact point has not been investigated; it's limited to chrono's range. const int chrono_timestamp_min = -12'687'428; // -32767-01-01Z const int chrono_timestamp_max = 11'248'737; // 32767-12-31Z +#else + const int chrono_timestamp_min = 0; // 1970-01-01Z + const int chrono_timestamp_max = 376'583; // 3001-01-19Z +#endif const int days = ptr_sp->GetValueAsSigned(0); if (days < chrono_timestamp_min || days > chrono_timestamp_max) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py index fb35481d55514..0737a5bc7e6eb 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py @@ -14,6 +14,7 @@ class LibcxxChronoDataFormatterTestCase(TestBase): @skipIf(compiler="clang", compiler_version=["<", "17.0"]) def test_with_run_command(self): """Test that that file and class static variables display correctly.""" +isNotWindowsHost = lldbplatformutil.getHostPlatform() != "windows" self.build() (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "break here", lldb.SBFileSpec("main.cpp", False) @@ -57,7 +58,11 @@ def test_with_run_command(self): self.expect( "frame variable ss_neg_date_time", substrs=[ -"ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s" +( +"ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s" +if isNotWindowsHost +else "ss_neg_date_time = timestamp=-1096193779200 s" +) ], ) self.expect( @@ -68,7 +73,11 @@ def test_with_run_command(self): self.expect( "frame variable ss_pos_date_time", substrs=[ -"ss_pos_date_time = date/time=32767-12-31T23:59:59Z timestamp=971890963199 s" +( +"ss_pos_date_time = date/time=32767-12-31T23:59:59Z timestamp=971890963199 s" +if isNotWindowsHost +else "ss_pos_date_time = timestamp=971890963199 s" +) ], ) self.expect( @@ -103,7 +112,13 @@ def test_with_run_command(self): ) self.expect( "frame variable sd_neg_date", -substrs=["sd_neg_date = date=-32767-01-01Z timestamp=-12687428 days"], +substrs=[ +( +
[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)
https://github.com/medismailben approved this pull request. https://github.com/llvm/llvm-project/pull/92618 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Refactor string manipulation in Debugger.cpp (#91209) (PR #92565)
https://github.com/aabhinavg updated https://github.com/llvm/llvm-project/pull/92565 >From 13fefb6846b6641900843c37746b03140063a955 Mon Sep 17 00:00:00 2001 From: aabhinavg Date: Fri, 17 May 2024 21:17:51 +0530 Subject: [PATCH 1/2] removed unwanted file --- lldb/source/Core/Debugger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 9951fbcd3e7c3..70303173925e3 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -2067,7 +2067,7 @@ void Debugger::HandleProgressEvent(const lldb::EventSP _sp) { const uint32_t term_width = GetTerminalWidth(); const uint32_t ellipsis = 3; if (message.size() + ellipsis >= term_width) -message = message.substr(0, term_width - ellipsis); +message.resize(message.size() - ellipsis); const bool use_color = GetUseColor(); llvm::StringRef ansi_prefix = GetShowProgressAnsiPrefix(); >From 3ed69bf19942a6e9470fda66efd54b25cbac176e Mon Sep 17 00:00:00 2001 From: aabhinavg Date: Sat, 18 May 2024 08:39:21 +0530 Subject: [PATCH 2/2] updated the patch --- lldb/source/Core/Debugger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 70303173925e3..d08aa1dc476f6 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -2067,7 +2067,7 @@ void Debugger::HandleProgressEvent(const lldb::EventSP _sp) { const uint32_t term_width = GetTerminalWidth(); const uint32_t ellipsis = 3; if (message.size() + ellipsis >= term_width) -message.resize(message.size() - ellipsis); +message.resize(term_width - ellipsis); const bool use_color = GetUseColor(); llvm::StringRef ansi_prefix = GetShowProgressAnsiPrefix(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 1e9324a - [lldb] Namespace SBSourceLanguageName (NFC)
Author: Jonas Devlieghere Date: 2024-05-17T18:43:09-07:00 New Revision: 1e9324a8c734aaa933d2672522cc22d5022c6200 URL: https://github.com/llvm/llvm-project/commit/1e9324a8c734aaa933d2672522cc22d5022c6200 DIFF: https://github.com/llvm/llvm-project/commit/1e9324a8c734aaa933d2672522cc22d5022c6200.diff LOG: [lldb] Namespace SBSourceLanguageName (NFC) Added: Modified: lldb/include/lldb/API/SBExpressionOptions.h lldb/source/API/SBExpressionOptions.cpp Removed: diff --git a/lldb/include/lldb/API/SBExpressionOptions.h b/lldb/include/lldb/API/SBExpressionOptions.h index 19c416d0f3bcb..a9e929a4c0bd9 100644 --- a/lldb/include/lldb/API/SBExpressionOptions.h +++ b/lldb/include/lldb/API/SBExpressionOptions.h @@ -71,7 +71,7 @@ class LLDB_API SBExpressionOptions { /// Set the language using a pair of language code and version as /// defined by the DWARF 6 specification. /// WARNING: These codes may change until DWARF 6 is finalized. - void SetLanguage(SBSourceLanguageName name, uint32_t version); + void SetLanguage(lldb::SBSourceLanguageName name, uint32_t version); #ifndef SWIG void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton); diff --git a/lldb/source/API/SBExpressionOptions.cpp b/lldb/source/API/SBExpressionOptions.cpp index ce686112ff719..15ed403eaaea1 100644 --- a/lldb/source/API/SBExpressionOptions.cpp +++ b/lldb/source/API/SBExpressionOptions.cpp @@ -156,7 +156,7 @@ void SBExpressionOptions::SetLanguage(lldb::LanguageType language) { m_opaque_up->SetLanguage(language); } -void SBExpressionOptions::SetLanguage(SBSourceLanguageName name, +void SBExpressionOptions::SetLanguage(lldb::SBSourceLanguageName name, uint32_t version) { LLDB_INSTRUMENT_VA(this, name, version); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)
jimingham wrote: I'm fine with adding the to be searched for term to the alias help. https://github.com/llvm/llvm-project/pull/92618 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)
jimingham wrote: In simple aliases, apropos could get this right itself by resolving the command the alias points to and if THAT help string had the searched term, list the alias. But bt is an alias to a regex command. Again, you could look through all the branches of the regex command finding their commands and do the same. But you'd really want to report `bt` not `_regexp-bt`. That's getting a bit involved. https://github.com/llvm/llvm-project/pull/92618 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
JDevlieghere wrote: > @JDevlieghere I know we discussed this in the past and it made sense to me, > but I'm right now failing to connect the dots. Why couldn't the same > single-line interface be used to print nested events something like this? > > ``` > Evaluating expression > Type Checking > Importing "vector" > Finding > "begin" in Foo.o > ``` Shadowing happens with _unrelated_ events. The problem is that you don't want to show something like this: ``` Evaluating expression > Type Checking > Some unrelated background operation > Importing "vector" ``` Or let's say you're doing some work in parallel: ``` Doing some work on thread 1 > Doing some work on thread 2 > Some nested work on thread 2 > Some nested work on thread 1 ``` For a single event, you can update it, as we do for importing the Swift modules. For your example, today you can show something like this: ``` Evaluating expression: Type Checking Evaluating expression: Importing "vector" Evaluating expression: Finding "begin" in Foo.o ``` Compared to your approach, you lose out on the additional context that's not part of the title/category before the colon. On the other hand, that's how we aggregate events in the progress manager. If we want to support nested _related_ events, I think that wouldn't be too hard. An event could have a parent event ID and LLDB could append events that belong to the currently displayed event. But we'd still shadow _unrelated_ events. https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/92618 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Refactor string manipulation in Debugger.cpp (#91209) (PR #92565)
@@ -2067,7 +2067,7 @@ void Debugger::HandleProgressEvent(const lldb::EventSP _sp) { const uint32_t term_width = GetTerminalWidth(); const uint32_t ellipsis = 3; if (message.size() + ellipsis >= term_width) -message = message.substr(0, term_width - ellipsis); +message.resize(message.size() - ellipsis); adrian-prantl wrote: Can you explain why `term_width` does not appear in the new patch? https://github.com/llvm/llvm-project/pull/92565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
adrian-prantl wrote: > No, on the terminal it works that way by design. Unless you switch to > something that takes full control of your screen (like curses) there's no > good way to display multiple progress events at the same time and not doing > the shadowing (i.e. letting more recent progress events through) defeats the > purpose of highlighting long running operations. @JDevlieghere I know we discussed this in the past and it made sense to me, but I'm right now failing to connect the dots. Why couldn't the same single-line interface be used to print nested events something like this? ``` Evaluating expression > Type Checking > Importing "vector" > Finding "begin" in Foo.o ``` https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)
kastiglione wrote: Open to alternative rewordings that include "backtrace". https://github.com/llvm/llvm-project/pull/92618 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/92618 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Dave Lee (kastiglione) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/92618.diff 2 Files Affected: - (modified) lldb/source/Commands/CommandObjectThread.cpp (+2-2) - (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+5-5) ``diff diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 4397ee14ea074..db96ee2cec383 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -114,8 +114,8 @@ class CommandObjectThreadBacktrace : public CommandObjectIterateOverThreads { CommandObjectThreadBacktrace(CommandInterpreter ) : CommandObjectIterateOverThreads( interpreter, "thread backtrace", -"Show thread call stacks. Defaults to the current thread, thread " -"indexes can be specified as arguments.\n" +"Show backtraces of thread call stacks. Defaults to the current " +"thread, thread indexes can be specified as arguments.\n" "Use the thread-index \"all\" to see all threads.\n" "Use the thread-index \"unique\" to see threads grouped by unique " "call stacks.\n" diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 4c58ecc3c1848..3e470a6989bbf 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -816,11 +816,11 @@ void CommandInterpreter::LoadCommandDictionary() { std::unique_ptr bt_regex_cmd_up( new CommandObjectRegexCommand( *this, "_regexp-bt", - "Show the current thread's call stack. Any numeric argument " - "displays at most that many " - "frames. The argument 'all' displays all threads. Use 'settings" - " set frame-format' to customize the printing of individual frames " - "and 'settings set thread-format' to customize the thread header.", + "Show backtrace of the current thread's call stack. Any numeric " + "argument displays at most that many frames. The argument 'all' " + "displays all threads. Use 'settings set frame-format' to customize " + "the printing of individual frames and 'settings set thread-format' " + "to customize the thread header.", "bt [ | all]", 0, false)); if (bt_regex_cmd_up) { // accept but don't document "bt -c " -- before bt was a regex `` https://github.com/llvm/llvm-project/pull/92618 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add the word "backtrace" to bt help string (PR #92618)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/92618 None >From 1564ae4ce3a56fc1f11e03e82e0da1e01f25f3ed Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 16 May 2024 14:01:22 -0700 Subject: [PATCH] [lldb] Add the word "backtrace" to bt help string --- lldb/source/Commands/CommandObjectThread.cpp | 4 ++-- lldb/source/Interpreter/CommandInterpreter.cpp | 10 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 4397ee14ea074..db96ee2cec383 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -114,8 +114,8 @@ class CommandObjectThreadBacktrace : public CommandObjectIterateOverThreads { CommandObjectThreadBacktrace(CommandInterpreter ) : CommandObjectIterateOverThreads( interpreter, "thread backtrace", -"Show thread call stacks. Defaults to the current thread, thread " -"indexes can be specified as arguments.\n" +"Show backtraces of thread call stacks. Defaults to the current " +"thread, thread indexes can be specified as arguments.\n" "Use the thread-index \"all\" to see all threads.\n" "Use the thread-index \"unique\" to see threads grouped by unique " "call stacks.\n" diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 4c58ecc3c1848..3e470a6989bbf 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -816,11 +816,11 @@ void CommandInterpreter::LoadCommandDictionary() { std::unique_ptr bt_regex_cmd_up( new CommandObjectRegexCommand( *this, "_regexp-bt", - "Show the current thread's call stack. Any numeric argument " - "displays at most that many " - "frames. The argument 'all' displays all threads. Use 'settings" - " set frame-format' to customize the printing of individual frames " - "and 'settings set thread-format' to customize the thread header.", + "Show backtrace of the current thread's call stack. Any numeric " + "argument displays at most that many frames. The argument 'all' " + "displays all threads. Use 'settings set frame-format' to customize " + "the printing of individual frames and 'settings set thread-format' " + "to customize the thread header.", "bt [ | all]", 0, false)); if (bt_regex_cmd_up) { // accept but don't document "bt -c " -- before bt was a regex ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)
@@ -0,0 +1,215 @@ +""" +Test SBAddressRange APIs. +""" + +import lldb +from lldbsuite.test.lldbtest import * + + +class AddressRangeTestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def setUp(self): +TestBase.setUp(self) + +self.build() +exe = self.getBuildArtifact("a.out") + +self.dbg.SetAsync(True) + +self.target = self.dbg.CreateTarget(exe) +self.assertTrue(self.target, VALID_TARGET) +self.launch_info = self.target.GetLaunchInfo() + self.launch_info.SetWorkingDirectory(self.get_process_working_directory()) + +self.bp1 = self.target.BreakpointCreateByName("main", "a.out") +self.bp2 = self.target.BreakpointCreateByName("foo", "a.out") +self.bp3 = self.target.BreakpointCreateByName("bar", "a.out") + +self.assertTrue(self.bp1.IsValid()) +self.assertTrue(self.bp2.IsValid()) +self.assertTrue(self.bp3.IsValid()) + +self.addr1 = self.bp1.GetLocationAtIndex(0).GetAddress() +self.addr2 = self.bp2.GetLocationAtIndex(0).GetAddress() +self.addr3 = self.bp3.GetLocationAtIndex(0).GetAddress() + +self.assertTrue(self.addr1.IsValid()) +self.assertTrue(self.addr2.IsValid()) +self.assertTrue(self.addr3.IsValid()) + +def test_address_range_default(self): +"""Testing default constructor.""" +empty_range = lldb.SBAddressRange() +self.assertEqual(empty_range.IsValid(), False) + +def test_address_range_construction(self): +"""Make sure the construction and getters work.""" +range = lldb.SBAddressRange(self.addr1, 8) +self.assertEqual(range.IsValid(), True) +self.assertEqual(range.GetBaseAddress(), self.addr1) +self.assertEqual(range.GetByteSize(), 8) + +def test_address_range_clear(self): +"""Make sure the clear method works.""" +range = lldb.SBAddressRange(self.addr1, 8) +self.assertEqual(range.IsValid(), True) +self.assertEqual(range.GetBaseAddress(), self.addr1) +self.assertEqual(range.GetByteSize(), 8) + +range.Clear() +self.assertEqual(range.IsValid(), False) + +def test_function(self): +"""Make sure the range works in SBFunction APIs.""" + +# Setup breakpoints in main +loc = self.bp1.GetLocationAtIndex(0) +loc_addr = loc.GetAddress() +func = loc_addr.GetFunction() +ranges = func.GetRanges() +self.assertEqual(ranges.GetSize(), 1) + +range = ranges.GetAddressRangeAtIndex(0) +self.assertEqual( +range.GetByteSize(), +func.GetEndAddress().GetOffset() - func.GetStartAddress().GetOffset(), +) +self.assertEqual( +range.GetBaseAddress().GetOffset(), +func.GetStartAddress().GetOffset(), +) + +def test_block(self): +"""Make sure the range works in SBBlock APIs.""" +loc = self.bp1.GetLocationAtIndex(0) +loc_addr = loc.GetAddress() +block = loc_addr.GetBlock() + +ranges = block.GetRanges() +self.assertEqual(ranges.GetSize(), 1) + +range = ranges.GetAddressRangeAtIndex(0) +self.assertEqual( +range.GetByteSize(), +block.GetRangeEndAddress(0).GetOffset() +- block.GetRangeStartAddress(0).GetOffset(), +) +self.assertEqual( +range.GetBaseAddress().GetOffset(), +block.GetRangeStartAddress(0).GetOffset(), +) + +def test_address_range_list(self): +"""Make sure the SBAddressRangeList works by adding and getting ranges.""" +range1 = lldb.SBAddressRange(self.addr1, 8) +range2 = lldb.SBAddressRange(self.addr2, 16) +range3 = lldb.SBAddressRange(self.addr3, 32) + +range_list = lldb.SBAddressRangeList() +self.assertEqual(range_list.GetSize(), 0) + +range_list.Append(range1) +range_list.Append(range2) +range_list.Append(range3) +self.assertEqual(range_list.GetSize(), 3) +self.assertRaises(IndexError, lambda: range_list[3]) + +range1_copy = range_list.GetAddressRangeAtIndex(0) +self.assertEqual(range1.GetByteSize(), range1_copy.GetByteSize()) +self.assertEqual( +range1.GetBaseAddress().GetOffset(), +range1_copy.GetBaseAddress().GetOffset(), +) + +range2_copy = range_list.GetAddressRangeAtIndex(1) +self.assertEqual(range2.GetByteSize(), range2_copy.GetByteSize()) +self.assertEqual( +range2.GetBaseAddress().GetOffset(), +range2_copy.GetBaseAddress().GetOffset(), +) + +range3_copy = range_list.GetAddressRangeAtIndex(2) +self.assertEqual(range3.GetByteSize(), range3_copy.GetByteSize()) +self.assertEqual( +range3.GetBaseAddress().GetOffset(), +range3_copy.GetBaseAddress().GetOffset(), +)
[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)
@@ -0,0 +1,102 @@ +//===-- SBAddressRange.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 "lldb/API/SBAddressRange.h" +#include "Utils.h" +#include "lldb/API/SBAddress.h" +#include "lldb/API/SBStream.h" +#include "lldb/API/SBTarget.h" +#include "lldb/Core/AddressRange.h" +#include "lldb/Core/Section.h" +#include "lldb/Utility/Instrumentation.h" +#include "lldb/Utility/Stream.h" +#include +#include + +using namespace lldb; +using namespace lldb_private; + +SBAddressRange::SBAddressRange() +: m_opaque_up(std::make_unique()) { + LLDB_INSTRUMENT_VA(this); +} + +SBAddressRange::SBAddressRange(const SBAddressRange ) { + LLDB_INSTRUMENT_VA(this, rhs); + + m_opaque_up = clone(rhs.m_opaque_up); +} + +SBAddressRange::SBAddressRange(lldb::SBAddress addr, lldb::addr_t byte_size) +: m_opaque_up(std::make_unique(addr.ref(), byte_size)) { + LLDB_INSTRUMENT_VA(this, addr, byte_size); +} + +SBAddressRange::~SBAddressRange() = default; + +const SBAddressRange ::operator=(const SBAddressRange ) { + LLDB_INSTRUMENT_VA(this, rhs); + + if (this != ) +m_opaque_up = clone(rhs.m_opaque_up); + return *this; +} + +bool SBAddressRange::operator==(const SBAddressRange ) { + LLDB_INSTRUMENT_VA(this, rhs); + + if (!IsValid() || !rhs.IsValid()) +return false; + return m_opaque_up->operator==(*(rhs.m_opaque_up)); +} + +bool SBAddressRange::operator!=(const SBAddressRange ) { + LLDB_INSTRUMENT_VA(this, rhs); + + return !(*this == rhs); +} + +void SBAddressRange::Clear() { + LLDB_INSTRUMENT_VA(this); + + m_opaque_up.reset(); +} + +bool SBAddressRange::IsValid() const { + LLDB_INSTRUMENT_VA(this); + + return m_opaque_up && m_opaque_up->IsValid(); +} + +lldb::SBAddress SBAddressRange::GetBaseAddress() const { + LLDB_INSTRUMENT_VA(this); + + if (!IsValid()) +return lldb::SBAddress(); + return lldb::SBAddress(m_opaque_up->GetBaseAddress()); +} + +lldb::addr_t SBAddressRange::GetByteSize() const { + LLDB_INSTRUMENT_VA(this); + + if (!IsValid()) +return 0; + return m_opaque_up->GetByteSize(); +} + +bool SBAddressRange::GetDescription(SBStream ) { + LLDB_INSTRUMENT_VA(this, description); + + Stream = description.ref(); + if (!IsValid()) { +stream << ""; +return true; + } + m_opaque_up->GetDescription(, nullptr); mbucko wrote: Need to figure out how to get hold of the current target to pass into GetDescription() so that we can resolve the loaded address. https://github.com/llvm/llvm-project/pull/92014 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)
https://github.com/mbucko updated https://github.com/llvm/llvm-project/pull/92014 >From 0d8a110b922fde8e0439391f87a117c1d82913c4 Mon Sep 17 00:00:00 2001 From: Miro Bucko Date: Fri, 10 May 2024 12:42:03 -0700 Subject: [PATCH] Add AddressRange to SB API Summary: This adds new SB API calls and classes to allow a user of the SB API to obtain an address range from SBFunction and SBBlock. Test Plan: llvm-lit -sv llvm-project/lldb/test/API/python_api/address_range/TestAddressRange.py Reviewers: clayborg Subscribers: lldb-commits Tasks: Tags: --- lldb/bindings/headers.swig| 2 + .../interface/SBAddressRangeDocstrings.i | 3 + .../interface/SBAddressRangeExtensions.i | 1 + .../interface/SBAddressRangeListDocstrings.i | 3 + .../interface/SBAddressRangeListExtensions.i | 25 ++ lldb/bindings/interfaces.swig | 6 + lldb/include/lldb/API/LLDB.h | 2 + lldb/include/lldb/API/SBAddress.h | 1 + lldb/include/lldb/API/SBAddressRange.h| 65 ++ lldb/include/lldb/API/SBAddressRangeList.h| 54 + lldb/include/lldb/API/SBBlock.h | 4 + lldb/include/lldb/API/SBDefines.h | 2 + lldb/include/lldb/API/SBFunction.h| 3 + lldb/include/lldb/API/SBStream.h | 2 + lldb/include/lldb/API/SBTarget.h | 1 + lldb/include/lldb/Core/AddressRange.h | 14 ++ lldb/include/lldb/Core/AddressRangeListImpl.h | 51 + lldb/include/lldb/Symbol/Block.h | 2 + lldb/include/lldb/lldb-forward.h | 3 + lldb/source/API/CMakeLists.txt| 2 + lldb/source/API/SBAddressRange.cpp| 102 + lldb/source/API/SBAddressRangeList.cpp| 90 lldb/source/API/SBBlock.cpp | 10 + lldb/source/API/SBFunction.cpp| 14 ++ lldb/source/Core/AddressRange.cpp | 39 lldb/source/Core/AddressRangeListImpl.cpp | 50 lldb/source/Core/CMakeLists.txt | 1 + lldb/source/Symbol/Block.cpp | 16 ++ .../API/python_api/address_range/Makefile | 3 + .../address_range/TestAddressRange.py | 215 ++ .../API/python_api/address_range/main.cpp | 8 + 31 files changed, 794 insertions(+) create mode 100644 lldb/bindings/interface/SBAddressRangeDocstrings.i create mode 100644 lldb/bindings/interface/SBAddressRangeExtensions.i create mode 100644 lldb/bindings/interface/SBAddressRangeListDocstrings.i create mode 100644 lldb/bindings/interface/SBAddressRangeListExtensions.i create mode 100644 lldb/include/lldb/API/SBAddressRange.h create mode 100644 lldb/include/lldb/API/SBAddressRangeList.h create mode 100644 lldb/include/lldb/Core/AddressRangeListImpl.h create mode 100644 lldb/source/API/SBAddressRange.cpp create mode 100644 lldb/source/API/SBAddressRangeList.cpp create mode 100644 lldb/source/Core/AddressRangeListImpl.cpp create mode 100644 lldb/test/API/python_api/address_range/Makefile create mode 100644 lldb/test/API/python_api/address_range/TestAddressRange.py create mode 100644 lldb/test/API/python_api/address_range/main.cpp diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig index e8d0cda288141..2b53eefc8568b 100644 --- a/lldb/bindings/headers.swig +++ b/lldb/bindings/headers.swig @@ -8,6 +8,8 @@ %{ #include "lldb/lldb-public.h" #include "lldb/API/SBAddress.h" +#include "lldb/API/SBAddressRange.h" +#include "lldb/API/SBAddressRangeList.h" #include "lldb/API/SBAttachInfo.h" #include "lldb/API/SBBlock.h" #include "lldb/API/SBBreakpoint.h" diff --git a/lldb/bindings/interface/SBAddressRangeDocstrings.i b/lldb/bindings/interface/SBAddressRangeDocstrings.i new file mode 100644 index 0..650195704d73e --- /dev/null +++ b/lldb/bindings/interface/SBAddressRangeDocstrings.i @@ -0,0 +1,3 @@ +%feature("docstring", +"API clients can get address range information." +) lldb::SBAddressRange; diff --git a/lldb/bindings/interface/SBAddressRangeExtensions.i b/lldb/bindings/interface/SBAddressRangeExtensions.i new file mode 100644 index 0..bca359868232d --- /dev/null +++ b/lldb/bindings/interface/SBAddressRangeExtensions.i @@ -0,0 +1 @@ +STRING_EXTENSION_OUTSIDE(SBAddressRange) diff --git a/lldb/bindings/interface/SBAddressRangeListDocstrings.i b/lldb/bindings/interface/SBAddressRangeListDocstrings.i new file mode 100644 index 0..e4b96b9ca5931 --- /dev/null +++ b/lldb/bindings/interface/SBAddressRangeListDocstrings.i @@ -0,0 +1,3 @@ +%feature("docstring", +"Represents a list of :py:class:`SBAddressRange`." +) lldb::SBAddressRangeList; diff --git a/lldb/bindings/interface/SBAddressRangeListExtensions.i b/lldb/bindings/interface/SBAddressRangeListExtensions.i new file mode 100644 index 0..08bfa6d9aef60 --- /dev/null +++ b/lldb/bindings/interface/SBAddressRangeListExtensions.i @@ -0,0 +1,25 @@
[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r c675a58edec6d1a876a0d0e7d261f74764855b38...939d42eba9f88d90ac72782415640bbab360645c lldb/test/API/python_api/address_range/TestAddressRange.py `` View the diff from darker here. ``diff --- TestAddressRange.py 2024-05-17 14:39:10.00 + +++ TestAddressRange.py 2024-05-17 21:07:58.763834 + @@ -63,11 +63,11 @@ loc = self.bp1.GetLocationAtIndex(0) loc_addr = loc.GetAddress() func = loc_addr.GetFunction() ranges = func.GetRanges() self.assertEqual(ranges.GetSize(), 1) - + range = ranges.GetAddressRangeAtIndex(0) self.assertEqual( range.GetByteSize(), func.GetEndAddress().GetOffset() - func.GetStartAddress().GetOffset(), ) `` https://github.com/llvm/llvm-project/pull/92014 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)
https://github.com/mbucko updated https://github.com/llvm/llvm-project/pull/92014 >From 939d42eba9f88d90ac72782415640bbab360645c Mon Sep 17 00:00:00 2001 From: Miro Bucko Date: Fri, 10 May 2024 12:42:03 -0700 Subject: [PATCH] Add AddressRange to SB API Summary: This adds new SB API calls and classes to allow a user of the SB API to obtain an address range from SBFunction and SBBlock. Test Plan: llvm-lit -sv llvm-project/lldb/test/API/python_api/address_range/TestAddressRange.py Reviewers: clayborg Subscribers: lldb-commits Tasks: Tags: --- lldb/bindings/headers.swig| 2 + .../interface/SBAddressRangeDocstrings.i | 3 + .../interface/SBAddressRangeExtensions.i | 1 + .../interface/SBAddressRangeListDocstrings.i | 3 + .../interface/SBAddressRangeListExtensions.i | 25 +++ lldb/bindings/interfaces.swig | 6 + lldb/include/lldb/API/LLDB.h | 2 + lldb/include/lldb/API/SBAddress.h | 1 + lldb/include/lldb/API/SBAddressRange.h| 65 ++ lldb/include/lldb/API/SBAddressRangeList.h| 54 + lldb/include/lldb/API/SBBlock.h | 4 + lldb/include/lldb/API/SBDefines.h | 2 + lldb/include/lldb/API/SBFunction.h| 3 + lldb/include/lldb/API/SBStream.h | 2 + lldb/include/lldb/Core/AddressRange.h | 12 ++ lldb/include/lldb/Core/AddressRangeListImpl.h | 51 + lldb/include/lldb/Symbol/Block.h | 2 + lldb/include/lldb/lldb-forward.h | 3 + lldb/source/API/CMakeLists.txt| 2 + lldb/source/API/SBAddressRange.cpp| 102 ++ lldb/source/API/SBAddressRangeList.cpp| 81 lldb/source/API/SBBlock.cpp | 10 + lldb/source/API/SBFunction.cpp| 14 ++ lldb/source/Core/AddressRange.cpp | 15 ++ lldb/source/Core/AddressRangeListImpl.cpp | 50 + lldb/source/Core/CMakeLists.txt | 1 + lldb/source/Symbol/Block.cpp | 16 ++ .../API/python_api/address_range/Makefile | 3 + .../address_range/TestAddressRange.py | 191 ++ .../API/python_api/address_range/main.cpp | 8 + 30 files changed, 734 insertions(+) create mode 100644 lldb/bindings/interface/SBAddressRangeDocstrings.i create mode 100644 lldb/bindings/interface/SBAddressRangeExtensions.i create mode 100644 lldb/bindings/interface/SBAddressRangeListDocstrings.i create mode 100644 lldb/bindings/interface/SBAddressRangeListExtensions.i create mode 100644 lldb/include/lldb/API/SBAddressRange.h create mode 100644 lldb/include/lldb/API/SBAddressRangeList.h create mode 100644 lldb/include/lldb/Core/AddressRangeListImpl.h create mode 100644 lldb/source/API/SBAddressRange.cpp create mode 100644 lldb/source/API/SBAddressRangeList.cpp create mode 100644 lldb/source/Core/AddressRangeListImpl.cpp create mode 100644 lldb/test/API/python_api/address_range/Makefile create mode 100644 lldb/test/API/python_api/address_range/TestAddressRange.py create mode 100644 lldb/test/API/python_api/address_range/main.cpp diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig index e8d0cda288141..2b53eefc8568b 100644 --- a/lldb/bindings/headers.swig +++ b/lldb/bindings/headers.swig @@ -8,6 +8,8 @@ %{ #include "lldb/lldb-public.h" #include "lldb/API/SBAddress.h" +#include "lldb/API/SBAddressRange.h" +#include "lldb/API/SBAddressRangeList.h" #include "lldb/API/SBAttachInfo.h" #include "lldb/API/SBBlock.h" #include "lldb/API/SBBreakpoint.h" diff --git a/lldb/bindings/interface/SBAddressRangeDocstrings.i b/lldb/bindings/interface/SBAddressRangeDocstrings.i new file mode 100644 index 0..650195704d73e --- /dev/null +++ b/lldb/bindings/interface/SBAddressRangeDocstrings.i @@ -0,0 +1,3 @@ +%feature("docstring", +"API clients can get address range information." +) lldb::SBAddressRange; diff --git a/lldb/bindings/interface/SBAddressRangeExtensions.i b/lldb/bindings/interface/SBAddressRangeExtensions.i new file mode 100644 index 0..bca359868232d --- /dev/null +++ b/lldb/bindings/interface/SBAddressRangeExtensions.i @@ -0,0 +1 @@ +STRING_EXTENSION_OUTSIDE(SBAddressRange) diff --git a/lldb/bindings/interface/SBAddressRangeListDocstrings.i b/lldb/bindings/interface/SBAddressRangeListDocstrings.i new file mode 100644 index 0..e4b96b9ca5931 --- /dev/null +++ b/lldb/bindings/interface/SBAddressRangeListDocstrings.i @@ -0,0 +1,3 @@ +%feature("docstring", +"Represents a list of :py:class:`SBAddressRange`." +) lldb::SBAddressRangeList; diff --git a/lldb/bindings/interface/SBAddressRangeListExtensions.i b/lldb/bindings/interface/SBAddressRangeListExtensions.i new file mode 100644 index 0..08bfa6d9aef60 --- /dev/null +++ b/lldb/bindings/interface/SBAddressRangeListExtensions.i @@ -0,0 +1,25 @@ +STRING_EXTENSION_OUTSIDE(SBAddressRangeList) + +%extend
[Lldb-commits] [lldb] bdfb04a - [lldb-dap] Bump the version to 0.2.1
Author: Jonas Devlieghere Date: 2024-05-17T14:00:24-07:00 New Revision: bdfb04a63d73c31ee75395064762d0d6ccb45819 URL: https://github.com/llvm/llvm-project/commit/bdfb04a63d73c31ee75395064762d0d6ccb45819 DIFF: https://github.com/llvm/llvm-project/commit/bdfb04a63d73c31ee75395064762d0d6ccb45819.diff LOG: [lldb-dap] Bump the version to 0.2.1 Bump the version to 0.2.1 to test the publishing workflow and update the extension README and URL. Added: Modified: lldb/tools/lldb-dap/package.json Removed: diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json index 45fcb83cf81d8..adffc3f0a2c58 100644 --- a/lldb/tools/lldb-dap/package.json +++ b/lldb/tools/lldb-dap/package.json @@ -1,7 +1,7 @@ { "name": "lldb-dap", "displayName": "LLDB DAP", - "version": "0.2.0", + "version": "0.2.1", "publisher": "llvm-vs-code-extensions", "homepage": "https://lldb.llvm.org;, "description": "LLDB debugging from VSCode", ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)
@@ -731,8 +747,11 @@ class Debugger : public std::enable_shared_from_this, lldb::TargetSP m_dummy_target_sp; Diagnostics::CallbackID m_diagnostics_callback_id; - lldb_private::DebuggerDestroyCallback m_destroy_callback = nullptr; - void *m_destroy_callback_baton = nullptr; + std::recursive_mutex m_destroy_callback_mutex; royitaqi wrote: This is out-dated. Latest commit uses `std::mutex` and improve the loop in `HandleDestroyCallbacks` to avoid recurssive mutex. https://github.com/llvm/llvm-project/pull/89868 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)
@@ -731,8 +746,11 @@ class Debugger : public std::enable_shared_from_this, lldb::TargetSP m_dummy_target_sp; Diagnostics::CallbackID m_diagnostics_callback_id; - lldb_private::DebuggerDestroyCallback m_destroy_callback = nullptr; - void *m_destroy_callback_baton = nullptr; + std::recursive_mutex m_destroy_callback_mutex; + lldb::destroy_callback_token_t m_destroy_callback_next_token = 0; + llvm::SmallDenseMap> + m_destroy_callback_and_baton; royitaqi wrote: Updated to use `SmallVector`. https://github.com/llvm/llvm-project/pull/89868 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Windows] Skip the TestDataFormatterLibcxxChrono test to avoid python crash (PR #92575)
Michael137 wrote: I think we should just fix https://github.com/llvm/llvm-project/issues/92574 since it seems pretty trivial to do with an ifdef https://github.com/llvm/llvm-project/pull/92575 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
@@ -135,7 +136,8 @@ CommandInterpreter::CommandInterpreter(Debugger , m_skip_lldbinit_files(false), m_skip_app_init_files(false), m_comment_char('#'), m_batch_command_mode(false), m_truncation_warning(eNoOmission), m_max_depth_warning(eNoOmission), - m_command_source_depth(0) { + m_command_source_depth(0), + m_transcript(std::make_shared()) { royitaqi wrote: This is out-dated now. In the latest commit, the field is now a `StructuredData::Array`. The initializer has been removed. https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
@@ -766,6 +768,12 @@ class CommandInterpreter : public Broadcaster, CommandUsageMap m_command_usages; StreamString m_transcript_stream; + + /// Contains a list of handled commands, output and error. Each element in + /// the list is a dictionary with three keys: "command" (string), "output" + /// (list of strings) and optionally "error" (list of strings). Each string + /// in "output" and "error" is a line (without EOL characters). + StructuredData::ArraySP m_transcript; royitaqi wrote: Improve the loop as discussed (I think). https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
@@ -571,6 +571,15 @@ SBStructuredData SBCommandInterpreter::GetStatistics() { return data; } +SBStructuredData SBCommandInterpreter::GetTranscript() { + LLDB_INSTRUMENT_VA(this); + + SBStructuredData data; + if (IsValid()) +data.m_impl_up->SetObjectSP(m_opaque_ptr->GetTranscript()); royitaqi wrote: Made a (deep) copy in the latest commit. Added test to verify that the user's copy isn't modified when more commands are run in the debugger. https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a4ad052 - [lldb-dap] Replace `assertEquals` with `assertEqual` (NFC)
Author: Jonas Devlieghere Date: 2024-05-17T10:12:51-07:00 New Revision: a4ad05284e97dd188c44252846486cbfb74a884c URL: https://github.com/llvm/llvm-project/commit/a4ad05284e97dd188c44252846486cbfb74a884c DIFF: https://github.com/llvm/llvm-project/commit/a4ad05284e97dd188c44252846486cbfb74a884c.diff LOG: [lldb-dap] Replace `assertEquals` with `assertEqual` (NFC) Fixes new test that were added or modified after #82073. Also fixes a formatting issue. Added: Modified: lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py Removed: diff --git a/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py b/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py index 52c0bbfb33dad..1e0e40d4a0130 100644 --- a/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py +++ b/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py @@ -27,10 +27,10 @@ def test_duplicate_start_addresses(self): response_x = self.dap_server.request_dataBreakpointInfo(0, "") response_arr_2 = self.dap_server.request_dataBreakpointInfo(0, "arr+2") # Test response from dataBreakpointInfo request. -self.assertEquals(response_x["body"]["dataId"].split("/")[1], "4") -self.assertEquals(response_x["body"]["accessTypes"], self.accessTypes) -self.assertEquals(response_arr_2["body"]["dataId"].split("/")[1], "4") -self.assertEquals(response_arr_2["body"]["accessTypes"], self.accessTypes) +self.assertEqual(response_x["body"]["dataId"].split("/")[1], "4") +self.assertEqual(response_x["body"]["accessTypes"], self.accessTypes) +self.assertEqual(response_arr_2["body"]["dataId"].split("/")[1], "4") +self.assertEqual(response_arr_2["body"]["accessTypes"], self.accessTypes) # The first one should be overwritten by the third one as they start at # the same address. This is indicated by returning {verified: False} for # the first one. @@ -40,7 +40,7 @@ def test_duplicate_start_addresses(self): {"dataId": response_x["body"]["dataId"], "accessType": "write"}, ] set_response = self.dap_server.request_setDataBreakpoint(dataBreakpoints) -self.assertEquals( +self.assertEqual( set_response["body"]["breakpoints"], [{"verified": False}, {"verified": True}, {"verified": True}], ) @@ -48,14 +48,14 @@ def test_duplicate_start_addresses(self): self.continue_to_next_stop() x_val = self.dap_server.get_local_variable_value("x") i_val = self.dap_server.get_local_variable_value("i") -self.assertEquals(x_val, "2") -self.assertEquals(i_val, "1") +self.assertEqual(x_val, "2") +self.assertEqual(i_val, "1") self.continue_to_next_stop() arr_2 = self.dap_server.get_local_variable_child("arr", "[2]") i_val = self.dap_server.get_local_variable_value("i") -self.assertEquals(arr_2["value"], "42") -self.assertEquals(i_val, "2") +self.assertEqual(arr_2["value"], "42") +self.assertEqual(i_val, "2") @skipIfWindows @skipIfRemote @@ -72,16 +72,16 @@ def test_expression(self): response_x = self.dap_server.request_dataBreakpointInfo(0, "") response_arr_2 = self.dap_server.request_dataBreakpointInfo(0, "arr+2") # Test response from dataBreakpointInfo request. -self.assertEquals(response_x["body"]["dataId"].split("/")[1], "4") -self.assertEquals(response_x["body"]["accessTypes"], self.accessTypes) -self.assertEquals(response_arr_2["body"]["dataId"].split("/")[1], "4") -self.assertEquals(response_arr_2["body"]["accessTypes"], self.accessTypes) +self.assertEqual(response_x["body"]["dataId"].split("/")[1], "4") +self.assertEqual(response_x["body"]["accessTypes"], self.accessTypes) +self.assertEqual(response_arr_2["body"]["dataId"].split("/")[1], "4") +self.assertEqual(response_arr_2["body"]["accessTypes"], self.accessTypes) dataBreakpoints = [ {"dataId": response_x["body"]["dataId"], "accessType": "write"}, {"dataId": response_arr_2["body"]["dataId"], "accessType": "write"}, ] set_response = self.dap_server.request_setDataBreakpoint(dataBreakpoints) -self.assertEquals( +self.assertEqual( set_response["body"]["breakpoints"], [{"verified": True}, {"verified": True}], ) @@ -89,14 +89,14 @@ def test_expression(self): self.continue_to_next_stop() x_val = self.dap_server.get_local_variable_value("x") i_val = self.dap_server.get_local_variable_value("i") -self.assertEquals(x_val, "2") -
[Lldb-commits] [lldb] d74bc82 - [lldb] Include SBLanguages in the SWIG bindings (#92470)
Author: Jonas Devlieghere Date: 2024-05-17T09:58:56-07:00 New Revision: d74bc823beabbb7067a4b4ae2d69a36d874f5132 URL: https://github.com/llvm/llvm-project/commit/d74bc823beabbb7067a4b4ae2d69a36d874f5132 DIFF: https://github.com/llvm/llvm-project/commit/d74bc823beabbb7067a4b4ae2d69a36d874f5132.diff LOG: [lldb] Include SBLanguages in the SWIG bindings (#92470) Added: Modified: lldb/bindings/CMakeLists.txt lldb/bindings/headers.swig lldb/bindings/interfaces.swig lldb/bindings/lua/CMakeLists.txt lldb/bindings/python/CMakeLists.txt Removed: diff --git a/lldb/bindings/CMakeLists.txt b/lldb/bindings/CMakeLists.txt index 296eae1ae77f8..bec694e43bd7b 100644 --- a/lldb/bindings/CMakeLists.txt +++ b/lldb/bindings/CMakeLists.txt @@ -3,6 +3,7 @@ file(GLOB_RECURSE SWIG_SOURCES *.swig) file(GLOB SWIG_HEADERS ${LLDB_SOURCE_DIR}/include/lldb/API/*.h ${LLDB_SOURCE_DIR}/include/lldb/*.h + ${LLDB_BINARY_DIR}/include/lldb/API/SBLanguages.h ) file(GLOB SWIG_PRIVATE_HEADERS ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h @@ -30,6 +31,7 @@ set(SWIG_COMMON_FLAGS -w361,362,509 -features autodoc -I${LLDB_SOURCE_DIR}/include + -I${LLDB_BINARY_DIR}/include -I${CMAKE_CURRENT_SOURCE_DIR} ${DARWIN_EXTRAS} ) diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig index e8d0cda288141..ffdc3c31ec883 100644 --- a/lldb/bindings/headers.swig +++ b/lldb/bindings/headers.swig @@ -36,6 +36,7 @@ #include "lldb/API/SBHostOS.h" #include "lldb/API/SBInstruction.h" #include "lldb/API/SBInstructionList.h" +#include "lldb/API/SBLanguages.h" #include "lldb/API/SBLanguageRuntime.h" #include "lldb/API/SBLaunchInfo.h" #include "lldb/API/SBLineEntry.h" diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig index a31a0b4af1eb6..2a29a8dd7ef0b 100644 --- a/lldb/bindings/interfaces.swig +++ b/lldb/bindings/interfaces.swig @@ -114,6 +114,7 @@ %include "lldb/API/SBHostOS.h" %include "lldb/API/SBInstruction.h" %include "lldb/API/SBInstructionList.h" +%include "lldb/API/SBLanguages.h" %include "lldb/API/SBLanguageRuntime.h" %include "lldb/API/SBLaunchInfo.h" %include "lldb/API/SBLineEntry.h" diff --git a/lldb/bindings/lua/CMakeLists.txt b/lldb/bindings/lua/CMakeLists.txt index 2d128cc1864c8..4a110f7829b03 100644 --- a/lldb/bindings/lua/CMakeLists.txt +++ b/lldb/bindings/lua/CMakeLists.txt @@ -3,6 +3,7 @@ add_custom_command( DEPENDS ${SWIG_SOURCES} DEPENDS ${SWIG_INTERFACES} DEPENDS ${SWIG_HEADERS} + DEPENDS lldb-sbapi-dwarf-enums COMMAND ${SWIG_EXECUTABLE} ${SWIG_COMMON_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR} diff --git a/lldb/bindings/python/CMakeLists.txt b/lldb/bindings/python/CMakeLists.txt index 73b1239495e22..def6941e802bb 100644 --- a/lldb/bindings/python/CMakeLists.txt +++ b/lldb/bindings/python/CMakeLists.txt @@ -11,6 +11,7 @@ add_custom_command( DEPENDS ${SWIG_SOURCES} DEPENDS ${SWIG_INTERFACES} DEPENDS ${SWIG_HEADERS} + DEPENDS lldb-sbapi-dwarf-enums COMMAND ${SWIG_EXECUTABLE} ${SWIG_COMMON_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Windows] Skip the TestDataFormatterLibcxxChrono test to avoid python crash (PR #92575)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Dmitry Vasilyev (slydiman) Changes The python crashed with the exit code 0xC409 (STATUS_STACK_BUFFER_OVERRUN) on the command `frame variable ss_neg_seconds` running on Windows x86_64. See this issue for details https://github.com/llvm/llvm-project/issues/92574 --- Full diff: https://github.com/llvm/llvm-project/pull/92575.diff 1 Files Affected: - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py (+3) ``diff diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py index fb35481d55514..bb7310bc1a8c1 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py @@ -12,6 +12,9 @@ class LibcxxChronoDataFormatterTestCase(TestBase): @add_test_categories(["libc++"]) @skipIf(compiler="clang", compiler_version=["<", "17.0"]) +@skipIf( +hostoslist=["windows"], bugnumber="github.com/llvm/llvm-project/issues/92574" +) def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() `` https://github.com/llvm/llvm-project/pull/92575 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Windows] Skip the TestDataFormatterLibcxxChrono test to avoid python crash (PR #92575)
https://github.com/slydiman created https://github.com/llvm/llvm-project/pull/92575 The python crashed with the exit code 0xC409 (STATUS_STACK_BUFFER_OVERRUN) on the command `frame variable ss_neg_seconds` running on Windows x86_64. See this issue for details https://github.com/llvm/llvm-project/issues/92574 >From 019dcbd636a4cee19700b8d34279d45ec715b67c Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Fri, 17 May 2024 20:46:18 +0400 Subject: [PATCH] [lldb][Windows] Skip the TestDataFormatterLibcxxChrono test to avoid python crash The python crashed with the exit code 0xC409 (STATUS_STACK_BUFFER_OVERRUN) on the command `frame variable ss_neg_seconds` running on Windows x86_64. See this issue for details https://github.com/llvm/llvm-project/issues/92574 --- .../libcxx/chrono/TestDataFormatterLibcxxChrono.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py index fb35481d55514..bb7310bc1a8c1 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py @@ -12,6 +12,9 @@ class LibcxxChronoDataFormatterTestCase(TestBase): @add_test_categories(["libc++"]) @skipIf(compiler="clang", compiler_version=["<", "17.0"]) +@skipIf( +hostoslist=["windows"], bugnumber="github.com/llvm/llvm-project/issues/92574" +) def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)
joker-eph wrote: > It's a sed s/== None/is None/g - what is there to review? On my I'm not asking for more reviews, this is why I commented that this should be **pushed** in multiple commits, I don't even need to see PRs. Another thing also mentioned above was the problem of reverts. If there is a problem in one of the project and this needs to be reverted, then it'll affect the other projects. Also imagine that this lands, then someone refactor the python code in MLIR, and then LLDB finds an issue and tries to revert. They have now to figure out why is there a merge conflicts. More commits in the history for unrelated projects does not seem like "noise" to me. When I apply automated linter (clang-tidy), I will split these into 1 commit per file and push these. https://github.com/llvm/llvm-project/pull/91857 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Added Debuginfod tests and fixed a couple issues (PR #92572)
kevinfrei wrote: FYI: The previous diff exposed a bug in some ARM code that @DavidSpicket fixed in #91585, but (for understandable reasons) he didn't want to be left holding the back on restoring this diff, so I integrated some post-land feedback from @labath and put the diff back up for review. https://github.com/llvm/llvm-project/pull/92572 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/90703 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Added Debuginfod tests and fixed a couple issues (PR #92572)
https://github.com/kevinfrei ready_for_review https://github.com/llvm/llvm-project/pull/92572 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Added Debuginfod tests and fixed a couple issues (PR #92572)
https://github.com/kevinfrei edited https://github.com/llvm/llvm-project/pull/92572 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Added Debuginfod tests and fixed a couple issues (PR #92572)
https://github.com/kevinfrei edited https://github.com/llvm/llvm-project/pull/92572 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Added Debuginfod tests and fixed a couple issues (PR #92572)
https://github.com/kevinfrei edited https://github.com/llvm/llvm-project/pull/92572 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Added Debuginfod tests and fixed a couple issues (PR #92572)
https://github.com/kevinfrei created https://github.com/llvm/llvm-project/pull/92572 Here we go with attempt #5. Again, no changes to the LLDB code diffs that have been looked at several times. For the tests, I added a `@skipIfCurlSupportMissing` annotation so that the Debuginfod mocked server stuff won't run, and I also disabled non-Linux/FreeBSD hosts altogether, as they fail for platform reasons on macOS and Windows. In addition, I updated the process for extracting the GNU BuildID to no create a target, per some feedback on the previous diff. >From 8a544973fcdb0391f3342b6e6e44b4cf422d0429 Mon Sep 17 00:00:00 2001 From: Kevin Frei Date: Mon, 25 Mar 2024 08:23:47 -0700 Subject: [PATCH 01/12] Trying to deal with Linux AArch64 test failures :/ --- .../SymbolVendor/ELF/SymbolVendorELF.cpp | 18 ++ .../API/debuginfod/Normal/TestDebuginfod.py | 187 + .../SplitDWARF/TestDebuginfodDWP.py | 196 ++ 3 files changed, 401 insertions(+) create mode 100644 lldb/test/API/debuginfod/Normal/TestDebuginfod.py create mode 100644 lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py diff --git a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp index b5fe35d71032a..a881218a56cef 100644 --- a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp +++ b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp @@ -44,6 +44,24 @@ llvm::StringRef SymbolVendorELF::GetPluginDescriptionStatic() { "executables."; } +// If this is needed elsewhere, it can be exported/moved. +static bool IsDwpSymbolFile(const lldb::ModuleSP _sp, +const FileSpec _spec) { + DataBufferSP dwp_file_data_sp; + lldb::offset_t dwp_file_data_offset = 0; + // Try to create an ObjectFile from the file_spec. + ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin( + module_sp, _spec, 0, FileSystem::Instance().GetByteSize(file_spec), + dwp_file_data_sp, dwp_file_data_offset); + // The presence of a debug_cu_index section is the key identifying feature of + // a DWP file. Make sure we don't fill in the section list on dwp_obj_file + // (by calling GetSectionList(false)) as this is invoked before we may have + // all the symbol files collected and available. + return dwp_obj_file && ObjectFileELF::classof(dwp_obj_file.get()) && + dwp_obj_file->GetSectionList(false)->FindSectionByType( + eSectionTypeDWARFDebugCuIndex, false); +} + // CreateInstance // // Platforms can register a callback to use when creating symbol vendors to diff --git a/lldb/test/API/debuginfod/Normal/TestDebuginfod.py b/lldb/test/API/debuginfod/Normal/TestDebuginfod.py new file mode 100644 index 0..a662fb9fc6e68 --- /dev/null +++ b/lldb/test/API/debuginfod/Normal/TestDebuginfod.py @@ -0,0 +1,187 @@ +import os +import shutil +import tempfile +import struct + +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + + +def getUUID(aoutuuid): +""" +Pull the 20 byte UUID out of the .note.gnu.build-id section that was dumped +to a file already, as part of the build. +""" +with open(aoutuuid, "rb") as f: +data = f.read(36) +if len(data) != 36: +return None +header = struct.unpack_from("<4I", data) +if len(header) != 4: +return None +# 4 element 'prefix', 20 bytes of uuid, 3 byte long string: 'GNU': +if header[0] != 4 or header[1] != 20 or header[2] != 3 or header[3] != 0x554E47: +return None +return data[16:].hex() + + +""" +Test support for the DebugInfoD network symbol acquisition protocol. +This one is for simple / no split-dwarf scenarios. + +For no-split-dwarf scenarios, there are 2 variations: +1 - A stripped binary with it's corresponding unstripped binary: +2 - A stripped binary with a corresponding --only-keep-debug symbols file +""" + + +@skipUnlessPlatform(["linux", "freebsd"]) +class DebugInfodTests(TestBase): +# No need to try every flavor of debug inf. +NO_DEBUG_INFO_TESTCASE = True + +def test_normal_no_symbols(self): +""" +Validate behavior with no symbols or symbol locator. +('baseline negative' behavior) +""" +test_root = self.config_test(["a.out"]) +self.try_breakpoint(False) + +def test_normal_default(self): +""" +Validate behavior with symbols, but no symbol locator. +('baseline positive' behavior) +""" +test_root = self.config_test(["a.out", "a.out.debug"]) +self.try_breakpoint(True) + +def test_debuginfod_symbols(self): +""" +Test behavior with the full binary available from Debuginfod as +'debuginfo' from the plug-in. +""" +test_root = self.config_test(["a.out"], "a.out.full") +
[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)
https://github.com/royitaqi updated https://github.com/llvm/llvm-project/pull/90703 >From 0fd67e2de7e702ce6f7353845454ea7ff9f980d6 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Tue, 30 Apr 2024 21:35:49 -0700 Subject: [PATCH 01/18] Add SBCommandInterpreter::GetTranscript() --- lldb/include/lldb/API/SBCommandInterpreter.h | 12 +--- lldb/source/API/SBCommandInterpreter.cpp | 7 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h index ba2e049204b8e..d65f06d676f91 100644 --- a/lldb/include/lldb/API/SBCommandInterpreter.h +++ b/lldb/include/lldb/API/SBCommandInterpreter.h @@ -247,13 +247,13 @@ class SBCommandInterpreter { lldb::SBStringList , lldb::SBStringList ); - /// Returns whether an interrupt flag was raised either by the SBDebugger - + /// Returns whether an interrupt flag was raised either by the SBDebugger - /// when the function is not running on the RunCommandInterpreter thread, or /// by SBCommandInterpreter::InterruptCommand if it is. If your code is doing - /// interruptible work, check this API periodically, and interrupt if it + /// interruptible work, check this API periodically, and interrupt if it /// returns true. bool WasInterrupted() const; - + /// Interrupts the command currently executing in the RunCommandInterpreter /// thread. /// @@ -318,6 +318,12 @@ class SBCommandInterpreter { SBStructuredData GetStatistics(); + /// Returns a list of handled commands, output and error. Each element in + /// the list is a dictionary with three keys: "command" (string), "output" + /// (list of strings) and optionally "error" (list of strings). Each string + /// in "output" and "error" is a line (without EOL characteres). + SBStructuredData GetTranscript(); + protected: friend class lldb_private::CommandPluginInterfaceImplementation; diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 83c0951c56db6..242b3f8f09c48 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -150,7 +150,7 @@ bool SBCommandInterpreter::WasInterrupted() const { bool SBCommandInterpreter::InterruptCommand() { LLDB_INSTRUMENT_VA(this); - + return (IsValid() ? m_opaque_ptr->InterruptCommand() : false); } @@ -571,6 +571,11 @@ SBStructuredData SBCommandInterpreter::GetStatistics() { return data; } +SBStructuredData SBCommandInterpreter::GetTranscript() { + LLDB_INSTRUMENT_VA(this); + return SBStructuredData(); +} + lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand(const char *name, const char *help) { LLDB_INSTRUMENT_VA(this, name, help); >From a1c948ceabaccdc3407e0c4eae0ebc594a9b68b7 Mon Sep 17 00:00:00 2001 From: Roy Shi Date: Wed, 1 May 2024 13:45:47 -0700 Subject: [PATCH 02/18] Implement the new API --- .../lldb/Interpreter/CommandInterpreter.h | 12 +-- lldb/include/lldb/Utility/StructuredData.h| 11 +++--- lldb/source/API/SBCommandInterpreter.cpp | 8 - .../source/Interpreter/CommandInterpreter.cpp | 21 ++- lldb/source/Utility/StructuredData.cpp| 35 +++ 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 70a55a77465bf..9474c41c0dced 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -22,6 +22,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringList.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" @@ -241,7 +242,7 @@ class CommandInterpreter : public Broadcaster, eCommandTypesAllThem = 0x //< all commands }; - // The CommandAlias and CommandInterpreter both have a hand in + // The CommandAlias and CommandInterpreter both have a hand in // substituting for alias commands. They work by writing special tokens // in the template form of the Alias command, and then detecting them when the // command is executed. These are the special tokens: @@ -576,7 +577,7 @@ class CommandInterpreter : public Broadcaster, void SetEchoCommentCommands(bool enable); bool GetRepeatPreviousCommand() const; - + bool GetRequireCommandOverwrite() const; const CommandObject::CommandMap () const { @@ -647,6 +648,7 @@ class CommandInterpreter : public Broadcaster, } llvm::json::Value GetStatistics(); + StructuredData::ArraySP GetTranscript() const; protected: friend class Debugger; @@ -766,6 +768,12 @@ class CommandInterpreter : public Broadcaster, CommandUsageMap
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -983,6 +1005,73 @@ llvm::Error ProcessElfCore::ParseThreadContextsFromNoteSegment( } } +bool ProcessElfCore::IsElf(const lldb::addr_t address) { + uint8_t buf[4]; + Status error; + size_t byte_read = ReadMemory(address, buf, 4, error); + if (byte_read != 4) +return false; + return elf::ELFHeader::MagicBytesMatch(buf); +} + +std::optional ProcessElfCore::FindNote(const lldb::addr_t address, + const uint32_t type) { + if (!IsElf(address)) +return std::nullopt; + const uint32_t addr_size = GetAddressByteSize(); + const lldb::offset_t ehdr_phoff_offset = ELFOFFSETOF(Ehdr, e_phoff); + const lldb::offset_t ehdr_phentsize_offset = ELFOFFSETOF(Ehdr, e_phentsize); + const lldb::offset_t ehdr_phnum_offset = ELFOFFSETOF(Ehdr, e_phnum); + const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr) +: sizeof(llvm::ELF::Elf64_Ehdr); + + unsigned char buf[4096]; + Status error; + size_t byte_read = ReadMemory(address, buf, elf_header_size, error); + DataExtractor data(buf, 4096, GetByteOrder(), addr_size); + lldb::offset_t offset = ehdr_phoff_offset; + lldb::offset_t phoff = data.GetAddress(); + + offset = ehdr_phentsize_offset; + lldb::offset_t phentsize = data.GetU16(); + offset = ehdr_phnum_offset; + lldb::offset_t phnum = data.GetU16(); clayborg wrote: header for the `ELFHeader` class is in: ``` lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h ``` https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -983,6 +1005,73 @@ llvm::Error ProcessElfCore::ParseThreadContextsFromNoteSegment( } } +bool ProcessElfCore::IsElf(const lldb::addr_t address) { + uint8_t buf[4]; + Status error; + size_t byte_read = ReadMemory(address, buf, 4, error); + if (byte_read != 4) +return false; + return elf::ELFHeader::MagicBytesMatch(buf); +} + +std::optional ProcessElfCore::FindNote(const lldb::addr_t address, + const uint32_t type) { + if (!IsElf(address)) +return std::nullopt; + const uint32_t addr_size = GetAddressByteSize(); + const lldb::offset_t ehdr_phoff_offset = ELFOFFSETOF(Ehdr, e_phoff); + const lldb::offset_t ehdr_phentsize_offset = ELFOFFSETOF(Ehdr, e_phentsize); + const lldb::offset_t ehdr_phnum_offset = ELFOFFSETOF(Ehdr, e_phnum); clayborg wrote: pass `addr_size` to the macro https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -1649,6 +1679,26 @@ class Process : public std::enable_shared_from_this, lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status ); + /// Find a string within a memory region. + /// + /// This function searches for the string represented by the provided buffer + /// within the memory range specified by the low and high addresses. It uses + /// a bad character heuristic to optimize the search process. + /// + /// \param[in] low The starting address of the memory region to be searched. + /// + /// \param[in] high The ending address of the memory region to be searched. + /// + /// \param[in] buffer A pointer to the buffer containing the string to be + /// searched. clayborg wrote: ``` /// \param[in] buffer A pointer to the buffer containing the bytes to be /// searched. ``` https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -33,12 +35,17 @@ #include "Plugins/Process/elf-core/RegisterUtilities.h" #include "ProcessElfCore.h" #include "ThreadElfCore.h" +#include "lldb/lldb-types.h" using namespace lldb_private; namespace ELF = llvm::ELF; LLDB_PLUGIN_DEFINE(ProcessElfCore) +#define ELFOFFSETOF(T, M) \ + addr_size == 4 ? offsetof(llvm::ELF::Elf32_##T, M) \ + : offsetof(llvm::ELF::Elf64_##T, M) clayborg wrote: We should pass in `addr_size` here: ``` #define ELFOFFSETOF(type_name, member, addr_size) ... ``` https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -117,6 +117,13 @@ class ProcessElfCore : public lldb_private::PostMortemProcess { lldb::addr_t end; lldb::addr_t file_ofs; std::string path; +lldb_private::UUID uuid; //.note.gnu.build-id + }; + + struct Section_Note { +uint32_t namesz; +uint32_t descsz; +uint32_t type; clayborg wrote: or move it into ELFHeader.h and then add a parse method. We are using a ton of stuff already from ELFHeader.h, so we should follow that path https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -983,6 +1005,73 @@ llvm::Error ProcessElfCore::ParseThreadContextsFromNoteSegment( } } +bool ProcessElfCore::IsElf(const lldb::addr_t address) { + uint8_t buf[4]; + Status error; + size_t byte_read = ReadMemory(address, buf, 4, error); + if (byte_read != 4) +return false; + return elf::ELFHeader::MagicBytesMatch(buf); +} + +std::optional ProcessElfCore::FindNote(const lldb::addr_t address, clayborg wrote: Maybe the name of `FindNoteInCoreMemory`? https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -1649,6 +1679,26 @@ class Process : public std::enable_shared_from_this, lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status ); + /// Find a string within a memory region. clayborg wrote: Change to: ``` /// Find bytes within a memory range. https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -1649,6 +1679,26 @@ class Process : public std::enable_shared_from_this, lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status ); + /// Find a string within a memory region. + /// + /// This function searches for the string represented by the provided buffer clayborg wrote: change to: ``` /// This function searches for the bytes represented by the provided buffer ``` https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed the test TestGdbRemoteAttachWait running on a remote target (PR #92413)
https://github.com/slydiman closed https://github.com/llvm/llvm-project/pull/92413 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d38ea8c - [lldb] Fixed the test TestGdbRemoteAttachWait running on a remote target (#92413)
Author: Dmitry Vasilyev Date: 2024-05-17T20:14:09+04:00 New Revision: d38ea8c4c84be9496249098053599c24b87f1376 URL: https://github.com/llvm/llvm-project/commit/d38ea8c4c84be9496249098053599c24b87f1376 DIFF: https://github.com/llvm/llvm-project/commit/d38ea8c4c84be9496249098053599c24b87f1376.diff LOG: [lldb] Fixed the test TestGdbRemoteAttachWait running on a remote target (#92413) Install `_exe_to_attach` to a remote target if necessary. Added: Modified: lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py Removed: diff --git a/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py b/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py index f4c31fe2f5c07..84aab9c969aa4 100644 --- a/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py +++ b/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py @@ -17,7 +17,10 @@ def _set_up_inferior(self): # Use a shim to ensure that the process is ready to be attached from # the get-go. self._exe_to_run = "shim" -self._run_args = [self.getBuildArtifact(self._exe_to_attach)] +self._exe_to_attach = lldbutil.install_to_target( +self, self.getBuildArtifact(self._exe_to_attach) +) +self._run_args = [self._exe_to_attach] self.build(dictionary={"EXE": self._exe_to_run, "CXX_SOURCES": "shim.cpp"}) else: self._exe_to_run = self._exe_to_attach ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
JDevlieghere wrote: > @JDevlieghere @adrian-prantl are there plans to change the presentation layer > to prevent this kind of shadowing in the future? Would be nice if all we > needed to do was report progress, and not worry about other progress events > in the debugger being in-flight No, on the terminal it works that way by design. Unless you switch to something that takes full control of your screen (like curses) there's no good way to display multiple progress events at the same time and not doing the shadowing (i.e. letting more recent progress events through) defeats the purpose of highlighting long running operations. https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)
Michael137 wrote: I attached to clang and printed an expression. That resulted in 16801 calls to `Progress::Increment`, all of which I'm guessing translate to event broadcasts. I collected some timing numbers: ``` https://github.com/llvm/llvm-project/assets/14071464/97333f8a-2e35-47c9-8cd0-d610daa077fd;> ``` So across the various scenarios i tested the slowdown is somewhere between 10-90 ms on average. > I'd expect that a one of these operations (parsing/importing one type) would > be pretty fast, and that the whole process takes so long simply because > performing a very large number of these ops. @labath Mostly that's true. Occasionally these operations can take longer if we end up searching for types/functions across multiple object files (especially with https://github.com/apple/llvm-project/pull/8222). We could certainly consider some sort of rate limiting here. Or maybe find a better place to report progress on? > Anyway, if the code is recursive, we might need to do something like we did > for Swift, with one top-level event and callback that updates the details. @JDevlieghere @adrian-prantl are there plans to change the presentation layer to prevent this kind of shadowing in the future? Would be nice if all we needed to do was report progress, and not worry about other progress events in the debugger being in-flight https://github.com/llvm/llvm-project/pull/91452 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)
@@ -2306,6 +2345,11 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE , if (!die) return false; + ParsedDWARFTypeAttributes attrs(die); ZequanWu wrote: > How exactly do we get here in that case? >From https://github.com/llvm/llvm-project/pull/90663#issuecomment-2105194128, >.debug_names somehow contains entries that are declarations. This causes >`SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext` to return a type >created from declaration when searching for definition. A simple idea I have in mind is to make the `GetForwardDeclCompilerTypeToDIE`'s value type to a pair `{DIERef, bool}`, and the bool indicate if this is a definition or not. So we know that info without extra attribute parsing. How do you think? https://github.com/llvm/llvm-project/pull/92328 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)
JDevlieghere wrote: > It's a `sed s/== None/is None/g` - what is there to review? 10 separate > commits/PRs for the same exact `sed` costs more in commit noise (and effort > on the part of @e-kwsm) than one solid, patient, review here. In addition to what @ftynse said above, the `sed` might not be the right thing in the first place (e.g. #91858). https://github.com/llvm/llvm-project/pull/91857 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Refactor string manipulation in Debugger.cpp (#91209) (PR #92565)
github-actions[bot] wrote: ⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo. Please turn off [Keep my email addresses private](https://github.com/settings/emails) setting in your account. See [LLVM Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it) for more information. https://github.com/llvm/llvm-project/pull/92565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Refactor string manipulation in Debugger.cpp (#91209) (PR #92565)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (aabhinavg) Changes Summary of Changes: Replaced the ineffective call to `substr` with a more efficient use of `resize` to truncate the string. Adjusted the code to use 'resize' instead of 'substr' for better performance and readability. Removed unwanted file from the previous commit. Fixes: #91209 --- Full diff: https://github.com/llvm/llvm-project/pull/92565.diff 1 Files Affected: - (modified) lldb/source/Core/Debugger.cpp (+1-1) ``diff diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 9951fbcd3e7c3..70303173925e3 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -2067,7 +2067,7 @@ void Debugger::HandleProgressEvent(const lldb::EventSP _sp) { const uint32_t term_width = GetTerminalWidth(); const uint32_t ellipsis = 3; if (message.size() + ellipsis >= term_width) -message = message.substr(0, term_width - ellipsis); +message.resize(message.size() - ellipsis); const bool use_color = GetUseColor(); llvm::StringRef ansi_prefix = GetShowProgressAnsiPrefix(); `` https://github.com/llvm/llvm-project/pull/92565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Refactor string manipulation in Debugger.cpp (#91209) (PR #92565)
https://github.com/aabhinavg created https://github.com/llvm/llvm-project/pull/92565 Summary of Changes: Replaced the ineffective call to `substr` with a more efficient use of `resize` to truncate the string. Adjusted the code to use 'resize' instead of 'substr' for better performance and readability. Removed unwanted file from the previous commit. Fixes: #91209 >From 13fefb6846b6641900843c37746b03140063a955 Mon Sep 17 00:00:00 2001 From: aabhinavg Date: Fri, 17 May 2024 21:17:51 +0530 Subject: [PATCH] removed unwanted file --- lldb/source/Core/Debugger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 9951fbcd3e7c3..70303173925e3 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -2067,7 +2067,7 @@ void Debugger::HandleProgressEvent(const lldb::EventSP _sp) { const uint32_t term_width = GetTerminalWidth(); const uint32_t ellipsis = 3; if (message.size() + ellipsis >= term_width) -message = message.substr(0, term_width - ellipsis); +message.resize(message.size() - ellipsis); const bool use_color = GetUseColor(); llvm::StringRef ansi_prefix = GetShowProgressAnsiPrefix(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)
ashgti wrote: Sounds good to me https://github.com/llvm/llvm-project/pull/77026 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -117,6 +117,13 @@ class ProcessElfCore : public lldb_private::PostMortemProcess { lldb::addr_t end; lldb::addr_t file_ofs; std::string path; +lldb_private::UUID uuid; //.note.gnu.build-id + }; + + struct Section_Note { +uint32_t namesz; +uint32_t descsz; +uint32_t type; kevinfrei wrote: Move this to the ThreadElfCore.h header and add a 'parse' method to it, so the UUID is populated much like the PRPSINFO data and other useful info from the coredump. https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
https://github.com/kevinfrei edited https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
https://github.com/kevinfrei requested changes to this pull request. https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -271,6 +282,17 @@ Status ProcessElfCore::DoLoadCore() { return error; } +void ProcessElfCore::UpdateBuildIdForNTFileEntries() { + if (!m_nt_file_entries.empty()) { kevinfrei wrote: I'd suggest adding it to that pass as well, though it will be a little bit messier, as NT_PRPSINFO and NT_GNU_BUILD_ID have the same values, so they depend on the Name field (CORE and GNU, respectively...). Do a check for the GNU name at the very top (line 902ish?) and handle NT_GNU_BUILD_ID's before the rest of that loop body, or dealing with PRPSINFO logic will get much messier... https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -983,6 +1005,73 @@ llvm::Error ProcessElfCore::ParseThreadContextsFromNoteSegment( } } +bool ProcessElfCore::IsElf(const lldb::addr_t address) { + uint8_t buf[4]; + Status error; + size_t byte_read = ReadMemory(address, buf, 4, error); + if (byte_read != 4) +return false; + return elf::ELFHeader::MagicBytesMatch(buf); +} + +std::optional ProcessElfCore::FindNote(const lldb::addr_t address, kevinfrei wrote: I'd suggest instead, implement support for the Note section in the same fashion as the other ELF components, with a "parse" method and the like (check out ThreadElfCore.h) and integrated it into the top level loop, same as the other Program Header structures. https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb] Refactor string manipulation in Debugger.cpp (#91209) (PR #91880)
https://github.com/JOE1994 requested changes to this pull request. * The PR contains irrelevant changes to `X86` codegen. * Author of the commit shows up as another contributor. It seems like the author of this PR did a `git commit --amend` on top of e586556e375fc5c4f7e76b5c299cb981f2016108 to add new changes. Please update the branch to address these issues. https://github.com/llvm/llvm-project/pull/91880 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb] Refactor string manipulation in Debugger.cpp (#91209) (PR #91880)
https://github.com/JOE1994 reopened https://github.com/llvm/llvm-project/pull/91880 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)
walter-erquinigo wrote: Thanks, @labath , for chiming in. I actually agree with all your points. https://github.com/llvm/llvm-project/pull/91570 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)
walter-erquinigo wrote: I'm okay with anything that ensures hovering is fast. https://github.com/llvm/llvm-project/pull/77026 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed the DAP tests in case of a remote target (PR #92416)
walter-erquinigo wrote: That's a great idea. There's no such `dap` category at the moment, but it would be nice if such category is created as part of the ongoing lldb-dap test fixes. https://github.com/llvm/llvm-project/pull/92416 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed the test TestGdbRemoteAttachWait running on a remote target (PR #92413)
https://github.com/labath approved this pull request. Thanks. https://github.com/llvm/llvm-project/pull/92413 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed the test TestGdbRemoteAttachWait running on a remote target (PR #92413)
@@ -52,6 +52,9 @@ def test_attach_with_vAttachWait(self): server = self.connect_to_debug_monitor() self.do_handshake() +if self._run_args: +self._run_args[0] = lldbutil.install_to_target(self, self._run_args[0]) slydiman wrote: I have updated the patch. Thanks. https://github.com/llvm/llvm-project/pull/92413 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fixed the test TestGdbRemoteAttachWait running on a remote target (PR #92413)
https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/92413 >From d88cc6d992e1f753066aa5dccaa510d8a0a35b94 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Thu, 16 May 2024 19:18:21 +0400 Subject: [PATCH 1/2] [lldb] Fixed the test TestGdbRemoteAttachWait running on a remote target Install `_exe_to_attach` to a remote target if necessary. --- .../lldb-server/attach-wait/TestGdbRemoteAttachWait.py | 9 + 1 file changed, 9 insertions(+) diff --git a/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py b/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py index f4c31fe2f5c07..a8333210a72b1 100644 --- a/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py +++ b/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py @@ -52,6 +52,9 @@ def test_attach_with_vAttachWait(self): server = self.connect_to_debug_monitor() self.do_handshake() +if self._run_args: +self._run_args[0] = lldbutil.install_to_target(self, self._run_args[0]) + # Launch the first inferior (we shouldn't attach to this one). self._launch_and_wait_for_init() @@ -101,6 +104,9 @@ def test_launch_before_attach_with_vAttachOrWait(self): server = self.connect_to_debug_monitor() self.do_handshake() +if self._run_args: +self._run_args[0] = lldbutil.install_to_target(self, self._run_args[0]) + inferior = self._launch_and_wait_for_init() # Add attach packets. @@ -141,6 +147,9 @@ def test_launch_after_attach_with_vAttachOrWait(self): server = self.connect_to_debug_monitor() self.do_handshake() +if self._run_args: +self._run_args[0] = lldbutil.install_to_target(self, self._run_args[0]) + self.test_sequence.add_log_lines([self._attach_packet("vAttachOrWait")], True) # Run the stream until attachWait. context = self.expect_gdbremote_sequence() >From 1f329275f90c0be3ecf73f3e9e3c816439596116 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Fri, 17 May 2024 16:26:57 +0400 Subject: [PATCH 2/2] Moved install_to_target() to _set_up_inferior(). --- .../attach-wait/TestGdbRemoteAttachWait.py | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py b/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py index a8333210a72b1..84aab9c969aa4 100644 --- a/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py +++ b/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py @@ -17,7 +17,10 @@ def _set_up_inferior(self): # Use a shim to ensure that the process is ready to be attached from # the get-go. self._exe_to_run = "shim" -self._run_args = [self.getBuildArtifact(self._exe_to_attach)] +self._exe_to_attach = lldbutil.install_to_target( +self, self.getBuildArtifact(self._exe_to_attach) +) +self._run_args = [self._exe_to_attach] self.build(dictionary={"EXE": self._exe_to_run, "CXX_SOURCES": "shim.cpp"}) else: self._exe_to_run = self._exe_to_attach @@ -52,9 +55,6 @@ def test_attach_with_vAttachWait(self): server = self.connect_to_debug_monitor() self.do_handshake() -if self._run_args: -self._run_args[0] = lldbutil.install_to_target(self, self._run_args[0]) - # Launch the first inferior (we shouldn't attach to this one). self._launch_and_wait_for_init() @@ -104,9 +104,6 @@ def test_launch_before_attach_with_vAttachOrWait(self): server = self.connect_to_debug_monitor() self.do_handshake() -if self._run_args: -self._run_args[0] = lldbutil.install_to_target(self, self._run_args[0]) - inferior = self._launch_and_wait_for_init() # Add attach packets. @@ -147,9 +144,6 @@ def test_launch_after_attach_with_vAttachOrWait(self): server = self.connect_to_debug_monitor() self.do_handshake() -if self._run_args: -self._run_args[0] = lldbutil.install_to_target(self, self._run_args[0]) - self.test_sequence.add_log_lines([self._attach_packet("vAttachOrWait")], True) # Run the stream until attachWait. context = self.expect_gdbremote_sequence() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)
ftynse wrote: > 10 separate commits/PRs for the same exact sed costs more in commit noise > (and effort on the part of @e-kwsm) than one solid, patient, review here Not unless you subscribe only to a subproject. FWIW, I'm not comfortable blanket approving changes, however trivial, to subprojects I'm not actively working on, and I suspect most folks here are not. Subprojects may have some ongoing work that will be disrupted or reasons why they chose the suboptimal implementation. https://github.com/llvm/llvm-project/pull/91857 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -983,6 +1005,73 @@ llvm::Error ProcessElfCore::ParseThreadContextsFromNoteSegment( } } +bool ProcessElfCore::IsElf(const lldb::addr_t address) { + uint8_t buf[4]; + Status error; + size_t byte_read = ReadMemory(address, buf, 4, error); + if (byte_read != 4) +return false; + return elf::ELFHeader::MagicBytesMatch(buf); +} + +std::optional ProcessElfCore::FindNote(const lldb::addr_t address, + const uint32_t type) { + if (!IsElf(address)) +return std::nullopt; + const uint32_t addr_size = GetAddressByteSize(); + const lldb::offset_t ehdr_phoff_offset = ELFOFFSETOF(Ehdr, e_phoff); + const lldb::offset_t ehdr_phentsize_offset = ELFOFFSETOF(Ehdr, e_phentsize); + const lldb::offset_t ehdr_phnum_offset = ELFOFFSETOF(Ehdr, e_phnum); + const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr) +: sizeof(llvm::ELF::Elf64_Ehdr); + + unsigned char buf[4096]; + Status error; + size_t byte_read = ReadMemory(address, buf, elf_header_size, error); + DataExtractor data(buf, 4096, GetByteOrder(), addr_size); + lldb::offset_t offset = ehdr_phoff_offset; + lldb::offset_t phoff = data.GetAddress(); + + offset = ehdr_phentsize_offset; + lldb::offset_t phentsize = data.GetU16(); + offset = ehdr_phnum_offset; + lldb::offset_t phnum = data.GetU16(); labath wrote: Reuse the existing `ELFHeader` class for this. I.e., read the necessary amount of bytes (you can just always read `sizeof(Elf64_Ehdr)` as that's larger) into a DataExtractor and call `header.Parse(extractor, 0)`. https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -271,6 +282,17 @@ Status ProcessElfCore::DoLoadCore() { return error; } +void ProcessElfCore::UpdateBuildIdForNTFileEntries() { + if (!m_nt_file_entries.empty()) { labath wrote: Any specific reason doing this as a separate pass (and not from inside parsing loop on line 936)? https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -983,6 +1005,73 @@ llvm::Error ProcessElfCore::ParseThreadContextsFromNoteSegment( } } +bool ProcessElfCore::IsElf(const lldb::addr_t address) { + uint8_t buf[4]; + Status error; + size_t byte_read = ReadMemory(address, buf, 4, error); + if (byte_read != 4) +return false; + return elf::ELFHeader::MagicBytesMatch(buf); +} + +std::optional ProcessElfCore::FindNote(const lldb::addr_t address, + const uint32_t type) { + if (!IsElf(address)) +return std::nullopt; + const uint32_t addr_size = GetAddressByteSize(); + const lldb::offset_t ehdr_phoff_offset = ELFOFFSETOF(Ehdr, e_phoff); + const lldb::offset_t ehdr_phentsize_offset = ELFOFFSETOF(Ehdr, e_phentsize); + const lldb::offset_t ehdr_phnum_offset = ELFOFFSETOF(Ehdr, e_phnum); + const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr) +: sizeof(llvm::ELF::Elf64_Ehdr); + + unsigned char buf[4096]; + Status error; + size_t byte_read = ReadMemory(address, buf, elf_header_size, error); + DataExtractor data(buf, 4096, GetByteOrder(), addr_size); + lldb::offset_t offset = ehdr_phoff_offset; + lldb::offset_t phoff = data.GetAddress(); + + offset = ehdr_phentsize_offset; + lldb::offset_t phentsize = data.GetU16(); + offset = ehdr_phnum_offset; + lldb::offset_t phnum = data.GetU16(); + + Section_Note note; + const lldb::addr_t ph_addr = address + phoff; + + for (unsigned int i = 0; i < phnum; ++i) { +byte_read = ReadMemory(ph_addr + i * phentsize, buf, phentsize, error); +if (byte_read != phentsize) + break; +offset = 0; +uint32_t p_type = data.GetU32(); +if (p_type != llvm::ELF::PT_NOTE) + continue; +offset = ELFOFFSETOF(Phdr, p_vaddr); +lldb::addr_t p_vaddr = data.GetAddress(); +offset = ELFOFFSETOF(Phdr, p_memsz); +lldb::addr_t p_memsz = data.GetAddress(); + +byte_read = ReadMemory(p_vaddr, buf, p_memsz, error); +if (byte_read != p_memsz) + continue; +offset = 0; +while ( +offset < p_memsz && +data.GetU32(, , sizeof(Section_Note) / sizeof(uint32_t))) { + if (note.namesz == 4 && note.type == type) { +const char *name = data.GetCStr(); +if (name && strcmp("GNU", name) == 0) + return UUID( + llvm::ArrayRef(buf + offset, note.descsz /*byte size*/)); + } + offset += note.namesz + note.descsz; +} labath wrote: And `parseSegment` for this (despite the generic name, this is really for parsing note segments, maybe you could rename it while you're in here). https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -158,6 +165,16 @@ class ProcessElfCore : public lldb_private::PostMortemProcess { // Returns number of thread contexts stored in the core file uint32_t GetNumThreadContexts(); + // Populate gnu uuid for each NT_FILE entry + void UpdateBuildIdForNTFileEntries(); + + // Returns the value of certain type of note of a given start address + std::optional FindNote(const lldb::addr_t address, labath wrote: `const` on a value parameter (pointer and reference parameters are of course different) declaration don't actually do anything, and I don't believe we usually use them. If you really want to you can still make them `const` in [the function definition](https://godbolt.org/z/PxM739P84) even if they're not const in the header (though we usually don't do that either). https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -983,6 +1005,73 @@ llvm::Error ProcessElfCore::ParseThreadContextsFromNoteSegment( } } +bool ProcessElfCore::IsElf(const lldb::addr_t address) { + uint8_t buf[4]; + Status error; + size_t byte_read = ReadMemory(address, buf, 4, error); + if (byte_read != 4) +return false; + return elf::ELFHeader::MagicBytesMatch(buf); +} + +std::optional ProcessElfCore::FindNote(const lldb::addr_t address, labath wrote: Please give this a more specific name (to say what kind of note its searching for and where). An uninformed reader would think this is searching for a note in the core file itself. https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -406,6 +406,36 @@ class Process : public std::enable_shared_from_this, lldb::StateType state); } Notifications; + class ProcessMemoryIterator { labath wrote: AFAICT, this isn't necessary anymore. If you think it's useful, you can make it a separate patch. https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
https://github.com/labath commented: This looks much better, though, after looking at this closer, I don't think it's necessary to reimplement the elf parsing code. We already have all the necessary data structures for parsing notes in the core file itself, and it looks like it would be fairly easy to reuse them for this purpose as well. https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
@@ -983,6 +1005,73 @@ llvm::Error ProcessElfCore::ParseThreadContextsFromNoteSegment( } } +bool ProcessElfCore::IsElf(const lldb::addr_t address) { + uint8_t buf[4]; + Status error; + size_t byte_read = ReadMemory(address, buf, 4, error); + if (byte_read != 4) +return false; + return elf::ELFHeader::MagicBytesMatch(buf); +} + +std::optional ProcessElfCore::FindNote(const lldb::addr_t address, + const uint32_t type) { + if (!IsElf(address)) +return std::nullopt; + const uint32_t addr_size = GetAddressByteSize(); + const lldb::offset_t ehdr_phoff_offset = ELFOFFSETOF(Ehdr, e_phoff); + const lldb::offset_t ehdr_phentsize_offset = ELFOFFSETOF(Ehdr, e_phentsize); + const lldb::offset_t ehdr_phnum_offset = ELFOFFSETOF(Ehdr, e_phnum); + const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr) +: sizeof(llvm::ELF::Elf64_Ehdr); + + unsigned char buf[4096]; + Status error; + size_t byte_read = ReadMemory(address, buf, elf_header_size, error); + DataExtractor data(buf, 4096, GetByteOrder(), addr_size); + lldb::offset_t offset = ehdr_phoff_offset; + lldb::offset_t phoff = data.GetAddress(); + + offset = ehdr_phentsize_offset; + lldb::offset_t phentsize = data.GetU16(); + offset = ehdr_phnum_offset; + lldb::offset_t phnum = data.GetU16(); + + Section_Note note; + const lldb::addr_t ph_addr = address + phoff; + + for (unsigned int i = 0; i < phnum; ++i) { +byte_read = ReadMemory(ph_addr + i * phentsize, buf, phentsize, error); +if (byte_read != phentsize) + break; +offset = 0; +uint32_t p_type = data.GetU32(); +if (p_type != llvm::ELF::PT_NOTE) + continue; +offset = ELFOFFSETOF(Phdr, p_vaddr); +lldb::addr_t p_vaddr = data.GetAddress(); +offset = ELFOFFSETOF(Phdr, p_memsz); +lldb::addr_t p_memsz = data.GetAddress(); labath wrote: Similarly, you can use `ELFProgramHeader::Parse` for this bit. https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/92492 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits