summaryrefslogtreecommitdiff
path: root/compiler/nativeGen/Dwarf.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/nativeGen/Dwarf.hs')
-rw-r--r--compiler/nativeGen/Dwarf.hs28
1 files changed, 18 insertions, 10 deletions
diff --git a/compiler/nativeGen/Dwarf.hs b/compiler/nativeGen/Dwarf.hs
index 273949ecfd..35ee9c90ab 100644
--- a/compiler/nativeGen/Dwarf.hs
+++ b/compiler/nativeGen/Dwarf.hs
@@ -39,13 +39,15 @@ dwarfGen df modLoc us blocks = do
let procs = debugSplitProcs blocks
stripBlocks dbg = dbg { dblBlocks = [] }
compPath <- getCurrentDirectory
- let dwarfUnit = DwarfCompileUnit
+ let lowLabel = dblCLabel $ head procs
+ highLabel = mkAsmTempEndLabel $ dblCLabel $ last procs
+ dwarfUnit = DwarfCompileUnit
{ dwChildren = map (procToDwarf df) (map stripBlocks procs)
, dwName = fromMaybe "" (ml_hs_file modLoc)
, dwCompDir = addTrailingPathSeparator compPath
, dwProducer = cProjectName ++ " " ++ cProjectVersion
- , dwLowLabel = dblCLabel $ head procs
- , dwHighLabel = mkAsmTempEndLabel $ dblCLabel $ last procs
+ , dwLowLabel = lowLabel
+ , dwHighLabel = highLabel
, dwLineLabel = dwarfLineLabel
}
@@ -62,7 +64,8 @@ dwarfGen df modLoc us blocks = do
-- .debug_info section: Information records on procedures and blocks
let -- unique to identify start and end compilation unit .debug_inf
(unitU, us') = takeUniqFromSupply us
- infoSct = vcat [ dwarfInfoSection
+ infoSct = vcat [ ptext dwarfInfoLabel <> colon
+ , dwarfInfoSection
, compileUnitHeader unitU
, pprDwarfInfo haveSrc dwarfUnit
, compileUnitFooter unitU
@@ -79,18 +82,23 @@ dwarfGen df modLoc us blocks = do
ptext dwarfFrameLabel <> colon $$
pprDwarfFrame (debugFrame framesU procs)
- return (infoSct $$ abbrevSct $$ lineSct $$ frameSct, us'')
+ -- .aranges section: Information about the bounds of compilation units
+ let aranges = dwarfARangesSection $$
+ pprDwarfARange (DwarfARange lowLabel highLabel unitU)
+
+ return (infoSct $$ abbrevSct $$ lineSct $$ frameSct $$ aranges, us'')
-- | Header for a compilation unit, establishing global format
-- parameters
compileUnitHeader :: Unique -> SDoc
compileUnitHeader unitU = sdocWithPlatform $ \plat ->
- let cuLabel = mkAsmTempLabel unitU
+ let cuLabel = mkAsmTempLabel unitU -- sits right before initialLength field
length = ppr (mkAsmTempEndLabel cuLabel) <> char '-' <> ppr cuLabel
- in vcat [ ptext (sLit "\t.long ") <> length -- compilation unit size
- , ppr cuLabel <> colon
- , ptext (sLit "\t.word 3") -- DWARF version
- , sectionOffset dwarfAbbrevLabel dwarfAbbrevLabel
+ <> ptext (sLit "-4") -- length of initialLength field
+ in vcat [ ppr cuLabel <> colon
+ , ptext (sLit "\t.long ") <> length -- compilation unit size
+ , pprHalf 3 -- DWARF version
+ , sectionOffset (ptext dwarfAbbrevLabel) (ptext dwarfAbbrevLabel)
-- abbrevs offset
, ptext (sLit "\t.byte ") <> ppr (platformWordSize plat) -- word size
]