Make sure to close down cleanly
This involves some horrible forceful reading on exit to ensure that we get a response to the disconnect request. This ensures that any debugee is killed cleanly.
This commit is contained in:
parent
afe4c0db77
commit
eb11712cc1
2 changed files with 38 additions and 1 deletions
|
|
@ -67,7 +67,8 @@ function! vimspector#internal#job#StartDebugSession( config ) abort
|
||||||
\ 'exit_cb': function( 's:_OnExit' ),
|
\ 'exit_cb': function( 's:_OnExit' ),
|
||||||
\ 'close_cb': function( 's:_OnClose' ),
|
\ 'close_cb': function( 's:_OnClose' ),
|
||||||
\ 'out_cb': function( 's:_OnServerData' ),
|
\ 'out_cb': function( 's:_OnServerData' ),
|
||||||
\ 'err_cb': function( 's:_OnServerError' )
|
\ 'err_cb': function( 's:_OnServerError' ),
|
||||||
|
\ 'stoponexit': 'term',
|
||||||
\ }
|
\ }
|
||||||
\ )
|
\ )
|
||||||
|
|
||||||
|
|
@ -93,6 +94,15 @@ function! vimspector#internal#job#Reset() abort
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! vimspector#internal#job#ForceRead() abort
|
||||||
|
if exists( 's:job' )
|
||||||
|
let data = ch_readraw( job_getchannel( s:job ), { 'timeout': 1000 } )
|
||||||
|
if data != ''
|
||||||
|
call s:_OnServerData( job_getchannel( s:job ), data )
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Boilerplate {{{
|
" Boilerplate {{{
|
||||||
let &cpo=s:save_cpo
|
let &cpo=s:save_cpo
|
||||||
unlet s:save_cpo
|
unlet s:save_cpo
|
||||||
|
|
|
||||||
|
|
@ -274,9 +274,36 @@ class DebugSession( object ):
|
||||||
|
|
||||||
self._logger.info( 'Debug Adapter Started' )
|
self._logger.info( 'Debug Adapter Started' )
|
||||||
|
|
||||||
|
vim.command( 'augroup vimspector_cleanup' )
|
||||||
|
vim.command( 'autocmd!' )
|
||||||
|
vim.command( 'autocmd VimLeavePre * py3 _vimspector_session.CloseDown()' )
|
||||||
|
vim.command( 'augroup END' )
|
||||||
|
|
||||||
|
|
||||||
|
def CloseDown( self ):
|
||||||
|
state = { 'done': False }
|
||||||
|
|
||||||
|
def handler( self ):
|
||||||
|
state[ 'done' ] = True
|
||||||
|
|
||||||
|
self._connection.DoRequest( handler, {
|
||||||
|
'command': 'disconnect',
|
||||||
|
'arguments': {
|
||||||
|
'terminateDebugee': True
|
||||||
|
},
|
||||||
|
} )
|
||||||
|
|
||||||
|
while not state[ 'done' ]:
|
||||||
|
vim.eval( 'vimspector#internal#job#ForceRead()' )
|
||||||
|
|
||||||
|
vim.eval( 'vimspector#internal#job#StopDebugSession()' )
|
||||||
|
|
||||||
def _StopDebugAdapter( self, callback = None ):
|
def _StopDebugAdapter( self, callback = None ):
|
||||||
def handler( message ):
|
def handler( message ):
|
||||||
vim.eval( 'vimspector#internal#job#StopDebugSession()' )
|
vim.eval( 'vimspector#internal#job#StopDebugSession()' )
|
||||||
|
|
||||||
|
vim.command( 'au! vimspector_cleanup' )
|
||||||
|
|
||||||
self._connection.Reset()
|
self._connection.Reset()
|
||||||
self._connection = None
|
self._connection = None
|
||||||
self._stackTraceView.ConnectionClosed()
|
self._stackTraceView.ConnectionClosed()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue