From 98747d97f089354091d115fb300006f3cc506a0c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 9 Jan 2020 13:39:53 -0800 Subject: DWARF support for multiple line tables (#2557) Multiple tables appear to be emitted when linking files together. This fixes our support for that, which did not update their size properly. This required patching the YAML emitting code from LLVM in order to measure the size and then emit it, as that code is apparently not designed to handle changes in line table contents. Other minor fixes: * Set the flags for our dwarfdump command to emit the same as llvm-dwarfdump does with -v -all. * Add support for a few more opcodes, set_discriminator, set_basic_block, fixed_advance_pc, set_isa. * Handle a compile unit without abbreviations in the YAML code (again, apparently not something this LLVM code was intended to do). * Handle a compile unit with zero entries in the YAML code (ditto). * Properly set the AddressSize - we use the DWARFContext in a different way than LLVM expects, apparently. With this the emscripten test suite passes with -gforce_dwarf without crashing. My overall impression so from the the YAML code is that it probably isn't a long-term solution for us. Perhaps it may end up being scaffolding, that is, we can replace it with our own code eventually that is based on it, and remove most of the LLVM code. Before deciding that we should get everything working first, and this seems like the quickest path there. --- third_party/llvm-project/dwarf2yaml.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'third_party/llvm-project/dwarf2yaml.cpp') diff --git a/third_party/llvm-project/dwarf2yaml.cpp b/third_party/llvm-project/dwarf2yaml.cpp index bdaf1e429..7d5f2e048 100644 --- a/third_party/llvm-project/dwarf2yaml.cpp +++ b/third_party/llvm-project/dwarf2yaml.cpp @@ -146,7 +146,9 @@ void dumpDebugInfo(DWARFContext &DCtx, DWARFYAML::Data &Y) { NewUnit.Version = CU->getVersion(); if(NewUnit.Version >= 5) NewUnit.Type = (dwarf::UnitType)CU->getUnitType(); - NewUnit.AbbrOffset = CU->getAbbreviations()->getOffset(); + if (auto* Abbreviations = CU->getAbbreviations()) { // XXX BINARYEN + NewUnit.AbbrOffset = Abbreviations->getOffset(); + } NewUnit.AddrSize = CU->getAddressByteSize(); for (auto DIE : CU->dies()) { DWARFYAML::Entry NewEntry; -- cgit v1.2.3