mirror of
https://github.com/vim/vim
synced 2025-07-16 09:12:00 +00:00
patch 8.0.1713: terminal debugger doesn't handle arguments
Problem: Terminal debugger doesn't handle arguments. Solution: Use <f-args> and pass all the arguments to gdb, e.g. the core file or process number. (suggested by Christian Brabandt) Disallow starting the debugger twice.
This commit is contained in:
@ -649,6 +649,13 @@ the same as any command running in a terminal window.
|
|||||||
When the debugger ends, typically by typing "quit" in the gdb window, the two
|
When the debugger ends, typically by typing "quit" in the gdb window, the two
|
||||||
opened windows are closed.
|
opened windows are closed.
|
||||||
|
|
||||||
|
Only one debugger can be active at a time.
|
||||||
|
|
||||||
|
To attach gdb to an already running executable, or use a core file, pass extra
|
||||||
|
arguments. E.g.: >
|
||||||
|
:Termdebug vim core
|
||||||
|
:Termdebug vim 98343
|
||||||
|
|
||||||
|
|
||||||
Example session ~
|
Example session ~
|
||||||
*termdebug-example*
|
*termdebug-example*
|
||||||
|
@ -25,7 +25,7 @@ endif
|
|||||||
|
|
||||||
" The command that starts debugging, e.g. ":Termdebug vim".
|
" The command that starts debugging, e.g. ":Termdebug vim".
|
||||||
" To end type "quit" in the gdb window.
|
" To end type "quit" in the gdb window.
|
||||||
command -nargs=* -complete=file Termdebug call s:StartDebug(<q-args>)
|
command -nargs=* -complete=file Termdebug call s:StartDebug(<f-args>)
|
||||||
|
|
||||||
" Name of the gdb command, defaults to "gdb".
|
" Name of the gdb command, defaults to "gdb".
|
||||||
if !exists('termdebugger')
|
if !exists('termdebugger')
|
||||||
@ -43,7 +43,12 @@ else
|
|||||||
endif
|
endif
|
||||||
hi default debugBreakpoint term=reverse ctermbg=red guibg=red
|
hi default debugBreakpoint term=reverse ctermbg=red guibg=red
|
||||||
|
|
||||||
func s:StartDebug(cmd)
|
func s:StartDebug(...)
|
||||||
|
if exists('s:gdbwin')
|
||||||
|
echoerr 'Terminal debugger already running'
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
let s:startwin = win_getid(winnr())
|
let s:startwin = win_getid(winnr())
|
||||||
let s:startsigncolumn = &signcolumn
|
let s:startsigncolumn = &signcolumn
|
||||||
|
|
||||||
@ -90,7 +95,7 @@ func s:StartDebug(cmd)
|
|||||||
|
|
||||||
" Open a terminal window to run the debugger.
|
" Open a terminal window to run the debugger.
|
||||||
" Add -quiet to avoid the intro message causing a hit-enter prompt.
|
" Add -quiet to avoid the intro message causing a hit-enter prompt.
|
||||||
let cmd = [g:termdebugger, '-quiet', '-tty', pty, a:cmd]
|
let cmd = [g:termdebugger, '-quiet', '-tty', pty] + a:000
|
||||||
echomsg 'executing "' . join(cmd) . '"'
|
echomsg 'executing "' . join(cmd) . '"'
|
||||||
let s:gdbbuf = term_start(cmd, {
|
let s:gdbbuf = term_start(cmd, {
|
||||||
\ 'exit_cb': function('s:EndDebug'),
|
\ 'exit_cb': function('s:EndDebug'),
|
||||||
@ -112,7 +117,7 @@ func s:StartDebug(cmd)
|
|||||||
let try_count = 0
|
let try_count = 0
|
||||||
while 1
|
while 1
|
||||||
let response = ''
|
let response = ''
|
||||||
for lnum in range(1,20)
|
for lnum in range(1,200)
|
||||||
if term_getline(s:gdbbuf, lnum) =~ 'new-ui mi '
|
if term_getline(s:gdbbuf, lnum) =~ 'new-ui mi '
|
||||||
let response = term_getline(s:gdbbuf, lnum + 1)
|
let response = term_getline(s:gdbbuf, lnum + 1)
|
||||||
if response =~ 'Undefined command'
|
if response =~ 'Undefined command'
|
||||||
@ -182,6 +187,7 @@ endfunc
|
|||||||
func s:EndDebug(job, status)
|
func s:EndDebug(job, status)
|
||||||
exe 'bwipe! ' . s:ptybuf
|
exe 'bwipe! ' . s:ptybuf
|
||||||
exe 'bwipe! ' . s:commbuf
|
exe 'bwipe! ' . s:commbuf
|
||||||
|
unlet s:gdbwin
|
||||||
|
|
||||||
let curwinid = win_getid(winnr())
|
let curwinid = win_getid(winnr())
|
||||||
|
|
||||||
@ -295,6 +301,7 @@ func s:DeleteCommands()
|
|||||||
delcommand Evaluate
|
delcommand Evaluate
|
||||||
delcommand Gdb
|
delcommand Gdb
|
||||||
delcommand Program
|
delcommand Program
|
||||||
|
delcommand Source
|
||||||
delcommand Winbar
|
delcommand Winbar
|
||||||
|
|
||||||
nunmap K
|
nunmap K
|
||||||
|
@ -762,6 +762,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1713,
|
||||||
/**/
|
/**/
|
||||||
1712,
|
1712,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user