Merge pull request #169 from puremourning/breakpoints-clear
Fix listing breakpoints while debugging
This commit is contained in:
commit
b80c483284
8 changed files with 157 additions and 10 deletions
14
.vimspector.json
Normal file
14
.vimspector.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"configurations": {
|
||||
"Python: Attach To Vim": {
|
||||
"variables": {
|
||||
"port": "5678",
|
||||
"host": "localhost"
|
||||
},
|
||||
"adapter": "multi-session",
|
||||
"configuration": {
|
||||
"request": "attach"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ stages:
|
|||
- bash: pip3 install -r dev_requirements.txt
|
||||
displayName: "Install requirements"
|
||||
|
||||
- bash: $HOME/.local/bin/vint autoload/ plugin/ tests/
|
||||
- bash: $HOME/.local/bin/vint autoload/ compiler/ plugin/ tests/
|
||||
displayName: "Run vint"
|
||||
|
||||
- job: 'linux'
|
||||
|
|
|
|||
|
|
@ -13,12 +13,14 @@
|
|||
" See the License for the specific language governing permissions and
|
||||
" limitations under the License.
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
" Compiler plugin to help running vimspector tests
|
||||
|
||||
if exists("current_compiler")
|
||||
if exists('current_compiler')
|
||||
finish
|
||||
endif
|
||||
let current_compiler = "vimspector_test"
|
||||
let current_compiler = 'vimspector_test'
|
||||
|
||||
setlocal errorformat=
|
||||
\Found\ errors\ in\ %f:%.%#:
|
||||
|
|
@ -80,7 +82,7 @@ function! s:RunTestUnderCursor()
|
|||
let l:test_func_name = s:GetCurrentFunction()
|
||||
|
||||
if l:test_func_name ==# ''
|
||||
echo "No test method found"
|
||||
echo 'No test method found'
|
||||
return
|
||||
endif
|
||||
|
||||
|
|
@ -90,7 +92,9 @@ function! s:RunTestUnderCursor()
|
|||
let l:cwd = getcwd()
|
||||
execute 'lcd ' . s:root_dir
|
||||
try
|
||||
execute s:make_cmd . ' ' . get( b:, 'test_args', '' ) . ' ' . l:test_arg
|
||||
execute s:make_cmd . ' '
|
||||
\ . get( g:, 'vimspector_test_args', '' ) . ' '
|
||||
\ . l:test_arg
|
||||
finally
|
||||
execute 'lcd ' . l:cwd
|
||||
endtry
|
||||
|
|
@ -101,7 +105,9 @@ function! s:RunTest()
|
|||
let l:cwd = getcwd()
|
||||
execute 'lcd ' . s:root_dir
|
||||
try
|
||||
execute s:make_cmd . ' ' . get( b:, 'test_args', '' ) . ' %:p:t'
|
||||
execute s:make_cmd . ' '
|
||||
\ . get( g:, 'vimspector_test_args', '' )
|
||||
\ . ' %:p:t'
|
||||
finally
|
||||
execute 'lcd ' . l:cwd
|
||||
endtry
|
||||
|
|
@ -112,7 +118,8 @@ function! s:RunAllTests()
|
|||
let l:cwd = getcwd()
|
||||
execute 'lcd ' . s:root_dir
|
||||
try
|
||||
execute s:make_cmd . ' ' . get( b:, 'test_args', '' )
|
||||
execute s:make_cmd . ' '
|
||||
\ . get( g:, 'vimspector_test_args', '' )
|
||||
finally
|
||||
execute 'lcd ' . l:cwd
|
||||
endtry
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class ProjectBreakpoints( object ):
|
|||
# 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
|
||||
# object. This makes no sense and should be centralised so that we don't
|
||||
# have this duplication and bug factory.
|
||||
|
|
@ -115,7 +115,8 @@ class ProjectBreakpoints( object ):
|
|||
bp[ 'options' ] ),
|
||||
} )
|
||||
|
||||
vim.eval( 'setqflist( {} )'.format( json.dumps( qf ) ) )
|
||||
return qf
|
||||
|
||||
|
||||
def ClearBreakpoints( self ):
|
||||
# These are the user-entered breakpoints.
|
||||
|
|
|
|||
|
|
@ -979,7 +979,13 @@ class DebugSession( object ):
|
|||
self._stackTraceView.OnStopped( event )
|
||||
|
||||
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 ):
|
||||
return self._breakpoints.ToggleBreakpoint( options )
|
||||
|
|
|
|||
42
python3/vimspector/developer.py
Normal file
42
python3/vimspector/developer.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# vimspector - A multi-language debugging system for Vim
|
||||
# Copyright 2020 Ben Jackson
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
from vimspector import install, utils
|
||||
|
||||
|
||||
def SetUpDebugpy( wait=False, port=5678 ):
|
||||
sys.path.insert(
|
||||
1,
|
||||
os.path.join( install.GetGadgetDir( utils.GetVimspectorBase(),
|
||||
install.GetOS() ),
|
||||
'debugpy',
|
||||
'build',
|
||||
'lib' ) )
|
||||
import debugpy
|
||||
|
||||
exe = sys.executable
|
||||
try:
|
||||
# debugpy uses sys.executable (which is `vim`, so we hack it)
|
||||
sys.executable = 'python3'
|
||||
debugpy.listen( port )
|
||||
finally:
|
||||
sys.executable = exe
|
||||
|
||||
if wait:
|
||||
debugpy.wait_for_client()
|
||||
|
|
@ -452,3 +452,77 @@ endfunction
|
|||
" %bwipeout!
|
||||
" throw "xfail cpptools doesn't seem to honour conditions on function bps"
|
||||
" 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
|
||||
|
|
|
|||
|
|
@ -46,13 +46,16 @@ call ch_logfile( 'debuglog', 'w' )
|
|||
|
||||
" For consistency run all tests with 'nocompatible' set.
|
||||
" This also enables use of line continuation.
|
||||
" vint: Workaround for https://github.com/Vimjas/vint/issues/363
|
||||
" vint: -ProhibitSetNoCompatible
|
||||
set nocompatible
|
||||
" vint: +ProhibitSetNoCompatible
|
||||
|
||||
" Use utf-8 by default, instead of whatever the system default happens to be.
|
||||
" Individual tests can overrule this at the top of the file.
|
||||
" vint: -ProhibitEncodingOptionAfterScriptEncoding
|
||||
set encoding=utf-8
|
||||
" vint: +ProhibitEncodingOptionAfterScriptEncoding
|
||||
|
||||
" Avoid stopping at the "hit enter" prompt
|
||||
set nomore
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue