Wolfgang Jeltsch pushed to branch wip/jeltsch/textual-bytecode-output at Glasgow Haskell Compiler / GHC

Commits:

1 changed file:

Changes:

  • compiler/GHC/ByteCode/Show.hs
    ... ... @@ -31,6 +31,7 @@ import Text.Show (show)
    31 31
     import System.IO (IO, FilePath)
    
    32 32
     import Foreign.Storable (Storable)
    
    33 33
     import GHC.Data.Strict qualified as Strict (Maybe, maybe)
    
    34
    +import GHC.Data.FastString (unpackFS)
    
    34 35
     import GHC.Data.FlatBag (FlatBag, elemsFlatBag)
    
    35 36
     import GHC.Fingerprint (Fingerprint)
    
    36 37
     import GHC.Types.SrcLoc (noSrcSpan)
    
    ... ... @@ -41,7 +42,7 @@ import GHC.Types.SptEntry (SptEntry (..))
    41 42
     import GHC.Types.Error (MessageClass (MCDump))
    
    42 43
     import GHC.Utils.Logger (Logger, logMsg)
    
    43 44
     import GHC.Utils.Binary (BinSrcSpan (..))
    
    44
    -import GHC.Utils.Encoding.UTF8 (utf8DecodeShortByteString)
    
    45
    +import GHC.Utils.Encoding.UTF8 (utf8DecodeShortByteString, utf8DecodeByteString)
    
    45 46
     import GHC.Utils.Outputable
    
    46 47
            (
    
    47 48
                defaultDumpStyle,
    
    ... ... @@ -181,19 +182,26 @@ pprLiterals currentModule = entry (text "literals:") .
    181 182
     pprLiteral :: Module -> BCONPtr -> SDoc
    
    182 183
     pprLiteral currentModule literal = case literal of
    
    183 184
         BCONPtrWord word
    
    184
    -        -> text "word" <+> pprFixedSizeNatural word
    
    185
    +        -> text "word" <+>
    
    186
    +           pprFixedSizeNatural word
    
    185 187
         BCONPtrLbl label
    
    186
    -        -> text "label" <+> ppr label
    
    188
    +        -> text "label" <+>
    
    189
    +           ppr label
    
    187 190
         BCONPtrItbl infoTableName
    
    188
    -        -> text "info table" <+> ppr infoTableName
    
    191
    +        -> text "info table" <+>
    
    192
    +           ppr infoTableName
    
    189 193
         BCONPtrAddr addrName
    
    190
    -        -> text "address" <+> ppr addrName
    
    194
    +        -> text "address" <+>
    
    195
    +           ppr addrName
    
    191 196
         BCONPtrStr encodedString
    
    192
    -        -> text "top-level string" <+> pprByteString encodedString
    
    197
    +        -> text "top-level string" <+>
    
    198
    +           text (show (utf8DecodeByteString encodedString))
    
    193 199
         BCONPtrFS string
    
    194
    -        -> text "top-level string" <+> ppr string
    
    200
    +        -> text "top-level string" <+>
    
    201
    +           text (show (unpackFS string))
    
    195 202
         BCONPtrFFIInfo ffiInfo
    
    196
    -        -> text "foreign function" <+> pprFFIInfo ffiInfo
    
    203
    +        -> text "foreign function" <+>
    
    204
    +           pprFFIInfo ffiInfo
    
    197 205
         BCONPtrCostCentre breakpointID
    
    198 206
             -> text "cost center" <+>
    
    199 207
                pprInternalBreakpointID currentModule breakpointID
    
    ... ... @@ -283,7 +291,9 @@ pprPointerTag = entry (text "pointer tag:") . ppr
    283 291
     
    
    284 292
     -- | […]
    
    285 293
     pprDescription :: ByteString -> SDoc
    
    286
    -pprDescription = entry (text "description:") . pprByteString
    
    294
    +pprDescription = entry (text "description:") .
    
    295
    +                 text                        .
    
    296
    +                 utf8DecodeByteString
    
    287 297
     
    
    288 298
     -- | […]
    
    289 299
     pprTopLevelStrings :: [(Name, ByteString)] -> SDoc
    
    ... ... @@ -295,7 +305,10 @@ pprTopLevelStrings = entry (text "top-level strings:") .
    295 305
     pprTopLevelString :: Name -> ByteString -> SDoc
    
    296 306
     pprTopLevelString stringName encodedString
    
    297 307
         = entry (text "string" <+> ppr stringName <> text ":") $
    
    298
    -      pprByteString encodedString
    
    308
    +      text                                                 $
    
    309
    +      show                                                 $
    
    310
    +      utf8DecodeByteString                                 $
    
    311
    +      encodedString
    
    299 312
     
    
    300 313
     -- | […]
    
    301 314
     pprBreakpoints :: Module -> Maybe InternalModBreaks -> SDoc