Skip to content

Commit 0325d39

Browse files
committed
patch 8.2.3419: a failing debug expression may make Vim unusable
Problem: A failing debug expression may make Vim unusable. Solution: Suppress error messages. (closes #8848)
1 parent 070ac34 commit 0325d39

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

src/debugger.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -532,23 +532,17 @@ static linenr_T debuggy_find(int file,char_u *fname, linenr_T after, garray_T *g
532532

533533
/*
534534
* Evaluate the "bp->dbg_name" expression and return the result.
535-
* Restore the got_int and called_emsg flags.
535+
* Disables error messages.
536536
*/
537537
static typval_T *
538-
eval_expr_restore(struct debuggy *bp)
538+
eval_expr_no_emsg(struct debuggy *bp)
539539
{
540540
typval_T *tv;
541-
int prev_called_emsg = called_emsg;
542-
int prev_did_emsg = did_emsg;
543541

544-
got_int = FALSE;
542+
// Disable error messages, a bad expression would make Vim unusable.
543+
++emsg_off;
545544
tv = eval_expr(bp->dbg_name, NULL);
546-
547-
// Evaluating the expression should not result in breaking the sequence of
548-
// commands.
549-
got_int = FALSE;
550-
called_emsg = prev_called_emsg;
551-
did_emsg = prev_did_emsg;
545+
--emsg_off;
552546

553547
return tv;
554548
}
@@ -637,7 +631,7 @@ dbg_parsearg(
637631
{
638632
bp->dbg_name = vim_strsave(p);
639633
if (bp->dbg_name != NULL)
640-
bp->dbg_val = eval_expr_restore(bp);
634+
bp->dbg_val = eval_expr_no_emsg(bp);
641635
}
642636
else
643637
{
@@ -983,7 +977,7 @@ debuggy_find(
983977
typval_T *tv;
984978
int line = FALSE;
985979

986-
tv = eval_expr_restore(bp);
980+
tv = eval_expr_no_emsg(bp);
987981
if (tv != NULL)
988982
{
989983
if (bp->dbg_val == NULL)
@@ -1004,7 +998,7 @@ debuggy_find(
1004998
debug_oldval = typval_tostring(bp->dbg_val, TRUE);
1005999
// Need to evaluate again, typval_compare() overwrites
10061000
// "tv".
1007-
v = eval_expr_restore(bp);
1001+
v = eval_expr_no_emsg(bp);
10081002
debug_newval = typval_tostring(v, TRUE);
10091003
free_tv(bp->dbg_val);
10101004
bp->dbg_val = v;

src/testdir/test_debugger.vim

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,7 @@ func Test_Debugger()
271271
call RunDbgCmd(buf, 'breakd func a()', ['E475: Invalid argument: func a()'])
272272
call RunDbgCmd(buf, 'breakd func a', ['E161: Breakpoint not found: func a'])
273273
call RunDbgCmd(buf, 'breakd expr', ['E475: Invalid argument: expr'])
274-
call RunDbgCmd(buf, 'breakd expr x', [
275-
\ 'E121: Undefined variable: x',
276-
\ 'E161: Breakpoint not found: expr x'])
274+
call RunDbgCmd(buf, 'breakd expr x', ['E161: Breakpoint not found: expr x'])
277275

278276
" finish the current function
279277
call RunDbgCmd(buf, 'finish', [

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3419,
758760
/**/
759761
3418,
760762
/**/

0 commit comments

Comments
 (0)