aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorCarlos Alberto Enciso <Carlos.Enciso@sony.com>2024-11-28 05:21:47 +0000
committerGitHub <noreply@github.com>2024-11-28 05:21:47 +0000
commitfb3765959f2fcb97fbb2a247b619150926f0e0b6 (patch)
tree7e903d458360c635aa23105b349bf2d34611e378 /llvm/lib
parentf710b042336d93fd1080124d3ec889702b77a730 (diff)
downloadllvm-fb3765959f2fcb97fbb2a247b619150926f0e0b6.zip
llvm-fb3765959f2fcb97fbb2a247b619150926f0e0b6.tar.gz
llvm-fb3765959f2fcb97fbb2a247b619150926f0e0b6.tar.bz2
[llvm-debuginfo-analyzer] Common handling of unsigned attribute values. (#116027)
- In the DWARF reader, for those attributes that can have an unsigned value, allow for the following cases: * Is an implicit constant * Is an optional value - The testing is done by creating a file with generated DWARF, using `DwarfGenerator` (generate DWARF debug info for unit tests).
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
index 95d435b..a90c02f 100644
--- a/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
@@ -253,15 +253,18 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
// We are processing .debug_info section, implicit_const attribute
// values are not really stored here, but in .debug_abbrev section.
auto GetAsUnsignedConstant = [&]() -> int64_t {
- return AttrSpec.isImplicitConst() ? AttrSpec.getImplicitConstValue()
- : *FormValue.getAsUnsignedConstant();
+ if (AttrSpec.isImplicitConst())
+ return AttrSpec.getImplicitConstValue();
+ if (std::optional<uint64_t> Val = FormValue.getAsUnsignedConstant())
+ return *Val;
+ return 0;
};
auto GetFlag = [](const DWARFFormValue &FormValue) -> bool {
return FormValue.isFormClass(DWARFFormValue::FC_Flag);
};
- auto GetBoundValue = [](const DWARFFormValue &FormValue) -> int64_t {
+ auto GetBoundValue = [&AttrSpec](const DWARFFormValue &FormValue) -> int64_t {
switch (FormValue.getForm()) {
case dwarf::DW_FORM_ref_addr:
case dwarf::DW_FORM_ref1:
@@ -282,6 +285,8 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
return *FormValue.getAsUnsignedConstant();
case dwarf::DW_FORM_sdata:
return *FormValue.getAsSignedConstant();
+ case dwarf::DW_FORM_implicit_const:
+ return AttrSpec.getImplicitConstValue();
default:
return 0;
}
@@ -294,13 +299,13 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
switch (AttrSpec.Attr) {
case dwarf::DW_AT_accessibility:
- CurrentElement->setAccessibilityCode(*FormValue.getAsUnsignedConstant());
+ CurrentElement->setAccessibilityCode(GetAsUnsignedConstant());
break;
case dwarf::DW_AT_artificial:
CurrentElement->setIsArtificial();
break;
case dwarf::DW_AT_bit_size:
- CurrentElement->setBitSize(*FormValue.getAsUnsignedConstant());
+ CurrentElement->setBitSize(GetAsUnsignedConstant());
break;
case dwarf::DW_AT_call_file:
CurrentElement->setCallFilenameIndex(IncrementFileIndex
@@ -332,13 +337,12 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
Stream << hexString(Value, 2);
CurrentElement->setValue(Stream.str());
} else
- CurrentElement->setValue(
- hexString(*FormValue.getAsUnsignedConstant(), 2));
+ CurrentElement->setValue(hexString(GetAsUnsignedConstant(), 2));
} else
CurrentElement->setValue(dwarf::toStringRef(FormValue));
break;
case dwarf::DW_AT_count:
- CurrentElement->setCount(*FormValue.getAsUnsignedConstant());
+ CurrentElement->setCount(GetAsUnsignedConstant());
break;
case dwarf::DW_AT_decl_line:
CurrentElement->setLineNumber(GetAsUnsignedConstant());
@@ -357,10 +361,10 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
CurrentElement->setIsExternal();
break;
case dwarf::DW_AT_GNU_discriminator:
- CurrentElement->setDiscriminator(*FormValue.getAsUnsignedConstant());
+ CurrentElement->setDiscriminator(GetAsUnsignedConstant());
break;
case dwarf::DW_AT_inline:
- CurrentElement->setInlineCode(*FormValue.getAsUnsignedConstant());
+ CurrentElement->setInlineCode(GetAsUnsignedConstant());
break;
case dwarf::DW_AT_lower_bound:
CurrentElement->setLowerBound(GetBoundValue(FormValue));
@@ -380,7 +384,7 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
CurrentElement->setUpperBound(GetBoundValue(FormValue));
break;
case dwarf::DW_AT_virtuality:
- CurrentElement->setVirtualityCode(*FormValue.getAsUnsignedConstant());
+ CurrentElement->setVirtualityCode(GetAsUnsignedConstant());
break;
case dwarf::DW_AT_abstract_origin: