Patch 8.2.3013
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 #8392)
Files: src/vim9execute.c, src/testdir/test_debugger.vim
*** ../vim-8.2.3012/src/vim9execute.c 2021-06-16 19:19:44.870445048 +0200
--- src/vim9execute.c 2021-06-16 22:01:01.620379002 +0200
***************
*** 1433,1438 ****
--- 1433,1484 ----
return NULL;
}
+ static void
+ handle_debug(isn_T *iptr, ectx_T *ectx)
+ {
+ char_u *line;
+ ufunc_T *ufunc = (((dfunc_T *)def_functions.ga_data)
+ + ectx->ec_dfunc_idx)->df_ufunc;
+ isn_T *ni;
+ int end_lnum = iptr->isn_lnum;
+ garray_T ga;
+ int lnum;
+
+ SOURCING_LNUM = iptr->isn_lnum;
+ debug_context = ectx;
+ debug_var_count = iptr->isn_arg.number;
+
+ for (ni = iptr + 1; ni->isn_type != ISN_FINISH; ++ni)
+ if (ni->isn_type == ISN_DEBUG
+ || ni->isn_type == ISN_RETURN
+ || ni->isn_type == ISN_RETURN_VOID)
+ {
+ end_lnum = ni->isn_lnum;
+ break;
+ }
+
+ if (end_lnum > iptr->isn_lnum)
+ {
+ ga_init2(&ga, sizeof(char_u *), 10);
+ for (lnum = iptr->isn_lnum; lnum < end_lnum; ++lnum)
+ if (ga_grow(&ga, 1) == OK)
+ ((char_u **)(ga.ga_data))[ga.ga_len++] =
+ skipwhite(((char_u **)ufunc->uf_lines.ga_data)[lnum - 1]);
+ line = ga_concat_strings(&ga, " ");
+ vim_free(ga.ga_data);
+ }
+ else
+ line = ((char_u **)ufunc->uf_lines.ga_data)[iptr->isn_lnum - 1];
+ if (line == NULL)
+ line = (char_u *)"[empty]";
+
+ do_debug(line);
+ debug_context = NULL;
+
+ if (end_lnum > iptr->isn_lnum)
+ vim_free(line);
+ }
+
/*
* Execute instructions in execution context "ectx".
* Return OK or FAIL;
***************
*** 4156,4176 ****
case ISN_DEBUG:
if (ex_nesting_level <= debug_break_level)
! {
! char_u *line;
! ufunc_T *ufunc = (((dfunc_T *)def_functions.ga_data)
! + ectx->ec_dfunc_idx)->df_ufunc;
!
! SOURCING_LNUM = iptr->isn_lnum;
! debug_context = ectx;
! debug_var_count = iptr->isn_arg.number;
! line = ((char_u **)ufunc->uf_lines.ga_data)[
! iptr->isn_lnum - 1];
! if (line == NULL)
! line = (char_u *)"[empty]";
! do_debug(line);
! debug_context = NULL;
! }
break;
case ISN_SHUFFLE:
--- 4202,4208 ----
case ISN_DEBUG:
if (ex_nesting_level <= debug_break_level)
! handle_debug(iptr, ectx);
break;
case ISN_SHUFFLE:
*** ../vim-8.2.3012/src/testdir/test_debugger.vim 2021-06-16 19:19:44.870445048 +0200
--- src/testdir/test_debugger.vim 2021-06-16 22:16:40.949832540 +0200
***************
*** 885,903 ****
\ ':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, 'echo some', ['some var'])
call RunDbgCmd(buf, 'backtrace', [
\ '\V>backtrace',
\ '\V->0 function GlobalFunction',
! \ '\Vline 2: CallAFunction()',
\ ],
\ #{match: 'pattern'})
! 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'])
--- 885,903 ----
\ ':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, 'echo some', ['some var'])
call RunDbgCmd(buf, 'backtrace', [
\ '\V>backtrace',
\ '\V->0 function GlobalFunction',
! \ '\Vline 2: CallAFunction()',
\ ],
\ #{match: 'pattern'})
! 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'])
***************
*** 952,957 ****
--- 952,964 ----
endfor
echo "done"
enddef
+
+ def g:FuncWithDict()
+ var d = {
+ a: 1,
+ b: 2,
+ }
+ enddef
END
call writefile(file, 'Xtest.vim')
***************
*** 967,989 ****
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)
--- 974,1002 ----
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 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)
*** ../vim-8.2.3012/src/version.c 2021-06-16 19:28:30.508346274 +0200
--- src/version.c 2021-06-16 22:03:05.631817670 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 3013,
/**/
--
Contrary to popular belief, it's often your clothing that gets promoted, not
you.
(Scott Adams - The Dilbert principle)
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///