Commit 1e19183d authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot

nativeGen/dwarf: Only produce DW_AT_source_note DIEs in -g3

Standard debugging tools don't know how to understand these so let's not
produce them unless asked.
parent 0a7e592c
......@@ -1187,9 +1187,10 @@ initNCGConfig dflags this_mod = NCGConfig
ArchX86 -> v
_ -> Nothing
, ncgDwarfEnabled = debugLevel dflags > 0
, ncgDwarfEnabled = debugLevel dflags > 0
, ncgDwarfUnwindings = debugLevel dflags >= 1
, ncgDwarfStripBlockInfo = debugLevel dflags < 2 -- We strip out block information when running with -g0 or -g1.
, ncgExposeInternalSymbols = gopt Opt_ExposeInternalSymbols dflags
, ncgDwarfStripBlockInfo = debugLevel dflags < 2 -- We strip out block information when running with -g0 or -g1.
, ncgDwarfSourceNotes = debugLevel dflags >= 3 -- We produce GHC-specific source-note DIEs only with -g3
}
......@@ -40,6 +40,7 @@ data NCGConfig = NCGConfig
, ncgDwarfUnwindings :: !Bool -- ^ Enable unwindings
, ncgDwarfStripBlockInfo :: !Bool -- ^ Strip out block information from generated Dwarf
, ncgExposeInternalSymbols :: !Bool -- ^ Expose symbol table entries for internal symbols
, ncgDwarfSourceNotes :: !Bool -- ^ Enable GHC-specific source note DIEs
}
-- | Return Word size
......
......@@ -176,7 +176,7 @@ parent, B.
-- | Generate DWARF info for a procedure debug block
procToDwarf :: NCGConfig -> DebugBlock -> DwarfInfo
procToDwarf config prc
= DwarfSubprogram { dwChildren = map blockToDwarf (dblBlocks prc)
= DwarfSubprogram { dwChildren = map (blockToDwarf config) (dblBlocks prc)
, dwName = case dblSourceTick prc of
Just s@SourceNote{} -> sourceName s
_otherwise -> show (dblLabel prc)
......@@ -195,14 +195,17 @@ procToDwarf config prc
goodParent _ = True
-- | Generate DWARF info for a block
blockToDwarf :: DebugBlock -> DwarfInfo
blockToDwarf blk
= DwarfBlock { dwChildren = concatMap tickToDwarf (dblTicks blk)
++ map blockToDwarf (dblBlocks blk)
blockToDwarf :: NCGConfig -> DebugBlock -> DwarfInfo
blockToDwarf config blk
= DwarfBlock { dwChildren = map (blockToDwarf config) (dblBlocks blk) ++ srcNotes
, dwLabel = dblCLabel blk
, dwMarker = marker
}
where
srcNotes
| ncgDwarfSourceNotes config = concatMap tickToDwarf (dblTicks blk)
| otherwise = []
marker
| Just _ <- dblPosition blk = Just $ mkAsmTempLabel $ dblLabel blk
| otherwise = Nothing -- block was optimized out
......
......@@ -24,7 +24,9 @@ useable by most UNIX debugging tools.
* ``-g1``: produces stack unwinding records for top-level functions (sufficient for basic backtraces)
* ``-g2``: produces stack unwinding records for top-level functions as well
as inner blocks (allowing more precise backtraces than with ``-g1``).
* ``-g3``: same as ``-g2``.
* ``-g3``: produces GHC-specific DWARF information for use by more
sophisticated Haskell-aware debugging tools (see :ref:`dwarf-dies` for
details)
If ⟨n⟩ is omitted, level 2 is assumed.
......@@ -266,6 +268,7 @@ In particular GHC produces the following DWARF sections,
``.debug_arange``
Address range information necessary for efficient lookup in debug information.
.. _dwarf_dies:
Debugging information entities
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment