mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.3417: Vim9: a failing debug expression aborts script sourcing
Problem: Vim9: a failing debug expression aborts script sourcing. Solution: Do not let expression failure abort script sourcing. (closes #8848)
This commit is contained in:
@@ -530,6 +530,29 @@ static garray_T prof_ga = {0, 0, sizeof(struct debuggy), 4, NULL};
|
|||||||
|
|
||||||
static linenr_T debuggy_find(int file,char_u *fname, linenr_T after, garray_T *gap, int *fp);
|
static linenr_T debuggy_find(int file,char_u *fname, linenr_T after, garray_T *gap, int *fp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Evaluate the "bp->dbg_name" expression and return the result.
|
||||||
|
* Restore the got_int and called_emsg flags.
|
||||||
|
*/
|
||||||
|
static typval_T *
|
||||||
|
eval_expr_restore(struct debuggy *bp)
|
||||||
|
{
|
||||||
|
typval_T *tv;
|
||||||
|
int prev_called_emsg = called_emsg;
|
||||||
|
int prev_did_emsg = did_emsg;
|
||||||
|
|
||||||
|
got_int = FALSE;
|
||||||
|
tv = eval_expr(bp->dbg_name, NULL);
|
||||||
|
|
||||||
|
// Evaluating the expression should not result in breaking the sequence of
|
||||||
|
// commands.
|
||||||
|
got_int = FALSE;
|
||||||
|
called_emsg = prev_called_emsg;
|
||||||
|
did_emsg = prev_did_emsg;
|
||||||
|
|
||||||
|
return tv;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse the arguments of ":profile", ":breakadd" or ":breakdel" and put them
|
* Parse the arguments of ":profile", ":breakadd" or ":breakdel" and put them
|
||||||
* in the entry just after the last one in dbg_breakp. Note that "dbg_name"
|
* in the entry just after the last one in dbg_breakp. Note that "dbg_name"
|
||||||
@@ -614,7 +637,7 @@ dbg_parsearg(
|
|||||||
{
|
{
|
||||||
bp->dbg_name = vim_strsave(p);
|
bp->dbg_name = vim_strsave(p);
|
||||||
if (bp->dbg_name != NULL)
|
if (bp->dbg_name != NULL)
|
||||||
bp->dbg_val = eval_expr(bp->dbg_name, NULL);
|
bp->dbg_val = eval_expr_restore(bp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -960,10 +983,7 @@ debuggy_find(
|
|||||||
typval_T *tv;
|
typval_T *tv;
|
||||||
int line = FALSE;
|
int line = FALSE;
|
||||||
|
|
||||||
prev_got_int = got_int;
|
tv = eval_expr_restore(bp);
|
||||||
got_int = FALSE;
|
|
||||||
|
|
||||||
tv = eval_expr(bp->dbg_name, NULL);
|
|
||||||
if (tv != NULL)
|
if (tv != NULL)
|
||||||
{
|
{
|
||||||
if (bp->dbg_val == NULL)
|
if (bp->dbg_val == NULL)
|
||||||
@@ -984,7 +1004,7 @@ debuggy_find(
|
|||||||
debug_oldval = typval_tostring(bp->dbg_val, TRUE);
|
debug_oldval = typval_tostring(bp->dbg_val, TRUE);
|
||||||
// Need to evaluate again, typval_compare() overwrites
|
// Need to evaluate again, typval_compare() overwrites
|
||||||
// "tv".
|
// "tv".
|
||||||
v = eval_expr(bp->dbg_name, NULL);
|
v = eval_expr_restore(bp);
|
||||||
debug_newval = typval_tostring(v, TRUE);
|
debug_newval = typval_tostring(v, TRUE);
|
||||||
free_tv(bp->dbg_val);
|
free_tv(bp->dbg_val);
|
||||||
bp->dbg_val = v;
|
bp->dbg_val = v;
|
||||||
@@ -1006,8 +1026,6 @@ debuggy_find(
|
|||||||
lnum = after > 0 ? after : 1;
|
lnum = after > 0 ? after : 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
got_int |= prev_got_int;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -318,7 +318,9 @@ func Test_Debugger()
|
|||||||
call RunDbgCmd(buf, 'enew! | only!')
|
call RunDbgCmd(buf, 'enew! | only!')
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_Debugger_breakadd()
|
||||||
" Tests for :breakadd file and :breakadd here
|
" Tests for :breakadd file and :breakadd here
|
||||||
" Breakpoints should be set before sourcing the file
|
" Breakpoints should be set before sourcing the file
|
||||||
|
|
||||||
@@ -342,10 +344,37 @@ func Test_Debugger()
|
|||||||
|
|
||||||
call delete('Xtest.vim')
|
call delete('Xtest.vim')
|
||||||
%bw!
|
%bw!
|
||||||
|
|
||||||
call assert_fails('breakadd here', 'E32:')
|
call assert_fails('breakadd here', 'E32:')
|
||||||
call assert_fails('breakadd file Xtest.vim /\)/', 'E55:')
|
call assert_fails('breakadd file Xtest.vim /\)/', 'E55:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
def Test_Debugger_breakadd_expr()
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
func g:EarlyFunc()
|
||||||
|
endfunc
|
||||||
|
breakadd expr DoesNotExist()
|
||||||
|
func g:LaterFunc()
|
||||||
|
endfunc
|
||||||
|
breakdel *
|
||||||
|
END
|
||||||
|
writefile(lines, 'Xtest.vim')
|
||||||
|
|
||||||
|
# Start Vim in a terminal
|
||||||
|
var buf = RunVimInTerminal('-S Xtest.vim', {wait_for_ruler: 0})
|
||||||
|
call TermWait(buf)
|
||||||
|
|
||||||
|
# Despite the failure the functions are defined
|
||||||
|
RunDbgCmd(buf, ':function g:EarlyFunc',
|
||||||
|
['function EarlyFunc()', 'endfunction'], {match: 'pattern'})
|
||||||
|
RunDbgCmd(buf, ':function g:LaterFunc',
|
||||||
|
['function LaterFunc()', 'endfunction'], {match: 'pattern'})
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete('Xtest.vim')
|
||||||
|
enddef
|
||||||
|
|
||||||
func Test_Backtrace_Through_Source()
|
func Test_Backtrace_Through_Source()
|
||||||
CheckCWD
|
CheckCWD
|
||||||
let file1 =<< trim END
|
let file1 =<< trim END
|
||||||
|
@@ -755,6 +755,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3417,
|
||||||
/**/
|
/**/
|
||||||
3416,
|
3416,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user