[commit: ghc] master: RtClosureInspect: Fix inspecting Char# on 64-bit big-endian (d6c33da)

git at git.haskell.org git at git.haskell.org
Mon Oct 16 23:14:35 UTC 2017


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

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

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

commit d6c33da89b97d0d2a3b3b8f8077de8a09432d086
Author: James Clarke <jrtc27 at jrtc27.com>
Date:   Mon Oct 16 17:33:45 2017 -0400

    RtClosureInspect: Fix inspecting Char# on 64-bit big-endian
    
    Char# is represented with a full machine word, whereas Char's Storable
    instance uses an Int32, so we can't just treat it like a single-element
    Char array. Instead, read it as an Int and use chr to turn it into a
    Char. This fixes Trac #11262.
    
    Reviewers: austin, hvr, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie
    
    GHC Trac Issues: #11262
    
    Differential Revision: https://phabricator.haskell.org/D4089


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

d6c33da89b97d0d2a3b3b8f8077de8a09432d086
 compiler/ghci/RtClosureInspect.hs           | 5 ++++-
 testsuite/tests/ghci.debugger/scripts/all.T | 3 +--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/compiler/ghci/RtClosureInspect.hs b/compiler/ghci/RtClosureInspect.hs
index 7c532e5..63d1886 100644
--- a/compiler/ghci/RtClosureInspect.hs
+++ b/compiler/ghci/RtClosureInspect.hs
@@ -57,6 +57,7 @@ import TysWiredIn
 import DynFlags
 import Outputable as Ppr
 import GHC.Arr          ( Array(..) )
+import GHC.Char
 import GHC.Exts
 import GHC.IO ( IO(..) )
 
@@ -489,7 +490,9 @@ cPprTermBase y =
 repPrim :: TyCon -> [Word] -> SDoc
 repPrim t = rep where
    rep x
-    | t == charPrimTyCon             = text $ show (build x :: Char)
+    -- Char# uses native machine words, whereas Char's Storable instance uses
+    -- Int32, so we have to read it as an Int.
+    | t == charPrimTyCon             = text $ show (chr (build x :: Int))
     | t == intPrimTyCon              = text $ show (build x :: Int)
     | t == wordPrimTyCon             = text $ show (build x :: Word)
     | t == floatPrimTyCon            = text $ show (build x :: Float)
diff --git a/testsuite/tests/ghci.debugger/scripts/all.T b/testsuite/tests/ghci.debugger/scripts/all.T
index 9e533aa..d62dcd9 100644
--- a/testsuite/tests/ghci.debugger/scripts/all.T
+++ b/testsuite/tests/ghci.debugger/scripts/all.T
@@ -21,8 +21,7 @@ test('print018', extra_files(['../Test.hs']), ghci_script, ['print018.script'])
 test('print019', extra_files(['../Test.hs']), ghci_script, ['print019.script'])
 test('print020', extra_files(['../HappyTest.hs']), ghci_script, ['print020.script'])
 test('print021', normal, ghci_script, ['print021.script'])
-test('print022', when(arch('powerpc64'), expect_broken(11262)),
-      ghci_script, ['print022.script'])
+test('print022', normal, ghci_script, ['print022.script'])
 test('print023', extra_files(['../Test.hs']), ghci_script, ['print023.script'])
 test('print024', extra_files(['../Test.hs']), ghci_script, ['print024.script'])
 test('print025', normal, ghci_script, ['print025.script'])



More information about the ghc-commits mailing list