[RFC] Generate .debug_ghc section
AbandonedPublic

Authored by bgamari on Sep 4 2015, 5:29 AM.

Details

Reviewers
scpmw
austin
Summary

This patch was rebased and amended from @scpmw's profiling-ncg branch and will be built upon by D1215 to implement a simple statistical profiler with visibility into Core.

The conversion to DWARF is always lossy, so we put all the extra
bits of information into an extra object file section (.debug-ghc).

Notes:

  • We use the eventlog format. This might seem like a slightly arbitrary choice, but makes it easy to copy debug data into the eventlog later in order to do profiling. In the meantime, it's well-defined and extensible, so until we run out of record IDs there's no strong reason against it either.
  • Core notes now cause the complete Core to be copied. We are reasonably smart about this: We never emit a piece of Core twice, and use a compact binary representation for most Core constructors.

    On the other hand, we just pretty-print types as well as names and emit them as strings. This can sometimes lead to packets becoming too large for the eventlog format to handle (we had types break the 20k loc mark). In order to not run into these kinds of problems, we just omit packets that are longer than a certain threshold.
  • The amount of data generated here is significant. We therefore use faily low-level generation code using memory buffers. Furthermore, we include the data as a string, escaped using another well-optimized low-level routine. All this might make it hard to read debug data in the assembly, but is absolutely required for debugging not to become a significant resource hog.
  • The eventlog IDs used here were chosen primarily to avoid collisions. If this code gets merged they should be adjusted appropriately.

Depends on D1213.

Future Work

  • Compress .debug_ghc section to reduce file sizes
  • Document format of produced event log records.

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Lint WarningsExcuse: I'll fix it
SeverityLocationCodeMessage
Warningcompiler/nativeGen/Debug/GhcDebug.hs:39TXT3Line Too Long
Warningcompiler/nativeGen/Debug/GhcDebug.hs:141TXT3Line Too Long
Warningcompiler/nativeGen/Debug/GhcDebug.hs:144TXT3Line Too Long
Warningcompiler/nativeGen/Debug/GhcDebug.hs:152TXT3Line Too Long
Warningcompiler/nativeGen/Debug/GhcDebug.hs:182TXT3Line Too Long
Warningcompiler/nativeGen/Dwarf/Types.hs:519TXT3Line Too Long
Unit
No Unit Test Coverage
Build Status
Buildable 5510
Build 5924: GHC Patch Validation (amd64/Linux)
Build 5923: arc lint + arc unit
bgamari updated this revision to Diff 4063.Sep 4 2015, 5:29 AM
bgamari retitled this revision from to Generate .debug_ghc section.
bgamari updated this object.
bgamari edited the test plan for this revision. (Show Details)
bgamari added a reviewer: scpmw.
bgamari added a parent revision: D1213: [RFC] Core notes.
bgamari retitled this revision from Generate .debug_ghc section to [RFC] Generate .debug_ghc section.Sep 4 2015, 5:40 AM
bgamari edited edge metadata.
bgamari updated this object.Sep 4 2015, 7:25 AM
bgamari updated this object.
bgamari abandoned this revision.Sep 26 2015, 11:40 AM

This will likely be superceded by D1280.