diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-06-16 19:19:55 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-06-16 19:19:55 +0200 |
commit | 6bc30b05e6081bcaece6d1a7fcfca238ea5a194f (patch) | |
tree | 32f3fdd08c680d474aaa761cc289ee6cd6238038 /src/vim9execute.c | |
parent | 41a7f82dea525b3398bf372cbb9c268455845800 (diff) | |
download | vim-git-6bc30b05e6081bcaece6d1a7fcfca238ea5a194f.tar.gz |
patch 8.2.3011: Vim9: cannot get argument values during debuggingv8.2.3011
Problem: Vim9: cannot get argument values during debugging.
Solution: Lookup names in the list of arguments. Put debug instruction
halfway for command.
Diffstat (limited to 'src/vim9execute.c')
-rw-r--r-- | src/vim9execute.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/vim9execute.c b/src/vim9execute.c index e464732dd..bbcf7ffc3 100644 --- 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) |