Ticket #1377: noBreakInfo.patch

File noBreakInfo.patch, 2.8 KB (added by phercek, 6 years ago)

patch: do not print anything to stdout when stopping at a breakpoint with custom code defined

  • compiler/ghci/InteractiveUI.hs

    diff -rN -u old-ghc/compiler/ghci/InteractiveUI.hs new-ghc/compiler/ghci/InteractiveUI.hs
    old new  
    730730     GHC.RunOk names -> do
    731731        show_types <- isOptionSet ShowType
    732732        when show_types $ printTypeOfNames names
    733      GHC.RunBreak _ names mb_info 
    734          | isNothing  mb_info || 
     733     GHC.RunBreak _ names mb_info
     734         | isNothing  mb_info ||
    735735           step_here (GHC.resumeSpan $ head resumes) -> do
    736                printForUser $ ptext (sLit "Stopped at") <+>
    737                        ppr (GHC.resumeSpan $ head resumes)
    738 --               printTypeOfNames session names
    739                let namesSorted = sortBy compareNames names
    740                tythings <- catMaybes `liftM`
    741                               mapM GHC.lookupName namesSorted
    742                docs <- pprTypeAndContents [id | AnId id <- tythings]
    743                printForUserPartWay docs
    744                maybe (return ()) runBreakCmd mb_info
     736               mb_id_loc <- toBreakIdAndLocation mb_info
     737               let breakCmd = maybe "" ( \(_,l) -> onBreakCmd l ) mb_id_loc
     738               if (null breakCmd)
     739                 then printStoppedAtBreakInfo (head resumes) names
     740                 else enqueueCommands [breakCmd]
    745741               -- run the command set with ":set stop <cmd>"
    746742               st <- getGHCiState
    747743               enqueueCommands [stop st]
     
    757753
    758754  return (case run_result of GHC.RunOk _ -> True; _ -> False)
    759755
    760 runBreakCmd :: GHC.BreakInfo -> GHCi ()
    761 runBreakCmd info = do
     756toBreakIdAndLocation ::
     757  Maybe GHC.BreakInfo -> GHCi (Maybe (Int, BreakLocation))
     758toBreakIdAndLocation Nothing = return Nothing
     759toBreakIdAndLocation (Just info) = do
    762760  let mod = GHC.breakInfo_module info
    763761      nm  = GHC.breakInfo_number info
    764762  st <- getGHCiState
    765   case  [ loc | (_,loc) <- breaks st,
    766                 breakModule loc == mod, breakTick loc == nm ] of
    767         []  -> return ()
    768         loc:_ | null cmd  -> return ()
    769               | otherwise -> do enqueueCommands [cmd]; return ()
    770               where cmd = onBreakCmd loc
     763  return $ listToMaybe [ id_loc | id_loc@(_,loc) <- breaks st,
     764                                  breakModule loc == mod,
     765                                  breakTick loc == nm ]
     766
     767printStoppedAtBreakInfo :: Resume -> [Name] -> GHCi ()
     768printStoppedAtBreakInfo resume names = do
     769  printForUser $ ptext (sLit "Stopped at") <+>
     770    ppr (GHC.resumeSpan resume)
     771  --  printTypeOfNames session names
     772  let namesSorted = sortBy compareNames names
     773  tythings <- catMaybes `liftM` mapM GHC.lookupName namesSorted
     774  docs <- pprTypeAndContents [id | AnId id <- tythings]
     775  printForUserPartWay docs
    771776
    772777printTypeOfNames :: [Name] -> GHCi ()
    773778printTypeOfNames names