-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb][DWARF] Support retrieving DW_FORM_implicit_const value with DWARFDebugInfoEntry::GetAttributeValue #145328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Michael137
merged 1 commit into
llvm:main
from
Michael137:lldb/get-attribute-value-implicit-const
Jun 23, 2025
Merged
[lldb][DWARF] Support retrieving DW_FORM_implicit_const value with DWARFDebugInfoEntry::GetAttributeValue #145328
Michael137
merged 1 commit into
llvm:main
from
Michael137:lldb/get-attribute-value-implicit-const
Jun 23, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ARFDebugInfoEntry::GetAttributeValue `DWARFFormValue::ExtractValue` has nothing to extract for `DW_FORM_implicit_const` since the value is stored in the abbreviation. `DWARFFormValue` expects the user to have set the value of the implicit_const. This patch does so in `GetAttributeValue`.
@llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes
Full diff: https://github.com/llvm/llvm-project/pull/145328.diff 2 Files Affected:
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 8217c85f86014..13b68e747b1ce 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -403,6 +403,9 @@ dw_offset_t DWARFDebugInfoEntry::GetAttributeValue(
const dw_offset_t attr_offset = offset;
form_value.SetUnit(cu);
form_value.SetForm(abbrevDecl->getFormByIndex(idx));
+ if (abbrevDecl->getAttrIsImplicitConstByIndex(idx))
+ form_value.SetValue(abbrevDecl->getAttrImplicitConstValueByIndex(idx));
+
if (form_value.ExtractValue(data, &offset)) {
if (end_attr_offset_ptr)
*end_attr_offset_ptr = offset;
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
index 3f61d1607073c..0da26d99ad383 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
@@ -395,6 +395,64 @@ TEST(DWARFDIETest, GetContextInFunction) {
testing::ElementsAre(make_struct("struct_t")));
}
+TEST(DWARFDIETest, GetAttributeValue_ImplicitConst) {
+ // Make sure we can correctly retrieve the value of an attribute
+ // that has a DW_FORM_implicit_const form.
+
+ const char *yamldata = R"(
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_386
+DWARF:
+ debug_str:
+ - ''
+ debug_abbrev:
+ - ID: 0
+ Table:
+ - Code: 0x1
+ Tag: DW_TAG_compile_unit
+ Children: DW_CHILDREN_yes
+ - Code: 0x2
+ Tag: DW_TAG_subprogram
+ Children: DW_CHILDREN_no
+ Attributes:
+ - Attribute: DW_AT_name
+ Form: DW_FORM_string
+ - Attribute: DW_AT_object_pointer
+ Form: DW_FORM_implicit_const
+ Value: 5
+ debug_info:
+ - Version: 5
+ UnitType: DW_UT_compile
+ AddrSize: 8
+ Entries:
+ - AbbrCode: 0x1
+ - AbbrCode: 0x2
+ Values:
+ - Value: 0xDEADBEEFDEADBEEF
+ CStr: func
+ - AbbrCode: 0x0)";
+
+ YAMLModuleTester t(yamldata);
+ auto *symbol_file =
+ llvm::cast<SymbolFileDWARF>(t.GetModule()->GetSymbolFile());
+ DWARFUnit *unit = symbol_file->DebugInfo().GetUnitAtIndex(0);
+ ASSERT_TRUE(unit);
+
+ DWARFDIE subprogram = unit->DIE().GetFirstChild();
+ ASSERT_TRUE(subprogram);
+ dw_offset_t end_attr_offset;
+ DWARFFormValue form_value;
+ dw_offset_t offset = subprogram.GetDIE()->GetAttributeValue(
+ unit, DW_AT_object_pointer, form_value, &end_attr_offset);
+ EXPECT_EQ(form_value.Unsigned(), 5U);
+ EXPECT_GT(offset, 0U);
+ EXPECT_GT(end_attr_offset, 0U);
+}
+
struct GetAttributesTestFixture : public testing::TestWithParam<dw_attr_t> {};
TEST_P(GetAttributesTestFixture, TestGetAttributes_IterationOrder) {
|
adrian-prantl
approved these changes
Jun 23, 2025
Michael137
added a commit
that referenced
this pull request
Jun 23, 2025
miguelcsx
pushed a commit
to miguelcsx/llvm-project
that referenced
this pull request
Jun 23, 2025
…ARFDebugInfoEntry::GetAttributeValue (llvm#145328) `DWARFFormValue::ExtractValue` has nothing to extract for `DW_FORM_implicit_const` since the value is stored in the abbreviation. `DWARFFormValue` expects the user to have set the value of the implicit_const. This patch does so in `GetAttributeValue`.
llvm-sync bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Jun 23, 2025
…g of DW_AT_object_pointer (#144998) Starting with llvm/llvm-project#124790, Clang emits `DW_AT_object_pointer` encoded as integer constants rather than DIE references. This patch accounts for this. Depends on llvm/llvm-project#145328 and llvm/llvm-project#145126
Jaddyen
pushed a commit
to Jaddyen/llvm-project
that referenced
this pull request
Jun 23, 2025
…ARFDebugInfoEntry::GetAttributeValue (llvm#145328) `DWARFFormValue::ExtractValue` has nothing to extract for `DW_FORM_implicit_const` since the value is stored in the abbreviation. `DWARFFormValue` expects the user to have set the value of the implicit_const. This patch does so in `GetAttributeValue`.
Jaddyen
pushed a commit
to Jaddyen/llvm-project
that referenced
this pull request
Jun 23, 2025
…object_pointer (llvm#144998) Starting with llvm#124790, Clang emits `DW_AT_object_pointer` encoded as integer constants rather than DIE references. This patch accounts for this. Depends on llvm#145328 and llvm#145126
anthonyhatran
pushed a commit
to anthonyhatran/llvm-project
that referenced
this pull request
Jun 26, 2025
…ARFDebugInfoEntry::GetAttributeValue (llvm#145328) `DWARFFormValue::ExtractValue` has nothing to extract for `DW_FORM_implicit_const` since the value is stored in the abbreviation. `DWARFFormValue` expects the user to have set the value of the implicit_const. This patch does so in `GetAttributeValue`.
anthonyhatran
pushed a commit
to anthonyhatran/llvm-project
that referenced
this pull request
Jun 26, 2025
…object_pointer (llvm#144998) Starting with llvm#124790, Clang emits `DW_AT_object_pointer` encoded as integer constants rather than DIE references. This patch accounts for this. Depends on llvm#145328 and llvm#145126
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DWARFFormValue::ExtractValue
has nothing to extract forDW_FORM_implicit_const
since the value is stored in the abbreviation.DWARFFormValue
expects the user to have set the value of the implicit_const. This patch does so inGetAttributeValue
.