Commit 4c376e30 authored by Roland Senn's avatar Roland Senn Committed by Ben Gamari
Browse files

Fix #14690 - :steplocal panics after break-on-error

`:steplocal` enables only breakpoints in the current top-level binding.

When a normal breakpoint is hit, then the module name and the break id from the `BRK_FUN` byte code
allow us to access the corresponding entry in a ModBreak table. From this entry we then get the SrcSpan
(see compiler/main/InteractiveEval.hs:bindLocalsAtBreakpoint).
With this source-span we can then determine the current top-level binding, needed for the steplocal command.

However, if we break at an exception or at an error, we don't have an BRK_FUN byte-code, so we don't have any source information.
The function `bindLocalsAtBreakpoint` creates an `UnhelpfulSpan`, which doesn't allow us to determine the current top-level binding.
To avoid a `panic`, we have to check for `UnhelpfulSpan` in the function `ghc/GHCi/UI.hs:stepLocalCmd`.
Hence a :steplocal command after a break-on-exception or a break-on-error is not possible.

(cherry picked from commit 1be9c35c)
parent d04492c0
......@@ -2803,7 +2803,10 @@ commonly used commands.
.. ghci-cmd:: :steplocal
Enable only breakpoints in the current top-level binding and resume
evaluation at the last breakpoint.
evaluation at the last breakpoint. Continuation with
:ghci-cmd:`:steplocal` is not possible if this last breakpoint was
hit by an error (:ghc-flag:`-fbreak-on-error`) or an
exception (:ghc-flag:`-fbreak-on-exception`).
.. ghci-cmd:: :stepmodule
......
......@@ -3369,6 +3369,10 @@ stepLocalCmd arg = withSandboxOnly ":steplocal" $ step arg
mb_span <- getCurrentBreakSpan
case mb_span of
Nothing -> stepCmd []
Just (UnhelpfulSpan _) -> liftIO $ putStrLn ( -- #14690
":steplocal is not possible." ++
"\nCannot determine current top-level binding after " ++
"a break on error / exception.\nUse :stepmodule.")
Just loc -> do
md <- fromMaybe (panic "stepLocalCmd") <$> getCurrentBreakModule
current_toplevel_decl <- enclosingTickSpan md loc
......
Subproject commit b0e52fa173573705e861b129d9675e59de891e46
Subproject commit c6ffad5662cf97b688c1e4a516d436b8f909f190
:set -fbreak-on-error
error "abc"
:steplocal
:l T14690.hs
foo
:steplocal
Stopped in <exception thrown>, <unknown>
_exception :: e = _
:steplocal is not possible.
Cannot determine current top-level binding after a break on error / exception.
Use :stepmodule.
Stopped in <exception thrown>, <unknown>
_exception :: e = _
:steplocal is not possible.
Cannot determine current top-level binding after a break on error / exception.
Use :stepmodule.
......@@ -106,5 +106,6 @@ test('T8557', normal, ghci_script, ['T8557.script'])
test('T12458', normal, ghci_script, ['T12458.script'])
test('T13825-debugger', when(arch('powerpc64'), expect_broken(14455)),
ghci_script, ['T13825-debugger.script'])
test('T14690', normal, ghci_script, ['T14690.script'])
test('break029', extra_files(['break029.hs']), ghci_script, ['break029.script'])
Subproject commit b58b4e3770bf4cc84f31602a0a3711ef2013234d
Subproject commit efb556cc2689cae42abadae87d778ae20fbc0a14
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment