breakpoints list: fix listing while debugging
Also, open the quickfix list when listing breakpoints, and add a test
This commit is contained in:
parent
6a1c9a6b52
commit
8c4112cd1f
3 changed files with 84 additions and 3 deletions
|
|
@ -82,7 +82,7 @@ class ProjectBreakpoints( object ):
|
||||||
# FIXME: If the adapter type changes, we should probably forget this ?
|
# FIXME: If the adapter type changes, we should probably forget this ?
|
||||||
|
|
||||||
|
|
||||||
def ListBreakpoints( self ):
|
def BreakpointsAsQuickFix( self ):
|
||||||
# FIXME: Handling of breakpoints is a mess, split between _codeView and this
|
# FIXME: Handling of breakpoints is a mess, split between _codeView and this
|
||||||
# object. This makes no sense and should be centralised so that we don't
|
# object. This makes no sense and should be centralised so that we don't
|
||||||
# have this duplication and bug factory.
|
# have this duplication and bug factory.
|
||||||
|
|
@ -115,7 +115,8 @@ class ProjectBreakpoints( object ):
|
||||||
bp[ 'options' ] ),
|
bp[ 'options' ] ),
|
||||||
} )
|
} )
|
||||||
|
|
||||||
vim.eval( 'setqflist( {} )'.format( json.dumps( qf ) ) )
|
return qf
|
||||||
|
|
||||||
|
|
||||||
def ClearBreakpoints( self ):
|
def ClearBreakpoints( self ):
|
||||||
# These are the user-entered breakpoints.
|
# These are the user-entered breakpoints.
|
||||||
|
|
|
||||||
|
|
@ -979,7 +979,13 @@ class DebugSession( object ):
|
||||||
self._stackTraceView.OnStopped( event )
|
self._stackTraceView.OnStopped( event )
|
||||||
|
|
||||||
def ListBreakpoints( self ):
|
def ListBreakpoints( self ):
|
||||||
return self._breakpoints.ListBreakpoints()
|
if self._connection:
|
||||||
|
qf = self._codeView.BreakpointsAsQuickFix()
|
||||||
|
else:
|
||||||
|
qf = self._breakpoints.BreakpointsAsQuickFix()
|
||||||
|
|
||||||
|
vim.eval( 'setqflist( {} )'.format( json.dumps( qf ) ) )
|
||||||
|
vim.command( 'copen' )
|
||||||
|
|
||||||
def ToggleBreakpoint( self, options ):
|
def ToggleBreakpoint( self, options ):
|
||||||
return self._breakpoints.ToggleBreakpoint( options )
|
return self._breakpoints.ToggleBreakpoint( options )
|
||||||
|
|
|
||||||
|
|
@ -452,3 +452,77 @@ endfunction
|
||||||
" %bwipeout!
|
" %bwipeout!
|
||||||
" throw "xfail cpptools doesn't seem to honour conditions on function bps"
|
" throw "xfail cpptools doesn't seem to honour conditions on function bps"
|
||||||
" endfunction
|
" endfunction
|
||||||
|
|
||||||
|
function! s:CheckQuickFixEntries( entries )
|
||||||
|
let qf = getqflist()
|
||||||
|
let i = 0
|
||||||
|
for entry in a:entries
|
||||||
|
if i >= len( qf )
|
||||||
|
call assert_report( "Expected more quickfix entries" )
|
||||||
|
endif
|
||||||
|
for key in keys( entry )
|
||||||
|
call assert_equal( entry[ key ],
|
||||||
|
\ qf[ i ][ key ],
|
||||||
|
\ key . ' in ' . string( qf[ i ] )
|
||||||
|
\ . ' expected ' . entry[ key ] )
|
||||||
|
endfor
|
||||||
|
let i = i+1
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! Test_ListBreakpoints()
|
||||||
|
lcd testdata/cpp/simple
|
||||||
|
edit simple.cpp
|
||||||
|
call setpos( '.', [ 0, 15, 1 ] )
|
||||||
|
|
||||||
|
call vimspector#ListBreakpoints()
|
||||||
|
wincmd p
|
||||||
|
cclose
|
||||||
|
call s:CheckQuickFixEntries( [] )
|
||||||
|
|
||||||
|
call vimspector#ToggleBreakpoint()
|
||||||
|
call assert_equal( [], getqflist() )
|
||||||
|
|
||||||
|
call vimspector#ListBreakpoints()
|
||||||
|
call s:CheckQuickFixEntries( [
|
||||||
|
\ { 'lnum': 15, 'col': 1, 'bufnr': bufnr( 'simple.cpp', 0 ) }
|
||||||
|
\ ] )
|
||||||
|
|
||||||
|
" Cursor jumps to the quickfix window
|
||||||
|
call assert_equal( 'quickfix', &buftype )
|
||||||
|
cclose
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 15, 1 )
|
||||||
|
|
||||||
|
call vimspector#Launch()
|
||||||
|
" break on main
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 15, 1 )
|
||||||
|
|
||||||
|
call vimspector#ListBreakpoints()
|
||||||
|
call s:CheckQuickFixEntries( [
|
||||||
|
\ { 'lnum': 15, 'col': 1, 'bufnr': bufnr( 'simple.cpp', 0 ) }
|
||||||
|
\ ] )
|
||||||
|
call assert_equal( 'quickfix', &buftype )
|
||||||
|
wincmd p
|
||||||
|
cclose
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 15, 1 )
|
||||||
|
|
||||||
|
" Add a breakpoint that moves (from line 5 to line 9)
|
||||||
|
call cursor( [ 5, 1 ] )
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 5, 1 )
|
||||||
|
call vimspector#ToggleBreakpoint()
|
||||||
|
|
||||||
|
function! Check()
|
||||||
|
call vimspector#ListBreakpoints()
|
||||||
|
wincmd p
|
||||||
|
return assert_equal( 2, len( getqflist() ) )
|
||||||
|
endfunction
|
||||||
|
call WaitForAssert( function( 'Check' ) )
|
||||||
|
|
||||||
|
call s:CheckQuickFixEntries( [
|
||||||
|
\ { 'lnum': 15, 'col': 1, 'bufnr': bufnr( 'simple.cpp', 0 ) },
|
||||||
|
\ { 'lnum': 9, 'col': 1, 'bufnr': bufnr( 'simple.cpp', 0 ) },
|
||||||
|
\ ] )
|
||||||
|
|
||||||
|
call vimspector#test#setup#Reset()
|
||||||
|
%bwipe!
|
||||||
|
endfunction
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue