diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-14 05:18:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-14 05:18:21 +0800 |
commit | 8cd116729fe2a15d62cd10e5ba7d3dcf1f677337 (patch) | |
tree | c3697b80da96e6e1165742979deb121ca491b1d0 /src/nvim/debugger.c | |
parent | c1cbe3fb3d2ec1dbcfdc14ee2d9a5e8049d494ae (diff) | |
parent | 1ca2247639424994890ef70ab34f2bffa23ddd9f (diff) | |
download | rneovim-8cd116729fe2a15d62cd10e5ba7d3dcf1f677337.tar.gz rneovim-8cd116729fe2a15d62cd10e5ba7d3dcf1f677337.tar.bz2 rneovim-8cd116729fe2a15d62cd10e5ba7d3dcf1f677337.zip |
Merge pull request #19752 from zeertzjq/vim-8.2.0056
vim-patch:8.2.{0056,0061,0078,0097,0823}: execution stack
Diffstat (limited to 'src/nvim/debugger.c')
-rw-r--r-- | src/nvim/debugger.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 0eaff06833..76e1caff49 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -17,6 +17,7 @@ #include "nvim/os/os.h" #include "nvim/pos.h" #include "nvim/regexp.h" +#include "nvim/runtime.h" #include "nvim/screen.h" #include "nvim/types.h" #include "nvim/vim.h" @@ -98,14 +99,17 @@ void do_debug(char_u *cmd) xfree(debug_newval); debug_newval = NULL; } - if (sourcing_name != NULL) { - msg(sourcing_name); + char *sname = estack_sfile(); + if (sname != NULL) { + msg(sname); } - if (sourcing_lnum != 0) { - smsg(_("line %" PRId64 ": %s"), (int64_t)sourcing_lnum, cmd); + xfree(sname); + if (SOURCING_LNUM != 0) { + smsg(_("line %" PRId64 ": %s"), (int64_t)SOURCING_LNUM, cmd); } else { smsg(_("cmd: %s"), cmd); } + // Repeat getting a command and executing it. for (;;) { msg_scroll = true; @@ -287,12 +291,12 @@ void do_debug(char_u *cmd) debug_did_msg = true; } -static int get_maxbacktrace_level(void) +static int get_maxbacktrace_level(char *sname) { int maxbacktrace = 0; - if (sourcing_name != NULL) { - char *p = sourcing_name; + if (sname != NULL) { + char *p = sname; char *q; while ((q = strstr(p, "..")) != NULL) { p = q + 2; @@ -320,20 +324,24 @@ static void do_checkbacktracelevel(void) debug_backtrace_level = 0; msg(_("frame is zero")); } else { - int max = get_maxbacktrace_level(); + char *sname = estack_sfile(); + int max = get_maxbacktrace_level(sname); + if (debug_backtrace_level > max) { debug_backtrace_level = max; smsg(_("frame at highest level: %d"), max); } + xfree(sname); } } static void do_showbacktrace(char_u *cmd) { - if (sourcing_name != NULL) { + char *sname = estack_sfile(); + int max = get_maxbacktrace_level(sname); + if (sname != NULL) { int i = 0; - int max = get_maxbacktrace_level(); - char *cur = sourcing_name; + char *cur = sname; while (!got_int) { char *next = strstr(cur, ".."); if (next != NULL) { @@ -351,9 +359,11 @@ static void do_showbacktrace(char_u *cmd) *next = '.'; cur = next + 2; } + xfree(sname); } - if (sourcing_lnum != 0) { - smsg(_("line %" PRId64 ": %s"), (int64_t)sourcing_lnum, cmd); + + if (SOURCING_LNUM != 0) { + smsg(_("line %" PRId64 ": %s"), (int64_t)SOURCING_LNUM, cmd); } else { smsg(_("cmd: %s"), cmd); } |