diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-01-16 15:40:53 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-01-16 15:40:53 +0100 |
commit | f1f60f859cdbb2638b3662ccf7b1d179865fe7dc (patch) | |
tree | 739551087fb1b9948568366dc5d6187861dbcaf5 /src/eval.c | |
parent | e39b3d9fb4e4006684c33847d1ef6a0d742699dd (diff) |
patch 7.4.1102v7.4.1102
Problem: Debugger has no stack backtrace support.
Solution: Add "backtrace", "frame", "up" and "down" commands. (Alberto
Fanjul, closes #433)
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/eval.c b/src/eval.c index e97ddc4781..1e2a0419e6 100644 --- a/src/eval.c +++ b/src/eval.c @@ -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 ¤t_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,9 +21757,9 @@ find_var_ht(name, varname) if (*name == 'v') /* v: variable */ return &vimvarht; if (*name == 'a' && current_funccal != NULL) /* function argument */ - return ¤t_funccal->l_avars.dv_hashtab; + return &get_funccal()->l_avars.dv_hashtab; if (*name == 'l' && current_funccal != NULL) /* local function variable */ - return ¤t_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); @@ -21766,6 +21767,32 @@ find_var_ht(name, varname) } /* + * 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. * Returns NULL when it doesn't exist. |