[PATCH] D28303: Add iterator support to DWARFDie to allow child DIE iteration.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 5 14:57:51 PST 2017


On Thu, Jan 5, 2017 at 2:35 PM Greg Clayton via Phabricator <
reviews at reviews.llvm.org> wrote:

> clayborg added inline comments.
>
>
> ================
> Comment at: unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp:1228
> +  // the DWARFDie::end() iterator.
> +  EXPECT_EQ(DWARFDie::iterator(Null), Null.end());
> +}
> ----------------
> It isn't possible with the DWARF APIs currently without adding code that
> no one would want.
>
> I was able to use DwarfGenerator to generate a DWARF file that was close
> that I saved to disk. I then used obj2yaml to make a yaml file, edited it
> and got what we need:
> ```
> --- !mach-o
> FileHeader:
>   magic:           0xFEEDFACF
>   cputype:         0x01000007
>   cpusubtype:      0x00000003
>   filetype:        0x00000001
>   ncmds:           2
>   sizeofcmds:      248
>   flags:           0x00000000
>   reserved:        0x00000000
> LoadCommands:
>   - cmd:             LC_SEGMENT_64
>     cmdsize:         232
>     segname:         ''
>     vmaddr:          0
>     vmsize:          27
>     fileoff:         280
>     filesize:        27
>     maxprot:         7
>     initprot:        7
>     nsects:          2
>     flags:           0
>     Sections:
>       - sectname:        __debug_abbrev
>         segname:         __DWARF
>         addr:            0x0000000000000000
>         size:            5
>         offset:          0x00000118
>         align:           0
>         reloff:          0x00000000
>         nreloc:          0
>         flags:           0x02000000
>         reserved1:       0x00000000
>         reserved2:       0x00000000
>         reserved3:       0x00000000
>       - sectname:        __debug_info
>         segname:         __DWARF
>         addr:            0x000000000000000D
>         size:            14
>         offset:          0x00000125
>         align:           0
>         reloff:          0x00000000
>         nreloc:          0
>         flags:           0x02000000
>         reserved1:       0x00000000
>         reserved2:       0x00000000
>         reserved3:       0x00000000
>   - cmd:             LC_VERSION_MIN_MACOSX
>     cmdsize:         16
>     version:         1048576
>     sdk:             0
> DWARF:
>   debug_abbrev:
>     - Code:            0x00000001
>       Tag:             DW_TAG_compile_unit
>       Children:        DW_CHILDREN_yes
>       Attributes:
>   debug_info:
>     - Length:          10
>       Version:         4
>       AbbrOffset:      0
>       AddrSize:        8
>       Entries:
>         - AbbrCode:        0x00000001
>           Values:
>         - AbbrCode:        0x00000000
>           Values:
> ...
> ```
>
> Are you OK if I have this text in a "const char *" variable and use the
> yaml2obj APIs to create an in memory file and then parse that DWARF and
> then test this? I can't really use FileCheck to test this internal
> iteration API. Let me know if you are ok with this approach?
>

Chris - any ideas here? This seems like a canonical example of the sort of
test coverage we want and neither of the directions being pursued seem to
be covering it.

Are there avenues in either that would help here?

Honestly I'd be OK expanding LLVM's DWARF generation APIs to support this -
but eventually for these parser tests we'll want to expand them to cover
invalid DWARF which will be harder to justify/express there, perhaps.

- Dave


>
>
> https://reviews.llvm.org/D28303
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170105/ed7c3026/attachment.html>


More information about the llvm-commits mailing list