[PATCH] D28303: Add iterator support to DWARFDie to allow child DIE iteration.
Greg Clayton via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 5 14:35:28 PST 2017
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?
https://reviews.llvm.org/D28303
More information about the llvm-commits
mailing list