1 Star 0 Fork 0

dglxlcl/vimspector

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
stack_trace.test.vim 19.20 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
let s:fn='testdata/cpp/simple/threads.cpp'
function! SetUp()
call vimspector#test#setup#SetUpWithMappings( 'HUMAN' )
endfunction
function! TearDown()
call vimspector#test#setup#TearDown()
endfunction
function! s:StartDebugging()
exe 'edit ' . s:fn
call vimspector#SetLineBreakpoint( s:fn, 15 )
call vimspector#LaunchWithSettings( #{ configuration: 'run-to-breakpoint' } )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 15, 1 )
endfunction
function! Test_Multiple_Threads_Continue()
let thread_l = 67
let notify_l = 74
call vimspector#SetLineBreakpoint( s:fn, thread_l )
call vimspector#SetLineBreakpoint( s:fn, notify_l )
call s:StartDebugging()
call vimspector#Continue()
" As we step through the thread creation we should get Thread events
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_l, 1 )
call cursor( 1, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '- Thread [0-9]\+: .* (paused)',
\ ' .*: .*@threads.cpp:' . string( thread_l )
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ 1,
\ 2 )
\ )
\ } )
call vimspector#Continue()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_l, 1 )
call cursor( 1, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '- Thread [0-9]\+: .* (paused)',
\ ' .*: .*@threads.cpp:' . string( thread_l )
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ 1,
\ 2 )
\ )
\ } )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ '$',
\ '$' )
\ )
\ } )
call vimspector#Continue()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_l, 1 )
call cursor( 1, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '- Thread [0-9]\+: .* (paused)',
\ ' .*: .*@threads.cpp:' . string( thread_l )
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ 1,
\ 2 )
\ )
\ } )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ '$',
\ '$' )
\ )
\ } )
call vimspector#Continue()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_l, 1 )
call cursor( 1, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '- Thread [0-9]\+: .* (paused)',
\ ' .*: .*@threads.cpp:' . string( thread_l )
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ 1,
\ 2 )
\ )
\ } )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ '$',
\ '$' )
\ )
\ } )
call vimspector#Continue()
" This is the last one
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_l, 1 )
call cursor( 1, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '- Thread [0-9]\+: .* (paused)',
\ ' .*: .*@threads.cpp:' . string( thread_l )
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ 1,
\ 2 )
\ )
\ } )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ '$',
\ '$' )
\ )
\ } )
call vimspector#Continue()
" So we break out of the loop
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, notify_l, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '- Thread [0-9]\+: .* (paused)',
\ ' .*: .*@threads.cpp:' . string( notify_l )
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ 1,
\ 2 )
\ )
\ } )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ '$',
\ '$' )
\ )
\ } )
call vimspector#ClearBreakpoints()
call vimspector#test#setup#Reset()
%bwipe!
endfunction
function! Test_Multiple_Threads_Step()
let thread_l = 67
if $VIMSPECTOR_MIMODE ==# 'lldb'
" }
let thread_n = thread_l + 1
else
" for ....
let thread_n = 49
endif
let notify_l = 74
call vimspector#SetLineBreakpoint( s:fn, thread_l )
call vimspector#SetLineBreakpoint( s:fn, notify_l )
call s:StartDebugging()
call vimspector#Continue()
" As we step through the thread creation we should get Thread events
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_l, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '- Thread [0-9]\+: .* (paused)',
\ ' .*: .*@threads.cpp:' . string( thread_l )
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ 1,
\ 2 )
\ )
\ } )
call vimspector#StepOver()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_n, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ '$',
\ '$' )
\ )
\ } )
call vimspector#Continue()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_l, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ '$',
\ '$' )
\ )
\ } )
call vimspector#StepOver()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_n, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ -1,
\ '$' )
\ )
\ } )
call vimspector#Continue()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_l, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ -1,
\ '$' )
\ )
\ } )
call vimspector#StepOver()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_n, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ -2,
\ '$' )
\ )
\ } )
call vimspector#Continue()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_l, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ -2,
\ '$' )
\ )
\ } )
call vimspector#StepOver()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_n, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ -3,
\ '$' )
\ )
\ } )
call vimspector#Continue()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_l, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ -3,
\ '$' )
\ )
\ } )
call vimspector#StepOver()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, thread_n, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ -4,
\ '$' )
\ )
\ } )
call vimspector#Continue()
" So we break out of the loop
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, notify_l, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ '+ Thread [0-9]\+: .* (paused)',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ -4,
\ '$' )
\ )
\ } )
call vimspector#ClearBreakpoints()
call vimspector#test#setup#Reset()
%bwipe!
endfunction
function! Test_UpDownStack()
call SkipNeovim()
let fn='../support/test/python/simple_python/main.py'
exe 'edit ' . fn
call setpos( '.', [ 0, 6, 1 ] )
call vimspector#SetLineBreakpoint( fn, 15 )
call vimspector#LaunchWithSettings( { 'configuration': 'run' } )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 15, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '- Thread 1: MainThread (paused)',
\ ' 2: DoSomething@main.py:15',
\ ' 3: __init__@main.py:8',
\ ' 4: Main@main.py:23',
\ ' 5: <module>@main.py:29',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ 1,
\ '$' )
\ )
\ } )
call win_gotoid( g:vimspector_session_windows.stack_trace )
call WaitForAssert( { ->
\ vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorStackTrace',
\ 1,
\ 'vimspectorCurrentThread',
\ 200 ) } )
call WaitForAssert( { ->
\ vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorStackTrace',
\ 2,
\ 'vimspectorCurrentFrame',
\ 200 ) } )
wincmd w
call vimspector#DownFrame()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 15, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '- Thread 1: MainThread (paused)',
\ ' 2: DoSomething@main.py:15',
\ ' 3: __init__@main.py:8',
\ ' 4: Main@main.py:23',
\ ' 5: <module>@main.py:29',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ 1,
\ '$' )
\ )
\ } )
call win_gotoid( g:vimspector_session_windows.stack_trace )
call WaitForAssert( { ->
\ vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorStackTrace',
\ 1,
\ 'vimspectorCurrentThread',
\ 200 ) } )
call WaitForAssert( { ->
\ vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorStackTrace',
\ 2,
\ 'vimspectorCurrentFrame',
\ 200 ) } )
wincmd w
call vimspector#UpFrame()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 8, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '- Thread 1: MainThread (paused)',
\ ' 2: DoSomething@main.py:15',
\ ' 3: __init__@main.py:8',
\ ' 4: Main@main.py:23',
\ ' 5: <module>@main.py:29',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ 1,
\ '$' )
\ )
\ } )
call win_gotoid( g:vimspector_session_windows.stack_trace )
call WaitForAssert( { ->
\ vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorStackTrace',
\ 1,
\ 'vimspectorCurrentThread',
\ 200 ) } )
call WaitForAssert( { ->
\ vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorStackTrace',
\ 3,
\ 'vimspectorCurrentFrame',
\ 200 ) } )
wincmd w
call feedkeys( "\<Plug>VimspectorUpFrame", 'x' )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 23, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '- Thread 1: MainThread (paused)',
\ ' 2: DoSomething@main.py:15',
\ ' 3: __init__@main.py:8',
\ ' 4: Main@main.py:23',
\ ' 5: <module>@main.py:29',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ 1,
\ '$' )
\ )
\ } )
call win_gotoid( g:vimspector_session_windows.stack_trace )
call WaitForAssert( { ->
\ vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorStackTrace',
\ 1,
\ 'vimspectorCurrentThread',
\ 200 ) } )
call WaitForAssert( { ->
\ vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorStackTrace',
\ 4,
\ 'vimspectorCurrentFrame',
\ 200 ) } )
wincmd w
call feedkeys( "\<Plug>VimspectorDownFrame", 'x' )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 8, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '- Thread 1: MainThread (paused)',
\ ' 2: DoSomething@main.py:15',
\ ' 3: __init__@main.py:8',
\ ' 4: Main@main.py:23',
\ ' 5: <module>@main.py:29',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ 1,
\ '$' )
\ )
\ } )
call win_gotoid( g:vimspector_session_windows.stack_trace )
call WaitForAssert( { ->
\ vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorStackTrace',
\ 1,
\ 'vimspectorCurrentThread',
\ 200 ) } )
call WaitForAssert( { ->
\ vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorStackTrace',
\ 3,
\ 'vimspectorCurrentFrame',
\ 200 ) } )
wincmd w
call vimspector#DownFrame()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 15, 1 )
call WaitForAssert( {->
\ AssertMatchList(
\ [
\ '- Thread 1: MainThread (paused)',
\ ' 2: DoSomething@main.py:15',
\ ' 3: __init__@main.py:8',
\ ' 4: Main@main.py:23',
\ ' 5: <module>@main.py:29',
\ ],
\ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ),
\ 1,
\ '$' )
\ )
\ } )
call win_gotoid( g:vimspector_session_windows.stack_trace )
call WaitForAssert( { ->
\ vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorStackTrace',
\ 1,
\ 'vimspectorCurrentThread',
\ 200 ) } )
call WaitForAssert( { ->
\ vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorStackTrace',
\ 2,
\ 'vimspectorCurrentFrame',
\ 200 ) } )
wincmd w
call vimspector#ClearBreakpoints()
call vimspector#test#setup#Reset()
%bwipe!
endfunction
function! Test_JumpToProgramCounter()
let l:break_main_line = FunctionBreakOnBrace() ? 14 : 15
let l:break_foo_line = FunctionBreakOnBrace() ? 6 : 9
lcd testdata/cpp/simple
let fn = 'simple.cpp'
exe 'edit ' .. fn
call vimspector#SetLineBreakpoint( fn, 16 )
call vimspector#Launch()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn,
\ break_main_line,
\ 1 )
function! TestJumpToPCAux( line ) closure abort
call cursor( [ 1, 1 ] )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 1, 1 )
call vimspector#JumpToProgramCounter()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, a:line, 1 )
endfunction
call vimspector#Continue()
call TestJumpToPCAux( 16 )
call vimspector#StepInto()
call TestJumpToPCAux( break_foo_line )
edit struct.cpp
call vimspector#JumpToProgramCounter()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, break_foo_line, 1 )
call vimspector#ClearBreakpoints()
call vimspector#test#setup#Reset()
delfunc TestJumpToPCAux
%bwipe!
endfunction
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dglxlcl/vimspector.git
git@gitee.com:dglxlcl/vimspector.git
dglxlcl
vimspector
vimspector
master

搜索帮助