annotate runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @ 12499:d91cf2e26ef0

Update runtime files. commit https://github.com/vim/vim/commit/37c64c78fd87e086b5a945ad7032787c274e2dcb Author: Bram Moolenaar <Bram@vim.org> Date: Tue Sep 19 22:06:03 2017 +0200 Update runtime files.
author Christian Brabandt <cb@256bit.org>
date Tue, 19 Sep 2017 22:15:06 +0200
parents 3f16cf18386c
children 34c8ec888122
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
1 " Debugger plugin using gdb.
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 "
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " WORK IN PROGRESS - much doesn't work yet
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 "
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
5 " Open two visible terminal windows:
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 " 1. run a pty, as with ":term NONE"
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 " 2. run gdb, passing the pty
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
8 " The current window is used to view source code and follows gdb.
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
9 "
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
10 " A third terminal window is hidden, it is used for communication with gdb.
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
11 "
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
12 " The communication with gdb uses GDB/MI. See:
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
13 " https://sourceware.org/gdb/current/onlinedocs/gdb/GDB_002fMI.html
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 "
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 " Author: Bram Moolenaar
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
16 " Copyright: Vim license applies, see ":help license"
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
18 " In case this gets loaded twice.
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
19 if exists(':Termdebug')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
20 finish
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
21 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
22
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
23 " The command that starts debugging, e.g. ":Termdebug vim".
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
24 " To end type "quit" in the gdb window.
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 command -nargs=* -complete=file Termdebug call s:StartDebug(<q-args>)
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
27 " Name of the gdb command, defaults to "gdb".
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
28 if !exists('termdebugger')
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
29 let termdebugger = 'gdb'
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 endif
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
32 let s:pc_id = 12
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
33 let s:break_id = 13
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
34
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
35 if &background == 'light'
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
36 hi default debugPC term=reverse ctermbg=lightblue guibg=lightblue
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
37 else
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
38 hi default debugPC term=reverse ctermbg=darkblue guibg=darkblue
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
39 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
40 hi default debugBreakpoint term=reverse ctermbg=red guibg=red
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
41
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 func s:StartDebug(cmd)
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
43 let s:startwin = win_getid(winnr())
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
44 let s:startsigncolumn = &signcolumn
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
45
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
46 if exists('g:termdebug_wide') && &columns < g:termdebug_wide
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
47 let s:save_columns = &columns
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
48 let &columns = g:termdebug_wide
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
49 let vertical = 1
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
50 else
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
51 let s:save_columns = 0
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
52 let vertical = 0
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
53 endif
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
54
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 " Open a terminal window without a job, to run the debugged program
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
56 let s:ptybuf = term_start('NONE', {
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
57 \ 'term_name': 'gdb program',
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
58 \ 'vertical': vertical,
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
59 \ })
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
60 if s:ptybuf == 0
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
61 echoerr 'Failed to open the program terminal window'
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
62 return
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
63 endif
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
64 let pty = job_info(term_getjob(s:ptybuf))['tty_out']
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
65 let s:ptywin = win_getid(winnr())
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
66
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
67 " Create a hidden terminal window to communicate with gdb
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
68 let s:commbuf = term_start('NONE', {
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
69 \ 'term_name': 'gdb communication',
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
70 \ 'out_cb': function('s:CommOutput'),
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
71 \ 'hidden': 1,
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
72 \ })
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
73 if s:commbuf == 0
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
74 echoerr 'Failed to open the communication terminal window'
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
75 exe 'bwipe! ' . s:ptybuf
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
76 return
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
77 endif
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
78 let commpty = job_info(term_getjob(s:commbuf))['tty_out']
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 " Open a terminal window to run the debugger.
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
81 let cmd = [g:termdebugger, '-tty', pty, a:cmd]
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 echomsg 'executing "' . join(cmd) . '"'
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 let gdbbuf = term_start(cmd, {
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 \ 'exit_cb': function('s:EndDebug'),
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
85 \ 'term_finish': 'close',
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 \ })
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
87 if gdbbuf == 0
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
88 echoerr 'Failed to open the gdb terminal window'
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
89 exe 'bwipe! ' . s:ptybuf
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
90 exe 'bwipe! ' . s:commbuf
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
91 return
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
92 endif
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
93 let s:gdbwin = win_getid(winnr())
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
94
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
95 " Connect gdb to the communication pty, using the GDB/MI interface
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
96 call term_sendkeys(gdbbuf, 'new-ui mi ' . commpty . "\r")
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
97
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
98 " Sign used to highlight the line where the program has stopped.
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
99 " There can be only one.
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
100 sign define debugPC linehl=debugPC
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
101
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
102 " Sign used to indicate a breakpoint.
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
103 " Can be used multiple times.
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
104 sign define debugBreakpoint text=>> texthl=debugBreakpoint
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
105
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
106 " Install debugger commands in the text window.
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
107 call win_gotoid(s:startwin)
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
108 call s:InstallCommands()
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
109 call win_gotoid(s:gdbwin)
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
110
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
111 let s:breakpoints = {}
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
112
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
113 augroup TermDebug
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
114 au BufRead * call s:BufRead()
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
115 au BufUnload * call s:BufUnloaded()
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
116 augroup END
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 endfunc
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 func s:EndDebug(job, status)
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
120 exe 'bwipe! ' . s:ptybuf
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
121 exe 'bwipe! ' . s:commbuf
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
122
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
123 let curwinid = win_getid(winnr())
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
124
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
125 call win_gotoid(s:startwin)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
126 let &signcolumn = s:startsigncolumn
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
127 call s:DeleteCommands()
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
128
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
129 call win_gotoid(curwinid)
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
130 if s:save_columns > 0
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
131 let &columns = s:save_columns
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
132 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
133
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
134 au! TermDebug
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 endfunc
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
136
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
137 " Handle a message received from gdb on the GDB/MI interface.
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
138 func s:CommOutput(chan, msg)
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
139 let msgs = split(a:msg, "\r")
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
140
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
141 for msg in msgs
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
142 " remove prefixed NL
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
143 if msg[0] == "\n"
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
144 let msg = msg[1:]
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
145 endif
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
146 if msg != ''
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
147 if msg =~ '^\(\*stopped\|\*running\|=thread-selected\)'
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
148 call s:HandleCursor(msg)
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
149 elseif msg =~ '^\^done,bkpt=' || msg =~ '^=breakpoint-created,'
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
150 call s:HandleNewBreakpoint(msg)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
151 elseif msg =~ '^=breakpoint-deleted,'
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
152 call s:HandleBreakpointDelete(msg)
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
153 elseif msg =~ '^\^done,value='
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
154 call s:HandleEvaluate(msg)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
155 elseif msg =~ '^\^error,msg='
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
156 call s:HandleError(msg)
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
157 endif
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
158 endif
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
159 endfor
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
160 endfunc
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
161
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
162 " Install commands in the current window to control the debugger.
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
163 func s:InstallCommands()
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
164 command Break call s:SetBreakpoint()
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
165 command Delete call s:DeleteBreakpoint()
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
166 command Step call s:SendCommand('-exec-step')
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
167 command Over call s:SendCommand('-exec-next')
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
168 command Finish call s:SendCommand('-exec-finish')
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
169 command Continue call s:SendCommand('-exec-continue')
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
170 command -range -nargs=* Evaluate call s:Evaluate(<range>, <q-args>)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
171 command Gdb call win_gotoid(s:gdbwin)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
172 command Program call win_gotoid(s:ptywin)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
173
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
174 " TODO: can the K mapping be restored?
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
175 nnoremap K :Evaluate<CR>
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
176
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
177 if has('menu')
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
178 amenu WinBar.Step :Step<CR>
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
179 amenu WinBar.Next :Over<CR>
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
180 amenu WinBar.Finish :Finish<CR>
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
181 amenu WinBar.Cont :Continue<CR>
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
182 amenu WinBar.Eval :Evaluate<CR>
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
183 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
184 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
185
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
186 " Delete installed debugger commands in the current window.
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
187 func s:DeleteCommands()
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
188 delcommand Break
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
189 delcommand Delete
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
190 delcommand Step
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
191 delcommand Over
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
192 delcommand Finish
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
193 delcommand Continue
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
194 delcommand Evaluate
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
195 delcommand Gdb
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
196 delcommand Program
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
197
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
198 nunmap K
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
199
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
200 if has('menu')
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
201 aunmenu WinBar.Step
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
202 aunmenu WinBar.Next
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
203 aunmenu WinBar.Finish
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
204 aunmenu WinBar.Cont
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
205 aunmenu WinBar.Eval
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
206 endif
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
207
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
208 exe 'sign unplace ' . s:pc_id
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
209 for key in keys(s:breakpoints)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
210 exe 'sign unplace ' . (s:break_id + key)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
211 endfor
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
212 sign undefine debugPC
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
213 sign undefine debugBreakpoint
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
214 unlet s:breakpoints
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
215 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
216
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
217 " :Break - Set a breakpoint at the cursor position.
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
218 func s:SetBreakpoint()
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
219 call term_sendkeys(s:commbuf, '-break-insert --source '
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
220 \ . fnameescape(expand('%:p')) . ' --line ' . line('.') . "\r")
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
221 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
222
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
223 " :Delete - Delete a breakpoint at the cursor position.
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
224 func s:DeleteBreakpoint()
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
225 let fname = fnameescape(expand('%:p'))
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
226 let lnum = line('.')
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
227 for [key, val] in items(s:breakpoints)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
228 if val['fname'] == fname && val['lnum'] == lnum
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
229 call term_sendkeys(s:commbuf, '-break-delete ' . key . "\r")
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
230 " Assume this always wors, the reply is simply "^done".
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
231 exe 'sign unplace ' . (s:break_id + key)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
232 unlet s:breakpoints[key]
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
233 break
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
234 endif
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
235 endfor
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
236 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
237
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
238 " :Next, :Continue, etc - send a command to gdb
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
239 func s:SendCommand(cmd)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
240 call term_sendkeys(s:commbuf, a:cmd . "\r")
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
241 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
242
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
243 " :Evaluate - evaluate what is under the cursor
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
244 func s:Evaluate(range, arg)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
245 if a:arg != ''
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
246 let expr = a:arg
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
247 elseif a:range == 2
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
248 let pos = getcurpos()
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
249 let reg = getreg('v', 1, 1)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
250 let regt = getregtype('v')
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
251 normal! gv"vy
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
252 let expr = @v
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
253 call setpos('.', pos)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
254 call setreg('v', reg, regt)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
255 else
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
256 let expr = expand('<cexpr>')
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
257 endif
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
258 call term_sendkeys(s:commbuf, '-data-evaluate-expression "' . expr . "\"\r")
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
259 let s:evalexpr = expr
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
260 endfunc
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
261
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
262 " Handle the result of data-evaluate-expression
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
263 func s:HandleEvaluate(msg)
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
264 let value = substitute(a:msg, '.*value="\(.*\)"', '\1', '')
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
265 let value = substitute(value, '\\"', '"', 'g')
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
266 echomsg '"' . s:evalexpr . '": ' . value
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
267
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
268 if s:evalexpr[0] != '*' && value =~ '^0x' && value !~ '"$'
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
269 " Looks like a pointer, also display what it points to.
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
270 let s:evalexpr = '*' . s:evalexpr
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
271 call term_sendkeys(s:commbuf, '-data-evaluate-expression "' . s:evalexpr . "\"\r")
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
272 endif
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
273 endfunc
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
274
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
275 " Handle an error.
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
276 func s:HandleError(msg)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
277 echoerr substitute(a:msg, '.*msg="\(.*\)"', '\1', '')
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
278 endfunc
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
279
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
280 " Handle stopping and running message from gdb.
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
281 " Will update the sign that shows the current position.
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
282 func s:HandleCursor(msg)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
283 let wid = win_getid(winnr())
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
284
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
285 if win_gotoid(s:startwin)
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
286 let fname = substitute(a:msg, '.*fullname="\([^"]*\)".*', '\1', '')
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
287 if a:msg =~ '^\(\*stopped\|=thread-selected\)' && filereadable(fname)
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
288 let lnum = substitute(a:msg, '.*line="\([^"]*\)".*', '\1', '')
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
289 if lnum =~ '^[0-9]*$'
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
290 if expand('%:p') != fnamemodify(fname, ':p')
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
291 if &modified
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
292 " TODO: find existing window
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
293 exe 'split ' . fnameescape(fname)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
294 let s:startwin = win_getid(winnr())
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
295 else
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
296 exe 'edit ' . fnameescape(fname)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
297 endif
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
298 endif
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
299 exe lnum
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
300 exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC file=' . fname
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
301 setlocal signcolumn=yes
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
302 endif
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
303 else
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
304 exe 'sign unplace ' . s:pc_id
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
305 endif
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
306
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
307 call win_gotoid(wid)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
308 endif
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
309 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
310
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
311 " Handle setting a breakpoint
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
312 " Will update the sign that shows the breakpoint
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
313 func s:HandleNewBreakpoint(msg)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
314 let nr = substitute(a:msg, '.*number="\([0-9]\)*\".*', '\1', '') + 0
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
315 if nr == 0
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
316 return
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
317 endif
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
318
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
319 if has_key(s:breakpoints, nr)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
320 let entry = s:breakpoints[nr]
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
321 else
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
322 let entry = {}
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
323 let s:breakpoints[nr] = entry
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
324 endif
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
325
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
326 let fname = substitute(a:msg, '.*fullname="\([^"]*\)".*', '\1', '')
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
327 let lnum = substitute(a:msg, '.*line="\([^"]*\)".*', '\1', '')
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
328 let entry['fname'] = fname
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
329 let entry['lnum'] = lnum
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
330
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
331 if bufloaded(fname)
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
332 call s:PlaceSign(nr, entry)
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
333 endif
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
334 endfunc
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
335
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
336 func s:PlaceSign(nr, entry)
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
337 exe 'sign place ' . (s:break_id + a:nr) . ' line=' . a:entry['lnum'] . ' name=debugBreakpoint file=' . a:entry['fname']
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
338 let a:entry['placed'] = 1
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
339 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
340
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
341 " Handle deleting a breakpoint
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
342 " Will remove the sign that shows the breakpoint
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
343 func s:HandleBreakpointDelete(msg)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
344 let nr = substitute(a:msg, '.*id="\([0-9]*\)\".*', '\1', '') + 0
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
345 if nr == 0
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
346 return
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
347 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
348 if has_key(s:breakpoints, nr)
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
349 let entry = s:breakpoints[nr]
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
350 if has_key(entry, 'placed')
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
351 exe 'sign unplace ' . (s:break_id + nr)
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
352 unlet entry['placed']
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
353 endif
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
354 unlet s:breakpoints[nr]
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
355 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
356 endfunc
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
357
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
358 " Handle a BufRead autocommand event: place any signs.
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
359 func s:BufRead()
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
360 let fname = expand('<afile>:p')
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
361 for [nr, entry] in items(s:breakpoints)
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
362 if entry['fname'] == fname
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
363 call s:PlaceSign(nr, entry)
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
364 endif
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
365 endfor
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
366 endfunc
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
367
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
368 " Handle a BufUnloaded autocommand event: unplace any signs.
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
369 func s:BufUnloaded()
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
370 let fname = expand('<afile>:p')
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
371 for [nr, entry] in items(s:breakpoints)
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
372 if entry['fname'] == fname
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
373 let entry['placed'] = 0
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
374 endif
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
375 endfor
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
376 endfunc
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
377