mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
vim-patch:8.2.3395: Vim9: expression breakpoint not checked in :def function
Problem: Vim9: expression breakpoint not checked in :def function.
Solution: Always compile a function for debugging if there is an expression
breakpoint. (closes vim/vim#8803)
26a4484da2
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
49d126e005
commit
331d213c0b
@ -475,6 +475,7 @@ static garray_T dbg_breakp = { 0, 0, sizeof(struct debuggy), 4, NULL };
|
|||||||
#define BREAKP(idx) (((struct debuggy *)dbg_breakp.ga_data)[idx])
|
#define BREAKP(idx) (((struct debuggy *)dbg_breakp.ga_data)[idx])
|
||||||
#define DEBUGGY(gap, idx) (((struct debuggy *)(gap)->ga_data)[idx])
|
#define DEBUGGY(gap, idx) (((struct debuggy *)(gap)->ga_data)[idx])
|
||||||
static int last_breakp = 0; // nr of last defined breakpoint
|
static int last_breakp = 0; // nr of last defined breakpoint
|
||||||
|
static bool has_expr_breakpoint = false;
|
||||||
|
|
||||||
// Profiling uses file and func names similar to breakpoints.
|
// Profiling uses file and func names similar to breakpoints.
|
||||||
static garray_T prof_ga = { 0, 0, sizeof(struct debuggy), 4, NULL };
|
static garray_T prof_ga = { 0, 0, sizeof(struct debuggy), 4, NULL };
|
||||||
@ -620,6 +621,9 @@ void ex_breakadd(exarg_T *eap)
|
|||||||
// DBG_EXPR
|
// DBG_EXPR
|
||||||
DEBUGGY(gap, gap->ga_len++).dbg_nr = ++last_breakp;
|
DEBUGGY(gap, gap->ga_len++).dbg_nr = ++last_breakp;
|
||||||
debug_tick++;
|
debug_tick++;
|
||||||
|
if (gap == &dbg_breakp) {
|
||||||
|
has_expr_breakpoint = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -633,6 +637,17 @@ void ex_debuggreedy(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void update_has_expr_breakpoint(void)
|
||||||
|
{
|
||||||
|
has_expr_breakpoint = false;
|
||||||
|
for (int i = 0; i < dbg_breakp.ga_len; i++) {
|
||||||
|
if (BREAKP(i).dbg_type == DBG_EXPR) {
|
||||||
|
has_expr_breakpoint = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// ":breakdel" and ":profdel".
|
/// ":breakdel" and ":profdel".
|
||||||
void ex_breakdel(exarg_T *eap)
|
void ex_breakdel(exarg_T *eap)
|
||||||
{
|
{
|
||||||
@ -708,6 +723,9 @@ void ex_breakdel(exarg_T *eap)
|
|||||||
if (GA_EMPTY(gap)) {
|
if (GA_EMPTY(gap)) {
|
||||||
ga_clear(gap);
|
ga_clear(gap);
|
||||||
}
|
}
|
||||||
|
if (gap == &dbg_breakp) {
|
||||||
|
update_has_expr_breakpoint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ":breaklist".
|
/// ":breaklist".
|
||||||
|
@ -971,6 +971,28 @@ func Test_Backtrace_DefFunction()
|
|||||||
call delete('Xtest2.vim')
|
call delete('Xtest2.vim')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_DefFunction_expr()
|
||||||
|
CheckRunVimInTerminal
|
||||||
|
CheckCWD
|
||||||
|
let file3 =<< trim END
|
||||||
|
vim9script
|
||||||
|
g:someVar = "foo"
|
||||||
|
def g:ChangeVar()
|
||||||
|
g:someVar = "bar"
|
||||||
|
echo "changed"
|
||||||
|
enddef
|
||||||
|
defcompile
|
||||||
|
END
|
||||||
|
call writefile(file3, 'Xtest3.vim')
|
||||||
|
let buf = RunVimInTerminal('-S Xtest3.vim', {})
|
||||||
|
|
||||||
|
call RunDbgCmd(buf, ':breakadd expr g:someVar')
|
||||||
|
call RunDbgCmd(buf, ':call g:ChangeVar()', ['Oldval = "''foo''"', 'Newval = "''bar''"', 'function ChangeVar', 'line 2: echo "changed"'])
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete('Xtest3.vim')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_debug_def_and_legacy_function()
|
func Test_debug_def_and_legacy_function()
|
||||||
CheckRunVimInTerminal
|
CheckRunVimInTerminal
|
||||||
CheckCWD
|
CheckCWD
|
||||||
|
Loading…
Reference in New Issue
Block a user