This is a follow-up of D66472, where the return value of DWARFUnit::getLength() was changed from uint32_t to uint64_t.
The test checks that a unit header with Length > 4G can be successfully parsed and the value of the Length field is not truncated.
Details
- Reviewers
dblaikie probinson aprantl MaskRay - Commits
- rGbc48588f764a: Reland [DWARF] Add a unit test for DWARFUnit::getLength().
rL371510: Reland [DWARF] Add a unit test for DWARFUnit::getLength().
rG3565c6b15c54: [DWARF] Add a unit test for DWARFUnit::getLength().
rL371499: [DWARF] Add a unit test for DWARFUnit::getLength().
Diff Detail
- Repository
- rL LLVM
Event Timeline
As written, this will work only for little-endian. There are other unittests that are bi-endian that you ought to be able to use for examples; if nothing else, bail out after checking sys::IsLittleEndianHost (but a bi-endian test would be better).
I'm not sure the host endianness is relevant here, though - the input data is hardcoded & the parsing hardcodes the endianness when it constructs the DWARFDataExtractor (the "true" parameter specifies little endian). So I /think/ this will work correctly/pass on a little or big endian host.
Testing both endiannesses seems unnecessary to me - since that's part of DataExtractor that's already/otherwise tested.
unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp | ||
---|---|---|
3169–3175 ↗ | (On Diff #219093) | This intermediate step seems unnecessary - DWARFContext is basically passing back the string you put into the map, right? So maybe skipping all that and building the DWARFSEction around the StringRef around DebugInfoSecRaw and passing that into the DWARFDataExtractor. |
unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp | ||
---|---|---|
3169–3175 ↗ | (On Diff #219093) | But we still need a DWARFContext to pass to Header.extract(), and we also need a DWARFObject to pass to DWARFDataExtractor, right? So, we can eliminate only the call to Obj.forEachInfoSection(), replacing it with an artificial DWARFSection, which does not seem much. |
Looks good to me - thanks!
unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp | ||
---|---|---|
3169–3175 ↗ | (On Diff #219093) | Ah, fair enough! |