[llvm] r355233 - [DWARFFormValue] Cleanup DWARFFormValue interface. (2/2) (NFC)
Vlad Tsyrklevich via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 1 17:09:25 PST 2019
Jonas, I reverted this change in r355255 as it caused UBSan failures
<http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/30050/steps/check-llvm%20ubsan/logs/stdio>
:
[ RUN ] LineTableTestParams/DebugLineParameterisedFixture.GetOrParseLineTableValidTable/3
/b/sanitizer-x86_64-linux-fast/build/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp:218:42:
runtime error: reference binding to null pointer of type 'const
llvm::DWARFUnit'
#0 0x1792018 in parseV5DirFileTables
/b/sanitizer-x86_64-linux-fast/build/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp:217:38
#1 0x1792018 in
llvm::DWARFDebugLine::Prologue::parse(llvm::DWARFDataExtractor const&,
unsigned int*, llvm::DWARFContext const&, llvm::DWARFUnit const*)
/b/sanitizer-x86_64-linux-fast/build/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp:323
#2 0x179357b in
llvm::DWARFDebugLine::LineTable::parse(llvm::DWARFDataExtractor&,
unsigned int*, llvm::DWARFContext const&, llvm::DWARFUnit const*,
std::function<void (llvm::Error)>, llvm::raw_ostream*)
/b/sanitizer-x86_64-linux-fast/build/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp:482:32
#3 0x17931ea in
llvm::DWARFDebugLine::getOrParseLineTable(llvm::DWARFDataExtractor&,
unsigned int, llvm::DWARFContext const&, llvm::DWARFUnit const*,
std::function<void (llvm::Error)>)
/b/sanitizer-x86_64-linux-fast/build/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp:467:17
#4 0x4ecbfa in (anonymous
namespace)::DebugLineParameterisedFixture_GetOrParseLineTableValidTable_Test::TestBody()
/b/sanitizer-x86_64-linux-fast/build/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp:247:33
#5 0x1993db6 in testing::Test::Run()
/b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2474:5
#6 0x1994ef3 in testing::TestInfo::Run()
/b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
#7 0x19958d2 in testing::TestCase::Run()
/b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
#8 0x199d2c2 in testing::internal::UnitTestImpl::RunAllTests()
/b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
#9 0x199cd06 in testing::UnitTest::Run()
/b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4257:10
#10 0x198c5b7 in RUN_ALL_TESTS
/b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
#11 0x198c5b7 in main
/b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50
#12 0x7f315bb802e0 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
#13 0x4474f9 in _start
(/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/unittests/DebugInfo/DWARF/DebugInfoDWARFTests+0x4474f9)
On Fri, Mar 1, 2019 at 2:25 PM Jonas Devlieghere via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: jdevlieghere
> Date: Fri Mar 1 14:14:24 2019
> New Revision: 355233
>
> URL: http://llvm.org/viewvc/llvm-project?rev=355233&view=rev
> Log:
> [DWARFFormValue] Cleanup DWARFFormValue interface. (2/2) (NFC)
>
> Continues the work started in r354941. Changes (all but one) uses of the
> extractValue to static createFromData.
>
> Modified:
> llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
> llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
> llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
> llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp
> llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp
> llvm/trunk/tools/dsymutil/DwarfLinker.cpp
>
> Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h?rev=355233&r1=355232&r2=355233&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h Fri Mar 1
> 14:14:24 2019
> @@ -61,6 +61,10 @@ private:
>
> DWARFFormValue(dwarf::Form F, ValueType V) : Form(F), Value(V) {}
>
> + bool extractValue(const DWARFDataExtractor &Data, uint32_t *OffsetPtr,
> + dwarf::FormParams FormParams, const DWARFUnit *Unit,
> + const DWARFContext *Ctx);
> +
> public:
> DWARFFormValue(dwarf::Form F = dwarf::Form(0)) : Form(F) {}
>
> @@ -69,8 +73,13 @@ public:
> static DWARFFormValue createFromPValue(dwarf::Form F, const char *V);
> static DWARFFormValue createFromBlockValue(dwarf::Form F,
> ArrayRef<uint8_t> D);
> - static DWARFFormValue createFromUnit(dwarf::Form F, const DWARFUnit
> *Unit,
> - uint32_t *OffsetPtr);
> +
> + /// Creates a from value from the given data. The DWARF context form
> the unit
> + /// is used, unless one is provided explicitly.
> + static DWARFFormValue
> + createFromData(dwarf::Form F, dwarf::FormParams FormParams,
> + const DWARFUnit &U, const DWARFDataExtractor &Data,
> + uint32_t *OffsetPtr, const DWARFContext *Ctx = nullptr);
>
> dwarf::Form getForm() const { return Form; }
> uint64_t getRawUValue() const { return Value.uval; }
> @@ -83,18 +92,10 @@ public:
> static void dumpAddressSection(const DWARFObject &Obj, raw_ostream &OS,
> DIDumpOptions DumpOpts, uint64_t
> SectionIndex);
>
> - /// Extracts a value in \p Data at offset \p *OffsetPtr. The information
> - /// in \p FormParams is needed to interpret some forms. The optional
> - /// \p Context and \p Unit allows extracting information if the form
> refers
> - /// to other sections (e.g., .debug_str).
> - bool extractValue(const DWARFDataExtractor &Data, uint32_t *OffsetPtr,
> - dwarf::FormParams FormParams,
> - const DWARFContext *Context = nullptr,
> - const DWARFUnit *Unit = nullptr);
> -
> + /// Legacy interface for initializing a DWARFFormValue from data.
> bool extractValue(const DWARFDataExtractor &Data, uint32_t *OffsetPtr,
> - dwarf::FormParams FormParams, const DWARFUnit *U) {
> - return extractValue(Data, OffsetPtr, FormParams, nullptr, U);
> + dwarf::FormParams FormParams) {
> + return extractValue(Data, OffsetPtr, FormParams, nullptr, nullptr);
> }
>
> bool isInlinedCStr() const {
> @@ -116,20 +117,6 @@ public:
>
> /// Skip a form's value in \p DebugInfoData at the offset specified by
> /// \p OffsetPtr.
> - ///
> - /// Skips the bytes for the current form and updates the offset.
> - ///
> - /// \param DebugInfoData The data where we want to skip the value.
> - /// \param OffsetPtr A reference to the offset that will be updated.
> - /// \param Params DWARF parameters to help interpret forms.
> - /// \returns true on success, false if the form was not skipped.
> - bool skipValue(DataExtractor DebugInfoData, uint32_t *OffsetPtr,
> - const dwarf::FormParams Params) const {
> - return DWARFFormValue::skipValue(Form, DebugInfoData, OffsetPtr,
> Params);
> - }
> -
> - /// Skip a form's value in \p DebugInfoData at the offset specified by
> - /// \p OffsetPtr.
> ///
> /// Skips the bytes for the specified form and updates the offset.
> ///
>
> Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp?rev=355233&r1=355232&r2=355233&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
> (original)
> +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp Fri
> Mar 1 14:14:24 2019
> @@ -166,10 +166,8 @@ Optional<DWARFFormValue> DWARFAbbreviati
> if (Spec.isImplicitConst())
> return DWARFFormValue::createFromSValue(Spec.Form,
>
> Spec.getImplicitConstValue());
> -
> - DWARFFormValue FormValue(Spec.Form);
> - if (FormValue.extractValue(DebugInfoData, &Offset,
> U.getFormParams(), &U))
> - return FormValue;
> + return DWARFFormValue::createFromData(Spec.Form, U.getFormParams(),
> U,
> + U.getDebugInfoExtractor(),
> &Offset);
> }
> // March Offset along until we get to the attribute we want.
> if (auto FixedSize = Spec.getByteSize(U))
>
> Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp?rev=355233&r1=355232&r2=355233&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp Fri Mar 1 14:14:24
> 2019
> @@ -212,15 +212,14 @@ parseV5DirFileTables(const DWARFDataExtr
> if (*OffsetPtr >= EndPrologueOffset)
> return false;
> for (auto Descriptor : DirDescriptors) {
> - DWARFFormValue Value(Descriptor.Form);
> switch (Descriptor.Type) {
> case DW_LNCT_path:
> - if (!Value.extractValue(DebugLineData, OffsetPtr, FormParams,
> &Ctx, U))
> - return false;
> - IncludeDirectories.push_back(Value);
> + IncludeDirectories.push_back(DWARFFormValue::createFromData(
> + Descriptor.Form, FormParams, *U, DebugLineData, OffsetPtr,
> &Ctx));
> break;
> default:
> - if (!Value.skipValue(DebugLineData, OffsetPtr, FormParams))
> + if (!DWARFFormValue::skipValue(Descriptor.Form, DebugLineData,
> + OffsetPtr, FormParams))
> return false;
> }
> }
> @@ -240,9 +239,8 @@ parseV5DirFileTables(const DWARFDataExtr
> return false;
> DWARFDebugLine::FileNameEntry FileEntry;
> for (auto Descriptor : FileDescriptors) {
> - DWARFFormValue Value(Descriptor.Form);
> - if (!Value.extractValue(DebugLineData, OffsetPtr, FormParams, &Ctx,
> U))
> - return false;
> + DWARFFormValue Value = DWARFFormValue::createFromData(
> + Descriptor.Form, FormParams, *U, DebugLineData, OffsetPtr,
> &Ctx);
> switch (Descriptor.Type) {
> case DW_LNCT_path:
> FileEntry.Name = Value;
>
> Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp?rev=355233&r1=355232&r2=355233&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp Fri Mar 1 14:14:24 2019
> @@ -278,7 +278,8 @@ static void dumpAttribute(raw_ostream &O
> OS << formatv(" [{0}]", Form);
>
> DWARFUnit *U = Die.getDwarfUnit();
> - DWARFFormValue FormValue = DWARFFormValue::createFromUnit(Form, U,
> OffsetPtr);
> + DWARFFormValue FormValue = DWARFFormValue::createFromData(
> + Form, U->getFormParams(), *U, U->getDebugInfoExtractor(),
> OffsetPtr);
>
> OS << "\t(";
>
> @@ -686,8 +687,9 @@ void DWARFDie::attribute_iterator::updat
> uint32_t ParseOffset = AttrValue.Offset;
> auto U = Die.getDwarfUnit();
> assert(U && "Die must have valid DWARF unit");
> - AttrValue.Value = DWARFFormValue::createFromUnit(
> - AbbrDecl.getFormByIndex(Index), U, &ParseOffset);
> + AttrValue.Value = DWARFFormValue::createFromData(
> + AbbrDecl.getFormByIndex(Index), U->getFormParams(), *U,
> + U->getDebugInfoExtractor(), &ParseOffset);
> AttrValue.ByteSize = ParseOffset - AttrValue.Offset;
> } else {
> assert(Index == NumAttrs && "Indexes should be [0, NumAttrs) only");
>
> Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp?rev=355233&r1=355232&r2=355233&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp Fri Mar 1 14:14:24
> 2019
> @@ -97,11 +97,14 @@ DWARFFormValue DWARFFormValue::createFro
> return DWARFFormValue(F, V);
> }
>
> -DWARFFormValue DWARFFormValue::createFromUnit(dwarf::Form F, const
> DWARFUnit *U,
> - uint32_t *OffsetPtr) {
> +DWARFFormValue DWARFFormValue::createFromData(dwarf::Form F,
> + dwarf::FormParams
> FormParams,
> + const DWARFUnit &U,
> + const DWARFDataExtractor
> &Data,
> + uint32_t *OffsetPtr,
> + const DWARFContext *Ctx) {
> DWARFFormValue FormValue(F);
> - FormValue.extractValue(U->getDebugInfoExtractor(), OffsetPtr,
> - U->getFormParams(), U);
> + FormValue.extractValue(Data, OffsetPtr, FormParams, &U, Ctx);
> return FormValue;
> }
>
> @@ -231,8 +234,8 @@ bool DWARFFormValue::isFormClass(DWARFFo
>
> bool DWARFFormValue::extractValue(const DWARFDataExtractor &Data,
> uint32_t *OffsetPtr, dwarf::FormParams
> FP,
> - const DWARFContext *Ctx,
> - const DWARFUnit *CU) {
> + const DWARFUnit *CU,
> + const DWARFContext *Ctx) {
> if (!Ctx && CU)
> Ctx = &CU->getContext();
> C = Ctx;
>
> Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=355233&r1=355232&r2=355233&view=diff
>
> ==============================================================================
> --- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)
> +++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Fri Mar 1 14:14:24 2019
> @@ -584,7 +584,7 @@ unsigned DwarfLinker::shouldKeepVariable
> MyInfo.InDebugMap = true;
> return Flags | TF_Keep;
> }
> -
> +
> Optional<uint32_t> LocationIdx =
> Abbrev->findAttributeIndex(dwarf::DW_AT_location);
> if (!LocationIdx)
> @@ -754,7 +754,9 @@ void DwarfLinker::keepDIEAndDependencies
> continue;
> }
>
> - Val.extractValue(Data, &Offset, Unit.getFormParams(), &Unit);
> + Val = DWARFFormValue::createFromData(AttrSpec.Form,
> Unit.getFormParams(),
> + Unit,
> Unit.getDebugInfoExtractor(),
> + &Offset);
> CompileUnit *ReferencedCU;
> if (auto RefDie = resolveDIEReference(*this, DMO, Units, Val, Unit,
> Die,
> ReferencedCU)) {
> @@ -1552,9 +1554,9 @@ DIE *DwarfLinker::DIECloner::cloneDIE(
> continue;
> }
>
> - DWARFFormValue Val(AttrSpec.Form);
> uint32_t AttrSize = Offset;
> - Val.extractValue(Data, &Offset, U.getFormParams(), &U);
> + DWARFFormValue Val = DWARFFormValue::createFromData(
> + AttrSpec.Form, U.getFormParams(), U, Data, &Offset);
> AttrSize = Offset - AttrSize;
>
> OutOffset += cloneAttribute(*Die, InputDIE, DMO, Unit, StringPool,
> Val,
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190301/5c110a3c/attachment-0001.html>
More information about the llvm-commits
mailing list