mirror of
https://github.com/vim/vim
synced 2025-07-16 09:12:00 +00:00
patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Problem: Terminal debugger does not handle unexpected debugger exit. Solution: Check for debugger job ended and close unused buffers. (Damien)
This commit is contained in:
@ -142,6 +142,13 @@ func s:StartDebug_internal(dict)
|
|||||||
endif
|
endif
|
||||||
endfunc
|
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)
|
func s:StartDebug_term(dict)
|
||||||
" Open a terminal window without a job, to run the debugged program in.
|
" Open a terminal window without a job, to run the debugged program in.
|
||||||
let s:ptybuf = term_start('NONE', {
|
let s:ptybuf = term_start('NONE', {
|
||||||
@ -181,13 +188,11 @@ func s:StartDebug_term(dict)
|
|||||||
let cmd = [g:termdebugger, '-quiet', '-tty', pty] + gdb_args
|
let cmd = [g:termdebugger, '-quiet', '-tty', pty] + gdb_args
|
||||||
call ch_log('executing "' . join(cmd) . '"')
|
call ch_log('executing "' . join(cmd) . '"')
|
||||||
let s:gdbbuf = term_start(cmd, {
|
let s:gdbbuf = term_start(cmd, {
|
||||||
\ 'exit_cb': function('s:EndTermDebug'),
|
|
||||||
\ 'term_finish': 'close',
|
\ 'term_finish': 'close',
|
||||||
\ })
|
\ })
|
||||||
if s:gdbbuf == 0
|
if s:gdbbuf == 0
|
||||||
echoerr 'Failed to open the gdb terminal window'
|
echoerr 'Failed to open the gdb terminal window'
|
||||||
exe 'bwipe! ' . s:ptybuf
|
call s:CloseBuffers()
|
||||||
exe 'bwipe! ' . s:commbuf
|
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let s:gdbwin = win_getid(winnr())
|
let s:gdbwin = win_getid(winnr())
|
||||||
@ -204,6 +209,13 @@ func s:StartDebug_term(dict)
|
|||||||
" why the debugger doesn't work.
|
" why the debugger doesn't work.
|
||||||
let try_count = 0
|
let try_count = 0
|
||||||
while 1
|
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 = ''
|
let response = ''
|
||||||
for lnum in range(1,200)
|
for lnum in range(1,200)
|
||||||
if term_getline(s:gdbbuf, lnum) =~ 'new-ui mi '
|
if term_getline(s:gdbbuf, lnum) =~ 'new-ui mi '
|
||||||
@ -211,8 +223,7 @@ func s:StartDebug_term(dict)
|
|||||||
let response = term_getline(s:gdbbuf, lnum) . term_getline(s:gdbbuf, lnum + 1)
|
let response = term_getline(s:gdbbuf, lnum) . term_getline(s:gdbbuf, lnum + 1)
|
||||||
if response =~ 'Undefined command'
|
if response =~ 'Undefined command'
|
||||||
echoerr 'Sorry, your gdb is too old, gdb 7.12 is required'
|
echoerr 'Sorry, your gdb is too old, gdb 7.12 is required'
|
||||||
exe 'bwipe! ' . s:ptybuf
|
call s:CloseBuffers()
|
||||||
exe 'bwipe! ' . s:commbuf
|
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
if response =~ 'New UI allocated'
|
if response =~ 'New UI allocated'
|
||||||
@ -243,6 +254,7 @@ func s:StartDebug_term(dict)
|
|||||||
" "Type <return> to continue" prompt.
|
" "Type <return> to continue" prompt.
|
||||||
call s:SendCommand('set pagination off')
|
call s:SendCommand('set pagination off')
|
||||||
|
|
||||||
|
call job_setoptions(gdbproc, {'exit_cb': function('s:EndTermDebug')})
|
||||||
call s:StartDebugCommon(a:dict)
|
call s:StartDebugCommon(a:dict)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@ -799,6 +799,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
621,
|
||||||
/**/
|
/**/
|
||||||
620,
|
620,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user