To: vim_dev@googlegroups.com Subject: Patch 8.2.3039 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3039 Problem: Vim9: breakpoint at a comment line does not work. Solution: Add the comment line number to the debug instruction. (closes #8429) Files: src/vim9.h, src/vim9compile.c, src/vim9execute.c, src/testdir/test_debugger.vim, src/testdir/test_vim9_disassemble.vim *** ../vim-8.2.3038/src/vim9.h 2021-06-21 19:43:59.146216296 +0200 --- src/vim9.h 2021-06-23 18:40:19.322750317 +0200 *************** *** 168,175 **** ISN_PROF_START, // start a line for profiling ISN_PROF_END, // end a line for profiling ! ISN_DEBUG, // check for debug breakpoint, isn_arg.number is current ! // number of local variables ISN_UNPACK, // unpack list into items, uses isn_arg.unpack ISN_SHUFFLE, // move item on stack up or down --- 168,174 ---- ISN_PROF_START, // start a line for profiling ISN_PROF_END, // end a line for profiling ! ISN_DEBUG, // check for debug breakpoint, uses isn_arg.debug ISN_UNPACK, // unpack list into items, uses isn_arg.unpack ISN_SHUFFLE, // move item on stack up or down *************** *** 391,396 **** --- 390,401 ---- int invert; } tobool_T; + // arguments to ISN_DEBUG + typedef struct { + varnumber_T dbg_var_names_len; // current number of local variables + int dbg_break_lnum; // first line to break after + } debug_T; + /* * Instruction */ *************** *** 439,444 **** --- 444,450 ---- tostring_T tostring; tobool_T tobool; getitem_T getitem; + debug_T debug; } isn_arg; }; *** ../vim-8.2.3038/src/vim9compile.c 2021-06-21 19:43:59.146216296 +0200 --- src/vim9compile.c 2021-06-23 20:20:09.318883401 +0200 *************** *** 174,179 **** --- 174,182 ---- char_u *ctx_line_start; // start of current line or NULL garray_T ctx_instr; // generated instructions + int ctx_prev_lnum; // line number below previous command, for + // debugging + compiletype_T ctx_compile_type; garray_T ctx_locals; // currently visible local variables *************** *** 585,591 **** if ((isn = generate_instr(cctx, ISN_DEBUG)) == NULL) return NULL; ! isn->isn_arg.number = dfunc->df_var_names.ga_len; return isn; } --- 588,595 ---- if ((isn = generate_instr(cctx, ISN_DEBUG)) == NULL) return NULL; ! isn->isn_arg.debug.dbg_var_names_len = dfunc->df_var_names.ga_len; ! isn->isn_arg.debug.dbg_break_lnum = cctx->ctx_prev_lnum; return isn; } *************** *** 9270,9275 **** --- 9274,9280 ---- debug_lnum = cctx.ctx_lnum; generate_instr_debug(&cctx); } + cctx.ctx_prev_lnum = cctx.ctx_lnum + 1; // Some things can be recognized by the first character. switch (*ea.cmd) *** ../vim-8.2.3038/src/vim9execute.c 2021-06-21 19:43:59.146216296 +0200 --- src/vim9execute.c 2021-06-23 18:41:29.386584506 +0200 *************** *** 1473,1486 **** // check for the next breakpoint if needed breakpoint = dbg_find_breakpoint(FALSE, ufunc->uf_name, ! iptr->isn_lnum - 1); if (breakpoint <= 0 || breakpoint > iptr->isn_lnum) return; } 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 --- 1473,1486 ---- // check for the next breakpoint if needed breakpoint = dbg_find_breakpoint(FALSE, ufunc->uf_name, ! iptr->isn_arg.debug.dbg_break_lnum); if (breakpoint <= 0 || breakpoint > iptr->isn_lnum) return; } SOURCING_LNUM = iptr->isn_lnum; debug_context = ectx; ! debug_var_count = iptr->isn_arg.debug.dbg_var_names_len; for (ni = iptr + 1; ni->isn_type != ISN_FINISH; ++ni) if (ni->isn_type == ISN_DEBUG *************** *** 5476,5483 **** break; case ISN_DEBUG: ! smsg("%s%4d DEBUG line %d varcount %lld", pfx, current, ! iptr->isn_lnum, iptr->isn_arg.number); break; case ISN_UNPACK: smsg("%s%4d UNPACK %d%s", pfx, current, --- 5476,5485 ---- break; case ISN_DEBUG: ! smsg("%s%4d DEBUG line %d-%d varcount %lld", pfx, current, ! iptr->isn_arg.debug.dbg_break_lnum + 1, ! iptr->isn_lnum, ! iptr->isn_arg.debug.dbg_var_names_len); break; case ISN_UNPACK: smsg("%s%4d UNPACK %d%s", pfx, current, *** ../vim-8.2.3038/src/testdir/test_debugger.vim 2021-06-20 20:09:38.590432377 +0200 --- src/testdir/test_debugger.vim 2021-06-23 20:17:53.799227630 +0200 *************** *** 947,953 **** def LocalFunc() echo "first" echo "second" ! breakadd func 1 LegacyFunc LegacyFunc() enddef --- 947,953 ---- def LocalFunc() echo "first" echo "second" ! breakadd func LegacyFunc LegacyFunc() enddef *************** *** 1010,1015 **** --- 1010,1022 ---- eval 1 enddef enddef + def g:FuncComment() + # comment + echo "first" + .. "one" + # comment + echo "second" + enddef END call writefile(file, 'Xtest.vim') *************** *** 1049,1054 **** --- 1056,1067 ---- \ ['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) *** ../vim-8.2.3038/src/testdir/test_vim9_disassemble.vim 2021-06-21 19:43:59.146216296 +0200 --- src/testdir/test_vim9_disassemble.vim 2021-06-23 18:41:17.626612223 +0200 *************** *** 2176,2182 **** --- 2176,2184 ---- enddef def s:Profiled(): string + # comment echo "profiled" + # comment var some = "some text" return "done" enddef *************** *** 2187,2204 **** endif var res = execute('disass profile s:Profiled') assert_match('\d*_Profiled\_s*' .. 'echo "profiled"\_s*' .. ! '\d PROFILE START line 1\_s*' .. '\d PUSHS "profiled"\_s*' .. '\d ECHO 1\_s*' .. 'var some = "some text"\_s*' .. '\d PROFILE END\_s*' .. ! '\d PROFILE START line 2\_s*' .. '\d PUSHS "some text"\_s*' .. '\d STORE $0\_s*' .. 'return "done"\_s*' .. '\d PROFILE END\_s*' .. ! '\d PROFILE START line 3\_s*' .. '\d PUSHS "done"\_s*' .. '\d\+ RETURN\_s*' .. '\d\+ PROFILE END', --- 2189,2208 ---- endif var res = execute('disass profile s:Profiled') assert_match('\d*_Profiled\_s*' .. + '# comment\_s*' .. 'echo "profiled"\_s*' .. ! '\d PROFILE START line 2\_s*' .. '\d PUSHS "profiled"\_s*' .. '\d ECHO 1\_s*' .. + '# comment\_s*' .. 'var some = "some text"\_s*' .. '\d PROFILE END\_s*' .. ! '\d PROFILE START line 4\_s*' .. '\d PUSHS "some text"\_s*' .. '\d STORE $0\_s*' .. 'return "done"\_s*' .. '\d PROFILE END\_s*' .. ! '\d PROFILE START line 5\_s*' .. '\d PUSHS "done"\_s*' .. '\d\+ RETURN\_s*' .. '\d\+ PROFILE END', *************** *** 2208,2223 **** def Test_debugged() var res = execute('disass debug s:Profiled') assert_match('\d*_Profiled\_s*' .. 'echo "profiled"\_s*' .. ! '\d DEBUG line 1 varcount 0\_s*' .. '\d PUSHS "profiled"\_s*' .. '\d ECHO 1\_s*' .. 'var some = "some text"\_s*' .. ! '\d DEBUG line 2 varcount 0\_s*' .. '\d PUSHS "some text"\_s*' .. '\d STORE $0\_s*' .. 'return "done"\_s*' .. ! '\d DEBUG line 3 varcount 1\_s*' .. '\d PUSHS "done"\_s*' .. '\d RETURN\_s*', res) --- 2212,2229 ---- def Test_debugged() var res = execute('disass debug s:Profiled') assert_match('\d*_Profiled\_s*' .. + '# comment\_s*' .. 'echo "profiled"\_s*' .. ! '\d DEBUG line 1-2 varcount 0\_s*' .. '\d PUSHS "profiled"\_s*' .. '\d ECHO 1\_s*' .. + '# comment\_s*' .. 'var some = "some text"\_s*' .. ! '\d DEBUG line 3-4 varcount 0\_s*' .. '\d PUSHS "some text"\_s*' .. '\d STORE $0\_s*' .. 'return "done"\_s*' .. ! '\d DEBUG line 5-5 varcount 1\_s*' .. '\d PUSHS "done"\_s*' .. '\d RETURN\_s*', res) *** ../vim-8.2.3038/src/version.c 2021-06-23 15:52:39.974570654 +0200 --- src/version.c 2021-06-23 17:02:26.565360387 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3039, /**/ -- In many of the more relaxed civilizations on the Outer Eastern Rim of the Galaxy, "The Hitchhiker's Guide to the Galaxy" has already supplanted the great "Encyclopedia Galactica" as the standard repository of all knowledge and wisdom, for though it has many omissions and contains much that is apocryphal, or at least wildly inaccurate, it scores over the older, more pedestrian work in two important respects. First, it is slightly cheaper; and second, it has the words "DON'T PANIC" inscribed in large friendly letters on its cover. -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy" /// Bram Moolenaar -- Bram@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 ///