Handle debug and terminated events
Somewhat at least.
This commit is contained in:
parent
45a8176de3
commit
eeabd00b4a
5 changed files with 86 additions and 12 deletions
|
|
@ -81,7 +81,6 @@ class CodeView( object ):
|
||||||
vim.command( 'sign unplace {0}'.format( self._signs[ 'vimspectorPC' ] ) )
|
vim.command( 'sign unplace {0}'.format( self._signs[ 'vimspectorPC' ] ) )
|
||||||
self._signs[ 'vimspectorPC' ] = None
|
self._signs[ 'vimspectorPC' ] = None
|
||||||
|
|
||||||
|
|
||||||
# TODO: You know what, move breakpoint handling out of here into its own
|
# TODO: You know what, move breakpoint handling out of here into its own
|
||||||
# thing. It really doesn't directly relate to the code view.
|
# thing. It really doesn't directly relate to the code view.
|
||||||
def AddBreakpoints( self, source, breakpoints ):
|
def AddBreakpoints( self, source, breakpoints ):
|
||||||
|
|
@ -100,6 +99,31 @@ class CodeView( object ):
|
||||||
self._logger.debug( 'Breakpoints at this point: {0}'.format(
|
self._logger.debug( 'Breakpoints at this point: {0}'.format(
|
||||||
json.dumps( self._breakpoints, indent = 2 ) ) )
|
json.dumps( self._breakpoints, indent = 2 ) ) )
|
||||||
|
|
||||||
|
def UpdateBreakpoint( self, bp ):
|
||||||
|
if 'id' not in bp:
|
||||||
|
self.AddBreakpoints( None, [ bp ] )
|
||||||
|
|
||||||
|
for _, breakpoint_list in self._breakpoints.items():
|
||||||
|
for index, breakpoint in enumerate( breakpoint_list ):
|
||||||
|
if 'id' in breakpoint and breakpoint[ 'id' ] == bp[ 'id' ]:
|
||||||
|
breakpoint_list[ index ] = bp
|
||||||
|
return
|
||||||
|
|
||||||
|
# Not found. Assume new
|
||||||
|
self.AddBreakpoints( None, [ bp ] )
|
||||||
|
|
||||||
|
def DeleteBreakpoint( self, bp ):
|
||||||
|
if 'id' not in bp:
|
||||||
|
return
|
||||||
|
|
||||||
|
for _, breakpoint_list in self._breakpoints.items():
|
||||||
|
for index, breakpoint in enumerate( breakpoint_list ):
|
||||||
|
if 'id' in breakpoint and breakpoint[ 'id' ] == bp[ 'id' ]:
|
||||||
|
del breakpoint_list[ index ]
|
||||||
|
return
|
||||||
|
|
||||||
|
# Not found. Shrug.
|
||||||
|
|
||||||
def _UndisplaySigns( self ):
|
def _UndisplaySigns( self ):
|
||||||
for sign_id in self._signs[ 'breakpoints' ]:
|
for sign_id in self._signs[ 'breakpoints' ]:
|
||||||
vim.command( 'sign unplace {0}'.format( sign_id ) )
|
vim.command( 'sign unplace {0}'.format( sign_id ) )
|
||||||
|
|
|
||||||
|
|
@ -126,3 +126,6 @@ class DebugAdapterConnection( object ):
|
||||||
method = 'OnEvent_' + message[ 'event' ]
|
method = 'OnEvent_' + message[ 'event' ]
|
||||||
if method in dir( self._handler ):
|
if method in dir( self._handler ):
|
||||||
getattr( self._handler, method )( message )
|
getattr( self._handler, method )( message )
|
||||||
|
else:
|
||||||
|
utils.UserMessage( 'Unhandled event: {0}'.format( message[ 'event' ] ),
|
||||||
|
persist = True )
|
||||||
|
|
|
||||||
|
|
@ -242,6 +242,45 @@ class DebugSession( object ):
|
||||||
|
|
||||||
self._SendBreakpoints()
|
self._SendBreakpoints()
|
||||||
|
|
||||||
|
def OnEvent_thread( self, message ):
|
||||||
|
# TODO: set self_currentThread ? Not really that useful I guess as the
|
||||||
|
# stopped event basically gives us this.
|
||||||
|
pass
|
||||||
|
|
||||||
|
def OnEvent_breakpoint( self, message ):
|
||||||
|
# Useful:
|
||||||
|
#
|
||||||
|
# /** The reason for the event.
|
||||||
|
# Values: 'changed', 'new', 'removed', etc.
|
||||||
|
# */
|
||||||
|
|
||||||
|
reason = message[ 'body' ][ 'reason' ]
|
||||||
|
bp = message[ 'body' ][ 'breakpoint' ]
|
||||||
|
if reason == 'changed':
|
||||||
|
self._codeView.UpdateBreakpoint( bp )
|
||||||
|
elif reason == 'new':
|
||||||
|
self._codeView.AddBreakpoints( None, bp )
|
||||||
|
elif reason == 'removed':
|
||||||
|
# TODO
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
utils.UserMessage(
|
||||||
|
'Unrecognised breakpoint event (undocumented): {0}'.format( reason ),
|
||||||
|
persist = True )
|
||||||
|
|
||||||
|
|
||||||
|
def OnEvent_terminated( self, message ):
|
||||||
|
utils.UserMessage( "The program was terminated because: {0}".format(
|
||||||
|
message.get( 'body', {} ).get( 'reason', "No specific reason" ) ) )
|
||||||
|
|
||||||
|
self._codeView.Clear()
|
||||||
|
self._stackTraceView.Clear()
|
||||||
|
self._variablesView.Clear()
|
||||||
|
|
||||||
|
with utils.ModifiableScratchBuffer( self._threadsBuffer ):
|
||||||
|
self._threadsBuffer[:] = None
|
||||||
|
|
||||||
|
|
||||||
def _SendBreakpoints( self ):
|
def _SendBreakpoints( self ):
|
||||||
for file_name, line_breakpoints in self._breakpoints.items():
|
for file_name, line_breakpoints in self._breakpoints.items():
|
||||||
breakpoints = []
|
breakpoints = []
|
||||||
|
|
@ -276,17 +315,17 @@ class DebugSession( object ):
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO: Remove this!
|
# TODO: Remove this!
|
||||||
self._connection.DoRequest(
|
# self._connection.DoRequest(
|
||||||
functools.partial( self._UpdateBreakpoints, None ),
|
# functools.partial( self._UpdateBreakpoints, None ),
|
||||||
{
|
# {
|
||||||
'command': 'setFunctionBreakpoints',
|
# 'command': 'setFunctionBreakpoints',
|
||||||
'arguments': {
|
# 'arguments': {
|
||||||
'breakpoints': [
|
# 'breakpoints': [
|
||||||
{ 'name': 'main' },
|
# { 'name': 'main' },
|
||||||
],
|
# ],
|
||||||
},
|
# },
|
||||||
}
|
# }
|
||||||
)
|
# )
|
||||||
|
|
||||||
self._connection.DoRequest( None, {
|
self._connection.DoRequest( None, {
|
||||||
'command': 'configurationDone',
|
'command': 'configurationDone',
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@ class StackTraceView( object ):
|
||||||
|
|
||||||
self._line_to_frame = {}
|
self._line_to_frame = {}
|
||||||
|
|
||||||
|
def Clear( self ):
|
||||||
|
with utils.ModifiableScratchBuffer( self._buf ):
|
||||||
|
self._buf[:] = None
|
||||||
|
|
||||||
def LoadStackTrace( self, thread_id ):
|
def LoadStackTrace( self, thread_id ):
|
||||||
self._connection.DoRequest( self._PrintStackTrace, {
|
self._connection.DoRequest( self._PrintStackTrace, {
|
||||||
'command': 'stackTrace',
|
'command': 'stackTrace',
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,10 @@ class VariablesView( object ):
|
||||||
|
|
||||||
utils.SetUpScratchBuffer( self._buf )
|
utils.SetUpScratchBuffer( self._buf )
|
||||||
|
|
||||||
|
def Clear( self ):
|
||||||
|
with utils.ModifiableScratchBuffer( self._buf ):
|
||||||
|
self._buf[:] = None
|
||||||
|
|
||||||
def LoadScopes( self, frame ):
|
def LoadScopes( self, frame ):
|
||||||
def scopes_consumer( message ):
|
def scopes_consumer( message ):
|
||||||
self._scopes = []
|
self._scopes = []
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue