Wolfgang Jeltsch pushed to branch wip/jeltsch/textual-bytecode-output at Glasgow Haskell Compiler / GHC Commits: 4c81de9a by Wolfgang Jeltsch at 2026-07-13T17:53:40+03:00 Make output of cost center literals more precise - - - - - 5088065d by Wolfgang Jeltsch at 2026-07-13T20:09:37+03:00 Improve titles in breakpoint output - - - - - b9f1729b by Wolfgang Jeltsch at 2026-07-13T20:11:49+03:00 Remove offset from known-variable output - - - - - 1 changed file: - compiler/GHC/ByteCode/Show.hs Changes: ===================================== compiler/GHC/ByteCode/Show.hs ===================================== @@ -11,7 +11,7 @@ import Control.Exception (assert) import Data.Eq ((==)) import Data.Bits (FiniteBits, finiteBitSize) import Data.Function (($), id, (.)) -import Data.Tuple (uncurry) +import Data.Tuple (fst, uncurry) import Data.Bool (Bool, otherwise, not) import Data.Int (Int) import Data.Word (Word) @@ -191,7 +191,7 @@ pprLiteral currentModule literal = case literal of -> text "foreign function" <+> quotes (pprFFIInfo ffiInfo) BCONPtrCostCentre breakpointID - -> text "cost center" <+> + -> text "cost center of breakpoint" <+> pprInternalBreakpointID currentModule breakpointID -- | […] @@ -285,35 +285,35 @@ pprBreakpoints currentModule pprBreakpointsData :: Module -> InternalModBreaks -> SDoc pprBreakpointsData currentModule InternalModBreaks {..} = vcat [ - pprBreakpointsInSource currentModule $ imodBreaks_modBreaks, - pprBreakpointsInByteCode currentModule $ imodBreaks_breakInfo + pprSourceBreakpoints currentModule $ imodBreaks_modBreaks, + pprByteCodeBreakpoints currentModule $ imodBreaks_breakInfo ] -- | […] -pprBreakpointsInSource :: Module -> ModBreaks -> SDoc -pprBreakpointsInSource currentModule ModBreaks {..} - = entry (text "breakpoints in source") $ +pprSourceBreakpoints :: Module -> ModBreaks -> SDoc +pprSourceBreakpoints currentModule ModBreaks {..} + = entry (text "source breakpoints") $ assert (modBreaks_module == currentModule) $ assert (bounds modBreaks_locs_ == bounds modBreaks_decls) $ assert (bounds modBreaks_locs_ == bounds modBreaks_vars) $ vcatOrNone $ - zipWith4 pprBreakpointInSource (indices modBreaks_locs_) - (elems modBreaks_locs_) - (elems modBreaks_decls) - (elems modBreaks_vars) + zipWith4 pprSourceBreakpoint (indices modBreaks_locs_) + (elems modBreaks_locs_) + (elems modBreaks_decls) + (elems modBreaks_vars) -- The cost center infos in `modBreaks_ccs`, when present, just contain -- textual representations of the declaration paths in `modBreaks_decls` -- and the source spans in `modBreaks_locs_` and are therefore never -- shown. -- | […] -pprBreakpointInSource :: BreakTickIndex - -> BinSrcSpan - -> [String] - -> [OccName] - -> SDoc -pprBreakpointInSource ix srcSpan declarationPath freeVars - = entry (text "breakpoint" <+> ppr ix) $ +pprSourceBreakpoint :: BreakTickIndex + -> BinSrcSpan + -> [String] + -> [OccName] + -> SDoc +pprSourceBreakpoint ix srcSpan declarationPath freeVars + = entry (text "source breakpoint" <+> ppr ix) $ vcat [ pprSrcSpan $ srcSpan, pprDeclarationPath $ declarationPath, @@ -333,22 +333,22 @@ pprFreeVariables :: [OccName] -> SDoc pprFreeVariables = entry (text "free variables") . vcatOrNone . map ppr -- | […] -pprBreakpointsInByteCode :: Module -> IntMap CgBreakInfo -> SDoc -pprBreakpointsInByteCode currentModule - = entry (text "breakpoints in bytecode") . - vcatOrNone . - map (uncurry (pprBreakpointInByteCode currentModule)) . +pprByteCodeBreakpoints :: Module -> IntMap CgBreakInfo -> SDoc +pprByteCodeBreakpoints currentModule + = entry (text "bytecode breakpoints") . + vcatOrNone . + map (uncurry (pprByteCodeBreakpoint currentModule)) . IntMap.toList -- | […] -pprBreakpointInByteCode :: Module -> Int -> CgBreakInfo -> SDoc -pprBreakpointInByteCode currentModule ix CgBreakInfo {..} - = entry (text "breakpoint" <+> ppr ix) $ +pprByteCodeBreakpoint :: Module -> Int -> CgBreakInfo -> SDoc +pprByteCodeBreakpoint currentModule ix CgBreakInfo {..} + = entry (text "bytecode breakpoint" <+> ppr ix) $ vcat [ - pprType $ cgb_resty, - pprTypeVariables $ cgb_tyvars, - pprVariables $ cgb_vars, - pprOrigin currentModule $ cgb_tick_id + pprType $ cgb_resty, + pprTypeVariables $ cgb_tyvars, + pprVariables $ cgb_vars, + pprCorrespondingSourceBreakpoint currentModule $ cgb_tick_id ] -- That the 'cgb_resty' field holds the type of the breakpoint is apparent -- from the fact that this field is set by @@ -377,15 +377,7 @@ pprVariables = entry (text "variables") . vcatOrNone . map pprVariable -- | […] pprVariable :: Maybe (IfaceIdBndr, Word) -> SDoc -pprVariable = maybe (text "<unknown>") (uncurry pprKnownVariable) - -pprKnownVariable :: IfaceIdBndr -> Word -> SDoc -pprKnownVariable binder offset = pprVariableBinder binder <+> - text "@" <+> - ppr offset --- That the second argument is an offset is apparent from the use of the --- identifier @offset@ in the implementation of --- 'GHC.StgToByteCode.dehydrateCgBreakInfo'. +pprVariable = maybe (text "<unknown>") (pprVariableBinder . fst) -- | […] pprVariableBinder :: IfaceIdBndr -> SDoc @@ -393,10 +385,13 @@ pprVariableBinder (multiplicity, name, type_) = text "%" <> ppr multiplicity <+> ppr name <+> text "::" <+> ppr type_ -pprOrigin :: Module -> Either InternalBreakLoc BreakpointId -> SDoc -pprOrigin currentModule = entry (text "origin") . - pprBreakpointID currentModule . - either internalBreakLoc id +pprCorrespondingSourceBreakpoint :: Module + -> Either InternalBreakLoc BreakpointId + -> SDoc +pprCorrespondingSourceBreakpoint currentModule + = entry (text "corresponding source breakpoint") . + pprBreakpointID currentModule . + either internalBreakLoc id -- | […] [analogous to 'pprInternalBreakpointID' but the meaning of the index is different] pprBreakpointID :: Module -> BreakpointId -> SDoc View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c461ef90e2cd36eb8c28b0de196b38f... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c461ef90e2cd36eb8c28b0de196b38f... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Wolfgang Jeltsch (@jeltsch)