:Rexplore pi_netrw.txt /*:Rexplore*
:RmVimball pi_vimball.txt /*:RmVimball*
:Run terminal.txt /*:Run*
+:RunOrContinue terminal.txt /*:RunOrContinue*
:RustEmitAsm ft_rust.txt /*:RustEmitAsm*
:RustEmitIr ft_rust.txt /*:RustEmitIr*
:RustExpand ft_rust.txt /*:RustExpand*
:Termdebug terminal.txt /*:Termdebug*
:TermdebugCommand terminal.txt /*:TermdebugCommand*
:Texplore pi_netrw.txt /*:Texplore*
+:ToggleBreak terminal.txt /*:ToggleBreak*
:Tutor pi_tutor.txt /*:Tutor*
:URLOpen eval.txt /*:URLOpen*
:Until terminal.txt /*:Until*
-*terminal.txt* For Vim version 9.1. Last change: 2025 Sep 02
+*terminal.txt* For Vim version 9.1. Last change: 2025 Sep 14
VIM REFERENCE MANUAL by Bram Moolenaar
:Tbreak {position}
set a temporary breakpoint at the specified position
*:Clear* delete the breakpoint at the cursor position
+ *:ToggleBreak* set a breakpoint at the cursor position or delete all
+ breakpoints at the cursor positoin
*:Step* execute the gdb "step" command
*:Over* execute the gdb "next" command (`:Next` is a Vim command)
*:Until* execute the gdb "until" command
*:Finish* execute the gdb "finish" command
*:Continue* execute the gdb "continue" command
+ *:RunOrContinue* execute the gdb "continue" command if program is running,
+ otherwise run the program
*:Stop* interrupt the program
If 'mouse' is set the plugin adds a window toolbar with these entries:
# Author: Bram Moolenaar
# Copyright: Vim license applies, see ":help license"
-# Last Change: 2025 Sep 02
+# Last Change: 2025 Sep 14
# Converted to Vim9: Ubaldo Tiberi <ubaldo.tiberi@gmail.com>
# WORK IN PROGRESS - The basics works stable, more to come
command -nargs=? Break SetBreakpoint(<q-args>)
command -nargs=? Tbreak SetBreakpoint(<q-args>, true)
+ command ToggleBreak ToggleBreak()
command Clear ClearBreakpoint()
command Step SendResumingCommand('-exec-step')
command Over SendResumingCommand('-exec-next')
command -nargs=* Arguments SendResumingCommand('-exec-arguments ' .. <q-args>)
command Stop StopCommand()
command Continue ContinueCommand()
+ command RunOrContinue RunOrContinue()
command -nargs=* Frame Frame(<q-args>)
command -count=1 Up Up(<count>)
delcommand Asm
delcommand Var
delcommand Winbar
+ delcommand RunOrContinue
+ delcommand ToggleBreak
if !empty(saved_K_map) && !saved_K_map.buffer
endif
enddef
+def ToggleBreak()
+ var fname = fnameescape(expand('%:p'))
+ var lnum = line('.')
+ var bploc = printf('%s:%d', fname, lnum)
+ if has_key(breakpoint_locations, bploc)
+ while has_key(breakpoint_locations, bploc)
+ ClearBreakpoint()
+ endwhile
+ else
+ SetBreakpoint("")
+ endif
+enddef
+
def Run(args: string)
if args != ''
SendResumingCommand($'-exec-arguments {args}')
SendResumingCommand('-exec-run')
enddef
+def RunOrContinue()
+ if running
+ ContinueCommand()
+ else
+ Run('')
+ endif
+enddef
+
# :Frame - go to a specific frame in the stack
def Frame(arg: string)
# Note: we explicit do not use mi's command
if !has_key(breakpoint_locations, bploc)
breakpoint_locations[bploc] = []
endif
- breakpoint_locations[bploc] += [id]
+ if breakpoint_locations[bploc]->index(id) == -1
+ # Make sure all ids are unique
+ breakpoint_locations[bploc] += [id]
+ endif
var posMsg = ''
if bufloaded(fname)
unlet g:termdebug_config
endfunction
+func Test_termdebug_toggle_break()
+ let g:test_is_flaky = 1
+ let bin_name = 'XTD_tbreak'
+ let src_name = bin_name .. '.c'
+
+ eval s:generate_files(bin_name)
+
+ execute 'edit ' .. src_name
+ execute 'Termdebug ./' .. bin_name
+
+ call WaitForAssert({-> assert_true(get(g:, "termdebug_is_running", v:false))})
+ call WaitForAssert({-> assert_equal(3, winnr('$'))})
+ let gdb_buf = winbufnr(1)
+ wincmd b
+
+ let bp_line = 22 " 'return' statement in main
+ execute "normal! " .. bp_line .. "G"
+ execute "ToggleBreak"
+
+ call term_wait(gdb_buf)
+ redraw!
+ call assert_equal([
+ \ {'lnum': bp_line, 'id': 1014, 'name': 'debugBreakpoint1.0',
+ \ 'priority': 110, 'group': 'TermDebug'}],
+ \ sign_getplaced('', #{group: 'TermDebug'})[0].signs)
+
+ RunOrContinue
+ call term_wait(gdb_buf, 400)
+ redraw!
+ call WaitForAssert({-> assert_equal([
+ \ {'lnum': bp_line, 'id': 12, 'name': 'debugPC', 'priority': 110,
+ \ 'group': 'TermDebug'},
+ \ {'lnum': bp_line, 'id': 1014, 'name': 'debugBreakpoint1.0',
+ \ 'priority': 110, 'group': 'TermDebug'}],
+ \ sign_getplaced('', #{group: 'TermDebug'})[0].signs)})
+
+ " Add one break point
+ execute "normal! " .. bp_line .. "G"
+ execute "ToggleBreak"
+ call term_wait(gdb_buf)
+ redraw!
+ call WaitForAssert({-> assert_equal([
+ \ {'lnum': bp_line, 'id': 12, 'name': 'debugPC', 'priority': 110,
+ \ 'group': 'TermDebug'}],
+ \ sign_getplaced('', #{group: 'TermDebug'})[0].signs)})
+
+ " Remove one break point
+ execute "normal! " .. bp_line .. "G"
+ execute "ToggleBreak"
+ call term_wait(gdb_buf)
+ redraw!
+ call WaitForAssert({-> assert_equal([
+ \ {'lnum': bp_line, 'id': 2014, 'name': 'debugBreakpoint2.0',
+ \ 'priority': 110, 'group': 'TermDebug'},
+ \ {'lnum': bp_line, 'id': 12, 'name': 'debugPC', 'priority': 110,
+ \ 'group': 'TermDebug'}],
+ \ sign_getplaced('', #{group: 'TermDebug'})[0].signs)})
+
+ " Remove multiple break points
+ execute "Break"
+ execute "Break"
+ execute "Break"
+ execute "Break"
+ call term_wait(gdb_buf, 400)
+ execute "ToggleBreak"
+ call term_wait(gdb_buf)
+ redraw!
+ call WaitForAssert({-> assert_equal([
+ \ {'lnum': bp_line, 'id': 12, 'name': 'debugPC', 'priority': 110,
+ \ 'group': 'TermDebug'}],
+ \ sign_getplaced('', #{group: 'TermDebug'})[0].signs)})
+
+
+ wincmd t
+ quit!
+ redraw!
+ call WaitForAssert({-> assert_equal(1, winnr('$'))})
+ call assert_equal([], sign_getplaced('', #{group: 'TermDebug'})[0].signs)
+
+ eval s:cleanup_files(bin_name)
+ %bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab