From 7855afba393218d1b9f5a1552e53e124a9919845 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Wed, 21 Oct 2015 14:30:06 +0100 Subject: 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 --- compiler/ghci/DebuggerUtils.hs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'compiler/ghci/DebuggerUtils.hs') 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) -- cgit v1.2.1