[Lldb-commits] FreeBSD kernel debugging fixes

Koropoff, Brian via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 20 15:41:17 PDT 2017


Greetings.  I'm submitting a few patches that resolve issues I
encountered when using lldb to symbolicate FreeBSD kernel backtraces.
The problems mostly centered around FreeBSD kernel modules actually
being relocatable (.o) ELF Files.

The major problems:

- Relocations were not being applied to the DWARF debug info despite
  there being code to do this.  Several issues prevented it from working:

  * Relocations are computed at the same time as the symbol table, but
    in the case of split debug files, symbol table parsing always
    redirects to the primary object file, meaning that relocations
    would never be applied in the debug file.

  * There's actually no guarantee that the symbol table has been
    parsed yet when trying to parse debug information.

  * When actually applying relocations, it will segfault because the
    object files are not mapped with MAP_PRIVATE and PROT_WRITE.

- LLDB returned invalid results when performing ordinary
  address-to-symbol resolution. It turned out that the addresses
  specified in the section headers were all 0, so LLDB believed all the
  sections had overlapping "file addresses" and would sometimes
  return a symbol from the wrong section.

I rearranged some of the symbol table parsing code to ensure
relocations would get applied consistently and added manual calls to
make sure it happens before trying to use DWARF info, but it feels
kind of hacky.  I'm open to suggestions for refactoring it.

I solved the file address problem by computing synthetic addresses for
the sections in object files so that they would not overlap in LLDB's
lookup maps.

With all these changes I'm able to successfully symbolicate backtraces
that pass through FreeBSD kernel modules.  Let me know if there is a
better/cleaner way to achieve any of these fixes.

--

Brian Koropoff
Dell EMC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20170920/dae0854e/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ObjectFile-ELF-use-private-memory-mappings.patch
Type: text/x-patch
Size: 1557 bytes
Desc: 0001-ObjectFile-ELF-use-private-memory-mappings.patch
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20170920/dae0854e/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-ObjectFile-ELF-ensure-relocations-are-done-for-split.patch
Type: text/x-patch
Size: 4834 bytes
Desc: 0002-ObjectFile-ELF-ensure-relocations-are-done-for-split.patch
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20170920/dae0854e/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-SymbolFile-DWARF-force-application-of-relocations.patch
Type: text/x-patch
Size: 1061 bytes
Desc: 0003-SymbolFile-DWARF-force-application-of-relocations.patch
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20170920/dae0854e/attachment-0006.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-ObjectFile-ELF-create-synthetic-file-addresses-for-r.patch
Type: text/x-patch
Size: 3911 bytes
Desc: 0004-ObjectFile-ELF-create-synthetic-file-addresses-for-r.patch
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20170920/dae0854e/attachment-0007.bin>


More information about the lldb-commits mailing list