summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0575
blob: 05314da9808c8e0a3662bd8355819056a2e90c66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0575
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0575
Problem:    Termdebug: clearing multi-breakpoint does not work.
Solution:   Delete all X.Y breakpoints.  Keep more information about placed
            breakpoints. (Ozaki Kiichi, closes #3641)
Files:	    runtime/pack/dist/opt/termdebug/plugin/termdebug.vim


*** ../vim-8.1.0574/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim	2018-12-02 13:45:47.088708659 +0100
--- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim	2018-12-09 15:46:07.909886080 +0100
***************
*** 74,83 ****
  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)
--- 74,83 ----
  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 -> 123004
! " The main breakpoint has a zero subid.
! func s:Breakpoint2SignNumber(id, subid)
!   return s:break_id + a:id * 1000 + a:subid
  endfunction
  
  func s:Highlight(init, old, new)
***************
*** 362,369 ****
--- 362,378 ----
  
    " Contains breakpoints that have been placed, key is a string with the GDB
    " breakpoint number.
+   " Each entry is a dict, containing the sub-breakpoints.  Key is the subid.
+   " For a breakpoint that is just a number the subid is zero.
+   " For a breakpoint "123.4" the id is "123" and subid is "4".
+   " Example, when breakpoint "44", "123", "123.1" and "123.2" exist:
+   " {'44': {'0': entry}, '123': {'0': entry, '1': entry, '2': entry}}
    let s:breakpoints = {}
  
+   " Contains breakpoints by file/lnum.  The key is "fname:lnum".
+   " Each entry is a list of breakpoint IDs at that position.
+   let s:breakpoint_locations = {}
+ 
    augroup TermDebug
      au BufRead * call s:BufRead()
      au BufUnload * call s:BufUnloaded()
***************
*** 683,692 ****
    endif
  
    exe 'sign unplace ' . s:pc_id
!   for key in keys(s:breakpoints)
!     exe 'sign unplace ' . (s:break_id + s:Breakpoint2SignNumber(key))
    endfor
    unlet s:breakpoints
  
    sign undefine debugPC
    for val in s:BreakpointSigns
--- 692,704 ----
    endif
  
    exe 'sign unplace ' . s:pc_id
!   for [id, entries] in items(s:breakpoints)
!     for subid in keys(entries)
!       exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid)
!     endfor
    endfor
    unlet s:breakpoints
+   unlet s:breakpoint_locations
  
    sign undefine debugPC
    for val in s:BreakpointSigns
***************
*** 721,735 ****
  func s:ClearBreakpoint()
    let fname = fnameescape(expand('%:p'))
    let lnum = line('.')
!   for [key, val] in items(s:breakpoints)
!     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 + s:Breakpoint2SignNumber(key))
!       unlet s:breakpoints[key]
!       break
      endif
!   endfor
  endfunc
  
  func s:Run(args)
--- 733,759 ----
  func s:ClearBreakpoint()
    let fname = fnameescape(expand('%:p'))
    let lnum = line('.')
!   let bploc = printf('%s:%d', fname, lnum)
!   if has_key(s:breakpoint_locations, bploc)
!     let idx = 0
!     for id in s:breakpoint_locations[bploc]
!       if has_key(s:breakpoints, id)
!         " Assume this always works, the reply is simply "^done".
!         call s:SendCommand('-break-delete ' . id)
!         for subid in keys(s:breakpoints[id])
!           exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid)
!         endfor
!         unlet s:breakpoints[id]
!         unlet s:breakpoint_locations[bploc][idx]
!         break
!       else
! 	let idx += 1
!       endif
!     endfor
!     if empty(s:breakpoint_locations[bploc])
!       unlet s:breakpoint_locations[bploc]
      endif
!   endif
  endfunc
  
  func s:Run(args)
***************
*** 873,887 ****
  
  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=" . substitute(a:nr, '\..*', '', '') . " texthl=debugBreakpoint"
    endif
  endfunc
  
! func s:SplitMsg(s)
!   return split(a:s, '{\%([a-z-]\+=[^,]\+,*\)\+}\zs')
  endfunction
  
  " Handle setting a breakpoint
--- 897,912 ----
  
  let s:BreakpointSigns = []
  
! func s:CreateBreakpoint(id, subid)
!   let nr = printf('%d.%d', a:id, a:subid)
!   if index(s:BreakpointSigns, nr) == -1
!     call add(s:BreakpointSigns, nr)
!     exe "sign define debugBreakpoint" . nr . " text=" . substitute(nr, '\..*', '', '') . " texthl=debugBreakpoint"
    endif
  endfunc
  
! func! s:SplitMsg(s)
!   return split(a:s, '{.\{-}}\zs')
  endfunction
  
  " Handle setting a breakpoint
***************
*** 900,947 ****
      if empty(nr)
        return
      endif
-     call s:CreateBreakpoint(nr)
  
!     if has_key(s:breakpoints, nr)
!       let entry = s:breakpoints[nr]
      else
        let entry = {}
!       let s:breakpoints[nr] = entry
      endif
  
      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 +  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 key = substitute(a:msg, '.*id="\([0-9.]*\)\".*', '\1', '')
!   if empty(key)
      return
    endif
!   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 + s:Breakpoint2SignNumber(nr))
!       unlet entry['placed']
!     endif
!     unlet s:breakpoints[nr]
!   endfor
  endfunc
  
  " Handle the debugged program starting to run.
--- 925,987 ----
      if empty(nr)
        return
      endif
  
!     " If "nr" is 123 it becomes "123.0" and subid is "0".
!     " If "nr" is 123.4 it becomes "123.4.0" and subid is "4"; "0" is discarded.
!     let [id, subid; _] = map(split(nr . '.0', '\.'), 'v:val + 0')
!     call s:CreateBreakpoint(id, subid)
! 
!     if has_key(s:breakpoints, id)
!       let entries = s:breakpoints[id]
!     else
!       let entries = {}
!       let s:breakpoints[id] = entries
!     endif
!     if has_key(entries, subid)
!       let entry = entries[subid]
      else
        let entry = {}
!       let entries[subid] = entry
      endif
  
      let lnum = substitute(msg, '.*line="\([^"]*\)".*', '\1', '')
      let entry['fname'] = fname
      let entry['lnum'] = lnum
  
+     let bploc = printf('%s:%d', fname, lnum)
+     if !has_key(s:breakpoint_locations, bploc)
+       let s:breakpoint_locations[bploc] = []
+     endif
+     let s:breakpoint_locations[bploc] += [id]
+ 
      if bufloaded(fname)
!       call s:PlaceSign(id, subid, entry)
      endif
    endfor
  endfunc
  
! func s:PlaceSign(id, subid, entry)
!   let nr = printf('%d.%d', a:id, a:subid)
!   exe 'sign place ' . s:Breakpoint2SignNumber(a:id, a:subid) . ' line=' . a:entry['lnum'] . ' name=debugBreakpoint' . 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 id = substitute(a:msg, '.*id="\([0-9]*\)\".*', '\1', '') + 0
!   if empty(id)
      return
    endif
!   if has_key(s:breakpoints, id)
!     for [subid, entry] in items(s:breakpoints[id])
!       if has_key(entry, 'placed')
!         exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid)
!         unlet entry['placed']
!       endif
!     endfor
!     unlet s:breakpoints[id]
!   endif
  endfunc
  
  " Handle the debugged program starting to run.
***************
*** 958,977 ****
  " Handle a BufRead autocommand event: place any signs.
  func s:BufRead()
    let fname = expand('<afile>:p')
!   for [nr, entry] in items(s:breakpoints)
!     if entry['fname'] == fname
!       call s:PlaceSign(nr, entry)
!     endif
    endfor
  endfunc
  
  " Handle a BufUnloaded autocommand event: unplace any signs.
  func s:BufUnloaded()
    let fname = expand('<afile>:p')
!   for [nr, entry] in items(s:breakpoints)
!     if entry['fname'] == fname
!       let entry['placed'] = 0
!     endif
    endfor
  endfunc
  
--- 998,1021 ----
  " Handle a BufRead autocommand event: place any signs.
  func s:BufRead()
    let fname = expand('<afile>:p')
!   for [id, entries] in items(s:breakpoints)
!     for [subid, entry] in items(entries)
!       if entry['fname'] == fname
!         call s:PlaceSign(id, subid, entry)
!       endif
!     endfor
    endfor
  endfunc
  
  " Handle a BufUnloaded autocommand event: unplace any signs.
  func s:BufUnloaded()
    let fname = expand('<afile>:p')
!   for [id, entries] in items(s:breakpoints)
!     for [subid, entry] in items(entries)
!       if entry['fname'] == fname
!         let entry['placed'] = 0
!       endif
!     endfor
    endfor
  endfunc
  
*** ../vim-8.1.0574/src/version.c	2018-12-09 15:00:47.985798600 +0100
--- src/version.c	2018-12-09 15:51:55.863826210 +0100
***************
*** 794,795 ****
--- 794,797 ----
  {   /* Add new patch number below this line */
+ /**/
+     575,
  /**/

-- 
Are leaders born or made?  And if they're made, can we return them under
warranty?
				(Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///