From 3d3a9152fa6de7038fdfd6d6de25230ed825552a Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Wed, 23 Aug 2023 17:14:49 +0100 Subject: runtime(termdebug): more termdebug fixes and improvements (#12892) - Fix and attempt to simplify :Frame/:Up/:Down documentation. - Accept a count instead for :Up/:Down/+/-. - Update the "Last Change" dates. - Fix a missing :let (caused an error if gdb fails to start). - Wipe the prompt buffer when ending prompt mode (if it exists and wasn't wiped by the user first). Avoids issues with stale prompt buffers (such as E95 when starting a new prompt mode session). - Kill the gdb job if the prompt buffer is unloaded (similar to what's done for a terminal buffer). Fixes not being able to start a new termdebug session if the buffer was wiped by the user, for example. Signed-off-by: Christian Brabandt --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 44 ++++++++-------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 'runtime/pack') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index f9cfe8cdf7..7d9b80f510 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -2,7 +2,7 @@ " " Author: Bram Moolenaar " Copyright: Vim license applies, see ":help license" -" Last Change: 2023 Jun 24 +" Last Change: 2023 Aug 23 " " WORK IN PROGRESS - The basics works stable, more to come " Note: In general you need at least GDB 7.12 because this provides the @@ -235,7 +235,7 @@ func s:CloseBuffers() if s:varbuf > 0 && bufexists(s:varbuf) exe 'bwipe! ' . s:varbuf endif - s:running = 0 + let s:running = 0 unlet! s:gdbwin endfunc @@ -453,6 +453,8 @@ func s:StartDebug_prompt(dict) exe 'bwipe! ' . s:promptbuf return endif + exe $'au BufUnload ++once ' .. + \ 'call job_stop(s:gdbjob, ''kill'')' " Mark the buffer modified so that it's not easy to close. set modified let s:gdb_channel = job_getchannel(s:gdbjob) @@ -782,12 +784,8 @@ func s:EndPromptDebug(job, status) doauto User TermdebugStopPre endif - let curwinid = win_getid() - call win_gotoid(s:gdbwin) - set nomodified - close - if curwinid != s:gdbwin - call win_gotoid(curwinid) + if bufexists(s:promptbuf) + exe 'bwipe! ' . s:promptbuf endif call s:EndDebugCommon() @@ -973,8 +971,8 @@ func s:InstallCommands() endif command -nargs=* Frame call s:Frame() - command -nargs=* Up call s:Up() - command -nargs=* Down call s:Down() + command -count=1 Up call s:Up() + command -count=1 Down call s:Down() command -range -nargs=* Evaluate call s:Evaluate(, ) command Gdb call win_gotoid(s:gdbwin) @@ -1001,7 +999,7 @@ func s:InstallCommands() endif if map let s:plus_map_saved = maparg('+', 'n', 0, 1) - nnoremap + :Up + nnoremap + $'{v:count1}Up' endif let map = 1 @@ -1010,7 +1008,7 @@ func s:InstallCommands() endif if map let s:minus_map_saved = maparg('-', 'n', 0, 1) - nnoremap - :Down + nnoremap - $'{v:count1}Down' endif @@ -1240,26 +1238,16 @@ func s:Frame(arg) endif endfunc -" :Up - go one frame in the stack "higher" -func s:Up(arg) - if a:arg != '' - let s:cmd = '"up ' . a:arg . '"' - else - let s:cmd = '"up"' - endif +" :Up - go a:count frames in the stack "higher" +func s:Up(count) " the 'correct' one would be -stack-select-frame N, but we don't know N - call s:SendCommand('-interpreter-exec console ' . s:cmd) + call s:SendCommand($'-interpreter-exec console "up {a:count}"') endfunc -" :Down - go one frame in the stack "below" -func s:Down(arg) - if a:arg != '' - let s:cmd = '"down ' . a:arg . '"' - else - let s:cmd = '"down"' - endif +" :Down - go a:count frames in the stack "below" +func s:Down(count) " the 'correct' one would be -stack-select-frame N, but we don't know N - call s:SendCommand('-interpreter-exec console ' . s:cmd) + call s:SendCommand($'-interpreter-exec console "down {a:count}"') endfunc func s:SendEval(expr) -- cgit v1.2.3