From 5ce3b89ff354e3e43d323b49f92dbce3bdd191c8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:34:43 +0800 Subject: vim-patch:8.2.2985: Vim9: a compiled function cannot be debugged Problem: Vim9: a compiled function cannot be debugged. Solution: Add initial debugging support. https://github.com/vim/vim/commit/e99d422bbd3e47620915bf89671673f0711671b4 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_debugger.vim | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index ba3f4715ca..6b9fc9033b 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -923,19 +923,20 @@ func Test_Backtrace_DefFunction() \ ':debug call GlobalFunction()', \ ['cmd: call GlobalFunction()']) - " FIXME: Vim9 lines are not debugged! - call RunDbgCmd(buf, 'step', ['line 1: source Xtest2.vim']) + call RunDbgCmd(buf, 'step', ['line 1: CallAFunction()']) - " But they do appear in the backtrace + " FIXME: not quite right call RunDbgCmd(buf, 'backtrace', [ \ '\V>backtrace', - \ '\V 2 function GlobalFunction[1]', - \ '\V 1 \.\*_CallAFunction[1]', - \ '\V->0 \.\*_SourceAnotherFile', - \ '\Vline 1: source Xtest2.vim'], + \ '\V->0 function GlobalFunction', + \ '\Vline 1: CallAFunction()', + \ ], \ #{match: 'pattern'}) - + call RunDbgCmd(buf, 'step', ['line 1: SourceAnotherFile()']) + call RunDbgCmd(buf, 'step', ['line 1: source Xtest2.vim']) + " FIXME: repeated line + call RunDbgCmd(buf, 'step', ['line 1: source Xtest2.vim']) call RunDbgCmd(buf, 'step', ['line 1: vim9script']) call RunDbgCmd(buf, 'step', ['line 3: def DoAThing(): number']) call RunDbgCmd(buf, 'step', ['line 9: export def File2Function()']) @@ -952,7 +953,7 @@ func Test_Backtrace_DefFunction() \ #{match: 'pattern'}) " Don't step into compiled functions... - call RunDbgCmd(buf, 'step', ['line 15: End of sourced file']) + call RunDbgCmd(buf, 'next', ['line 15: End of sourced file']) call RunDbgCmd(buf, 'backtrace', [ \ '\V>backtrace', \ '\V 3 function GlobalFunction[1]', @@ -962,7 +963,6 @@ func Test_Backtrace_DefFunction() \ '\Vline 15: End of sourced file'], \ #{match: 'pattern'}) - call StopVimInTerminal(buf) call delete('Xtest1.vim') call delete('Xtest2.vim') @@ -1156,6 +1156,7 @@ func Test_debug_backtrace_level() \ [ 'E121: Undefined variable: s:file1_var' ] ) call RunDbgCmd(buf, 'echo s:file2_var', [ 'file2' ] ) + call RunDbgCmd(buf, 'cont') call StopVimInTerminal(buf) call delete('Xtest1.vim') call delete('Xtest2.vim') -- cgit From 04d951685bcdfeb219e7fdc2fac8e6baf198e847 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:35:42 +0800 Subject: vim-patch:8.2.2996: Vim9: when debugging cannot inspect local variables Problem: Vim9: when debugging cannot inspect local variables. Solution: Make local variables available when debugging. https://github.com/vim/vim/commit/b69c6fb7b423ddc4578b093cb19257cad459dfae Co-authored-by: Bram Moolenaar --- src/nvim/debugger.c | 2 +- test/old/testdir/test_debugger.vim | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 31aad11d60..9bd2238c25 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -230,7 +230,7 @@ void do_debug(char *cmd) } if (last_cmd != 0) { - // Execute debug command: decided where to break next and return. + // Execute debug command: decide where to break next and return. switch (last_cmd) { case CMD_CONT: debug_break_level = -1; diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index 6b9fc9033b..3da4c66f32 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -892,6 +892,7 @@ func Test_Backtrace_DefFunction() enddef def g:GlobalFunction() + var some = "some var" CallAFunction() enddef @@ -923,19 +924,21 @@ func Test_Backtrace_DefFunction() \ ':debug call GlobalFunction()', \ ['cmd: call GlobalFunction()']) - call RunDbgCmd(buf, 'step', ['line 1: CallAFunction()']) + call RunDbgCmd(buf, 'step', ['line 1: var some = "some var"']) + call RunDbgCmd(buf, 'step', ['line 2: CallAFunction()']) + call RunDbgCmd(buf, 'echo some', ['some var']) - " FIXME: not quite right call RunDbgCmd(buf, 'backtrace', [ \ '\V>backtrace', \ '\V->0 function GlobalFunction', - \ '\Vline 1: CallAFunction()', + \ '\Vline 2: CallAFunction()', \ ], \ #{match: 'pattern'}) call RunDbgCmd(buf, 'step', ['line 1: SourceAnotherFile()']) call RunDbgCmd(buf, 'step', ['line 1: source Xtest2.vim']) - " FIXME: repeated line + " Repeated line, because we fist are in the compiled function before the + " EXEC and then in do_cmdline() before the :source command. call RunDbgCmd(buf, 'step', ['line 1: source Xtest2.vim']) call RunDbgCmd(buf, 'step', ['line 1: vim9script']) call RunDbgCmd(buf, 'step', ['line 3: def DoAThing(): number']) @@ -945,7 +948,7 @@ func Test_Backtrace_DefFunction() call RunDbgCmd(buf, 'step', ['line 14: File2Function()']) call RunDbgCmd(buf, 'backtrace', [ \ '\V>backtrace', - \ '\V 3 function GlobalFunction[1]', + \ '\V 3 function GlobalFunction[2]', \ '\V 2 \.\*_CallAFunction[1]', \ '\V 1 \.\*_SourceAnotherFile[1]', \ '\V->0 script ' .. getcwd() .. '/Xtest2.vim', @@ -956,7 +959,7 @@ func Test_Backtrace_DefFunction() call RunDbgCmd(buf, 'next', ['line 15: End of sourced file']) call RunDbgCmd(buf, 'backtrace', [ \ '\V>backtrace', - \ '\V 3 function GlobalFunction[1]', + \ '\V 3 function GlobalFunction[2]', \ '\V 2 \.\*_CallAFunction[1]', \ '\V 1 \.\*_SourceAnotherFile[1]', \ '\V->0 script ' .. getcwd() .. '/Xtest2.vim', -- cgit From 3e8541f4a0d8177bf8451f7aa6387e6f04b0d963 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:36:34 +0800 Subject: vim-patch:8.2.3003: Vim9: closure compiled with wrong compile type Problem: Vim9: closure compiled with wrong compile type. Solution: Use COMPILE_TYPE() when calling a function. (closes vim/vim#8384) https://github.com/vim/vim/commit/968a5b62ffd3e08005d907d93eaaf807be466a88 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_debugger.vim | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index 3da4c66f32..8e7c814ac7 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -971,6 +971,34 @@ func Test_Backtrace_DefFunction() call delete('Xtest2.vim') endfunc +func Test_debug_def_function() + CheckRunVimInTerminal + CheckCWD + let file =<< trim END + vim9script + def g:Func() + var n: number + def Closure(): number + return n + 3 + enddef + n += Closure() + echo 'result: ' .. n + enddef + END + call writefile(file, 'Xtest.vim') + + let buf = RunVimInTerminal('-S Xtest.vim', {}) + + call RunDbgCmd(buf, + \ ':debug call Func()', + \ ['cmd: call Func()']) + call RunDbgCmd(buf, 'next', ['result: 3']) + call term_sendkeys(buf, "\r") + + call StopVimInTerminal(buf) + call delete('Xtest.vim') +endfunc + func Test_debug_backtrace_level() CheckRunVimInTerminal CheckCWD -- cgit From d46b6b2978808adf328b3326d6253ebcc01996e3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:39:39 +0800 Subject: vim-patch:8.2.3011: Vim9: cannot get argument values during debugging Problem: Vim9: cannot get argument values during debugging. Solution: Lookup names in the list of arguments. Put debug instruction halfway for command. https://github.com/vim/vim/commit/6bc30b05e6081bcaece6d1a7fcfca238ea5a194f Co-authored-by: Bram Moolenaar --- test/old/testdir/test_debugger.vim | 43 ++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index 8e7c814ac7..0f6b55cf07 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -977,12 +977,20 @@ func Test_debug_def_function() let file =<< trim END vim9script def g:Func() - var n: number - def Closure(): number - return n + 3 - enddef - n += Closure() - echo 'result: ' .. n + var n: number + def Closure(): number + return n + 3 + enddef + n += Closure() + echo 'result: ' .. n + enddef + + def g:FuncWithArgs(text: string, nr: number, ...items: list) + echo text .. nr + for it in items + echo it + endfor + echo "done" enddef END call writefile(file, 'Xtest.vim') @@ -994,7 +1002,30 @@ func Test_debug_def_function() \ ['cmd: call Func()']) call RunDbgCmd(buf, 'next', ['result: 3']) call term_sendkeys(buf, "\r") + call RunDbgCmd(buf, 'cont') + call RunDbgCmd(buf, + \ ':debug call FuncWithArgs("asdf", 42, 1, 2, 3)', + \ ['cmd: call FuncWithArgs("asdf", 42, 1, 2, 3)']) + call RunDbgCmd(buf, 'step', ['line 1: echo text .. nr']) + call RunDbgCmd(buf, 'echo text', ['asdf']) + call RunDbgCmd(buf, 'echo nr', ['42']) + call RunDbgCmd(buf, 'echo items', ['[1, 2, 3]']) + call RunDbgCmd(buf, 'step', ['asdf42', 'function FuncWithArgs', 'line 2: for it in items']) + call RunDbgCmd(buf, 'echo it', ['1']) + call RunDbgCmd(buf, 'step', ['line 3: echo it']) + call RunDbgCmd(buf, 'step', ['1', 'function FuncWithArgs', 'line 4: endfor']) + call RunDbgCmd(buf, 'step', ['line 2: for it in items']) + call RunDbgCmd(buf, 'echo it', ['2']) + call RunDbgCmd(buf, 'step', ['line 3: echo it']) + call RunDbgCmd(buf, 'step', ['2', 'function FuncWithArgs', 'line 4: endfor']) + call RunDbgCmd(buf, 'step', ['line 2: for it in items']) + call RunDbgCmd(buf, 'echo it', ['3']) + call RunDbgCmd(buf, 'step', ['line 3: echo it']) + call RunDbgCmd(buf, 'step', ['3', 'function FuncWithArgs', 'line 4: endfor']) + call RunDbgCmd(buf, 'step', ['line 5: echo "done"']) + + call RunDbgCmd(buf, 'cont') call StopVimInTerminal(buf) call delete('Xtest.vim') endfunc -- cgit From 02a43ddf1ef5d779cae7a67f69904dd983ea53ee Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:41:10 +0800 Subject: vim-patch:8.2.3013: Vim: when debugging only first line of command is displayed Problem: Vim: when debugging only the first line of a command using line continuation is displayed. Solution: Find the next command and concatenate lines until that one. (closes vim/vim#8392) https://github.com/vim/vim/commit/4cea536bdf48df459e7ad651dfee006844bbf2c0 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_debugger.vim | 45 ++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index 0f6b55cf07..2e881ca0b8 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -924,19 +924,19 @@ func Test_Backtrace_DefFunction() \ ':debug call GlobalFunction()', \ ['cmd: call GlobalFunction()']) - call RunDbgCmd(buf, 'step', ['line 1: var some = "some var"']) - call RunDbgCmd(buf, 'step', ['line 2: CallAFunction()']) + call RunDbgCmd(buf, 'step', ['line 1: var some = "some var"']) + call RunDbgCmd(buf, 'step', ['line 2: CallAFunction()']) call RunDbgCmd(buf, 'echo some', ['some var']) call RunDbgCmd(buf, 'backtrace', [ \ '\V>backtrace', \ '\V->0 function GlobalFunction', - \ '\Vline 2: CallAFunction()', + \ '\Vline 2: CallAFunction()', \ ], \ #{match: 'pattern'}) - call RunDbgCmd(buf, 'step', ['line 1: SourceAnotherFile()']) - call RunDbgCmd(buf, 'step', ['line 1: source Xtest2.vim']) + call RunDbgCmd(buf, 'step', ['line 1: SourceAnotherFile()']) + call RunDbgCmd(buf, 'step', ['line 1: source Xtest2.vim']) " Repeated line, because we fist are in the compiled function before the " EXEC and then in do_cmdline() before the :source command. call RunDbgCmd(buf, 'step', ['line 1: source Xtest2.vim']) @@ -992,6 +992,13 @@ func Test_debug_def_function() endfor echo "done" enddef + + def g:FuncWithDict() + var d = { + a: 1, + b: 2, + } + enddef END call writefile(file, 'Xtest.vim') @@ -1007,23 +1014,29 @@ func Test_debug_def_function() call RunDbgCmd(buf, \ ':debug call FuncWithArgs("asdf", 42, 1, 2, 3)', \ ['cmd: call FuncWithArgs("asdf", 42, 1, 2, 3)']) - call RunDbgCmd(buf, 'step', ['line 1: echo text .. nr']) + call RunDbgCmd(buf, 'step', ['line 1: echo text .. nr']) call RunDbgCmd(buf, 'echo text', ['asdf']) call RunDbgCmd(buf, 'echo nr', ['42']) call RunDbgCmd(buf, 'echo items', ['[1, 2, 3]']) - call RunDbgCmd(buf, 'step', ['asdf42', 'function FuncWithArgs', 'line 2: for it in items']) + call RunDbgCmd(buf, 'step', ['asdf42', 'function FuncWithArgs', 'line 2: for it in items']) call RunDbgCmd(buf, 'echo it', ['1']) - call RunDbgCmd(buf, 'step', ['line 3: echo it']) - call RunDbgCmd(buf, 'step', ['1', 'function FuncWithArgs', 'line 4: endfor']) - call RunDbgCmd(buf, 'step', ['line 2: for it in items']) + call RunDbgCmd(buf, 'step', ['line 3: echo it']) + call RunDbgCmd(buf, 'step', ['1', 'function FuncWithArgs', 'line 4: endfor']) + call RunDbgCmd(buf, 'step', ['line 2: for it in items']) call RunDbgCmd(buf, 'echo it', ['2']) - call RunDbgCmd(buf, 'step', ['line 3: echo it']) - call RunDbgCmd(buf, 'step', ['2', 'function FuncWithArgs', 'line 4: endfor']) - call RunDbgCmd(buf, 'step', ['line 2: for it in items']) + call RunDbgCmd(buf, 'step', ['line 3: echo it']) + call RunDbgCmd(buf, 'step', ['2', 'function FuncWithArgs', 'line 4: endfor']) + call RunDbgCmd(buf, 'step', ['line 2: for it in items']) call RunDbgCmd(buf, 'echo it', ['3']) - call RunDbgCmd(buf, 'step', ['line 3: echo it']) - call RunDbgCmd(buf, 'step', ['3', 'function FuncWithArgs', 'line 4: endfor']) - call RunDbgCmd(buf, 'step', ['line 5: echo "done"']) + call RunDbgCmd(buf, 'step', ['line 3: echo it']) + call RunDbgCmd(buf, 'step', ['3', 'function FuncWithArgs', 'line 4: endfor']) + call RunDbgCmd(buf, 'step', ['line 5: echo "done"']) + call RunDbgCmd(buf, 'cont') + + call RunDbgCmd(buf, + \ ':debug call FuncWithDict()', + \ ['cmd: call FuncWithDict()']) + call RunDbgCmd(buf, 'step', ['line 1: var d = { a: 1, b: 2, }']) call RunDbgCmd(buf, 'cont') call StopVimInTerminal(buf) -- cgit From 940d9c59a76e1c38a7331492eb6d1b3da7f123ef Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:41:38 +0800 Subject: vim-patch:8.2.3017: Vim9: debugger shows too many lines Problem: Vim9: debugger shows too many lines. Solution: Truncate at a comment, "enddef", etc. (closes vim/vim#8392) https://github.com/vim/vim/commit/59b50c3bee908694ae4ac10b26bfebf99d09d466 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_debugger.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index 2e881ca0b8..bda40e0459 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -998,6 +998,10 @@ func Test_debug_def_function() a: 1, b: 2, } + # comment + def Inner() + eval 1 + enddef enddef END call writefile(file, 'Xtest.vim') @@ -1037,6 +1041,7 @@ func Test_debug_def_function() \ ':debug call FuncWithDict()', \ ['cmd: call FuncWithDict()']) call RunDbgCmd(buf, 'step', ['line 1: var d = { a: 1, b: 2, }']) + call RunDbgCmd(buf, 'step', ['line 6: def Inner()']) call RunDbgCmd(buf, 'cont') call StopVimInTerminal(buf) -- cgit From 0bca5bff534af515a1e1e831c01bd53b0a08a56d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:42:09 +0800 Subject: vim-patch:8.2.3026: Vim9: cannot set breakpoint in compiled function Problem: Vim9: cannot set breakpoint in compiled function. Solution: Check for breakpoint when calling a function. https://github.com/vim/vim/commit/4f8f54280fa728b7d5a63b67d02b60a3b3dce543 Co-authored-by: Bram Moolenaar --- src/nvim/debugger.c | 2 +- test/old/testdir/test_debugger.vim | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 9bd2238c25..2ed8beaafb 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -550,7 +550,7 @@ static int dbg_parsearg(char *arg, garray_T *gap) } if (bp->dbg_type == DBG_FUNC) { - bp->dbg_name = xstrdup(p); + bp->dbg_name = xstrdup(strncmp(p, "g:", 2) == 0 ? p + 2 : p); } else if (here) { bp->dbg_name = xstrdup(curbuf->b_ffname); } else if (bp->dbg_type == DBG_EXPR) { diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index bda40e0459..f98b718c32 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -971,6 +971,32 @@ func Test_Backtrace_DefFunction() call delete('Xtest2.vim') endfunc +func Test_debug_DefFunction() + CheckRunVimInTerminal + CheckCWD + let file =<< trim END + vim9script + def g:SomeFunc() + echo "here" + echo "and" + echo "there" + enddef + breakadd func 2 g:SomeFunc + END + call writefile(file, 'XtestDebug.vim') + + let buf = RunVimInTerminal('-S XtestDebug.vim', {}) + + call RunDbgCmd(buf,':call SomeFunc()', ['line 2: echo "and"']) + call RunDbgCmd(buf,'next', ['line 3: echo "there"']) + + call RunDbgCmd(buf, 'cont') + + call StopVimInTerminal(buf) + call delete('Xtest1.vim') + call delete('Xtest2.vim') +endfunc + func Test_debug_def_function() CheckRunVimInTerminal CheckCWD -- cgit From 7e789137e9d5cc6713be5a2abde5c10b5713de82 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:44:56 +0800 Subject: vim-patch:8.2.3027: Vim9: breakpoint in compiled function not always checked Problem: Vim9: breakpoint in compiled function not always checked. Solution: Check for breakpoint when calling compiled function from compiled function. https://github.com/vim/vim/commit/2ac4b2536a40e5cd75b4ff7a3d44a282d2f4f008 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_debugger.vim | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index f98b718c32..90f7b4abd0 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -980,7 +980,22 @@ func Test_debug_DefFunction() echo "here" echo "and" echo "there" + breakadd func 2 LocalFunc + LocalFunc() enddef + + def LocalFunc() + echo "first" + echo "second" + breakadd func 1 LegacyFunc + LegacyFunc() + enddef + + func LegacyFunc() + echo "legone" + echo "legtwo" + endfunc + breakadd func 2 g:SomeFunc END call writefile(file, 'XtestDebug.vim') @@ -989,6 +1004,13 @@ func Test_debug_DefFunction() call RunDbgCmd(buf,':call SomeFunc()', ['line 2: echo "and"']) call RunDbgCmd(buf,'next', ['line 3: echo "there"']) + call RunDbgCmd(buf,'next', ['line 4: breakadd func 2 LocalFunc']) + + " continue, next breakpoint is in LocalFunc() + call RunDbgCmd(buf,'cont', ['line 2: echo "second"']) + + " continue, next breakpoint is in LegacyFunc() + call RunDbgCmd(buf,'cont', ['line 1: echo "legone"']) call RunDbgCmd(buf, 'cont') -- cgit From 06acf78cd323c82cc40d701c92997503ecb4aeb5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:45:33 +0800 Subject: vim-patch:8.2.3039: Vim9: breakpoint at a comment line does not work Problem: Vim9: breakpoint at a comment line does not work. Solution: Add the comment line number to the debug instruction. (closes vim/vim#8429) https://github.com/vim/vim/commit/8cec9273d2518f2a9abcbd326722a2eba38d2a13 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_debugger.vim | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index 90f7b4abd0..ba3893ae26 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -987,7 +987,7 @@ func Test_debug_DefFunction() def LocalFunc() echo "first" echo "second" - breakadd func 1 LegacyFunc + breakadd func LegacyFunc LegacyFunc() enddef @@ -1051,6 +1051,13 @@ func Test_debug_def_function() eval 1 enddef enddef + def g:FuncComment() + # comment + echo "first" + .. "one" + # comment + echo "second" + enddef END call writefile(file, 'Xtest.vim') @@ -1090,6 +1097,12 @@ func Test_debug_def_function() \ ['cmd: call FuncWithDict()']) call RunDbgCmd(buf, 'step', ['line 1: var d = { a: 1, b: 2, }']) call RunDbgCmd(buf, 'step', ['line 6: def Inner()']) + call RunDbgCmd(buf, 'cont') + + call RunDbgCmd(buf, ':breakadd func 1 FuncComment') + call RunDbgCmd(buf, ':call FuncComment()', ['function FuncComment', 'line 2: echo "first" .. "one"']) + call RunDbgCmd(buf, ':breakadd func 3 FuncComment') + call RunDbgCmd(buf, 'cont', ['function FuncComment', 'line 5: echo "second"']) call RunDbgCmd(buf, 'cont') call StopVimInTerminal(buf) -- cgit From 32012b3fe872d146085c6bf200ae396f36cc5ae1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:46:46 +0800 Subject: vim-patch:8.2.3066: Vim9: debugging lambda does not work Problem: Vim9: debugging lambda does not work. Solution: Use the compile type of the function when compiling a lambda. (closes vim/vim#8412) https://github.com/vim/vim/commit/17d868b8b268c9b9670421039d1a772341937add Co-authored-by: Bram Moolenaar --- test/old/testdir/test_debugger.vim | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index ba3893ae26..f1f546a027 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -971,7 +971,7 @@ func Test_Backtrace_DefFunction() call delete('Xtest2.vim') endfunc -func Test_debug_DefFunction() +func Test_debug_def_and_legacy_function() CheckRunVimInTerminal CheckCWD let file =<< trim END @@ -1109,6 +1109,34 @@ func Test_debug_def_function() call delete('Xtest.vim') endfunc +func Test_debug_def_function_with_lambda() + CheckRunVimInTerminal + CheckCWD + let lines =<< trim END + vim9script + def g:Func() + var s = 'a' + ['b']->map((_, v) => s) + echo "done" + enddef + breakadd func 2 g:Func + END + call writefile(lines, 'XtestLambda.vim') + + let buf = RunVimInTerminal('-S XtestLambda.vim', {}) + + call RunDbgCmd(buf, + \ ':call g:Func()', + \ ['function Func', 'line 2: [''b'']->map((_, v) => s)']) + call RunDbgCmd(buf, + \ 'next', + \ ['function Func', 'line 3: echo "done"']) + + call RunDbgCmd(buf, 'cont') + call StopVimInTerminal(buf) + call delete('XtestLambda.vim') +endfunc + func Test_debug_backtrace_level() CheckRunVimInTerminal CheckCWD -- cgit From 1cc2143710e9eb982c5184ee23eae542333a27e3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:48:09 +0800 Subject: vim-patch:8.2.3086: Vim9: breakpoint on "for" does not work Problem: Vim9: breakpoint on "for" does not work. Solution: Use the right line number in ISN_DEBUG. (closes vim/vim#8486) https://github.com/vim/vim/commit/6fc016168249360f0524b68f72cf33efd0574d40 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_debugger.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index f1f546a027..c6228815c9 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -1058,6 +1058,13 @@ func Test_debug_def_function() # comment echo "second" enddef + def g:FuncForLoop() + eval 1 + for i in [11, 22, 33] + eval i + endfor + echo "done" + enddef END call writefile(file, 'Xtest.vim') @@ -1103,6 +1110,15 @@ func Test_debug_def_function() call RunDbgCmd(buf, ':call FuncComment()', ['function FuncComment', 'line 2: echo "first" .. "one"']) call RunDbgCmd(buf, ':breakadd func 3 FuncComment') call RunDbgCmd(buf, 'cont', ['function FuncComment', 'line 5: echo "second"']) + call RunDbgCmd(buf, 'cont') + + call RunDbgCmd(buf, ':breakadd func 2 FuncForLoop') + call RunDbgCmd(buf, ':call FuncForLoop()', ['function FuncForLoop', 'line 2: for i in [11, 22, 33]']) + call RunDbgCmd(buf, 'echo i', ['11']) + call RunDbgCmd(buf, 'next', ['function FuncForLoop', 'line 3: eval i']) + call RunDbgCmd(buf, 'next', ['function FuncForLoop', 'line 4: endfor']) + call RunDbgCmd(buf, 'next', ['function FuncForLoop', 'line 2: for i in [11, 22, 33]']) + call RunDbgCmd(buf, 'echo i', ['22']) call RunDbgCmd(buf, 'cont') call StopVimInTerminal(buf) -- cgit From 310d0f15c0db1622d24e8fda855e7dfa3d2fe832 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:48:33 +0800 Subject: vim-patch:8.2.3096: temp files remain after running tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Temp files remain after running tests. Solution: Delete the right files. (Dominique Pellé, closes vim/vim#8509) https://github.com/vim/vim/commit/6c72fd51a899e6f0c272b08b9784d3c7a3cede20 Co-authored-by: Dominique Pelle --- test/old/testdir/test_debugger.vim | 3 +-- test/old/testdir/test_lambda.vim | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index c6228815c9..ae7672bffa 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -1015,8 +1015,7 @@ func Test_debug_def_and_legacy_function() call RunDbgCmd(buf, 'cont') call StopVimInTerminal(buf) - call delete('Xtest1.vim') - call delete('Xtest2.vim') + call delete('XtestDebug.vim') endfunc func Test_debug_def_function() diff --git a/test/old/testdir/test_lambda.vim b/test/old/testdir/test_lambda.vim index 025eb016a8..810b41b389 100644 --- a/test/old/testdir/test_lambda.vim +++ b/test/old/testdir/test_lambda.vim @@ -329,6 +329,7 @@ func Test_closure_error() let caught_932 = 1 endtry call assert_equal(1, caught_932) + call delete('Xscript') endfunc " vim: shiftwidth=2 sts=2 expandtab -- cgit From b313109a25ac5d910b109410ed34324785bf3142 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:49:23 +0800 Subject: vim-patch:8.2.3116: Vim9: crash when debugging a function with line continuation Problem: Vim9: crash when debugging a function with line continuation. Solution: Check for a NULL pointer. (closes vim/vim#8521) https://github.com/vim/vim/commit/303215d60cece0462f040035502b5bc95373bd6e Co-authored-by: Bram Moolenaar --- test/old/testdir/test_debugger.vim | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index ae7672bffa..4cf25b9521 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -1050,6 +1050,7 @@ func Test_debug_def_function() eval 1 enddef enddef + def g:FuncComment() # comment echo "first" @@ -1057,6 +1058,7 @@ func Test_debug_def_function() # comment echo "second" enddef + def g:FuncForLoop() eval 1 for i in [11, 22, 33] @@ -1064,6 +1066,11 @@ func Test_debug_def_function() endfor echo "done" enddef + + def g:FuncWithSplitLine() + eval 1 + | eval 2 + enddef END call writefile(file, 'Xtest.vim') @@ -1119,6 +1126,12 @@ func Test_debug_def_function() call RunDbgCmd(buf, 'next', ['function FuncForLoop', 'line 2: for i in [11, 22, 33]']) call RunDbgCmd(buf, 'echo i', ['22']) + call RunDbgCmd(buf, 'breakdel *') + call RunDbgCmd(buf, 'cont') + + call RunDbgCmd(buf, ':breakadd func FuncWithSplitLine') + call RunDbgCmd(buf, ':call FuncWithSplitLine()', ['function FuncWithSplitLine', 'line 1: eval 1 | eval 2']) + call RunDbgCmd(buf, 'cont') call StopVimInTerminal(buf) call delete('Xtest.vim') -- cgit From 49d126e005211d6fbe54bccff9aa0f0e1eeefcef Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:49:44 +0800 Subject: vim-patch:8.2.3138: debugger test fails Problem: Debugger test fails. Solution: Adjust eval command. https://github.com/vim/vim/commit/31e21766d6fb0a386e15ccc8c2192f6a3a210f53 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_debugger.vim | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index 4cf25b9521..fce80a948a 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -1047,7 +1047,7 @@ func Test_debug_def_function() } # comment def Inner() - eval 1 + eval 1 + 2 enddef enddef @@ -1060,16 +1060,16 @@ func Test_debug_def_function() enddef def g:FuncForLoop() - eval 1 + eval 1 + 2 for i in [11, 22, 33] - eval i + eval i + 2 endfor echo "done" enddef def g:FuncWithSplitLine() - eval 1 - | eval 2 + eval 1 + 2 + | eval 2 + 3 enddef END call writefile(file, 'Xtest.vim') @@ -1121,7 +1121,7 @@ func Test_debug_def_function() call RunDbgCmd(buf, ':breakadd func 2 FuncForLoop') call RunDbgCmd(buf, ':call FuncForLoop()', ['function FuncForLoop', 'line 2: for i in [11, 22, 33]']) call RunDbgCmd(buf, 'echo i', ['11']) - call RunDbgCmd(buf, 'next', ['function FuncForLoop', 'line 3: eval i']) + call RunDbgCmd(buf, 'next', ['function FuncForLoop', 'line 3: eval i + 2']) call RunDbgCmd(buf, 'next', ['function FuncForLoop', 'line 4: endfor']) call RunDbgCmd(buf, 'next', ['function FuncForLoop', 'line 2: for i in [11, 22, 33]']) call RunDbgCmd(buf, 'echo i', ['22']) @@ -1130,7 +1130,7 @@ func Test_debug_def_function() call RunDbgCmd(buf, 'cont') call RunDbgCmd(buf, ':breakadd func FuncWithSplitLine') - call RunDbgCmd(buf, ':call FuncWithSplitLine()', ['function FuncWithSplitLine', 'line 1: eval 1 | eval 2']) + call RunDbgCmd(buf, ':call FuncWithSplitLine()', ['function FuncWithSplitLine', 'line 1: eval 1 + 2 | eval 2 + 3']) call RunDbgCmd(buf, 'cont') call StopVimInTerminal(buf) -- cgit From 331d213c0b35066fb53830f9d71ebf6b9dfdce2a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:50:20 +0800 Subject: vim-patch:8.2.3395: Vim9: expression breakpoint not checked in :def function Problem: Vim9: expression breakpoint not checked in :def function. Solution: Always compile a function for debugging if there is an expression breakpoint. (closes vim/vim#8803) https://github.com/vim/vim/commit/26a4484da20039b61f18d3565a4b4339c4d1f7e3 Co-authored-by: Bram Moolenaar --- src/nvim/debugger.c | 18 ++++++++++++++++++ test/old/testdir/test_debugger.vim | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 2ed8beaafb..bfb15d59f5 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -475,6 +475,7 @@ static garray_T dbg_breakp = { 0, 0, sizeof(struct debuggy), 4, NULL }; #define BREAKP(idx) (((struct debuggy *)dbg_breakp.ga_data)[idx]) #define DEBUGGY(gap, idx) (((struct debuggy *)(gap)->ga_data)[idx]) static int last_breakp = 0; // nr of last defined breakpoint +static bool has_expr_breakpoint = false; // Profiling uses file and func names similar to breakpoints. static garray_T prof_ga = { 0, 0, sizeof(struct debuggy), 4, NULL }; @@ -620,6 +621,9 @@ void ex_breakadd(exarg_T *eap) // DBG_EXPR DEBUGGY(gap, gap->ga_len++).dbg_nr = ++last_breakp; debug_tick++; + if (gap == &dbg_breakp) { + has_expr_breakpoint = true; + } } } @@ -633,6 +637,17 @@ void ex_debuggreedy(exarg_T *eap) } } +static void update_has_expr_breakpoint(void) +{ + has_expr_breakpoint = false; + for (int i = 0; i < dbg_breakp.ga_len; i++) { + if (BREAKP(i).dbg_type == DBG_EXPR) { + has_expr_breakpoint = true; + break; + } + } +} + /// ":breakdel" and ":profdel". void ex_breakdel(exarg_T *eap) { @@ -708,6 +723,9 @@ void ex_breakdel(exarg_T *eap) if (GA_EMPTY(gap)) { ga_clear(gap); } + if (gap == &dbg_breakp) { + update_has_expr_breakpoint(); + } } /// ":breaklist". diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index fce80a948a..5836523898 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -971,6 +971,28 @@ func Test_Backtrace_DefFunction() call delete('Xtest2.vim') endfunc +func Test_DefFunction_expr() + CheckRunVimInTerminal + CheckCWD + let file3 =<< trim END + vim9script + g:someVar = "foo" + def g:ChangeVar() + g:someVar = "bar" + echo "changed" + enddef + defcompile + END + call writefile(file3, 'Xtest3.vim') + let buf = RunVimInTerminal('-S Xtest3.vim', {}) + + call RunDbgCmd(buf, ':breakadd expr g:someVar') + call RunDbgCmd(buf, ':call g:ChangeVar()', ['Oldval = "''foo''"', 'Newval = "''bar''"', 'function ChangeVar', 'line 2: echo "changed"']) + + call StopVimInTerminal(buf) + call delete('Xtest3.vim') +endfunc + func Test_debug_def_and_legacy_function() CheckRunVimInTerminal CheckCWD -- cgit From 2503de4c92108a0c51a11c9c6871afcb7047e9d2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:58:57 +0800 Subject: vim-patch:8.2.3984: debugger test fails Problem: Debugger test fails. Solution: Adjust the test for modified debugging of a for loop. https://github.com/vim/vim/commit/3d0da09bb2d31afc611bf1c4b35796739d87ed63 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_debugger.vim | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index 5836523898..3a21c453a1 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -1112,18 +1112,21 @@ func Test_debug_def_function() call RunDbgCmd(buf, 'echo text', ['asdf']) call RunDbgCmd(buf, 'echo nr', ['42']) call RunDbgCmd(buf, 'echo items', ['[1, 2, 3]']) - call RunDbgCmd(buf, 'step', ['asdf42', 'function FuncWithArgs', 'line 2: for it in items']) - call RunDbgCmd(buf, 'echo it', ['1']) + call RunDbgCmd(buf, 'step', ['asdf42', 'function FuncWithArgs', 'line 2: for it in items']) + call RunDbgCmd(buf, 'step', ['function FuncWithArgs', 'line 2: for it in items']) + call RunDbgCmd(buf, 'echo it', ['0']) call RunDbgCmd(buf, 'step', ['line 3: echo it']) + call RunDbgCmd(buf, 'echo it', ['1']) call RunDbgCmd(buf, 'step', ['1', 'function FuncWithArgs', 'line 4: endfor']) call RunDbgCmd(buf, 'step', ['line 2: for it in items']) - call RunDbgCmd(buf, 'echo it', ['2']) + call RunDbgCmd(buf, 'echo it', ['1']) call RunDbgCmd(buf, 'step', ['line 3: echo it']) call RunDbgCmd(buf, 'step', ['2', 'function FuncWithArgs', 'line 4: endfor']) call RunDbgCmd(buf, 'step', ['line 2: for it in items']) - call RunDbgCmd(buf, 'echo it', ['3']) + call RunDbgCmd(buf, 'echo it', ['2']) call RunDbgCmd(buf, 'step', ['line 3: echo it']) call RunDbgCmd(buf, 'step', ['3', 'function FuncWithArgs', 'line 4: endfor']) + call RunDbgCmd(buf, 'step', ['line 2: for it in items']) call RunDbgCmd(buf, 'step', ['line 5: echo "done"']) call RunDbgCmd(buf, 'cont') @@ -1141,11 +1144,13 @@ func Test_debug_def_function() call RunDbgCmd(buf, 'cont') call RunDbgCmd(buf, ':breakadd func 2 FuncForLoop') - call RunDbgCmd(buf, ':call FuncForLoop()', ['function FuncForLoop', 'line 2: for i in [11, 22, 33]']) - call RunDbgCmd(buf, 'echo i', ['11']) + call RunDbgCmd(buf, ':call FuncForLoop()', ['function FuncForLoop', 'line 2: for i in [11, 22, 33]']) + call RunDbgCmd(buf, 'step', ['line 2: for i in [11, 22, 33]']) call RunDbgCmd(buf, 'next', ['function FuncForLoop', 'line 3: eval i + 2']) + call RunDbgCmd(buf, 'echo i', ['11']) call RunDbgCmd(buf, 'next', ['function FuncForLoop', 'line 4: endfor']) call RunDbgCmd(buf, 'next', ['function FuncForLoop', 'line 2: for i in [11, 22, 33]']) + call RunDbgCmd(buf, 'next', ['line 3: eval i + 2']) call RunDbgCmd(buf, 'echo i', ['22']) call RunDbgCmd(buf, 'breakdel *') -- cgit From c5d4d1cc0df70d3d380066d21017e506628bec3c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 06:59:34 +0800 Subject: vim-patch:8.2.4020: debugger test fails Problem: Debugger test fails. Solution: Fix import statement. https://github.com/vim/vim/commit/84c62d59a3604d15c447f28e89679944a4926cc3 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_debugger.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index 3a21c453a1..fab6773fd1 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -880,7 +880,7 @@ func Test_Backtrace_DefFunction() CheckCWD let file1 =<< trim END vim9script - import File2Function from './Xtest2.vim' + import './Xtest2.vim' as imp def SourceAnotherFile() source Xtest2.vim @@ -888,7 +888,7 @@ func Test_Backtrace_DefFunction() def CallAFunction() SourceAnotherFile() - File2Function() + imp.File2Function() enddef def g:GlobalFunction() -- cgit From d064f557041cddc11a60d27e2bfc6977a7e4e43b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 07:00:45 +0800 Subject: vim-patch:8.2.4541: Crash in debugger when a variable is not available Problem: Crash in debugger when a variable is not available in the current block. Solution: Check for a NULL name. (closes vim/vim#9926) https://github.com/vim/vim/commit/e406ff87c86de9da2d02d0e5ebbbf5c5eac051a6 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_debugger.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/old/testdir/test_debugger.vim b/test/old/testdir/test_debugger.vim index fab6773fd1..7ac45a0bd4 100644 --- a/test/old/testdir/test_debugger.vim +++ b/test/old/testdir/test_debugger.vim @@ -73,6 +73,13 @@ func Test_Debugger() endtry return var1 endfunc + def Vim9Func() + for cmd in ['confirm', 'xxxxxxx'] + for _ in [1, 2] + echo cmd + endfor + endfor + enddef END call writefile(lines, 'Xtest.vim') @@ -298,6 +305,14 @@ func Test_Debugger() \ 'line 5: catch']) call RunDbgCmd(buf, 'c') + " Test showing local variable in :def function + call RunDbgCmd(buf, ':breakadd func 2 Vim9Func') + call RunDbgCmd(buf, ':call Vim9Func()', ['line 2: for _ in [1, 2]']) + call RunDbgCmd(buf, 'next', ['line 2: for _ in [1, 2]']) + call RunDbgCmd(buf, 'echo cmd', ['confirm']) + call RunDbgCmd(buf, 'breakdel *') + call RunDbgCmd(buf, 'cont') + " Test for :quit call RunDbgCmd(buf, ':debug echo Foo()') call RunDbgCmd(buf, 'breakdel *') -- cgit