[commit: ghc] master: Dwarf: Produce {low, high}_pc attributes for compilation units (cbf58a2)
git at git.haskell.org
git at git.haskell.org
Sat Aug 29 11:25:49 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/cbf58a217785acf519a3129916a5e9bb98a7b268/ghc
>---------------------------------------------------------------
commit cbf58a217785acf519a3129916a5e9bb98a7b268
Author: Ben Gamari <bgamari.foss at gmail.com>
Date: Sat Aug 29 12:24:54 2015 +0200
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
>---------------------------------------------------------------
cbf58a217785acf519a3129916a5e9bb98a7b268
compiler/nativeGen/Dwarf.hs | 6 +++++-
compiler/nativeGen/Dwarf/Types.hs | 9 ++++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/compiler/nativeGen/Dwarf.hs b/compiler/nativeGen/Dwarf.hs
index 34f1ed6..273949e 100644
--- a/compiler/nativeGen/Dwarf.hs
+++ b/compiler/nativeGen/Dwarf.hs
@@ -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
diff --git a/compiler/nativeGen/Dwarf/Types.hs b/compiler/nativeGen/Dwarf/Types.hs
index f9262b4..9a600bd 100644
--- a/compiler/nativeGen/Dwarf/Types.hs
+++ b/compiler/nativeGen/Dwarf/Types.hs
@@ -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
More information about the ghc-commits
mailing list