WIP: Data breakpoints (though can't find a server which supports them)
This commit is contained in:
parent
32360236ff
commit
c2353b388d
5 changed files with 108 additions and 0 deletions
|
|
@ -220,6 +220,14 @@ function! vimspector#SetVariableValue( ... ) abort
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! vimspector#AddDataBreakpoint( ... ) abort
|
||||||
|
if !s:Enabled()
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
" TODO: how to set options?
|
||||||
|
py3 _vimspector_session.AddDataBreakpoint( {} )
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! vimspector#DeleteWatch() abort
|
function! vimspector#DeleteWatch() abort
|
||||||
if !s:Enabled()
|
if !s:Enabled()
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ class ProjectBreakpoints( object ):
|
||||||
self._func_breakpoints = []
|
self._func_breakpoints = []
|
||||||
self._exception_breakpoints = None
|
self._exception_breakpoints = None
|
||||||
self._configured_breakpoints = {}
|
self._configured_breakpoints = {}
|
||||||
|
self._data_breakponts = []
|
||||||
|
|
||||||
# FIXME: Remove this. Remove breakpoints nonesense from code.py
|
# FIXME: Remove this. Remove breakpoints nonesense from code.py
|
||||||
self._breakpoints_handler = None
|
self._breakpoints_handler = None
|
||||||
|
|
@ -270,6 +271,18 @@ class ProjectBreakpoints( object ):
|
||||||
|
|
||||||
# TODO: We don't really have aanything to update here, but if we're going to
|
# TODO: We don't really have aanything to update here, but if we're going to
|
||||||
# have a UI list of them we should update that at this point
|
# have a UI list of them we should update that at this point
|
||||||
|
# but note that while debugging, this is when we actually _send_ the
|
||||||
|
# breakpoints.
|
||||||
|
self.UpdateUI()
|
||||||
|
|
||||||
|
|
||||||
|
def AddDataBreakpoint( self, dataId, options ):
|
||||||
|
self._data_breakponts.append( {
|
||||||
|
'state': 'ENABLED',
|
||||||
|
'dataId': dataId,
|
||||||
|
'options': options,
|
||||||
|
} )
|
||||||
|
|
||||||
self.UpdateUI()
|
self.UpdateUI()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -402,6 +415,27 @@ class ProjectBreakpoints( object ):
|
||||||
failure_handler = response_received
|
failure_handler = response_received
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self._data_breakponts and self._server_capabilities[
|
||||||
|
'supportsDataBreakpoints' ]:
|
||||||
|
awaiting += 1
|
||||||
|
breakpoints = []
|
||||||
|
for bp in self._data_breakponts:
|
||||||
|
if bp[ 'state' ] != 'ENABLED':
|
||||||
|
continue
|
||||||
|
data_bp = {}
|
||||||
|
data_bp.update( bp[ 'options' ] )
|
||||||
|
data_bp[ 'dataId' ] = bp[ 'dataId' ]
|
||||||
|
breakpoints.append( data_bp )
|
||||||
|
|
||||||
|
self._connection.DoRequest(
|
||||||
|
lambda msg: response_handler( None, None ),
|
||||||
|
{
|
||||||
|
'command': 'setDataBreakpoints',
|
||||||
|
'arguments': breakpoints,
|
||||||
|
},
|
||||||
|
failure_handler = response_received
|
||||||
|
)
|
||||||
|
|
||||||
if self._exception_breakpoints:
|
if self._exception_breakpoints:
|
||||||
awaiting = awaiting + 1
|
awaiting = awaiting + 1
|
||||||
self._connection.DoRequest(
|
self._connection.DoRequest(
|
||||||
|
|
@ -494,6 +528,11 @@ class ProjectBreakpoints( object ):
|
||||||
file_name,
|
file_name,
|
||||||
bp[ 'line' ] )
|
bp[ 'line' ] )
|
||||||
|
|
||||||
|
# TODO could/should we show a sign in the variables view when there's a data
|
||||||
|
# brakpoint on the variable? Not sure how best to actually do that, but
|
||||||
|
# maybe the variable view can pass that info when calling AddDataBreakpoint,
|
||||||
|
# such as the variablesReference/name
|
||||||
|
|
||||||
|
|
||||||
def _SignToLine( self, file_name, bp ):
|
def _SignToLine( self, file_name, bp ):
|
||||||
if 'sign_id' not in bp:
|
if 'sign_id' not in bp:
|
||||||
|
|
|
||||||
|
|
@ -535,6 +535,21 @@ class DebugSession( object ):
|
||||||
def SetVariableValue( self, new_value = None, buf = None, line_num = None ):
|
def SetVariableValue( self, new_value = None, buf = None, line_num = None ):
|
||||||
self._variablesView.SetVariableValue( new_value, buf, line_num )
|
self._variablesView.SetVariableValue( new_value, buf, line_num )
|
||||||
|
|
||||||
|
@IfConnected()
|
||||||
|
def AddDataBreakpoint( self, opts, buf = None, line_num = None ):
|
||||||
|
def add_bp( breakpoint_info ):
|
||||||
|
if breakpoint_info[ 'dataId' ] is None:
|
||||||
|
utils.UserMessage(
|
||||||
|
"Can't set data breakpoint here: { breakpoint_info[ 'description' ] }"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
# TODO: Ask the user about the possible DataBreakpointAccessType's and add
|
||||||
|
# that in to opts here
|
||||||
|
self._breakpoints.AddDataBreakpoint( breakpoint_info[ 'dataId' ], opts )
|
||||||
|
|
||||||
|
self._variablesView.GetDataBreakpointInfo( add_bp, buf, line_num )
|
||||||
|
|
||||||
@IfConnected()
|
@IfConnected()
|
||||||
def AddWatch( self, expression ):
|
def AddWatch( self, expression ):
|
||||||
self._variablesView.AddWatch( self._stackTraceView.GetCurrentFrame(),
|
self._variablesView.AddWatch( self._stackTraceView.GetCurrentFrame(),
|
||||||
|
|
|
||||||
|
|
@ -580,6 +580,33 @@ class VariablesView( object ):
|
||||||
}, failure_handler = failure_handler )
|
}, failure_handler = failure_handler )
|
||||||
|
|
||||||
|
|
||||||
|
def GetDataBreakpointInfo( self,
|
||||||
|
then,
|
||||||
|
buf = None,
|
||||||
|
line_num = None ):
|
||||||
|
variable: Variable
|
||||||
|
view: View
|
||||||
|
|
||||||
|
if not self._server_capabilities.get( 'supportsDataBreakpoints' ):
|
||||||
|
return None
|
||||||
|
|
||||||
|
variable, view = self._GetVariable( buf, line_num )
|
||||||
|
if variable is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
arguments = {
|
||||||
|
'name': variable.variable[ 'name' ],
|
||||||
|
}
|
||||||
|
if variable.IsContained():
|
||||||
|
arguments[ 'variablesReference' ] = (
|
||||||
|
variable.container.VariablesReference() )
|
||||||
|
|
||||||
|
self._connection.DoRequest( lambda msg: then( msg[ 'body' ] ), {
|
||||||
|
'command': 'dataBreakpointInfo',
|
||||||
|
'arguments': arguments,
|
||||||
|
} )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _DrawVariables( self, view, variables, indent, is_short = False ):
|
def _DrawVariables( self, view, variables, indent, is_short = False ):
|
||||||
assert indent > 0
|
assert indent > 0
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,25 @@
|
||||||
package main
|
package main
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
|
type Toaster struct {
|
||||||
|
Power int
|
||||||
|
Colour string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Test struct {
|
||||||
|
Test string
|
||||||
|
Toast Toaster
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var v = "test"
|
var v = "test"
|
||||||
|
test := Test{
|
||||||
|
Test: "This is\na\ntest",
|
||||||
|
Toast: Toaster{
|
||||||
|
Power: 10,
|
||||||
|
Colour: "green",
|
||||||
|
},
|
||||||
|
}
|
||||||
fmt.Println("hello world: " + v)
|
fmt.Println("hello world: " + v)
|
||||||
|
fmt.Println("Hi " + test.Test)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue