[PATCH] D67276: [DWARF] Add a unit test for DWARFUnit::getLength().
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 13:46:15 PDT 2019
dblaikie added a comment.
In D67276#1661066 <https://reviews.llvm.org/D67276#1661066>, @probinson wrote:
> 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.
================
Comment at: unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp:3169-3175
+ StringMap<std::unique_ptr<MemoryBuffer>> Sections;
+ Sections.insert(std::make_pair(
+ "debug_info", MemoryBuffer::getMemBuffer(
+ StringRef(DebugInfoSecRaw, sizeof(DebugInfoSecRaw)))));
+ auto Context = DWARFContext::create(Sections, 8, true);
+ const auto &Obj = Context->getDWARFObj();
+ Obj.forEachInfoSections([&](const DWARFSection &Sec) {
----------------
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.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67276/new/
https://reviews.llvm.org/D67276
More information about the llvm-commits
mailing list