summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0621
blob: 0c2a9594c20dc0178be9b2788b85a190780d7752 (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
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0621
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.0621
Problem:    Terminal debugger does not handle unexpected debugger exit.
Solution:   Check for debugger job ended and close unused buffers. (Damien)
Files:	    runtime/pack/dist/opt/termdebug/plugin/termdebug.vim


*** ../vim-8.1.0620/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim	2018-12-09 15:52:57.091463593 +0100
--- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim	2018-12-22 15:10:55.681015048 +0100
***************
*** 142,147 ****
--- 142,154 ----
    endif
  endfunc
  
+ " Use when debugger didn't start or ended.
+ func s:CloseBuffers()
+   exe 'bwipe! ' . s:ptybuf
+   exe 'bwipe! ' . s:commbuf
+   unlet! s:gdbwin
+ endfunc
+ 
  func s:StartDebug_term(dict)
    " Open a terminal window without a job, to run the debugged program in.
    let s:ptybuf = term_start('NONE', {
***************
*** 181,193 ****
    let cmd = [g:termdebugger, '-quiet', '-tty', pty] + gdb_args
    call ch_log('executing "' . join(cmd) . '"')
    let s:gdbbuf = term_start(cmd, {
-         \ 'exit_cb': function('s:EndTermDebug'),
          \ 'term_finish': 'close',
          \ })
    if s:gdbbuf == 0
      echoerr 'Failed to open the gdb terminal window'
!     exe 'bwipe! ' . s:ptybuf
!     exe 'bwipe! ' . s:commbuf
      return
    endif
    let s:gdbwin = win_getid(winnr())
--- 188,198 ----
    let cmd = [g:termdebugger, '-quiet', '-tty', pty] + gdb_args
    call ch_log('executing "' . join(cmd) . '"')
    let s:gdbbuf = term_start(cmd, {
          \ 'term_finish': 'close',
          \ })
    if s:gdbbuf == 0
      echoerr 'Failed to open the gdb terminal window'
!     call s:CloseBuffers()
      return
    endif
    let s:gdbwin = win_getid(winnr())
***************
*** 204,209 ****
--- 209,221 ----
    " why the debugger doesn't work.
    let try_count = 0
    while 1
+     let gdbproc = term_getjob(s:gdbbuf)
+     if gdbproc == v:null || job_status(gdbproc) !=# 'run'
+       echoerr string(g:termdebugger) . ' exited unexpectedly'
+       call s:CloseBuffers()
+       return
+     endif
+ 
      let response = ''
      for lnum in range(1,200)
        if term_getline(s:gdbbuf, lnum) =~ 'new-ui mi '
***************
*** 211,218 ****
          let response = term_getline(s:gdbbuf, lnum) . term_getline(s:gdbbuf, lnum + 1)
          if response =~ 'Undefined command'
            echoerr 'Sorry, your gdb is too old, gdb 7.12 is required'
!           exe 'bwipe! ' . s:ptybuf
!           exe 'bwipe! ' . s:commbuf
            return
          endif
          if response =~ 'New UI allocated'
--- 223,229 ----
          let response = term_getline(s:gdbbuf, lnum) . term_getline(s:gdbbuf, lnum + 1)
          if response =~ 'Undefined command'
            echoerr 'Sorry, your gdb is too old, gdb 7.12 is required'
! 	  call s:CloseBuffers()
            return
          endif
          if response =~ 'New UI allocated'
***************
*** 243,248 ****
--- 254,260 ----
    " "Type <return> to continue" prompt.
    call s:SendCommand('set pagination off')
  
+   call job_setoptions(gdbproc, {'exit_cb': function('s:EndTermDebug')})
    call s:StartDebugCommon(a:dict)
  endfunc
  
*** ../vim-8.1.0620/src/version.c	2018-12-22 14:58:58.750451917 +0100
--- src/version.c	2018-12-22 15:14:08.407563485 +0100
***************
*** 801,802 ****
--- 801,804 ----
  {   /* Add new patch number below this line */
+ /**/
+     621,
  /**/

-- 
A day without sunshine is like, well, night.

 /// 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    ///