mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Problem: Termdebug: gdb may use X.Y for breakpoint number. Solution: Handle X.Y breakpoint numbers. (Yasuhiro Matsumoto, close #3641)
This commit is contained in:
@@ -73,6 +73,13 @@ let s:pc_id = 12
|
||||
let s:break_id = 13 " breakpoint number is added to this
|
||||
let s:stopped = 1
|
||||
|
||||
" Take a breakpoint number as used by GDB and turn it into an integer.
|
||||
" The breakpoint may contain a dot: 123.4
|
||||
func s:Breakpoint2SignNumber(nr)
|
||||
let t = split(a:nr, '\.')
|
||||
return t[0] * 1000 + (len(t) == 2 ? t[1] : 0)
|
||||
endfunction
|
||||
|
||||
func s:Highlight(init, old, new)
|
||||
let default = a:init ? 'default ' : ''
|
||||
if a:new ==# 'light' && a:old !=# 'light'
|
||||
@@ -353,7 +360,8 @@ func s:StartDebugCommon(dict)
|
||||
endif
|
||||
endif
|
||||
|
||||
" Contains breakpoints that have been placed, key is the number.
|
||||
" Contains breakpoints that have been placed, key is a string with the GDB
|
||||
" breakpoint number.
|
||||
let s:breakpoints = {}
|
||||
|
||||
augroup TermDebug
|
||||
@@ -479,6 +487,9 @@ endfunc
|
||||
|
||||
" Extract the "name" value from a gdb message with fullname="name".
|
||||
func s:GetFullname(msg)
|
||||
if a:msg !~ 'fullname'
|
||||
return ''
|
||||
endif
|
||||
let name = s:DecodeMessage(substitute(a:msg, '.*fullname=', '', ''))
|
||||
if has('win32') && name =~ ':\\\\'
|
||||
" sometimes the name arrives double-escaped
|
||||
@@ -673,7 +684,7 @@ func s:DeleteCommands()
|
||||
|
||||
exe 'sign unplace ' . s:pc_id
|
||||
for key in keys(s:breakpoints)
|
||||
exe 'sign unplace ' . (s:break_id + key)
|
||||
exe 'sign unplace ' . (s:break_id + s:Breakpoint2SignNumber(key))
|
||||
endfor
|
||||
unlet s:breakpoints
|
||||
|
||||
@@ -714,7 +725,7 @@ func s:ClearBreakpoint()
|
||||
if val['fname'] == fname && val['lnum'] == lnum
|
||||
call s:SendCommand('-break-delete ' . key)
|
||||
" Assume this always wors, the reply is simply "^done".
|
||||
exe 'sign unplace ' . (s:break_id + key)
|
||||
exe 'sign unplace ' . (s:break_id + s:Breakpoint2SignNumber(key))
|
||||
unlet s:breakpoints[key]
|
||||
break
|
||||
endif
|
||||
@@ -865,10 +876,14 @@ let s:BreakpointSigns = []
|
||||
func s:CreateBreakpoint(nr)
|
||||
if index(s:BreakpointSigns, a:nr) == -1
|
||||
call add(s:BreakpointSigns, a:nr)
|
||||
exe "sign define debugBreakpoint" . a:nr . " text=" . a:nr . " texthl=debugBreakpoint"
|
||||
exe "sign define debugBreakpoint" . a:nr . " text=" . substitute(a:nr, '\..*', '', '') . " texthl=debugBreakpoint"
|
||||
endif
|
||||
endfunc
|
||||
|
||||
func s:SplitMsg(s)
|
||||
return split(a:s, '{\%([a-z-]\+=[^,]\+,*\)\+}\zs')
|
||||
endfunction
|
||||
|
||||
" Handle setting a breakpoint
|
||||
" Will update the sign that shows the breakpoint
|
||||
func s:HandleNewBreakpoint(msg)
|
||||
@@ -876,9 +891,13 @@ func s:HandleNewBreakpoint(msg)
|
||||
" a watch does not have a file name
|
||||
return
|
||||
endif
|
||||
|
||||
let nr = substitute(a:msg, '.*number="\([0-9]*\)".*', '\1', '') + 0
|
||||
if nr == 0
|
||||
for msg in s:SplitMsg(a:msg)
|
||||
let fname = s:GetFullname(msg)
|
||||
if empty(fname)
|
||||
continue
|
||||
endif
|
||||
let nr = substitute(msg, '.*number="\([0-9.]*\)\".*', '\1', '')
|
||||
if empty(nr)
|
||||
return
|
||||
endif
|
||||
call s:CreateBreakpoint(nr)
|
||||
@@ -890,36 +909,39 @@ func s:HandleNewBreakpoint(msg)
|
||||
let s:breakpoints[nr] = entry
|
||||
endif
|
||||
|
||||
let fname = s:GetFullname(a:msg)
|
||||
let lnum = substitute(a:msg, '.*line="\([^"]*\)".*', '\1', '')
|
||||
let lnum = substitute(msg, '.*line="\([^"]*\)".*', '\1', '')
|
||||
let entry['fname'] = fname
|
||||
let entry['lnum'] = lnum
|
||||
|
||||
if bufloaded(fname)
|
||||
call s:PlaceSign(nr, entry)
|
||||
endif
|
||||
endfor
|
||||
endfunc
|
||||
|
||||
func s:PlaceSign(nr, entry)
|
||||
exe 'sign place ' . (s:break_id + a:nr) . ' line=' . a:entry['lnum'] . ' name=debugBreakpoint' . a:nr . ' file=' . a:entry['fname']
|
||||
exe 'sign place ' . (s:break_id + s:Breakpoint2SignNumber(a:nr)) . ' line=' . a:entry['lnum'] . ' name=debugBreakpoint' . a:nr . ' file=' . a:entry['fname']
|
||||
let a:entry['placed'] = 1
|
||||
endfunc
|
||||
|
||||
" Handle deleting a breakpoint
|
||||
" Will remove the sign that shows the breakpoint
|
||||
func s:HandleBreakpointDelete(msg)
|
||||
let nr = substitute(a:msg, '.*id="\([0-9]*\)\".*', '\1', '') + 0
|
||||
if nr == 0
|
||||
let key = substitute(a:msg, '.*id="\([0-9.]*\)\".*', '\1', '')
|
||||
if empty(key)
|
||||
return
|
||||
endif
|
||||
if has_key(s:breakpoints, nr)
|
||||
for [nr, entry] in items(s:breakpoints)
|
||||
if stridx(nr, key) != 0
|
||||
continue
|
||||
endif
|
||||
let entry = s:breakpoints[nr]
|
||||
if has_key(entry, 'placed')
|
||||
exe 'sign unplace ' . (s:break_id + nr)
|
||||
exe 'sign unplace ' . (s:break_id + s:Breakpoint2SignNumber(nr))
|
||||
unlet entry['placed']
|
||||
endif
|
||||
unlet s:breakpoints[nr]
|
||||
endif
|
||||
endfor
|
||||
endfunc
|
||||
|
||||
" Handle the debugged program starting to run.
|
||||
|
@@ -792,6 +792,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
557,
|
||||
/**/
|
||||
556,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user