Mercurial > vim
diff src/vim9execute.c @ 24948:5c418c774f95 v8.2.3011
patch 8.2.3011: Vim9: cannot get argument values during debugging
Commit: https://github.com/vim/vim/commit/6bc30b05e6081bcaece6d1a7fcfca238ea5a194f
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jun 16 19:19:55 2021 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 16 Jun 2021 19:30:04 +0200 |
parents | 345619f35112 |
children | ffe784fdec57 |
line wrap: on
line diff
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -1394,7 +1394,7 @@ typedef struct subs_expr_S { // Set when calling do_debug(). static ectx_T *debug_context = NULL; -static int debug_arg_count; +static int debug_var_count; /* * When debugging lookup "name" and return the typeval. @@ -1405,20 +1405,31 @@ lookup_debug_var(char_u *name) { int idx; dfunc_T *dfunc; + ufunc_T *ufunc; ectx_T *ectx = debug_context; + int varargs_off; if (ectx == NULL) return NULL; dfunc = ((dfunc_T *)def_functions.ga_data) + ectx->ec_dfunc_idx; // Go through the local variable names, from last to first. - for (idx = debug_arg_count - 1; idx >= 0; --idx) + for (idx = debug_var_count - 1; idx >= 0; --idx) { - char_u *s = ((char_u **)dfunc->df_var_names.ga_data)[idx]; - if (STRCMP(s, name) == 0) + if (STRCMP(((char_u **)dfunc->df_var_names.ga_data)[idx], name) == 0) return STACK_TV_VAR(idx); } + // Go through argument names. + ufunc = dfunc->df_ufunc; + varargs_off = ufunc->uf_va_name == NULL ? 0 : 1; + for (idx = 0; idx < ufunc->uf_args.ga_len; ++idx) + if (STRCMP(((char_u **)(ufunc->uf_args.ga_data))[idx], name) == 0) + return STACK_TV(ectx->ec_frame_idx - ufunc->uf_args.ga_len + - varargs_off + idx); + if (ufunc->uf_va_name != NULL && STRCMP(ufunc->uf_va_name, name) == 0) + return STACK_TV(ectx->ec_frame_idx - 1); + return NULL; } @@ -4152,7 +4163,7 @@ exec_instructions(ectx_T *ectx) SOURCING_LNUM = iptr->isn_lnum; debug_context = ectx; - debug_arg_count = iptr->isn_arg.number; + debug_var_count = iptr->isn_arg.number; line = ((char_u **)ufunc->uf_lines.ga_data)[ iptr->isn_lnum - 1]; if (line == NULL)