Mercurial > vim
comparison src/debugger.c @ 25767:dfa045d2cc89 v8.2.3419
patch 8.2.3419: a failing debug expression may make Vim unusable
Commit: https://github.com/vim/vim/commit/0325d3967ce7d0fd35bc1472fd476b911b895b76
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Sep 9 12:34:19 2021 +0200
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 https://github.com/vim/vim/issues/8848)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 09 Sep 2021 12:45:03 +0200 |
parents | 5e7c96e9036d |
children | 336e2d9924e6 |
comparison
equal
deleted
inserted
replaced
25766:c0b0335f8aa9 | 25767:dfa045d2cc89 |
---|---|
530 | 530 |
531 static linenr_T debuggy_find(int file,char_u *fname, linenr_T after, garray_T *gap, int *fp); | 531 static linenr_T debuggy_find(int file,char_u *fname, linenr_T after, garray_T *gap, int *fp); |
532 | 532 |
533 /* | 533 /* |
534 * Evaluate the "bp->dbg_name" expression and return the result. | 534 * Evaluate the "bp->dbg_name" expression and return the result. |
535 * Restore the got_int and called_emsg flags. | 535 * Disables error messages. |
536 */ | 536 */ |
537 static typval_T * | 537 static typval_T * |
538 eval_expr_restore(struct debuggy *bp) | 538 eval_expr_no_emsg(struct debuggy *bp) |
539 { | 539 { |
540 typval_T *tv; | 540 typval_T *tv; |
541 int prev_called_emsg = called_emsg; | 541 |
542 int prev_did_emsg = did_emsg; | 542 // Disable error messages, a bad expression would make Vim unusable. |
543 | 543 ++emsg_off; |
544 got_int = FALSE; | |
545 tv = eval_expr(bp->dbg_name, NULL); | 544 tv = eval_expr(bp->dbg_name, NULL); |
546 | 545 --emsg_off; |
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; | |
552 | 546 |
553 return tv; | 547 return tv; |
554 } | 548 } |
555 | 549 |
556 /* | 550 /* |
635 bp->dbg_name = vim_strsave(curbuf->b_ffname); | 629 bp->dbg_name = vim_strsave(curbuf->b_ffname); |
636 else if (bp->dbg_type == DBG_EXPR) | 630 else if (bp->dbg_type == DBG_EXPR) |
637 { | 631 { |
638 bp->dbg_name = vim_strsave(p); | 632 bp->dbg_name = vim_strsave(p); |
639 if (bp->dbg_name != NULL) | 633 if (bp->dbg_name != NULL) |
640 bp->dbg_val = eval_expr_restore(bp); | 634 bp->dbg_val = eval_expr_no_emsg(bp); |
641 } | 635 } |
642 else | 636 else |
643 { | 637 { |
644 // Expand the file name in the same way as do_source(). This means | 638 // Expand the file name in the same way as do_source(). This means |
645 // doing it twice, so that $DIR/file gets expanded when $DIR is | 639 // doing it twice, so that $DIR/file gets expanded when $DIR is |
981 else if (bp->dbg_type == DBG_EXPR) | 975 else if (bp->dbg_type == DBG_EXPR) |
982 { | 976 { |
983 typval_T *tv; | 977 typval_T *tv; |
984 int line = FALSE; | 978 int line = FALSE; |
985 | 979 |
986 tv = eval_expr_restore(bp); | 980 tv = eval_expr_no_emsg(bp); |
987 if (tv != NULL) | 981 if (tv != NULL) |
988 { | 982 { |
989 if (bp->dbg_val == NULL) | 983 if (bp->dbg_val == NULL) |
990 { | 984 { |
991 debug_oldval = typval_tostring(NULL, TRUE); | 985 debug_oldval = typval_tostring(NULL, TRUE); |
1002 | 996 |
1003 line = TRUE; | 997 line = TRUE; |
1004 debug_oldval = typval_tostring(bp->dbg_val, TRUE); | 998 debug_oldval = typval_tostring(bp->dbg_val, TRUE); |
1005 // Need to evaluate again, typval_compare() overwrites | 999 // Need to evaluate again, typval_compare() overwrites |
1006 // "tv". | 1000 // "tv". |
1007 v = eval_expr_restore(bp); | 1001 v = eval_expr_no_emsg(bp); |
1008 debug_newval = typval_tostring(v, TRUE); | 1002 debug_newval = typval_tostring(v, TRUE); |
1009 free_tv(bp->dbg_val); | 1003 free_tv(bp->dbg_val); |
1010 bp->dbg_val = v; | 1004 bp->dbg_val = v; |
1011 } | 1005 } |
1012 free_tv(tv); | 1006 free_tv(tv); |