Skip to content

Commit a15b0a9

Browse files
committed
patch 8.1.0089: error when ending the terminal debugger
Problem: error when ending the terminal debugger Solution: Fix deleting defined signs for breakpoints. Make the debugger work better on MS-Windows.
1 parent 5319191 commit a15b0a9

2 files changed

Lines changed: 32 additions & 12 deletions

File tree

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

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ func s:GdbOutCallback(channel, text)
408408

409409
" Drop the gdb prompt, we have our own.
410410
" Drop status and echo'd commands.
411-
if a:text == '(gdb) ' || a:text == '^done' || a:text[0] == '&' || a:text[0] == '='
411+
if a:text == '(gdb) ' || a:text == '^done' || a:text[0] == '&'
412412
return
413413
endif
414414
if a:text =~ '^^error,msg='
@@ -439,7 +439,7 @@ endfunc
439439
" to the next ", unescaping characters.
440440
func s:DecodeMessage(quotedText)
441441
if a:quotedText[0] != '"'
442-
echoerr 'DecodeMessage(): missing quote'
442+
echoerr 'DecodeMessage(): missing quote in ' . a:quotedText
443443
return
444444
endif
445445
let result = ''
@@ -459,6 +459,16 @@ func s:DecodeMessage(quotedText)
459459
return result
460460
endfunc
461461

462+
" Extract the "name" value from a gdb message with fullname="name".
463+
func s:GetFullname(msg)
464+
let name = s:DecodeMessage(substitute(a:msg, '.*fullname=', '', ''))
465+
if has('win32') && name =~ ':\\\\'
466+
" sometimes the name arrives double-escaped
467+
let name = substitute(name, '\\\\', '\\', 'g')
468+
endif
469+
return name
470+
endfunc
471+
462472
func s:EndTermDebug(job, status)
463473
exe 'bwipe! ' . s:commbuf
464474
unlet s:gdbwin
@@ -639,9 +649,13 @@ func s:DeleteCommands()
639649
for key in keys(s:breakpoints)
640650
exe 'sign unplace ' . (s:break_id + key)
641651
endfor
642-
sign undefine debugPC
643-
sign undefine debugBreakpoint
644652
unlet s:breakpoints
653+
654+
sign undefine debugPC
655+
for val in s:BreakpointSigns
656+
exe "sign undefine debugBreakpoint" . val
657+
endfor
658+
unlet s:BreakpointSigns
645659
endfunc
646660

647661
" :Break - Set a breakpoint at the cursor position.
@@ -660,8 +674,9 @@ func s:SetBreakpoint()
660674
endif
661675
sleep 10m
662676
endif
663-
call s:SendCommand('-break-insert --source '
664-
\ . fnameescape(expand('%:p')) . ' --line ' . line('.'))
677+
" Use the fname:lnum format, older gdb can't handle --source.
678+
call s:SendCommand('-break-insert '
679+
\ . fnameescape(expand('%:p')) . ':' . line('.'))
665680
if do_continue
666681
call s:SendCommand('-exec-continue')
667682
endif
@@ -790,7 +805,11 @@ func s:HandleCursor(msg)
790805

791806
call s:GotoSourcewinOrCreateIt()
792807

793-
let fname = substitute(a:msg, '.*fullname="\([^"]*\)".*', '\1', '')
808+
if a:msg =~ 'fullname='
809+
let fname = s:GetFullname(a:msg)
810+
else
811+
let fname = ''
812+
endif
794813
if a:msg =~ '^\(\*stopped\|=thread-selected\)' && filereadable(fname)
795814
let lnum = substitute(a:msg, '.*line="\([^"]*\)".*', '\1', '')
796815
if lnum =~ '^[0-9]*$'
@@ -816,13 +835,12 @@ func s:HandleCursor(msg)
816835
call win_gotoid(wid)
817836
endfunc
818837

838+
let s:BreakpointSigns = []
839+
819840
func s:CreateBreakpoint(nr)
820-
if !exists("s:BreakpointSigns")
821-
let s:BreakpointSigns = []
822-
endif
823841
if index(s:BreakpointSigns, a:nr) == -1
824842
call add(s:BreakpointSigns, a:nr)
825-
exe "sign define debugBreakpoint". a:nr . " text=" . a:nr . " texthl=debugBreakpoint"
843+
exe "sign define debugBreakpoint" . a:nr . " text=" . a:nr . " texthl=debugBreakpoint"
826844
endif
827845
endfunc
828846

@@ -842,7 +860,7 @@ func s:HandleNewBreakpoint(msg)
842860
let s:breakpoints[nr] = entry
843861
endif
844862

845-
let fname = substitute(a:msg, '.*fullname="\([^"]*\)".*', '\1', '')
863+
let fname = s:GetFullname(a:msg)
846864
let lnum = substitute(a:msg, '.*line="\([^"]*\)".*', '\1', '')
847865
let entry['fname'] = fname
848866
let entry['lnum'] = lnum

src/version.c

Lines changed: 2 additions & 0 deletions
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+
89,
764766
/**/
765767
88,
766768
/**/

0 commit comments

Comments
 (0)