<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 5, 2017 at 2:35 PM Greg Clayton via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">clayborg added inline comments.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
================<br class="gmail_msg">
Comment at: unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp:1228<br class="gmail_msg">
+  // the DWARFDie::end() iterator.<br class="gmail_msg">
+  EXPECT_EQ(DWARFDie::iterator(Null), Null.end());<br class="gmail_msg">
+}<br class="gmail_msg">
----------------<br class="gmail_msg">
It isn't possible with the DWARF APIs currently without adding code that no one would want.<br class="gmail_msg">
<br class="gmail_msg">
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:<br class="gmail_msg">
```<br class="gmail_msg">
--- !mach-o<br class="gmail_msg">
FileHeader:<br class="gmail_msg">
  magic:           0xFEEDFACF<br class="gmail_msg">
  cputype:         0x01000007<br class="gmail_msg">
  cpusubtype:      0x00000003<br class="gmail_msg">
  filetype:        0x00000001<br class="gmail_msg">
  ncmds:           2<br class="gmail_msg">
  sizeofcmds:      248<br class="gmail_msg">
  flags:           0x00000000<br class="gmail_msg">
  reserved:        0x00000000<br class="gmail_msg">
LoadCommands:<br class="gmail_msg">
  - cmd:             LC_SEGMENT_64<br class="gmail_msg">
    cmdsize:         232<br class="gmail_msg">
    segname:         ''<br class="gmail_msg">
    vmaddr:          0<br class="gmail_msg">
    vmsize:          27<br class="gmail_msg">
    fileoff:         280<br class="gmail_msg">
    filesize:        27<br class="gmail_msg">
    maxprot:         7<br class="gmail_msg">
    initprot:        7<br class="gmail_msg">
    nsects:          2<br class="gmail_msg">
    flags:           0<br class="gmail_msg">
    Sections:<br class="gmail_msg">
      - sectname:        __debug_abbrev<br class="gmail_msg">
        segname:         __DWARF<br class="gmail_msg">
        addr:            0x0000000000000000<br class="gmail_msg">
        size:            5<br class="gmail_msg">
        offset:          0x00000118<br class="gmail_msg">
        align:           0<br class="gmail_msg">
        reloff:          0x00000000<br class="gmail_msg">
        nreloc:          0<br class="gmail_msg">
        flags:           0x02000000<br class="gmail_msg">
        reserved1:       0x00000000<br class="gmail_msg">
        reserved2:       0x00000000<br class="gmail_msg">
        reserved3:       0x00000000<br class="gmail_msg">
      - sectname:        __debug_info<br class="gmail_msg">
        segname:         __DWARF<br class="gmail_msg">
        addr:            0x000000000000000D<br class="gmail_msg">
        size:            14<br class="gmail_msg">
        offset:          0x00000125<br class="gmail_msg">
        align:           0<br class="gmail_msg">
        reloff:          0x00000000<br class="gmail_msg">
        nreloc:          0<br class="gmail_msg">
        flags:           0x02000000<br class="gmail_msg">
        reserved1:       0x00000000<br class="gmail_msg">
        reserved2:       0x00000000<br class="gmail_msg">
        reserved3:       0x00000000<br class="gmail_msg">
  - cmd:             LC_VERSION_MIN_MACOSX<br class="gmail_msg">
    cmdsize:         16<br class="gmail_msg">
    version:         1048576<br class="gmail_msg">
    sdk:             0<br class="gmail_msg">
DWARF:<br class="gmail_msg">
  debug_abbrev:<br class="gmail_msg">
    - Code:            0x00000001<br class="gmail_msg">
      Tag:             DW_TAG_compile_unit<br class="gmail_msg">
      Children:        DW_CHILDREN_yes<br class="gmail_msg">
      Attributes:<br class="gmail_msg">
  debug_info:<br class="gmail_msg">
    - Length:          10<br class="gmail_msg">
      Version:         4<br class="gmail_msg">
      AbbrOffset:      0<br class="gmail_msg">
      AddrSize:        8<br class="gmail_msg">
      Entries:<br class="gmail_msg">
        - AbbrCode:        0x00000001<br class="gmail_msg">
          Values:<br class="gmail_msg">
        - AbbrCode:        0x00000000<br class="gmail_msg">
          Values:<br class="gmail_msg">
...<br class="gmail_msg">
```<br class="gmail_msg">
<br class="gmail_msg">
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?<br class="gmail_msg"></blockquote><div><br>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.<br><br>Are there avenues in either that would help here?<br><br>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.<br><br>- Dave<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D28303" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D28303</a><br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div></div>