[llvm] r240701 - dsymutil: Split out patchStmtList(), NFC

David Blaikie dblaikie at gmail.com
Thu Jun 25 15:16:13 PDT 2015


On Thu, Jun 25, 2015 at 2:42 PM, Duncan P. N. Exon Smith <
dexonsmith at apple.com> wrote:

> Author: dexonsmith
> Date: Thu Jun 25 16:42:46 2015
> New Revision: 240701
>
> URL: http://llvm.org/viewvc/llvm-project?rev=240701&view=rev
> Log:
> dsymutil: Split out patchStmtList(), NFC
>
> Split out code to patch up the `DW_AT_stmt_list` for the cloned DIE, and
> reorganize it so that it doesn't depend on `DIE::values_begin()` and
> `DIE::values_end()` (which I'm trying to kill off).
>
> David Blaikie and I talked about adding a range-algorithm version of
> `std::find_if()`, but the assertion *still* required getting at the end
> iterator.  IMO, a separate helper function with an early return is
> easier to reason about here.
>

I don't much mind an I == x.values().end(), but this does get into the more
interesting range-based algorithm design... find_if could return a trimmed
range (move the beginning of the range up to the first found item) and you
just test if it it's !empty(r). But then we have to wonder if different
names are needed for those algorithms... blah. blah. I haven't followed the
standards committee enough to know where the range proposals are going
there.


>
> A follow-up commit that removes `DIE::setValue()` and mutates the
> `DIEValue` directly is coming shortly.
>
> Modified:
>     llvm/trunk/tools/dsymutil/DwarfLinker.cpp
>
> Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=240701&r1=240700&r2=240701&view=diff
>
> ==============================================================================
> --- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)
> +++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Thu Jun 25 16:42:46 2015
> @@ -2364,6 +2364,17 @@ static void insertLineSequence(std::vect
>    Seq.clear();
>  }
>
> +static void patchStmtList(DIE &Die, DIEInteger Offset) {
> +  for (auto &V : Die.values())
> +    if (V.getAttribute() == dwarf::DW_AT_stmt_list) {
> +      Die.setValue(&V - Die.values_begin(),
> +                   DIEValue(V.getAttribute(), V.getForm(), Offset));
> +      return;
> +    }
> +
> +  llvm_unreachable("Didn't find DW_AT_stmt_list in cloned DIE!");
> +}
> +
>  /// \brief Extract the line table for \p Unit from \p OrigDwarf, and
>  /// recreate a relocated version of these for the address ranges that
>  /// are present in the binary.
> @@ -2376,18 +2387,8 @@ void DwarfLinker::patchLineTableForUnit(
>      return;
>
>    // Update the cloned DW_AT_stmt_list with the correct debug_line offset.
> -  if (auto *OutputDIE = Unit.getOutputUnitDIE()) {
> -    auto Stmt =
> -        std::find_if(OutputDIE->values_begin(), OutputDIE->values_end(),
> -                     [](const DIEValue &Value) {
> -                       return Value.getAttribute() ==
> dwarf::DW_AT_stmt_list;
> -                     });
> -    assert(Stmt != OutputDIE->values_end() &&
> -           "Didn't find DW_AT_stmt_list in cloned DIE!");
> -    OutputDIE->setValue(Stmt - OutputDIE->values_begin(),
> -                        DIEValue(Stmt->getAttribute(), Stmt->getForm(),
> -
>  DIEInteger(Streamer->getLineSectionSize())));
> -  }
> +  if (auto *OutputDIE = Unit.getOutputUnitDIE())
> +    patchStmtList(*OutputDIE, DIEInteger(Streamer->getLineSectionSize()));
>
>    // Parse the original line info for the unit.
>    DWARFDebugLine::LineTable LineTable;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150625/4fef8f10/attachment.html>


More information about the llvm-commits mailing list