To: vim_dev@googlegroups.com Subject: Patch 8.2.3086 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3086 Problem: Vim9: breakpoint on "for" does not work. Solution: Use the right line number in ISN_DEBUG. (closes #8486) Files: src/vim9compile.c, src/testdir/test_debugger.vim *** ../vim-8.2.3085/src/vim9compile.c 2021-06-30 20:39:11.366130953 +0200 --- src/vim9compile.c 2021-07-03 13:28:58.584405025 +0200 *************** *** 7747,7752 **** --- 7747,7753 ---- type_T *vartype; type_T *item_type = &t_any; int idx; + int prev_lnum = cctx->ctx_prev_lnum; p = skip_var_list(arg_start, TRUE, &var_count, &semicolon, FALSE); if (p == NULL) *************** *** 7774,7780 **** --- 7775,7785 ---- if (cctx->ctx_compile_type == CT_DEBUG && instr->ga_len > 0 && ((isn_T *)instr->ga_data)[instr->ga_len - 1] .isn_type == ISN_DEBUG) + { --instr->ga_len; + prev_lnum = ((isn_T *)instr->ga_data)[instr->ga_len] + .isn_arg.debug.dbg_break_lnum; + } scope = new_scope(cctx, FOR_SCOPE); if (scope == NULL) *************** *** 7934,7941 **** --- 7939,7953 ---- } if (cctx->ctx_compile_type == CT_DEBUG) + { + int save_prev_lnum = cctx->ctx_prev_lnum; + // Add ISN_DEBUG here, so that the loop variables can be inspected. + // Use the prev_lnum from the ISN_DEBUG instruction removed above. + cctx->ctx_prev_lnum = prev_lnum; generate_instr_debug(cctx); + cctx->ctx_prev_lnum = save_prev_lnum; + } return arg_end; *** ../vim-8.2.3085/src/testdir/test_debugger.vim 2021-06-27 16:29:50.119042807 +0200 --- src/testdir/test_debugger.vim 2021-07-03 13:36:01.467648710 +0200 *************** *** 1017,1022 **** --- 1017,1029 ---- # 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') *************** *** 1062,1067 **** --- 1069,1083 ---- 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) *** ../vim-8.2.3085/src/version.c 2021-07-03 13:04:21.831015567 +0200 --- src/version.c 2021-07-03 13:27:00.736607216 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3086, /**/ -- hundred-and-one symptoms of being an internet addict: 79. All of your most erotic dreams have a scrollbar at the right side. /// 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 ///