diff options
author | Roland Senn <rsx@bluewin.ch> | 2020-05-06 18:18:40 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-06-25 03:54:38 -0400 |
commit | 7e6d3d09d983337df30d12e5aaa96bae9b81b324 (patch) | |
tree | e376ca40ae31e8e0cbb11c501f3aae2d2c5a52eb /testsuite/tests/ghci.debugger | |
parent | 03a708ba8e8c323b07d8d2e0115d6eb59987cc02 (diff) | |
download | haskell-7e6d3d09d983337df30d12e5aaa96bae9b81b324.tar.gz |
In `:break ident` allow out of scope and nested identifiers (Fix #3000)
This patch fixes the bug and implements the feature request of #3000.
1. If `Module` is a real module name and `identifier` a name of a
top-level function in `Module` then `:break Module.identifer` works
also for an `identifier` that is out of scope.
2. Extend the syntax for `:break identifier` to:
:break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent]
`ModQual` is optional and is either the effective name of a module or
the local alias of a qualified import statement.
`topLevelIdent` is the name of a top level function in the module
referenced by `ModQual`.
`nestedIdent` is optional and the name of a function nested in a let or
where clause inside the previously mentioned function `nestedIdent` or
`topLevelIdent`.
If `ModQual` is a module name, then `topLevelIdent` can be any top level
identifier in this module. If `ModQual` is missing or a local alias of a
qualified import, then `topLevelIdent` must be in scope.
Breakpoints can be set on arbitrarily deeply nested functions, but the
whole chain of nested function names must be specified.
3. To support the new functionality rewrite the code to tab complete `:break`.
Diffstat (limited to 'testsuite/tests/ghci.debugger')
9 files changed, 73 insertions, 6 deletions
diff --git a/testsuite/tests/ghci.debugger/scripts/T17989.stdout b/testsuite/tests/ghci.debugger/scripts/T17989.stdout index ce658ace22..15ac9b62b9 100644 --- a/testsuite/tests/ghci.debugger/scripts/T17989.stdout +++ b/testsuite/tests/ghci.debugger/scripts/T17989.stdout @@ -1,9 +1,20 @@ -7 7 ":break " +18 18 ":break " "B.bar" "B.foo" +"B.foo.x" +"B.foo.y" "T17989A.bar" "T17989A.foo" +"T17989A.foo.x" +"T17989A.foo.y" +"T17989A.priv" +"T17989B.bar" +"T17989B.foo" +"T17989B.foo.x" +"T17989B.foo.y" +"T17989B.priv" "T17989C.foo" +"T17989C.priv" "foo" "main" Breakpoint 0 activated at T17989B.hs:10:9-25 @@ -13,8 +24,10 @@ Breakpoint 3 activated at T17989A.hs:4:9-14 Breakpoint 4 activated at T17989C.hs:4:9-26 Breakpoint 4 was already set at T17989C.hs:4:9-26 Breakpoint 5 activated at T17989M.hs:6:8-51 -2 2 ":break " +4 4 ":break " "B.bar" "B.foo" +"B.foo.x" +"B.foo.y" 1 1 ":break " "foo" diff --git a/testsuite/tests/ghci.debugger/scripts/T3000.hs b/testsuite/tests/ghci.debugger/scripts/T3000.hs new file mode 100644 index 0000000000..429b61b836 --- /dev/null +++ b/testsuite/tests/ghci.debugger/scripts/T3000.hs @@ -0,0 +1,4 @@ +import qualified T3000S as S + +main :: IO () +main = putStrLn $ S.sshow 7 diff --git a/testsuite/tests/ghci.debugger/scripts/T3000.script b/testsuite/tests/ghci.debugger/scripts/T3000.script new file mode 100644 index 0000000000..4cee82d4a0 --- /dev/null +++ b/testsuite/tests/ghci.debugger/scripts/T3000.script @@ -0,0 +1,16 @@ +:l T3000 +:break main +:break Main.main +:break T3000S.sshow +:break S.sshow +:break T3000S.hidden +:break T3000S.sshow.nest +:show breaks +-- Generate some error messages +:break xyz +:break sshow +:break S.hidden +:break S.hidden.nest +:break Foo.xyz +:break T3000S +:break T3000S.xyz diff --git a/testsuite/tests/ghci.debugger/scripts/T3000.stdout b/testsuite/tests/ghci.debugger/scripts/T3000.stdout new file mode 100644 index 0000000000..57c8459d81 --- /dev/null +++ b/testsuite/tests/ghci.debugger/scripts/T3000.stdout @@ -0,0 +1,21 @@ +Breakpoint 0 activated at T3000.hs:4:8-27 +Breakpoint 0 was already set at T3000.hs:4:8-27 +Breakpoint 1 activated at T3000S.hs:9:9-27 +Breakpoint 1 was already set at T3000S.hs:9:9-27 +Breakpoint 2 activated at T3000S.hs:12:12-23 +Breakpoint 3 activated at T3000S.hs:13:12-32 +Breakpoint 4 activated at T3000S.hs:6:18-38 +Breakpoint 5 activated at T3000S.hs:7:18-36 +[0] Main T3000.hs:4:8-27 enabled +[1] T3000S T3000S.hs:9:9-27 enabled +[2] T3000S T3000S.hs:12:12-23 enabled +[3] T3000S T3000S.hs:13:12-32 enabled +[4] T3000S T3000S.hs:6:18-38 enabled +[5] T3000S T3000S.hs:7:18-36 enabled +Cannot set breakpoint on ‘xyz’: ‘xyz’ not in scope +Cannot set breakpoint on ‘sshow’: ‘sshow’ not in scope +Cannot set breakpoint on ‘S.hidden’: ‘S.hidden’ not in scope +Cannot set breakpoint on ‘S.hidden.nest’: ‘S.hidden’ not in scope +Cannot set breakpoint on ‘Foo.xyz’: ‘Foo.xyz’ not in scope +Cannot set breakpoint on ‘T3000S’: Function name is missing +Cannot set breakpoint on ‘T3000S.xyz’: No breakpoint found for ‘xyz’ in module ‘T3000S’ diff --git a/testsuite/tests/ghci.debugger/scripts/T3000S.hs b/testsuite/tests/ghci.debugger/scripts/T3000S.hs new file mode 100644 index 0000000000..245b3963bd --- /dev/null +++ b/testsuite/tests/ghci.debugger/scripts/T3000S.hs @@ -0,0 +1,13 @@ +module T3000S (sshow) where + +sshow :: Int -> String +sshow n = + let nest :: Int -> String + nest 0 = " nest: " ++ hidden 0 + nest k = " nest: " ++ show k + in + " show: " ++ nest n + +hidden :: Int -> String +hidden 1 = " hidden: 1" +hidden n = " hidden: " ++ show n diff --git a/testsuite/tests/ghci.debugger/scripts/all.T b/testsuite/tests/ghci.debugger/scripts/all.T index aa998adef2..bd92d0ffa8 100644 --- a/testsuite/tests/ghci.debugger/scripts/all.T +++ b/testsuite/tests/ghci.debugger/scripts/all.T @@ -109,6 +109,7 @@ test('T1620', extra_files(['T1620/', 'T1620/T1620.hs']), ghci_script, ['T1620.script']) test('T2740', normal, ghci_script, ['T2740.script']) test('T2950', normal, ghci_script, ['T2950.script']) +test('T3000', normal, ghci_script, ['T3000.script']) test('getargs', extra_files(['../getargs.hs']), ghci_script, ['getargs.script']) test('T7386', normal, ghci_script, ['T7386.script']) diff --git a/testsuite/tests/ghci.debugger/scripts/break002.stdout b/testsuite/tests/ghci.debugger/scripts/break002.stdout index 72e0359c7b..40f07d3a1f 100644 --- a/testsuite/tests/ghci.debugger/scripts/break002.stdout +++ b/testsuite/tests/ghci.debugger/scripts/break002.stdout @@ -1,2 +1,2 @@ -cannot set breakpoint on map: module GHC.Base is not interpreted -cannot set breakpoint on map: module GHC.Base is not interpreted +Cannot set breakpoint on ‘Data.List.map’: Module ‘GHC.Base’ is not interpreted +Cannot set breakpoint on ‘Data.List.map’: Module ‘GHC.Base’ is not interpreted diff --git a/testsuite/tests/ghci.debugger/scripts/break019.stderr b/testsuite/tests/ghci.debugger/scripts/break019.stderr deleted file mode 100644 index 3cb286b7eb..0000000000 --- a/testsuite/tests/ghci.debugger/scripts/break019.stderr +++ /dev/null @@ -1,2 +0,0 @@ - -<interactive>:1:1: error: Not in scope: ‘Test2’ diff --git a/testsuite/tests/ghci.debugger/scripts/break019.stdout b/testsuite/tests/ghci.debugger/scripts/break019.stdout new file mode 100644 index 0000000000..4cc0e1d9db --- /dev/null +++ b/testsuite/tests/ghci.debugger/scripts/break019.stdout @@ -0,0 +1 @@ +Cannot set breakpoint on ‘Test2’: Function name is missing |