diff options
author | Simon Marlow <marlowsd@gmail.com> | 2015-10-21 14:30:06 +0100 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2015-10-21 14:30:06 +0100 |
commit | 7855afba393218d1b9f5a1552e53e124a9919845 (patch) | |
tree | 34f5fa4465a338871e267483a61dd80d0807e0bb /compiler/ghci/DebuggerUtils.hs | |
parent | 2bc6efc573d889a81dd28dcf00e0cbd7fafac1b7 (diff) | |
download | haskell-7855afba393218d1b9f5a1552e53e124a9919845.tar.gz |
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
Diffstat (limited to 'compiler/ghci/DebuggerUtils.hs')
-rw-r--r-- | compiler/ghci/DebuggerUtils.hs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/compiler/ghci/DebuggerUtils.hs b/compiler/ghci/DebuggerUtils.hs index 1bca75cedd..a7695fe537 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) |