The reason this doesn't work is the servers don't realy populate the breakpoints list in the response. Also, the file:line breakpoints just simply down't work in c++

This commit is contained in:
Ben Jackson 2018-05-23 00:34:08 +01:00
commit c4aefc110c
2 changed files with 63 additions and 18 deletions

View file

@ -16,6 +16,8 @@
import vim
import logging
import json
from collections import defaultdict
from vimspector import utils
SIGN_ID_OFFSET = 10000000
@ -29,9 +31,10 @@ class CodeView( object ):
utils.SetUpLogging( self._logger )
self._next_sign_id = SIGN_ID_OFFSET
self._breakpoints = defaultdict( list )
self._signs = {
'vimspectorPC': None,
'breakpoints': [],
'breakpoints': []
}
@ -81,17 +84,43 @@ class CodeView( object ):
self._signs[ 'vimspectorPC' ] = None
def ShowBreakpoints( self, file_name, breakpoints ):
def AddBreakpoints( self, breakpoints ):
for breakpoint in breakpoints:
if not breakpoint.get( 'verified', False ):
continue
if 'source' not in breakpoint:
self._logger.warn( 'source not in breakpoint {0}'.format(
json.dumps( breakpoint ) ) )
continue
self._breakpoints[ breakpoint[ 'source' ][ 'file' ] ].append(
breakpoint[ 'line' ] )
self._logger.debug( 'Breakpoints at this point: {0}'.format(
json.dumps( self._breakpoints, indent = 2 ) ) )
def _UndisplaySigns( self ):
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 ) )
self._signs[ 'breakpoints' ].clear()
def ClearBreakpoints( self ):
self._UndisplaySigns();
self._breakpoints = defaultdict( list )
def ShowBreakpoints( self ):
self._UndisplaySigns()
for file_name, lines in self._breakpoints.items():
for line in lines:
sign_id = self._next_sign_id
self._next_sign_id += 1
self._signs[ 'breakpoints' ].append( sign_id )
vim.command(
'sign place {0} line={1} name=vimspectorBP file={2}'.format(
sign_id,
line,
file_name ) )

View file

@ -16,7 +16,7 @@
import logging
import vim
import json
from functools import partial
import os
from collections import defaultdict
@ -216,24 +216,40 @@ class DebugSession( object ):
'arguments': launch_config
} )
def _UpdateBreakpoints( self, file_name, message ):
self._codeView.ShowBreakpoints( file_name,
message[ 'body' ][ 'breakpoints' ])
def _UpdateBreakpoints( self, message ):
self._codeView.AddBreakpoints( message[ 'body' ][ 'breakpoints' ] )
self._codeView.ShowBreakpoints()
def OnEvent_initialized( self, message ):
self._codeView.ClearBreakpoints()
for file_name, line_breakpoints in self._breakpoints.items():
breakpoints = [ { 'line': line } for line in line_breakpoints.keys() ]
self._connection.DoRequest(
partial( self._UpdateBreakpoints, file_name ),
self._UpdateBreakpoints,
{
'command': 'setBreakpoints',
'arguments': {
'source': {
'name': os.path.basename( file_name ),
'file': file_name,
},
'breakpoints': breakpoints,
},
}
)
self._connection.DoRequest(
self._UpdateBreakpoints,
{
'command': 'setFunctionBreakpoints',
'arguments': {
'breakpoints': [
{ 'name': 'main' },
],
},
} )
}
)
self._connection.DoRequest( None, {
'command': 'configurationDone',