Merge pull request #279 from puremourning/breakpoint-event
Fix breakpoint event
This commit is contained in:
commit
1eb9933e2a
6 changed files with 135 additions and 22 deletions
|
|
@ -183,7 +183,7 @@ function! vimspector#Evaluate( expr ) abort
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
py3 _vimspector_session.ShowOutput( 'Console' )
|
py3 _vimspector_session.ShowOutput( 'Console' )
|
||||||
py3 _vimspector_session.EvaluateConsole( vim.eval( 'a:expr' ) )
|
py3 _vimspector_session.EvaluateConsole( vim.eval( 'a:expr' ), True )
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vimspector#EvaluateConsole( expr ) abort
|
function! vimspector#EvaluateConsole( expr ) abort
|
||||||
|
|
@ -192,7 +192,7 @@ function! vimspector#EvaluateConsole( expr ) abort
|
||||||
endif
|
endif
|
||||||
stopinsert
|
stopinsert
|
||||||
setlocal nomodified
|
setlocal nomodified
|
||||||
py3 _vimspector_session.EvaluateConsole( vim.eval( 'a:expr' ) )
|
py3 _vimspector_session.EvaluateConsole( vim.eval( 'a:expr' ), False )
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vimspector#ShowOutput( ... ) abort
|
function! vimspector#ShowOutput( ... ) abort
|
||||||
|
|
|
||||||
|
|
@ -166,25 +166,29 @@ class CodeView( object ):
|
||||||
|
|
||||||
def AddBreakpoints( self, source, breakpoints ):
|
def AddBreakpoints( self, source, breakpoints ):
|
||||||
for breakpoint in breakpoints:
|
for breakpoint in breakpoints:
|
||||||
if 'source' not in breakpoint:
|
source = breakpoint.get( 'source' ) or source
|
||||||
if source:
|
if not source or 'path' not in source:
|
||||||
breakpoint[ 'source' ] = source
|
self._logger.warn( 'missing source/path in breakpoint {0}'.format(
|
||||||
else:
|
|
||||||
self._logger.warn( 'missing source in breakpoint {0}'.format(
|
|
||||||
json.dumps( breakpoint ) ) )
|
json.dumps( breakpoint ) ) )
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self._breakpoints[ breakpoint[ 'source' ][ 'path' ] ].append(
|
breakpoint[ 'source' ] = source
|
||||||
breakpoint )
|
self._breakpoints[ source[ 'path' ] ].append( breakpoint )
|
||||||
|
|
||||||
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 ) ) )
|
||||||
|
|
||||||
self.ShowBreakpoints()
|
self.ShowBreakpoints()
|
||||||
|
|
||||||
|
|
||||||
|
def AddBreakpoint( self, breakpoint ):
|
||||||
|
self.AddBreakpoints( None, [ breakpoint ] )
|
||||||
|
|
||||||
|
|
||||||
def UpdateBreakpoint( self, bp ):
|
def UpdateBreakpoint( self, bp ):
|
||||||
if 'id' not in bp:
|
if 'id' not in bp:
|
||||||
self.AddBreakpoints( None, [ bp ] )
|
self.AddBreakpoint( bp )
|
||||||
|
return
|
||||||
|
|
||||||
for _, breakpoint_list in self._breakpoints.items():
|
for _, breakpoint_list in self._breakpoints.items():
|
||||||
for index, breakpoint in enumerate( breakpoint_list ):
|
for index, breakpoint in enumerate( breakpoint_list ):
|
||||||
|
|
@ -194,7 +198,22 @@ class CodeView( object ):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Not found. Assume new
|
# Not found. Assume new
|
||||||
self.AddBreakpoints( None, [ bp ] )
|
self.AddBreakpoint( bp )
|
||||||
|
|
||||||
|
|
||||||
|
def RemoveBreakpoint( self, bp ):
|
||||||
|
for _, breakpoint_list in self._breakpoints.items():
|
||||||
|
found_index = None
|
||||||
|
for index, breakpoint in enumerate( breakpoint_list ):
|
||||||
|
if 'id' in breakpoint and breakpoint[ 'id' ] == bp[ 'id' ]:
|
||||||
|
found_index = index
|
||||||
|
break
|
||||||
|
|
||||||
|
if found_index is not None:
|
||||||
|
del breakpoint_list[ found_index ]
|
||||||
|
self.ShowBreakpoints()
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def _UndisplaySigns( self ):
|
def _UndisplaySigns( self ):
|
||||||
for sign_id in self._signs[ 'breakpoints' ]:
|
for sign_id in self._signs[ 'breakpoints' ]:
|
||||||
|
|
|
||||||
|
|
@ -467,9 +467,10 @@ class DebugSession( object ):
|
||||||
expression )
|
expression )
|
||||||
|
|
||||||
@IfConnected()
|
@IfConnected()
|
||||||
def EvaluateConsole( self, expression ):
|
def EvaluateConsole( self, expression, verbose ):
|
||||||
self._outputView.Evaluate( self._stackTraceView.GetCurrentFrame(),
|
self._outputView.Evaluate( self._stackTraceView.GetCurrentFrame(),
|
||||||
expression )
|
expression,
|
||||||
|
verbose )
|
||||||
|
|
||||||
@IfConnected()
|
@IfConnected()
|
||||||
def DeleteWatch( self ):
|
def DeleteWatch( self ):
|
||||||
|
|
@ -1050,7 +1051,9 @@ class DebugSession( object ):
|
||||||
if reason == 'changed':
|
if reason == 'changed':
|
||||||
self._codeView.UpdateBreakpoint( bp )
|
self._codeView.UpdateBreakpoint( bp )
|
||||||
elif reason == 'new':
|
elif reason == 'new':
|
||||||
self._codeView.AddBreakpoints( None, bp )
|
self._codeView.AddBreakpoint( bp )
|
||||||
|
elif reason == 'removed':
|
||||||
|
self._codeView.RemoveBreakpoint( bp )
|
||||||
else:
|
else:
|
||||||
utils.UserMessage(
|
utils.UserMessage(
|
||||||
'Unrecognised breakpoint event (undocumented): {0}'.format( reason ),
|
'Unrecognised breakpoint event (undocumented): {0}'.format( reason ),
|
||||||
|
|
|
||||||
|
|
@ -260,14 +260,18 @@ class DAPOutputView( OutputView ):
|
||||||
# Don't clear because output is probably still useful
|
# Don't clear because output is probably still useful
|
||||||
self._connection = None
|
self._connection = None
|
||||||
|
|
||||||
def Evaluate( self, frame, expression ):
|
def Evaluate( self, frame, expression, verbose ):
|
||||||
self._Print( 'Console', [ 'Evaluating: ' + expression ] )
|
if verbose:
|
||||||
|
self._Print( 'Console', f"Evaluating: { expression }" )
|
||||||
|
|
||||||
def print_result( message ):
|
def print_result( message ):
|
||||||
result = message[ 'body' ][ 'result' ]
|
result = message[ 'body' ][ 'result' ]
|
||||||
if result is None:
|
if result is None:
|
||||||
result = '<no result>'
|
result = '<no result>'
|
||||||
self._Print( 'Console', f' Result: { result }' )
|
self._Print( 'Console', result.splitlines() )
|
||||||
|
|
||||||
|
def print_failure( reason, msg ):
|
||||||
|
self._Print( 'Console', reason.splitlines() )
|
||||||
|
|
||||||
request = {
|
request = {
|
||||||
'command': 'evaluate',
|
'command': 'evaluate',
|
||||||
|
|
@ -280,4 +284,6 @@ class DAPOutputView( OutputView ):
|
||||||
if frame:
|
if frame:
|
||||||
request[ 'arguments' ][ 'frameId' ] = frame[ 'id' ]
|
request[ 'arguments' ][ 'frameId' ] = frame[ 'id' ]
|
||||||
|
|
||||||
self._connection.DoRequest( print_result, request )
|
self._connection.DoRequest( print_result,
|
||||||
|
request,
|
||||||
|
print_failure )
|
||||||
|
|
|
||||||
39
tests/testdata/cpp/simple/.vimspector.json
vendored
39
tests/testdata/cpp/simple/.vimspector.json
vendored
|
|
@ -68,6 +68,45 @@
|
||||||
"CALCULATED_STR", "${CALCULATED_STR}"
|
"CALCULATED_STR", "${CALCULATED_STR}"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"lldb-vscode": {
|
||||||
|
"adapter": "lldb-vscode",
|
||||||
|
"configuration": {
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceRoot}/${fileBasenameNoExtension}",
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "lldb"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"CodeLLDB": {
|
||||||
|
"adapter": "CodeLLDB",
|
||||||
|
"configuration": {
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceRoot}/${fileBasenameNoExtension}",
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"expressions": "native"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"adapters": {
|
||||||
|
"lldb-vscode": {
|
||||||
|
"variables": {
|
||||||
|
"LLVM": {
|
||||||
|
"shell": "brew --prefix llvm"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"attach": {
|
||||||
|
"pidProperty": "pid",
|
||||||
|
"pidSelect": "ask"
|
||||||
|
},
|
||||||
|
"command": [
|
||||||
|
"${LLVM}/bin/lldb-vscode"
|
||||||
|
],
|
||||||
|
"env": {
|
||||||
|
"LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY": "YES"
|
||||||
|
},
|
||||||
|
"name": "lldb"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -499,7 +499,7 @@ function Test_EvaluateConsole()
|
||||||
call WaitForAssert( {->
|
call WaitForAssert( {->
|
||||||
\ assert_equal(
|
\ assert_equal(
|
||||||
\ [
|
\ [
|
||||||
\ ' Result: 1'
|
\ '1'
|
||||||
\ ],
|
\ ],
|
||||||
\ getbufline( bufnr( 'vimspector.Console' ), '$', '$' )
|
\ getbufline( bufnr( 'vimspector.Console' ), '$', '$' )
|
||||||
\ )
|
\ )
|
||||||
|
|
@ -511,7 +511,7 @@ function Test_EvaluateConsole()
|
||||||
\ assert_equal(
|
\ assert_equal(
|
||||||
\ [
|
\ [
|
||||||
\ 'Evaluating: t.i',
|
\ 'Evaluating: t.i',
|
||||||
\ ' Result: 1'
|
\ '1'
|
||||||
\ ],
|
\ ],
|
||||||
\ getbufline( bufnr( 'vimspector.Console' ), len-1, '$' )
|
\ getbufline( bufnr( 'vimspector.Console' ), len-1, '$' )
|
||||||
\ )
|
\ )
|
||||||
|
|
@ -522,3 +522,49 @@ function Test_EvaluateConsole()
|
||||||
call vimspector#test#setup#Reset()
|
call vimspector#test#setup#Reset()
|
||||||
%bwipe!
|
%bwipe!
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function Test_EvaluatePromptConsole()
|
||||||
|
let fn = 'testdata/cpp/simple/struct.cpp'
|
||||||
|
call s:StartDebugging( #{ fn: fn, line: 24, col: 1, launch: #{
|
||||||
|
\ configuration: 'run-to-breakpoint'
|
||||||
|
\ } } )
|
||||||
|
|
||||||
|
" Make sure the Test t is initialised
|
||||||
|
call vimspector#StepOver()
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 26, 1 )
|
||||||
|
call vimspector#StepOver()
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 27, 1 )
|
||||||
|
|
||||||
|
VimspectorShowOutput
|
||||||
|
call assert_equal( bufnr( 'vimspector.Console' ),
|
||||||
|
\ winbufnr( g:vimspector_session_windows.output ) )
|
||||||
|
|
||||||
|
call feedkeys( "it.i\<CR>", 'xt' )
|
||||||
|
call WaitForAssert( {->
|
||||||
|
\ assert_equal(
|
||||||
|
\ [
|
||||||
|
\ '1'
|
||||||
|
\ ],
|
||||||
|
\ getbufline( bufnr( 'vimspector.Console' ), '$', '$' )
|
||||||
|
\ )
|
||||||
|
\ } )
|
||||||
|
|
||||||
|
let len = getbufinfo( 'vimspector.Console' )[ 0 ].linecount
|
||||||
|
|
||||||
|
call WaitForAssert( {->
|
||||||
|
\ assert_equal(
|
||||||
|
\ [
|
||||||
|
\ '> t.i',
|
||||||
|
\ '',
|
||||||
|
\ '1'
|
||||||
|
\ ],
|
||||||
|
\ getbufline( bufnr( 'vimspector.Console' ), len-2, '$' )
|
||||||
|
\ )
|
||||||
|
\ } )
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer(
|
||||||
|
\ 'vimspector.Console', len, v:null )
|
||||||
|
|
||||||
|
call vimspector#test#setup#Reset()
|
||||||
|
%bwipe!
|
||||||
|
endfunction
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue