summaryrefslogtreecommitdiff
path: root/src/vim9execute.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-06-20 19:28:14 +0200
committerBram Moolenaar <Bram@vim.org>2021-06-20 19:28:14 +0200
commit4f8f54280fa728b7d5a63b67d02b60a3b3dce543 (patch)
tree962b41838e72571485245ed05d17dab53e0b5bfd /src/vim9execute.c
parent0d5e1ec37fbe75e18acba6f650c59bf91063108c (diff)
downloadvim-git-4f8f54280fa728b7d5a63b67d02b60a3b3dce543.tar.gz
patch 8.2.3026: Vim9: cannot set breakpoint in compiled functionv8.2.3026
Problem: Vim9: cannot set breakpoint in compiled function. Solution: Check for breakpoint when calling a function.
Diffstat (limited to 'src/vim9execute.c')
-rw-r--r--src/vim9execute.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 218357a82..8b817e450 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -148,6 +148,23 @@ exe_newlist(int count, ectx_T *ectx)
}
/*
+ * If debug_tick changed check if "ufunc" has a breakpoint and update
+ * "uf_has_breakpoint".
+ */
+ static void
+update_has_breakpoint(ufunc_T *ufunc)
+{
+ if (ufunc->uf_debug_tick != debug_tick)
+ {
+ linenr_T breakpoint;
+
+ ufunc->uf_debug_tick = debug_tick;
+ breakpoint = dbg_find_breakpoint(FALSE, ufunc->uf_name, 0);
+ ufunc->uf_has_breakpoint = breakpoint > 0;
+ }
+}
+
+/*
* Call compiled function "cdf_idx" from compiled code.
* This adds a stack frame and sets the instruction pointer to the start of the
* called function.
@@ -1444,6 +1461,20 @@ handle_debug(isn_T *iptr, ectx_T *ectx)
garray_T ga;
int lnum;
+ if (ex_nesting_level > debug_break_level)
+ {
+ linenr_T breakpoint;
+
+ if (!ufunc->uf_has_breakpoint)
+ return;
+
+ // 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;
@@ -4206,8 +4237,7 @@ exec_instructions(ectx_T *ectx)
break;
case ISN_DEBUG:
- if (ex_nesting_level <= debug_break_level)
- handle_debug(iptr, ectx);
+ handle_debug(iptr, ectx);
break;
case ISN_SHUFFLE:
@@ -4383,6 +4413,9 @@ call_def_function(
#undef STACK_TV_VAR
#define STACK_TV_VAR(idx) (((typval_T *)ectx.ec_stack.ga_data) + ectx.ec_frame_idx + STACK_FRAME_SIZE + idx)
+ // Update uf_has_breakpoint if needed.
+ update_has_breakpoint(ufunc);
+
if (ufunc->uf_def_status == UF_NOT_COMPILED
|| ufunc->uf_def_status == UF_COMPILE_ERROR
|| (func_needs_compiling(ufunc, COMPILE_TYPE(ufunc))