forked from aniani/vim
patch 8.0.1725: terminal debugger doesn't handle command arguments
Problem: Terminal debugger doesn't handle command arguments. Solution: Add the :TermdebugCommand command. Use a ! to execute right away. (Christian Brabandt)
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user