[Lldb-commits] [lldb] [lldb] Fix type lookup in DWARF .o files via debug map (PR #87177)
https://github.com/marcauberer approved this pull request. https://github.com/llvm/llvm-project/pull/87177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix DWARF locations when we have large .dwp files. (PR #87164)
https://github.com/ayermolo approved this pull request. thx https://github.com/llvm/llvm-project/pull/87164 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix type lookup in DWARF .o files via debug map (PR #87177)
@@ -1233,7 +1233,7 @@ void SymbolFileDWARFDebugMap::FindTypes(const TypeQuery &query, std::lock_guard guard(GetModuleMutex()); ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { oso_dwarf->FindTypes(query, results); -return !results.Done(query); // Keep iterating if we aren't done. +return results.Done(query); // Keep iterating if we aren't done. Michael137 wrote: Outside the scope of this patch, but I think we should finally change the return type to an enum that makes it easier to figure out whether we want to "continue" versus "short-circuit". https://github.com/llvm/llvm-project/pull/87177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix type lookup in DWARF .o files via debug map (PR #87177)
@@ -1391,7 +1391,7 @@ void SymbolFileDWARFDebugMap::ParseDeclsForContext( lldb_private::CompilerDeclContext decl_ctx) { ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { oso_dwarf->ParseDeclsForContext(decl_ctx); -return true; // Keep iterating +return false; // Keep iterating Michael137 wrote: Outside the scope of this patch, but note that `ParseDeclsForContext` isn't actually doing anything specific to the object file. Calling it multiple times for the same `decl_ctx` happens to be a no-op, but this doesn't feel like something that should be on `SymbolFile`. https://github.com/llvm/llvm-project/pull/87177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 154cea4 - [lldb] Fix type lookup in DWARF .o files via debug map (#87177)
Author: Pablo Busse Date: 2024-03-31T17:17:32+01:00 New Revision: 154cea46732f4014bb409f1bcac9b39ac56df193 URL: https://github.com/llvm/llvm-project/commit/154cea46732f4014bb409f1bcac9b39ac56df193 DIFF: https://github.com/llvm/llvm-project/commit/154cea46732f4014bb409f1bcac9b39ac56df193.diff LOG: [lldb] Fix type lookup in DWARF .o files via debug map (#87177) An inverted condition causes `SymbolFileDWARFDebugMap::FindTypes` to bail out after inspecting the first .o file in each module. The same kind of bug is found in `SymbolFileDWARFDebugMap::ParseDeclsForContext`. Correct both early exit conditions and add a regression test for lookup of up a type defined in a secondary compilation unit. Fixes #87176 Added: lldb/test/API/functionalities/type_find_first/other.cpp Modified: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/test/API/functionalities/type_find_first/Makefile lldb/test/API/functionalities/type_find_first/TestFindFirstType.py lldb/test/API/functionalities/type_find_first/main.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 6dd3eb3677b7af..4bc2cfd60688a8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -1233,7 +1233,7 @@ void SymbolFileDWARFDebugMap::FindTypes(const TypeQuery &query, std::lock_guard guard(GetModuleMutex()); ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { oso_dwarf->FindTypes(query, results); -return !results.Done(query); // Keep iterating if we aren't done. +return results.Done(query); // Keep iterating if we aren't done. }); } @@ -1391,7 +1391,7 @@ void SymbolFileDWARFDebugMap::ParseDeclsForContext( lldb_private::CompilerDeclContext decl_ctx) { ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { oso_dwarf->ParseDeclsForContext(decl_ctx); -return true; // Keep iterating +return false; // Keep iterating }); } diff --git a/lldb/test/API/functionalities/type_find_first/Makefile b/lldb/test/API/functionalities/type_find_first/Makefile index 3d0b98f13f3d7b..e027553c7a6b09 100644 --- a/lldb/test/API/functionalities/type_find_first/Makefile +++ b/lldb/test/API/functionalities/type_find_first/Makefile @@ -1,2 +1,2 @@ -CXX_SOURCES := main.cpp +CXX_SOURCES := main.cpp other.cpp include Makefile.rules diff --git a/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py b/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py index 6347a35e72ea3f..b1c5659a324a4c 100644 --- a/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py +++ b/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py @@ -8,8 +8,6 @@ class TypeFindFirstTestCase(TestBase): -NO_DEBUG_INFO_TESTCASE = True - def test_find_first_type(self): """ Test SBTarget::FindFirstType() and SBModule::FindFirstType() APIs. @@ -19,19 +17,22 @@ def test_find_first_type(self): basename, FindFirstType() could end up failing depending on which type was found first in the debug info indexes. This test will ensure this doesn't regress in the future. + +The test also looks for a type defined in a diff erent compilation unit +to verify that SymbolFileDWARFDebugMap searches each symbol file in a +module. """ self.build() target = self.createTestTarget() -# Test the SBTarget APIs for FindFirstType -integer_type = target.FindFirstType("Integer::Point") -self.assertTrue(integer_type.IsValid()) -float_type = target.FindFirstType("Float::Point") -self.assertTrue(float_type.IsValid()) - -# Test the SBModule APIs for FindFirstType exe_module = target.GetModuleAtIndex(0) self.assertTrue(exe_module.IsValid()) -integer_type = exe_module.FindFirstType("Integer::Point") -self.assertTrue(integer_type.IsValid()) -float_type = exe_module.FindFirstType("Float::Point") -self.assertTrue(float_type.IsValid()) +# Test the SBTarget and SBModule APIs for FindFirstType +for api in [target, exe_module]: +integer_type = api.FindFirstType("Integer::Point") +self.assertTrue(integer_type.IsValid()) +float_type = api.FindFirstType("Float::Point") +self.assertTrue(float_type.IsValid()) +external_type = api.FindFirstType("OtherCompilationUnit::Type") +self.assertTrue(external_type.IsValid()) +nonexistent_type = api.FindFirstType("NonexistentType") +self.assertFalse(nonexistent_type.IsValid()) diff --git a/lldb/test/API/functionalities/type_find_first/main.cpp b/lldb/test/API/fu
[Lldb-commits] [lldb] [lldb] Fix type lookup in DWARF .o files via debug map (PR #87177)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/87177 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix type lookup in DWARF .o files via debug map (PR #87177)
github-actions[bot] wrote: @pabusse Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/87177 ___ 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 created https://github.com/llvm/llvm-project/pull/87197 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 >From 68cb68d3f93aed6b3479fb305131b99ec599c9d8 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Sun, 31 Mar 2024 10:59:38 -0700 Subject: [PATCH] [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 e7e35e2b2bffc0..0c8dbf384a326c 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 &value); + + /// 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 &error); /// 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 &type_sp); + /// Return the target load address assocaited with this value object. + lldb::addr_t GetLoadAddress(); + + lldb::ValueObjectSP CastDerivedToBaseType(CompilerType type, +const std::vector &idx); + + lldb::ValueObjectSP CastBaseToDerivedType(CompilerType type, uint64_t offset); + + lldb::ValueObjectSP CastScalarToBasicType(CompilerType type, Status &error); + + lldb::ValueObjectSP CastEnumToBasicType(CompilerType type); + + lldb::ValueObjectSP CastPointerToBasicType(CompilerType type); + + lldb::ValueObjectSP CastIntegerOrEnumToEnumType(CompilerType type); + + lldb::ValueObjectSP CastFloatToEnumType(CompilerType type, Status &error); + /// 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 &data, const ExecutionContext &exe_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 &v, +CompilerType type); + + static lldb::ValueObjectSP + CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat &v, + 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 { ClearUserVi
[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (cmtice) Changes 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 --- Patch is 20.16 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/87197.diff 2 Files Affected: - (modified) lldb/include/lldb/Core/ValueObject.h (+61) - (modified) lldb/source/Core/ValueObject.cpp (+405) ``diff diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index e7e35e2b2bffc0..0c8dbf384a326c 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 &value); + + /// 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 &error); /// 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 &type_sp); + /// Return the target load address assocaited with this value object. + lldb::addr_t GetLoadAddress(); + + lldb::ValueObjectSP CastDerivedToBaseType(CompilerType type, +const std::vector &idx); + + lldb::ValueObjectSP CastBaseToDerivedType(CompilerType type, uint64_t offset); + + lldb::ValueObjectSP CastScalarToBasicType(CompilerType type, Status &error); + + lldb::ValueObjectSP CastEnumToBasicType(CompilerType type); + + lldb::ValueObjectSP CastPointerToBasicType(CompilerType type); + + lldb::ValueObjectSP CastIntegerOrEnumToEnumType(CompilerType type); + + lldb::ValueObjectSP CastFloatToEnumType(CompilerType type, Status &error); + /// 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 &data, const ExecutionContext &exe_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 &v, +CompilerType type); + + static lldb::ValueObjectSP + CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat &v, + 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 f39bd07a255366..70cd3bdece8a40 100644 --- a/lldb/source/Core/ValueObject.cpp
[Lldb-commits] [lldb] 75f7d53 - Fix DWARF locations when we have large .dwp files. (#87164)
Author: Greg Clayton Date: 2024-03-31T12:08:59-07:00 New Revision: 75f7d53f0ba5d77920ea895021b330f261e808cd URL: https://github.com/llvm/llvm-project/commit/75f7d53f0ba5d77920ea895021b330f261e808cd DIFF: https://github.com/llvm/llvm-project/commit/75f7d53f0ba5d77920ea895021b330f261e808cd.diff LOG: Fix DWARF locations when we have large .dwp files. (#87164) We have the ability to load .dwp files with a .debug_info.dwo section that exceeds 4GB. There were 4 locations that were using 32 bit offsets and lengths to extract variable locations, and if a DIE was over the 4GB barrier, we would truncate the block offset for the variable locations and the variable expression would be garbage. This fixes the issues. It isn't possible to add a test for this as we don't want to create a 4GB .dwp file on test machines. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 1164bc62682a9a..49f13d2c89e380 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3420,8 +3420,8 @@ static DWARFExpressionList GetExprListFromAtLocation(DWARFFormValue form_value, if (DWARFFormValue::IsBlockForm(form_value.Form())) { const DWARFDataExtractor &data = die.GetData(); -uint32_t block_offset = form_value.BlockData() - data.GetDataStart(); -uint32_t block_length = form_value.Unsigned(); +uint64_t block_offset = form_value.BlockData() - data.GetDataStart(); +uint64_t block_length = form_value.Unsigned(); return DWARFExpressionList( module, DataExtractor(data, block_offset, block_length), die.GetCU()); } @@ -3450,9 +3450,9 @@ GetExprListFromAtConstValue(DWARFFormValue form_value, ModuleSP module, const DWARFDataExtractor &debug_info_data = die.GetData(); if (DWARFFormValue::IsBlockForm(form_value.Form())) { // Retrieve the value as a block expression. -uint32_t block_offset = +uint64_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); -uint32_t block_length = form_value.Unsigned(); +uint64_t block_length = form_value.Unsigned(); return DWARFExpressionList( module, DataExtractor(debug_info_data, block_offset, block_length), die.GetCU()); @@ -4061,8 +4061,8 @@ CollectCallSiteParameters(ModuleSP module, DWARFDIE call_site_die) { if (!DWARFFormValue::IsBlockForm(form_value.Form())) return {}; auto data = child.GetData(); - uint32_t block_offset = form_value.BlockData() - data.GetDataStart(); - uint32_t block_length = form_value.Unsigned(); + uint64_t block_offset = form_value.BlockData() - data.GetDataStart(); + uint64_t block_length = form_value.Unsigned(); return DWARFExpressionList( module, DataExtractor(data, block_offset, block_length), child.GetCU()); @@ -4167,8 +4167,8 @@ SymbolFileDWARF::CollectCallEdges(ModuleSP module, DWARFDIE function_die) { } auto data = child.GetData(); -uint32_t block_offset = form_value.BlockData() - data.GetDataStart(); -uint32_t block_length = form_value.Unsigned(); +uint64_t block_offset = form_value.BlockData() - data.GetDataStart(); +uint64_t block_length = form_value.Unsigned(); call_target = DWARFExpressionList( module, DataExtractor(data, block_offset, block_length), child.GetCU()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix DWARF locations when we have large .dwp files. (PR #87164)
https://github.com/clayborg closed https://github.com/llvm/llvm-project/pull/87164 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits