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:
parent
c9a45b3bdc
commit
c4aefc110c
2 changed files with 63 additions and 18 deletions
|
|
@ -16,6 +16,8 @@
|
||||||
import vim
|
import vim
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
from vimspector import utils
|
from vimspector import utils
|
||||||
|
|
||||||
SIGN_ID_OFFSET = 10000000
|
SIGN_ID_OFFSET = 10000000
|
||||||
|
|
@ -29,9 +31,10 @@ class CodeView( object ):
|
||||||
utils.SetUpLogging( self._logger )
|
utils.SetUpLogging( self._logger )
|
||||||
|
|
||||||
self._next_sign_id = SIGN_ID_OFFSET
|
self._next_sign_id = SIGN_ID_OFFSET
|
||||||
|
self._breakpoints = defaultdict( list )
|
||||||
self._signs = {
|
self._signs = {
|
||||||
'vimspectorPC': None,
|
'vimspectorPC': None,
|
||||||
'breakpoints': [],
|
'breakpoints': []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -81,17 +84,43 @@ class CodeView( object ):
|
||||||
self._signs[ 'vimspectorPC' ] = None
|
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' ]:
|
for sign_id in self._signs[ 'breakpoints' ]:
|
||||||
vim.command( 'sign unplace {0}'.format( sign_id ) )
|
vim.command( 'sign unplace {0}'.format( sign_id ) )
|
||||||
|
|
||||||
for breakpoint in breakpoints:
|
self._signs[ 'breakpoints' ].clear()
|
||||||
sign_id = self._next_sign_id
|
|
||||||
self._next_sign_id += 1
|
def ClearBreakpoints( self ):
|
||||||
self._signs[ 'breakpoints' ].append( sign_id )
|
self._UndisplaySigns();
|
||||||
self._logger.debug( 'breakpoint: {0}'.format( json.dumps( breakpoint,
|
self._breakpoints = defaultdict( list )
|
||||||
indent=2 ) ) )
|
|
||||||
vim.command( 'sign place {0} line={1} name=vimspectorBP file={2}'.format(
|
|
||||||
sign_id,
|
def ShowBreakpoints( self ):
|
||||||
breakpoint[ 'line' ],
|
self._UndisplaySigns()
|
||||||
file_name ) )
|
|
||||||
|
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 ) )
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
import logging
|
import logging
|
||||||
import vim
|
import vim
|
||||||
import json
|
import json
|
||||||
from functools import partial
|
import os
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
|
|
@ -216,24 +216,40 @@ class DebugSession( object ):
|
||||||
'arguments': launch_config
|
'arguments': launch_config
|
||||||
} )
|
} )
|
||||||
|
|
||||||
def _UpdateBreakpoints( self, file_name, message ):
|
def _UpdateBreakpoints( self, message ):
|
||||||
self._codeView.ShowBreakpoints( file_name,
|
self._codeView.AddBreakpoints( message[ 'body' ][ 'breakpoints' ] )
|
||||||
message[ 'body' ][ 'breakpoints' ])
|
self._codeView.ShowBreakpoints()
|
||||||
|
|
||||||
def OnEvent_initialized( self, message ):
|
def OnEvent_initialized( self, message ):
|
||||||
|
self._codeView.ClearBreakpoints()
|
||||||
|
|
||||||
for file_name, line_breakpoints in self._breakpoints.items():
|
for file_name, line_breakpoints in self._breakpoints.items():
|
||||||
breakpoints = [ { 'line': line } for line in line_breakpoints.keys() ]
|
breakpoints = [ { 'line': line } for line in line_breakpoints.keys() ]
|
||||||
self._connection.DoRequest(
|
self._connection.DoRequest(
|
||||||
partial( self._UpdateBreakpoints, file_name ),
|
self._UpdateBreakpoints,
|
||||||
{
|
{
|
||||||
'command': 'setBreakpoints',
|
'command': 'setBreakpoints',
|
||||||
'arguments': {
|
'arguments': {
|
||||||
'source': {
|
'source': {
|
||||||
|
'name': os.path.basename( file_name ),
|
||||||
'file': file_name,
|
'file': file_name,
|
||||||
},
|
},
|
||||||
'breakpoints': breakpoints,
|
'breakpoints': breakpoints,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self._connection.DoRequest(
|
||||||
|
self._UpdateBreakpoints,
|
||||||
|
{
|
||||||
|
'command': 'setFunctionBreakpoints',
|
||||||
|
'arguments': {
|
||||||
|
'breakpoints': [
|
||||||
|
{ 'name': 'main' },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
} )
|
}
|
||||||
|
)
|
||||||
|
|
||||||
self._connection.DoRequest( None, {
|
self._connection.DoRequest( None, {
|
||||||
'command': 'configurationDone',
|
'command': 'configurationDone',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue