[Lldb-commits] [PATCH] D107470: 2/3: [llvm+lldb] Remove dead-code in DWARFListTableHeader::extract modifying DWARFDataExtractor

Jan Kratochvil via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 12 09:22:32 PDT 2021


jankratochvil marked an inline comment as done.
jankratochvil added inline comments.


================
Comment at: llvm/unittests/DebugInfo/DWARF/DWARFListTableTest.cpp:128
+  EXPECT_EQ(Table.getAddrSize(), 8U);
+  Extractor.setAddressSize(Table.getAddrSize());
+  Expected<DWARFDebugRnglist> List = Table.findList(Extractor, Offset);
----------------
ikudrin wrote:
> This looks odd. `DWARFListTableBase::findList()` should not require the setting to be done in the calling code if it can apply it itself. 
I agree but as I have found it is not so simple. `findList` is being used also with uninitialized headers: [[ https://github.com/llvm/llvm-project/blob/e4977f9cb58ff7820d0287ba309490af57787749/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp#L619 | llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp DWARFUnit::findRnglistFromOffset ]]
So I had to implement `DWARFListTableBase::setAddrSize` which is a bit ugly. One cannot find appropriate `.debug_loclists` header just for the requested `offset` without `DW_AT_rnglists_base` which may be missing, that is what D106466 is about. Or one could use `DWARFListTableHeader::create` from that patch but that looks to me as too much complicated.

In fact the codebase is already designed so that caller has to prepare proper `DWARFDataExtractor` - `llvm::DWARFDebugLoclists` and `llvm::DWARFDebugLoc` also rely on it, I tried to implement this callee approach for them as: https://www.jankratochvil.net/t/gccoffset1-2-2b.patch
But I am not going to submit it as one either has to provide address size to both `DWARFDataExtractor` and `llvm::DWARFDebugLoc*` constructors or otherwise `DWARFDataExtractor` would have unset address size (implemented in the patch) which is also a bit ugly.

So personally I would choose the previous patch but I am fine also with this patch.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107470/new/

https://reviews.llvm.org/D107470



More information about the lldb-commits mailing list