0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 7.4.1102

Problem:    Debugger has no stack backtrace support.
Solution:   Add "backtrace", "frame", "up" and "down" commands. (Alberto
            Fanjul, closes #433)
This commit is contained in:
Bram Moolenaar
2016-01-16 15:40:53 +01:00
parent e39b3d9fb4
commit f1f60f859c
8 changed files with 382 additions and 8 deletions

View File

@@ -812,6 +812,7 @@ static char_u *get_tv_string_buf_chk __ARGS((typval_T *varp, char_u *buf));
static dictitem_T *find_var __ARGS((char_u *name, hashtab_T **htp, int no_autoload));
static dictitem_T *find_var_in_ht __ARGS((hashtab_T *ht, int htname, char_u *varname, int no_autoload));
static hashtab_T *find_var_ht __ARGS((char_u *name, char_u **varname));
static funccall_T *get_funccal __ARGS((void));
static void vars_clear_ext __ARGS((hashtab_T *ht, int free_val));
static void delete_var __ARGS((hashtab_T *ht, hashitem_T *hi));
static void list_one_var __ARGS((dictitem_T *v, char_u *prefix, int *first));
@@ -21735,7 +21736,7 @@ find_var_ht(name, varname)
if (current_funccal == NULL)
return &globvarht; /* global variable */
return &current_funccal->l_vars.dv_hashtab; /* l: variable */
return &get_funccal()->l_vars.dv_hashtab; /* l: variable */
}
*varname = name + 2;
if (*name == 'g') /* global variable */
@@ -21756,15 +21757,41 @@ find_var_ht(name, varname)
if (*name == 'v') /* v: variable */
return &vimvarht;
if (*name == 'a' && current_funccal != NULL) /* function argument */
return &current_funccal->l_avars.dv_hashtab;
return &get_funccal()->l_avars.dv_hashtab;
if (*name == 'l' && current_funccal != NULL) /* local function variable */
return &current_funccal->l_vars.dv_hashtab;
return &get_funccal()->l_vars.dv_hashtab;
if (*name == 's' /* script variable */
&& current_SID > 0 && current_SID <= ga_scripts.ga_len)
return &SCRIPT_VARS(current_SID);
return NULL;
}
/*
* Get function call environment based on bactrace debug level
*/
static funccall_T *
get_funccal()
{
int i;
funccall_T *funccal;
funccall_T *temp_funccal;
funccal = current_funccal;
if (debug_backtrace_level > 0)
{
for (i = 0; i < debug_backtrace_level; i++)
{
temp_funccal = funccal->caller;
if (temp_funccal)
funccal = temp_funccal;
else
/* backtrace level overflow. reset to max */
debug_backtrace_level = i;
}
}
return funccal;
}
/*
* Get the string value of a (global/local) variable.
* Note: see get_tv_string() for how long the pointer remains valid.