[commit: ghc] master: Fix breakage in the GHCi debugger (7855afb)

git at git.haskell.org git at git.haskell.org
Wed Oct 21 13:27:27 UTC 2015


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/7855afba393218d1b9f5a1552e53e124a9919845/ghc

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

commit 7855afba393218d1b9f5a1552e53e124a9919845
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Wed Oct 21 14:30:06 2015 +0100

    Fix breakage in the GHCi debugger
    
    Summary:
    There was a broken offset calculation that only worked when the
    sections of the binary were in a particular order, and this
    broke (sometimes) after we started mapping the sections separately in
    the linker (see D975).
    
    Test Plan: ghci debugger tests now work with DYNAMIC_GHC_PROGRAMS=NO
    
    Reviewers: austin, hvr, bgamari, erikd
    
    Reviewed By: bgamari
    
    Subscribers: Phyx, thomie, trommler
    
    Differential Revision: https://phabricator.haskell.org/D1346
    
    GHC Trac Issues: #10994


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

7855afba393218d1b9f5a1552e53e124a9919845
 compiler/ghci/DebuggerUtils.hs | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/compiler/ghci/DebuggerUtils.hs b/compiler/ghci/DebuggerUtils.hs
index 1bca75c..a7695fe 100644
--- a/compiler/ghci/DebuggerUtils.hs
+++ b/compiler/ghci/DebuggerUtils.hs
@@ -15,7 +15,6 @@ import Module
 import OccName
 import Name
 import Outputable
-import Platform
 import Util
 
 import Data.Char
@@ -96,15 +95,9 @@ dataConInfoPtrToName x = do
    getConDescAddress dflags ptr
     | ghciTablesNextToCode = do
        let ptr' = ptr `plusPtr` (- wORD_SIZE dflags)
-       -- offsetToString is really an StgWord, but we have to jump
-       -- through some hoops due to the way that our StgWord Haskell
-       -- type is the same on 32 and 64bit platforms
-       offsetToString <- case platformWordSize (targetPlatform dflags) of
-                         4 -> do w <- peek ptr'
-                                 return (fromIntegral (w :: Word32))
-                         8 -> do w <- peek ptr'
-                                 return (fromIntegral (w :: Word32))
-                         w -> panic ("getConDescAddress: Unknown platformWordSize: " ++ show w)
+       -- NB. the offset must be read as an Int32 not a Word32, so
+       -- that the sign is preserved when converting to an Int.
+       offsetToString <- fromIntegral <$> (peek ptr' :: IO Int32)
        return $ (ptr `plusPtr` stdInfoTableSizeB dflags) `plusPtr` offsetToString
     | otherwise =
        peek $ intPtrToPtr $ ptrToIntPtr ptr + fromIntegral (stdInfoTableSizeB dflags)



More information about the ghc-commits mailing list