- Just curr_loc -> do
- Just tick <- getCurrentBreakTick
- Just mod <- getCurrentBreakModule
- parent <- io$ GHC.findEnclosingDeclSpanByTick session mod tick
- allTicksRightmost <- (sortBy rightmost . map snd) `fmap`
- ticksIn mod parent
- let lastTick = null allTicksRightmost ||
- head allTicksRightmost == curr_loc
- if not lastTick
- then let f t = t `isSubspanOf` parent &&
- (curr_loc `leftmost_largest` t == LT)
- in doContinue f GHC.SingleStep
- else printForUser (text "Warning: no more breakpoints in this function body, switching to :step") >>
- doContinue (const True) GHC.SingleStep
-
-stepOverCmd expression = stepCmd expression
-
-{-
- The first tricky bit in stepOver is detecting that we have
- arrived to the last tick in an expression, in which case we must
- step normally to the next tick.
- What we do is:
- 1. Retrieve the enclosing expression block (with a tick)
- 2. Retrieve all the ticks there and sort them out by 'rightness'
- 3. See if the current tick turned out the first one in the list
-
- The second tricky bit is how to step over recursive calls.
-
--}
-
---ticksIn :: Module -> SrcSpan -> GHCi [Tick]
-ticksIn mod src = do
+ Just loc -> do
+ Just mod <- getCurrentBreakModule
+ current_toplevel_decl <- enclosingTickSpan mod loc
+ doContinue (`isSubspanOf` current_toplevel_decl) GHC.SingleStep
+
+stepLocalCmd expression = stepCmd expression
+
+stepModuleCmd :: String -> GHCi ()
+stepModuleCmd [] = do
+ mb_span <- getCurrentBreakSpan
+ case mb_span of
+ Nothing -> stepCmd []
+ Just loc -> do
+ Just span <- getCurrentBreakSpan
+ let f some_span = optSrcSpanFileName span == optSrcSpanFileName some_span
+ doContinue f GHC.SingleStep
+
+stepModuleCmd expression = stepCmd expression
+
+-- | Returns the span of the largest tick containing the srcspan given
+enclosingTickSpan :: Module -> SrcSpan -> GHCi SrcSpan
+enclosingTickSpan mod src = do