First attempt to make breakpoints work. Doesn't. Python at least responds with the breakpoints. MS CPP does not, and native debug just throws an error
This commit is contained in:
parent
171e1b58d5
commit
c9a45b3bdc
5 changed files with 71 additions and 14 deletions
|
|
@ -19,13 +19,18 @@ let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" TODO: Test function
|
|
||||||
function! vimspector#Launch() abort
|
|
||||||
py3 << EOF
|
py3 << EOF
|
||||||
from vimspector import debug_session
|
from vimspector import debug_session
|
||||||
_vimspector_session = debug_session.DebugSession()
|
_vimspector_session = debug_session.DebugSession()
|
||||||
_vimspector_session.Start()
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
" TODO: Test function
|
||||||
|
function! vimspector#Launch() abort
|
||||||
|
py3 _vimspector_session.Start()
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! vimspector#ToggleBreakpoint() abort
|
||||||
|
py3 _vimspector_session.ToggleBreakpoint()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vimspector#StepOver() abort
|
function! vimspector#StepOver() abort
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import vim
|
import vim
|
||||||
|
import logging
|
||||||
|
import json
|
||||||
|
from vimspector import utils
|
||||||
|
|
||||||
SIGN_ID_OFFSET = 10000000
|
SIGN_ID_OFFSET = 10000000
|
||||||
|
|
||||||
|
|
@ -22,9 +25,13 @@ class CodeView( object ):
|
||||||
def __init__( self, window ):
|
def __init__( self, window ):
|
||||||
self._window = window
|
self._window = window
|
||||||
|
|
||||||
|
self._logger = logging.getLogger( __name__ )
|
||||||
|
utils.SetUpLogging( self._logger )
|
||||||
|
|
||||||
self._next_sign_id = SIGN_ID_OFFSET
|
self._next_sign_id = SIGN_ID_OFFSET
|
||||||
self._signs = {
|
self._signs = {
|
||||||
'vimspectorPC': None,
|
'vimspectorPC': None,
|
||||||
|
'breakpoints': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -38,6 +45,7 @@ class CodeView( object ):
|
||||||
vim.command( 'nnoremenu WinBar.Stop :call vimspector#Stop()<CR>' )
|
vim.command( 'nnoremenu WinBar.Stop :call vimspector#Stop()<CR>' )
|
||||||
|
|
||||||
vim.command( 'sign define vimspectorPC text=>> texthl=Search' )
|
vim.command( 'sign define vimspectorPC text=>> texthl=Search' )
|
||||||
|
vim.command( 'sign define vimspectorBP text=>> texthl=Error' )
|
||||||
|
|
||||||
|
|
||||||
def SetCurrentFrame( self, frame ):
|
def SetCurrentFrame( self, frame ):
|
||||||
|
|
@ -71,3 +79,19 @@ class CodeView( object ):
|
||||||
if self._signs[ 'vimspectorPC' ]:
|
if self._signs[ 'vimspectorPC' ]:
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
|
def ShowBreakpoints( self, file_name, breakpoints ):
|
||||||
|
for sign_id in self._signs[ 'breakpoints' ]:
|
||||||
|
vim.command( 'sign unplace {0}'.format( sign_id ) )
|
||||||
|
|
||||||
|
for breakpoint in breakpoints:
|
||||||
|
sign_id = self._next_sign_id
|
||||||
|
self._next_sign_id += 1
|
||||||
|
self._signs[ 'breakpoints' ].append( sign_id )
|
||||||
|
self._logger.debug( 'breakpoint: {0}'.format( json.dumps( breakpoint,
|
||||||
|
indent=2 ) ) )
|
||||||
|
vim.command( 'sign place {0} line={1} name=vimspectorBP file={2}'.format(
|
||||||
|
sign_id,
|
||||||
|
breakpoint[ 'line' ],
|
||||||
|
file_name ) )
|
||||||
|
|
|
||||||
|
|
@ -120,8 +120,8 @@ class DebugAdapterConnection( object ):
|
||||||
else:
|
else:
|
||||||
self._logger.error(
|
self._logger.error(
|
||||||
'Request failed: {0}'.format( message[ 'message' ] ) )
|
'Request failed: {0}'.format( message[ 'message' ] ) )
|
||||||
utils.UserMessage( 'Request failed: {0}'.format( message[ 'message' ],
|
utils.UserMessage( 'Request failed: {0}'.format( message[ 'message' ] ),
|
||||||
persist = True ) )
|
persist = True )
|
||||||
elif message[ 'type' ] == 'event':
|
elif message[ 'type' ] == 'event':
|
||||||
method = 'OnEvent_' + message[ 'event' ]
|
method = 'OnEvent_' + message[ 'event' ]
|
||||||
if method in dir( self._handler ):
|
if method in dir( self._handler ):
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
import logging
|
import logging
|
||||||
import vim
|
import vim
|
||||||
import json
|
import json
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
from vimspector import ( code,
|
from vimspector import ( code,
|
||||||
debug_adapter_connection,
|
debug_adapter_connection,
|
||||||
|
|
@ -38,6 +41,22 @@ class DebugSession( object ):
|
||||||
self._currentThread = None
|
self._currentThread = None
|
||||||
self._currentFrame = None
|
self._currentFrame = None
|
||||||
|
|
||||||
|
self._breakpoints = defaultdict( dict )
|
||||||
|
|
||||||
|
def ToggleBreakpoint( self ):
|
||||||
|
line, column = vim.current.window.cursor
|
||||||
|
file_name = vim.current.buffer.name
|
||||||
|
|
||||||
|
if line in self._breakpoints[ file_name ]:
|
||||||
|
del self._breakpoints[ file_name ][ line ]
|
||||||
|
else:
|
||||||
|
self._breakpoints[ file_name ][ line ] = {
|
||||||
|
'state': 'ENABLED',
|
||||||
|
# 'condition': ...,
|
||||||
|
# 'hitCondition': ...,
|
||||||
|
# 'logMessage': ...
|
||||||
|
}
|
||||||
|
|
||||||
def Start( self, configuration = None ):
|
def Start( self, configuration = None ):
|
||||||
launch_config_file = utils.PathToConfigFile( '.vimspector.json' )
|
launch_config_file = utils.PathToConfigFile( '.vimspector.json' )
|
||||||
|
|
||||||
|
|
@ -197,15 +216,24 @@ class DebugSession( object ):
|
||||||
'arguments': launch_config
|
'arguments': launch_config
|
||||||
} )
|
} )
|
||||||
|
|
||||||
|
def _UpdateBreakpoints( self, file_name, message ):
|
||||||
|
self._codeView.ShowBreakpoints( file_name,
|
||||||
|
message[ 'body' ][ 'breakpoints' ])
|
||||||
|
|
||||||
def OnEvent_initialized( self, message ):
|
def OnEvent_initialized( self, message ):
|
||||||
self._connection.DoRequest( None, {
|
for file_name, line_breakpoints in self._breakpoints.items():
|
||||||
'command': 'setFunctionBreakpoints',
|
breakpoints = [ { 'line': line } for line in line_breakpoints.keys() ]
|
||||||
'arguments': {
|
self._connection.DoRequest(
|
||||||
'breakpoints': [
|
partial( self._UpdateBreakpoints, file_name ),
|
||||||
{ 'name': 'main' } # HAAACK: TODO: Support setting breakpoints
|
{
|
||||||
]
|
'command': 'setBreakpoints',
|
||||||
},
|
'arguments': {
|
||||||
} )
|
'source': {
|
||||||
|
'file': file_name,
|
||||||
|
},
|
||||||
|
'breakpoints': breakpoints,
|
||||||
|
},
|
||||||
|
} )
|
||||||
|
|
||||||
self._connection.DoRequest( None, {
|
self._connection.DoRequest( None, {
|
||||||
'command': 'configurationDone',
|
'command': 'configurationDone',
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ def UserMessage( msg, persist=False ):
|
||||||
vim.command( 'redraw' )
|
vim.command( 'redraw' )
|
||||||
cmd = 'echom' if persist else 'echo'
|
cmd = 'echom' if persist else 'echo'
|
||||||
for line in msg.split( '\n' ):
|
for line in msg.split( '\n' ):
|
||||||
vim.command( '{0} \'{1}\''.format( cmd, Escape( line ) ) )
|
vim.command( "{0} '{1}'".format( cmd, Escape( line ) ) )
|
||||||
|
|
||||||
|
|
||||||
def SelectFromList( prompt, options ):
|
def SelectFromList( prompt, options ):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue