@@ -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.
440440func 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
460460endfunc
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+
462472func 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
645659endfunc
646660
647661" :Break - Set a breakpoint at the cursor position.
@@ -660,8 +674,9 @@ func s:SetBreakpoint()
660674 endif
661675 sleep 10 m
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)
817836endfunc
818837
838+ let s: BreakpointSigns = []
839+
819840func 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
827845endfunc
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
0 commit comments