Skip to content

Commit de1a831

Browse files
committed
patch 8.1.0080: can't see the breakpoint number in the terminal debugger
Problem: Can't see the breakpoint number in the terminal debugger. Solution: Use the breakpoint number for the sign. (Christian Brabandt)
1 parent 8df6e5d commit de1a831

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

runtime/doc/terminal.txt

+19-5
Original file line numberDiff line numberDiff line change
@@ -705,11 +705,11 @@ Put focus on the gdb window and type: >
705705
Vim will start running in the program window. Put focus there and type: >
706706
:help gui
707707
Gdb will run into the ex_help breakpoint. The source window now shows the
708-
ex_cmds.c file. A ">>" marker will appear where the breakpoint was set. The
709-
line where the debugger stopped is highlighted. You can now step through the
710-
program. Let's use the mouse: click on the "Next" button in the window
711-
toolbar. You will see the highlighting move as the debugger executes a line
712-
of source code.
708+
ex_cmds.c file. A red "1 " marker will appear in the signcolumn where the
709+
breakpoint was set. The line where the debugger stopped is highlighted. You
710+
can now step through the program. Let's use the mouse: click on the "Next"
711+
button in the window toolbar. You will see the highlighting move as the
712+
debugger executes a line of source code.
713713

714714
Click "Next" a few times until the for loop is highlighted. Put the cursor on
715715
the end of "eap->arg", then click "Eval" in the toolbar. You will see this
@@ -788,6 +788,13 @@ source code, a new window will be created for the source code. This also
788788
happens if the buffer in the source code window has been modified and can't be
789789
abandoned.
790790

791+
Gdb gives each breakpoint a number. In Vim the number shows up in the sign
792+
column, with a red background. You can use these gdb commands:
793+
- info break list breakpoints
794+
- delete N delete breakpoint N
795+
You can also use the `:Clear` command if the cursor is in the line with the
796+
breakpoint, or use the "Clear breakpoint" right-click menu entry.
797+
791798

792799
Inspecting variables ~
793800
*termdebug-variables* *:Evaluate*
@@ -831,6 +838,13 @@ There is another, hidden, buffer, which is used for Vim to communicate with
831838
gdb. The buffer name is "gdb communication". Do not delete this buffer, it
832839
will break the debugger.
833840

841+
Gdb has some weird behavior, the plugin does its best to work around that.
842+
For example, after typing "continue" in the gdb window a CTRL-C can be used to
843+
interrupt the running program. But after using the MI command
844+
"-exec-continue" pressing CTRL-C does not interrupt. Therefore you will see
845+
"continue" being used for the `:Continue` command, instead of using the
846+
communication channel.
847+
834848

835849
Customizing ~
836850

runtime/pack/dist/opt/termdebug/plugin/termdebug.vim

+14-6
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ if !exists('termdebugger')
6767
endif
6868

6969
let s:pc_id = 12
70-
let s:break_id = 13
70+
let s:break_id = 13 " breakpoint number is added to this
7171
let s:stopped = 1
7272

7373
if &background == 'light'
@@ -325,10 +325,6 @@ func s:StartDebugCommon(dict)
325325
" There can be only one.
326326
sign define debugPC linehl=debugPC
327327

328-
" Sign used to indicate a breakpoint.
329-
" Can be used multiple times.
330-
sign define debugBreakpoint text=>> texthl=debugBreakpoint
331-
332328
" Install debugger commands in the text window.
333329
call win_gotoid(s:sourcewin)
334330
call s:InstallCommands()
@@ -345,6 +341,7 @@ func s:StartDebugCommon(dict)
345341
endif
346342
endif
347343

344+
" Contains breakpoints that have been placed, key is the number.
348345
let s:breakpoints = {}
349346

350347
augroup TermDebug
@@ -813,13 +810,24 @@ func s:HandleCursor(msg)
813810
call win_gotoid(wid)
814811
endfunc
815812

813+
func s:CreateBreakpoint(nr)
814+
if !exists("s:BreakpointSigns")
815+
let s:BreakpointSigns = []
816+
endif
817+
if index(s:BreakpointSigns, a:nr) == -1
818+
call add(s:BreakpointSigns, a:nr)
819+
exe "sign define debugBreakpoint". a:nr . " text=" . a:nr . " texthl=debugBreakpoint"
820+
endif
821+
endfunc
822+
816823
" Handle setting a breakpoint
817824
" Will update the sign that shows the breakpoint
818825
func s:HandleNewBreakpoint(msg)
819826
let nr = substitute(a:msg, '.*number="\([0-9]\)*\".*', '\1', '') + 0
820827
if nr == 0
821828
return
822829
endif
830+
call s:CreateBreakpoint(nr)
823831

824832
if has_key(s:breakpoints, nr)
825833
let entry = s:breakpoints[nr]
@@ -839,7 +847,7 @@ func s:HandleNewBreakpoint(msg)
839847
endfunc
840848

841849
func s:PlaceSign(nr, entry)
842-
exe 'sign place ' . (s:break_id + a:nr) . ' line=' . a:entry['lnum'] . ' name=debugBreakpoint file=' . a:entry['fname']
850+
exe 'sign place ' . (s:break_id + a:nr) . ' line=' . a:entry['lnum'] . ' name=debugBreakpoint' . a:nr . ' file=' . a:entry['fname']
843851
let a:entry['placed'] = 1
844852
endfunc
845853

src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
80,
764766
/**/
765767
79,
766768
/**/

0 commit comments

Comments
 (0)