[commit: ghc] wip/libdw-unwind: Dwarf: Add support for labels in unwind expressions (26cede0)

git at git.haskell.org git at git.haskell.org
Mon Jan 4 22:20:07 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/libdw-unwind
Link       : http://ghc.haskell.org/trac/ghc/changeset/26cede049997bd314e50cac528114a65a352c60b/ghc

>---------------------------------------------------------------

commit 26cede049997bd314e50cac528114a65a352c60b
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Sat Sep 5 13:33:02 2015 +0200

    Dwarf: Add support for labels in unwind expressions


>---------------------------------------------------------------

26cede049997bd314e50cac528114a65a352c60b
 compiler/cmm/Debug.hs                 | 3 +++
 compiler/nativeGen/Dwarf/Constants.hs | 3 ++-
 compiler/nativeGen/Dwarf/Types.hs     | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/compiler/cmm/Debug.hs b/compiler/cmm/Debug.hs
index fa4d645..7b93835 100644
--- a/compiler/cmm/Debug.hs
+++ b/compiler/cmm/Debug.hs
@@ -258,6 +258,7 @@ type UnwindTable = Map.Map GlobalReg UnwindExpr
 data UnwindExpr = UwConst Int                   -- ^ literal value
                 | UwReg GlobalReg Int           -- ^ register plus offset
                 | UwDeref UnwindExpr            -- ^ pointer dereferencing
+                | UwLabel CLabel
                 | UwPlus UnwindExpr UnwindExpr
                 | UwMinus UnwindExpr UnwindExpr
                 | UwTimes UnwindExpr UnwindExpr
@@ -268,6 +269,7 @@ instance Outputable UnwindExpr where
   pprPrec _ (UwReg g 0)     = ppr g
   pprPrec p (UwReg g x)     = pprPrec p (UwPlus (UwReg g 0) (UwConst x))
   pprPrec _ (UwDeref e)     = char '*' <> pprPrec 3 e
+  pprPrec _ (UwLabel l)     = pprPrec 3 l
   pprPrec p (UwPlus e0 e1)  | p <= 0
                             = pprPrec 0 e0 <> char '+' <> pprPrec 0 e1
   pprPrec p (UwMinus e0 e1) | p <= 0
@@ -292,6 +294,7 @@ extractUnwind b = go $ blockToList mid
 -- possible.
 toUnwindExpr :: CmmExpr -> UnwindExpr
 toUnwindExpr (CmmLit (CmmInt i _))       = UwConst (fromIntegral i)
+toUnwindExpr (CmmLit (CmmLabel l))       = UwLabel l
 toUnwindExpr (CmmRegOff (CmmGlobal g) i) = UwReg g i
 toUnwindExpr (CmmReg (CmmGlobal g))      = UwReg g 0
 toUnwindExpr (CmmLoad e _)               = UwDeref (toUnwindExpr e)
diff --git a/compiler/nativeGen/Dwarf/Constants.hs b/compiler/nativeGen/Dwarf/Constants.hs
index 6ba1f8a..a252066 100644
--- a/compiler/nativeGen/Dwarf/Constants.hs
+++ b/compiler/nativeGen/Dwarf/Constants.hs
@@ -130,9 +130,10 @@ dW_CFA_val_expression     = 0x16
 dW_CFA_offset             = 0x80
 
 -- * Operations
-dW_OP_deref, dW_OP_consts,
+dW_OP_addr, dW_OP_deref, dW_OP_consts,
   dW_OP_minus, dW_OP_mul, dW_OP_plus,
   dW_OP_lit0, dW_OP_breg0, dW_OP_call_frame_cfa :: Word8
+dW_OP_addr           = 0x03
 dW_OP_deref          = 0x06
 dW_OP_consts         = 0x11
 dW_OP_minus          = 0x1c
diff --git a/compiler/nativeGen/Dwarf/Types.hs b/compiler/nativeGen/Dwarf/Types.hs
index e80f2a1..39009e3 100644
--- a/compiler/nativeGen/Dwarf/Types.hs
+++ b/compiler/nativeGen/Dwarf/Types.hs
@@ -446,6 +446,7 @@ pprUnwindExpr spIsCFA expr
         pprE (UwReg g i)      = pprByte (dW_OP_breg0+dwarfGlobalRegNo plat g) $$
                                pprLEBInt i
         pprE (UwDeref u)      = pprE u $$ pprByte dW_OP_deref
+        pprE (UwLabel l)      = pprByte dW_OP_addr $$ pprWord (ppr l)
         pprE (UwPlus u1 u2)   = pprE u1 $$ pprE u2 $$ pprByte dW_OP_plus
         pprE (UwMinus u1 u2)  = pprE u1 $$ pprE u2 $$ pprByte dW_OP_minus
         pprE (UwTimes u1 u2)  = pprE u1 $$ pprE u2 $$ pprByte dW_OP_mul



More information about the ghc-commits mailing list