summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/GHC/CmmToAsm.hs5
-rw-r--r--compiler/GHC/CmmToAsm/Config.hs1
-rw-r--r--compiler/GHC/CmmToAsm/Dwarf.hs13
-rw-r--r--docs/users_guide/debug-info.rst5
4 files changed, 16 insertions, 8 deletions
diff --git a/compiler/GHC/CmmToAsm.hs b/compiler/GHC/CmmToAsm.hs
index 223eb33fb5..013ad24554 100644
--- a/compiler/GHC/CmmToAsm.hs
+++ b/compiler/GHC/CmmToAsm.hs
@@ -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
}
diff --git a/compiler/GHC/CmmToAsm/Config.hs b/compiler/GHC/CmmToAsm/Config.hs
index 141f1168be..8acd089757 100644
--- a/compiler/GHC/CmmToAsm/Config.hs
+++ b/compiler/GHC/CmmToAsm/Config.hs
@@ -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
diff --git a/compiler/GHC/CmmToAsm/Dwarf.hs b/compiler/GHC/CmmToAsm/Dwarf.hs
index d81bcd4f2e..7e03549b24 100644
--- a/compiler/GHC/CmmToAsm/Dwarf.hs
+++ b/compiler/GHC/CmmToAsm/Dwarf.hs
@@ -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
diff --git a/docs/users_guide/debug-info.rst b/docs/users_guide/debug-info.rst
index b1636bb81f..42afa9078f 100644
--- a/docs/users_guide/debug-info.rst
+++ b/docs/users_guide/debug-info.rst
@@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~