summaryrefslogtreecommitdiffstats
path: root/runtime/pack/dist/opt
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-04-16 16:21:49 +0200
committerBram Moolenaar <Bram@vim.org>2018-04-16 16:21:49 +0200
commit32c67ba733abcd4f2d729595fdccb2295445636a (patch)
treea891e193961f611322ecdd72a53ee67a08c4316e /runtime/pack/dist/opt
parent06965b838f3677251668dca726b07c5ad2499341 (diff)
patch 8.0.1725: terminal debugger doesn't handle command argumentsv8.0.1725
Problem: Terminal debugger doesn't handle command arguments. Solution: Add the :TermdebugCommand command. Use a ! to execute right away. (Christian Brabandt)
Diffstat (limited to 'runtime/pack/dist/opt')
-rw-r--r--runtime/pack/dist/opt/termdebug/plugin/termdebug.vim33
1 files changed, 30 insertions, 3 deletions
diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
index ded114a2d7..f2f0f0944d 100644
--- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
+++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
@@ -25,7 +25,8 @@ endif
" The command that starts debugging, e.g. ":Termdebug vim".
" To end type "quit" in the gdb window.
-command -nargs=* -complete=file Termdebug call s:StartDebug(<f-args>)
+command -nargs=* -complete=file -bang Termdebug call s:StartDebug(<bang>0, <f-args>)
+command -nargs=+ -complete=file -bang TermdebugCommand call s:StartDebugCommand(<bang>0, <f-args>)
" Name of the gdb command, defaults to "gdb".
if !exists('termdebugger')
@@ -43,7 +44,17 @@ else
endif
hi default debugBreakpoint term=reverse ctermbg=red guibg=red
-func s:StartDebug(...)
+func s:StartDebug(bang, ...)
+ " First argument is the command to debug, second core file or process ID.
+ call s:StartDebug_internal({'gdb_args': a:000, 'bang': a:bang})
+endfunc
+
+func s:StartDebugCommand(bang, ...)
+ " First argument is the command to debug, rest are run arguments.
+ call s:StartDebug_internal({'gdb_args': [a:1], 'proc_args': a:000[1:], 'bang': a:bang})
+endfunc
+
+func s:StartDebug_internal(dict)
if exists('s:gdbwin')
echoerr 'Terminal debugger already running'
return
@@ -95,7 +106,10 @@ func s:StartDebug(...)
" Open a terminal window to run the debugger.
" Add -quiet to avoid the intro message causing a hit-enter prompt.
- let cmd = [g:termdebugger, '-quiet', '-tty', pty] + a:000
+ let gdb_args = get(a:dict, 'gdb_args', [])
+ let proc_args = get(a:dict, 'proc_args', [])
+
+ let cmd = [g:termdebugger, '-quiet', '-tty', pty] + gdb_args
echomsg 'executing "' . join(cmd) . '"'
let s:gdbbuf = term_start(cmd, {
\ 'exit_cb': function('s:EndDebug'),
@@ -109,6 +123,11 @@ func s:StartDebug(...)
endif
let s:gdbwin = win_getid(winnr())
+ " Set arguments to be run
+ if len(proc_args)
+ call term_sendkeys(s:gdbbuf, 'set args ' . join(proc_args) . "\r")
+ endif
+
" Connect gdb to the communication pty, using the GDB/MI interface
call term_sendkeys(s:gdbbuf, 'new-ui mi ' . commpty . "\r")
@@ -182,6 +201,14 @@ func s:StartDebug(...)
au BufRead * call s:BufRead()
au BufUnload * call s:BufUnloaded()
augroup END
+
+ " Run the command if the bang attribute was given
+ " and got to the window
+ if get(a:dict, 'bang', 0)
+ call s:SendCommand('-exec-run')
+ call win_gotoid(s:ptywin)
+ endif
+
endfunc
func s:EndDebug(job, status)