blob: b002cad4c686e0b7f8a504ec798ec45f1ed5f4a5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
" Debugger commands.
"
" WORK IN PROGRESS - much doesn't work yet
"
" Open two terminal windows:
" 1. run a pty, as with ":term NONE"
" 2. run gdb, passing the pty
" The current window is used to edit source code and follows gdb.
"
" Author: Bram Moolenaar
" Copyright: Vim license applies
" In case this gets loaded twice.
if exists(':Termdebug')
finish
endif
command -nargs=* -complete=file Termdebug call s:StartDebug(<q-args>)
if !exists('debugger')
let debugger = 'gdb'
endif
func s:StartDebug(cmd)
" Open a terminal window without a job, to run the debugged program
let s:ptybuf = term_start('NONE', {})
let pty = job_info(term_getjob(s:ptybuf))['tty']
" Open a terminal window to run the debugger.
let cmd = [g:debugger, '-tty', pty, a:cmd]
echomsg 'executing "' . join(cmd) . '"'
let gdbbuf = term_start(cmd, {
\ 'exit_cb': function('s:EndDebug'),
\ 'term_finish': 'close'
\ })
endfunc
func s:EndDebug(job, status)
exe 'bwipe! ' . s:ptybuf
endfunc
|