Commit cbf58a21 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari

Dwarf: Produce {low,high}_pc attributes for compilation units

Some libraries (e.g. elfutils) need these otherwise they ignore our
DWARF annotations.

Test Plan: Test with elfutils' `readelf --debug-dump=cu_index`

Reviewers: scpmw, austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1173
parent 81ae26d3
......@@ -30,6 +30,7 @@ import qualified Compiler.Hoopl as H
-- | Generate DWARF/debug information
dwarfGen :: DynFlags -> ModLocation -> UniqSupply -> [DebugBlock]
-> IO (SDoc, UniqSupply)
dwarfGen _ _ us [] = return (empty, us)
dwarfGen df modLoc us blocks = do
-- Convert debug data structures to DWARF info records
......@@ -43,6 +44,8 @@ dwarfGen df modLoc us blocks = do
, dwName = fromMaybe "" (ml_hs_file modLoc)
, dwCompDir = addTrailingPathSeparator compPath
, dwProducer = cProjectName ++ " " ++ cProjectVersion
, dwLowLabel = dblCLabel $ head procs
, dwHighLabel = mkAsmTempEndLabel $ dblCLabel $ last procs
, dwLineLabel = dwarfLineLabel
}
......@@ -57,7 +60,8 @@ dwarfGen df modLoc us blocks = do
let abbrevSct = pprAbbrevDecls haveSrc
-- .debug_info section: Information records on procedures and blocks
let (unitU, us') = takeUniqFromSupply us
let -- unique to identify start and end compilation unit .debug_inf
(unitU, us') = takeUniqFromSupply us
infoSct = vcat [ dwarfInfoSection
, compileUnitHeader unitU
, pprDwarfInfo haveSrc dwarfUnit
......
......@@ -44,6 +44,8 @@ data DwarfInfo
, dwName :: String
, dwProducer :: String
, dwCompDir :: String
, dwLowLabel :: CLabel
, dwHighLabel :: CLabel
, dwLineLabel :: LitString }
| DwarfSubprogram { dwChildren :: [DwarfInfo]
, dwName :: String
......@@ -82,6 +84,8 @@ pprAbbrevDecls haveDebugLine =
, (dW_AT_language, dW_FORM_data4)
, (dW_AT_comp_dir, dW_FORM_string)
, (dW_AT_use_UTF8, dW_FORM_flag_present) -- not represented in body
, (dW_AT_low_pc, dW_FORM_addr)
, (dW_AT_high_pc, dW_FORM_addr)
] ++
(if haveDebugLine
then [ (dW_AT_stmt_list, dW_FORM_data4) ]
......@@ -112,12 +116,15 @@ pprDwarfInfo haveSrc d
-- that the binary format of this is paramterized in @abbrevDecls@ and
-- has to be kept in synch.
pprDwarfInfoOpen :: Bool -> DwarfInfo -> SDoc
pprDwarfInfoOpen haveSrc (DwarfCompileUnit _ name producer compDir lineLbl) =
pprDwarfInfoOpen haveSrc (DwarfCompileUnit _ name producer compDir lowLabel
highLabel lineLbl) =
pprAbbrev DwAbbrCompileUnit
$$ pprString name
$$ pprString producer
$$ pprData4 dW_LANG_Haskell
$$ pprString compDir
$$ pprWord (ppr lowLabel)
$$ pprWord (ppr highLabel)
$$ if haveSrc
then sectionOffset lineLbl dwarfLineLabel
else empty
......
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