Mercurial > vim
comparison runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @ 13682:fc660a6ef37d v8.0.1713
patch 8.0.1713: terminal debugger doesn't handle arguments
commit https://github.com/vim/vim/commit/b3623a382abc8f8e2bcfba4c1a2aa06b7578eb8d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 14 18:59:50 2018 +0200
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 14 Apr 2018 19:00:07 +0200 |
parents | a64485061f75 |
children | bfd9249f72e0 |
comparison
equal
deleted
inserted
replaced
13681:cea7c555bd3e | 13682:fc660a6ef37d |
---|---|
23 " Uncomment this line to write logging in "debuglog". | 23 " Uncomment this line to write logging in "debuglog". |
24 " call ch_logfile('debuglog', 'w') | 24 " call ch_logfile('debuglog', 'w') |
25 | 25 |
26 " The command that starts debugging, e.g. ":Termdebug vim". | 26 " The command that starts debugging, e.g. ":Termdebug vim". |
27 " To end type "quit" in the gdb window. | 27 " To end type "quit" in the gdb window. |
28 command -nargs=* -complete=file Termdebug call s:StartDebug(<q-args>) | 28 command -nargs=* -complete=file Termdebug call s:StartDebug(<f-args>) |
29 | 29 |
30 " Name of the gdb command, defaults to "gdb". | 30 " Name of the gdb command, defaults to "gdb". |
31 if !exists('termdebugger') | 31 if !exists('termdebugger') |
32 let termdebugger = 'gdb' | 32 let termdebugger = 'gdb' |
33 endif | 33 endif |
41 else | 41 else |
42 hi default debugPC term=reverse ctermbg=darkblue guibg=darkblue | 42 hi default debugPC term=reverse ctermbg=darkblue guibg=darkblue |
43 endif | 43 endif |
44 hi default debugBreakpoint term=reverse ctermbg=red guibg=red | 44 hi default debugBreakpoint term=reverse ctermbg=red guibg=red |
45 | 45 |
46 func s:StartDebug(cmd) | 46 func s:StartDebug(...) |
47 if exists('s:gdbwin') | |
48 echoerr 'Terminal debugger already running' | |
49 return | |
50 endif | |
51 | |
47 let s:startwin = win_getid(winnr()) | 52 let s:startwin = win_getid(winnr()) |
48 let s:startsigncolumn = &signcolumn | 53 let s:startsigncolumn = &signcolumn |
49 | 54 |
50 let s:save_columns = 0 | 55 let s:save_columns = 0 |
51 if exists('g:termdebug_wide') | 56 if exists('g:termdebug_wide') |
88 endif | 93 endif |
89 let commpty = job_info(term_getjob(s:commbuf))['tty_out'] | 94 let commpty = job_info(term_getjob(s:commbuf))['tty_out'] |
90 | 95 |
91 " Open a terminal window to run the debugger. | 96 " Open a terminal window to run the debugger. |
92 " Add -quiet to avoid the intro message causing a hit-enter prompt. | 97 " Add -quiet to avoid the intro message causing a hit-enter prompt. |
93 let cmd = [g:termdebugger, '-quiet', '-tty', pty, a:cmd] | 98 let cmd = [g:termdebugger, '-quiet', '-tty', pty] + a:000 |
94 echomsg 'executing "' . join(cmd) . '"' | 99 echomsg 'executing "' . join(cmd) . '"' |
95 let s:gdbbuf = term_start(cmd, { | 100 let s:gdbbuf = term_start(cmd, { |
96 \ 'exit_cb': function('s:EndDebug'), | 101 \ 'exit_cb': function('s:EndDebug'), |
97 \ 'term_finish': 'close', | 102 \ 'term_finish': 'close', |
98 \ }) | 103 \ }) |
110 " Wait for the response to show up, users may not notice the error and wonder | 115 " Wait for the response to show up, users may not notice the error and wonder |
111 " why the debugger doesn't work. | 116 " why the debugger doesn't work. |
112 let try_count = 0 | 117 let try_count = 0 |
113 while 1 | 118 while 1 |
114 let response = '' | 119 let response = '' |
115 for lnum in range(1,20) | 120 for lnum in range(1,200) |
116 if term_getline(s:gdbbuf, lnum) =~ 'new-ui mi ' | 121 if term_getline(s:gdbbuf, lnum) =~ 'new-ui mi ' |
117 let response = term_getline(s:gdbbuf, lnum + 1) | 122 let response = term_getline(s:gdbbuf, lnum + 1) |
118 if response =~ 'Undefined command' | 123 if response =~ 'Undefined command' |
119 echoerr 'Sorry, your gdb is too old, gdb 7.12 is required' | 124 echoerr 'Sorry, your gdb is too old, gdb 7.12 is required' |
120 exe 'bwipe! ' . s:ptybuf | 125 exe 'bwipe! ' . s:ptybuf |
180 endfunc | 185 endfunc |
181 | 186 |
182 func s:EndDebug(job, status) | 187 func s:EndDebug(job, status) |
183 exe 'bwipe! ' . s:ptybuf | 188 exe 'bwipe! ' . s:ptybuf |
184 exe 'bwipe! ' . s:commbuf | 189 exe 'bwipe! ' . s:commbuf |
190 unlet s:gdbwin | |
185 | 191 |
186 let curwinid = win_getid(winnr()) | 192 let curwinid = win_getid(winnr()) |
187 | 193 |
188 call win_gotoid(s:startwin) | 194 call win_gotoid(s:startwin) |
189 let &signcolumn = s:startsigncolumn | 195 let &signcolumn = s:startsigncolumn |
293 delcommand Stop | 299 delcommand Stop |
294 delcommand Continue | 300 delcommand Continue |
295 delcommand Evaluate | 301 delcommand Evaluate |
296 delcommand Gdb | 302 delcommand Gdb |
297 delcommand Program | 303 delcommand Program |
304 delcommand Source | |
298 delcommand Winbar | 305 delcommand Winbar |
299 | 306 |
300 nunmap K | 307 nunmap K |
301 | 308 |
302 if has('menu') | 309 if has('menu') |