aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorJurica Bradaric <jbradaric@gmail.com>2016-05-10 21:34:56 +0200
committerJurica Bradaric <jbradaric@gmail.com>2016-05-17 20:54:42 +0200
commitb4cbfd3c082732bf584d37671d90793fd5fa09a6 (patch)
tree92282fb3a60b27923c4c18afcd2af35651093c49 /src/nvim/eval.c
parent68717132b1828c7aeb36a9afb3d046ccb6a4a27a (diff)
downloadrneovim-b4cbfd3c082732bf584d37671d90793fd5fa09a6.tar.gz
rneovim-b4cbfd3c082732bf584d37671d90793fd5fa09a6.tar.bz2
rneovim-b4cbfd3c082732bf584d37671d90793fd5fa09a6.zip
vim-patch:7.4.1102
Problem: Debugger has no stack backtrace support. Solution: Add "backtrace", "frame", "up" and "down" commands. (Alberto Fanjul, closes vim/vim#433) https://github.com/vim/vim/commit/f1f60f859cdbb2638b3662ccf7b1d179865fe7dc
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 712ee06b85..201a71facb 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -18123,6 +18123,25 @@ static dictitem_T *find_var_in_ht(hashtab_T *ht, int htname, char_u *varname, in
return HI2DI(hi);
}
+// Get function call environment based on backtrace debug level
+static funccall_T *get_funccal(void)
+{
+ funccall_T *funccal = current_funccal;
+ if (debug_backtrace_level > 0) {
+ for (int i = 0; i < debug_backtrace_level; i++) {
+ funccall_T *temp_funccal = funccal->caller;
+ if (temp_funccal) {
+ funccal = temp_funccal;
+ } else {
+ // backtrace level overflow. reset to max
+ debug_backtrace_level = i;
+ }
+ }
+ }
+
+ return funccal;
+}
+
// Find the dict and hashtable used for a variable name. Set "varname" to the
// start of name without ':'.
static hashtab_T *find_var_ht_dict(char_u *name, uint8_t **varname, dict_T **d)
@@ -18147,7 +18166,11 @@ static hashtab_T *find_var_ht_dict(char_u *name, uint8_t **varname, dict_T **d)
return &compat_hashtab;
}
- *d = current_funccal ? &current_funccal->l_vars : &globvardict;
+ if (current_funccal == NULL) {
+ *d = &globvardict;
+ } else {
+ *d = &get_funccal()->l_vars; // l: variable
+ }
goto end;
}
@@ -18169,9 +18192,9 @@ static hashtab_T *find_var_ht_dict(char_u *name, uint8_t **varname, dict_T **d)
} else if (*name == 'v') { // v: variable
*d = &vimvardict;
} else if (*name == 'a' && current_funccal != NULL) { // function argument
- *d = &current_funccal->l_avars;
+ *d = &get_funccal()->l_avars;
} else if (*name == 'l' && current_funccal != NULL) { // local variable
- *d = &current_funccal->l_vars;
+ *d = &get_funccal()->l_vars;
} else if (*name == 's' // script variable
&& current_SID > 0 && current_SID <= ga_scripts.ga_len) {
*d = &SCRIPT_SV(current_SID)->sv_dict;