annotate 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
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
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
23 " Uncomment this line to write logging in "debuglog".
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
24 " call ch_logfile('debuglog', 'w')
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
25
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
26 " 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
27 " To end type "quit" in the gdb window.
13682
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
28 command -nargs=* -complete=file Termdebug call s:StartDebug(<f-args>)
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
30 " 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
31 if !exists('termdebugger')
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
32 let termdebugger = 'gdb'
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 endif
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
35 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
36 let s:break_id = 13
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
37 let s:stopped = 1
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
38
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
39 if &background == 'light'
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
40 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
41 else
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
42 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
43 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
44 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
45
13682
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
46 func s:StartDebug(...)
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
47 if exists('s:gdbwin')
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
48 echoerr 'Terminal debugger already running'
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
49 return
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
50 endif
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
51
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
52 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
53 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
54
12559
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
55 let s:save_columns = 0
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
56 if exists('g:termdebug_wide')
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
57 if &columns < g:termdebug_wide
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
58 let s:save_columns = &columns
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
59 let &columns = g:termdebug_wide
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
60 endif
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
61 let vertical = 1
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
62 else
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
63 let vertical = 0
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
64 endif
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
65
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 " 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
67 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
68 \ '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
69 \ '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
70 \ })
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
71 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
72 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
73 return
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
74 endif
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
75 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
76 let s:ptywin = win_getid(winnr())
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
77 if vertical
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
78 " Assuming the source code window will get a signcolumn, use two more
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
79 " columns for that, thus one less for the terminal window.
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
80 exe (&columns / 2 - 1) . "wincmd |"
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
81 endif
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
82
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
83 " 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
84 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
85 \ '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
86 \ '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
87 \ 'hidden': 1,
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
88 \ })
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
89 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
90 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
91 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
92 return
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
93 endif
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
94 let commpty = job_info(term_getjob(s:commbuf))['tty_out']
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 " Open a terminal window to run the debugger.
12773
d9067dad4ac6 patch 8.0.1264: terminal debugger gets stuck in small window
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
97 " Add -quiet to avoid the intro message causing a hit-enter prompt.
13682
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
98 let cmd = [g:termdebugger, '-quiet', '-tty', pty] + a:000
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 echomsg 'executing "' . join(cmd) . '"'
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
100 let s:gdbbuf = term_start(cmd, {
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 \ '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
102 \ 'term_finish': 'close',
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 \ })
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
104 if s:gdbbuf == 0
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
105 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
106 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
107 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
108 return
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
109 endif
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
110 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
111
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
112 " Connect gdb to the communication pty, using the GDB/MI interface
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
113 call term_sendkeys(s:gdbbuf, 'new-ui mi ' . commpty . "\r")
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
114
13450
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
115 " Wait for the response to show up, users may not notice the error and wonder
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
116 " why the debugger doesn't work.
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
117 let try_count = 0
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
118 while 1
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
119 let response = ''
13682
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
120 for lnum in range(1,200)
13450
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
121 if term_getline(s:gdbbuf, lnum) =~ 'new-ui mi '
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
122 let response = term_getline(s:gdbbuf, lnum + 1)
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
123 if response =~ 'Undefined command'
13564
a036c2cf4024 patch 8.0.1655: outdated gdb message in terminal debugger unclear
Christian Brabandt <cb@256bit.org>
parents: 13450
diff changeset
124 echoerr 'Sorry, your gdb is too old, gdb 7.12 is required'
13450
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
125 exe 'bwipe! ' . s:ptybuf
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
126 exe 'bwipe! ' . s:commbuf
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
127 return
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
128 endif
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
129 if response =~ 'New UI allocated'
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
130 " Success!
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
131 break
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
132 endif
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
133 endif
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
134 endfor
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
135 if response =~ 'New UI allocated'
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
136 break
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
137 endif
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
138 let try_count += 1
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
139 if try_count > 100
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
140 echoerr 'Cannot check if your gdb works, continuing anyway'
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
141 break
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
142 endif
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
143 sleep 10m
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
144 endwhile
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
145
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
146 " Interpret commands while the target is running. This should usualy only be
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
147 " exec-interrupt, since many commands don't work properly while the target is
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
148 " running.
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
149 call s:SendCommand('-gdb-set mi-async on')
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
150
13564
a036c2cf4024 patch 8.0.1655: outdated gdb message in terminal debugger unclear
Christian Brabandt <cb@256bit.org>
parents: 13450
diff changeset
151 " Disable pagination, it causes everything to stop at the gdb
a036c2cf4024 patch 8.0.1655: outdated gdb message in terminal debugger unclear
Christian Brabandt <cb@256bit.org>
parents: 13450
diff changeset
152 " "Type <return> to continue" prompt.
a036c2cf4024 patch 8.0.1655: outdated gdb message in terminal debugger unclear
Christian Brabandt <cb@256bit.org>
parents: 13450
diff changeset
153 call s:SendCommand('-gdb-set pagination off')
a036c2cf4024 patch 8.0.1655: outdated gdb message in terminal debugger unclear
Christian Brabandt <cb@256bit.org>
parents: 13450
diff changeset
154
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
155 " 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
156 " 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
157 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
158
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
159 " 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
160 " 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
161 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
162
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
163 " 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
164 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
165 call s:InstallCommands()
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
166 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
167
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
168 " Enable showing a balloon with eval info
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
169 if has("balloon_eval") || has("balloon_eval_term")
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
170 set balloonexpr=TermDebugBalloonExpr()
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
171 if has("balloon_eval")
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
172 set ballooneval
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
173 endif
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
174 if has("balloon_eval_term")
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
175 set balloonevalterm
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
176 endif
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
177 endif
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
178
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
179 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
180
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
181 augroup TermDebug
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
182 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
183 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
184 augroup END
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 endfunc
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 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
188 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
189 exe 'bwipe! ' . s:commbuf
13682
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
190 unlet s:gdbwin
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
191
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
192 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
193
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
194 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
195 let &signcolumn = s:startsigncolumn
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
196 call s:DeleteCommands()
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
197
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
198 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
199 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
200 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
201 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
202
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
203 if has("balloon_eval") || has("balloon_eval_term")
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
204 set balloonexpr=
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
205 if has("balloon_eval")
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
206 set noballooneval
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
207 endif
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
208 if has("balloon_eval_term")
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
209 set noballoonevalterm
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
210 endif
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
211 endif
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
212
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
213 au! TermDebug
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214 endfunc
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
215
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
216 " 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
217 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
218 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
219
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
220 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
221 " 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
222 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
223 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
224 endif
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
225 if msg != ''
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
226 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
227 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
228 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
229 call s:HandleNewBreakpoint(msg)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
230 elseif msg =~ '^=breakpoint-deleted,'
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
231 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
232 elseif msg =~ '^\^done,value='
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
233 call s:HandleEvaluate(msg)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
234 elseif msg =~ '^\^error,msg='
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
235 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
236 endif
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
237 endif
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
238 endfor
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
239 endfunc
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
240
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
241 " 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
242 func s:InstallCommands()
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
243 command Break call s:SetBreakpoint()
13377
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
244 command Clear call s:ClearBreakpoint()
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
245 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
246 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
247 command Finish call s:SendCommand('-exec-finish')
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
248 command -nargs=* Run call s:Run(<q-args>)
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
249 command -nargs=* Arguments call s:SendCommand('-exec-arguments ' . <q-args>)
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
250 command Stop call s:SendCommand('-exec-interrupt')
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
251 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
252 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
253 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
254 command Program call win_gotoid(s:ptywin)
13592
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
255 command Source call s:GotoStartwinOrCreateIt()
13377
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
256 command Winbar call s:InstallWinbar()
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
257
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
258 " 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
259 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
260
13051
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12883
diff changeset
261 if has('menu') && &mouse != ''
13377
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
262 call s:InstallWinbar()
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
263
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
264 if !exists('g:termdebug_popup') || g:termdebug_popup != 0
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
265 let s:saved_mousemodel = &mousemodel
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
266 let &mousemodel = 'popup_setpos'
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
267 an 1.200 PopUp.-SEP3- <Nop>
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
268 an 1.210 PopUp.Set\ breakpoint :Break<CR>
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
269 an 1.220 PopUp.Clear\ breakpoint :Clear<CR>
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
270 an 1.230 PopUp.Evaluate :Evaluate<CR>
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
271 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
272 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
273 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
274
13377
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
275 let s:winbar_winids = []
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
276
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
277 " Install the window toolbar in the current window.
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
278 func s:InstallWinbar()
13592
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
279 if has('menu') && &mouse != ''
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
280 nnoremenu WinBar.Step :Step<CR>
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
281 nnoremenu WinBar.Next :Over<CR>
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
282 nnoremenu WinBar.Finish :Finish<CR>
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
283 nnoremenu WinBar.Cont :Continue<CR>
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
284 nnoremenu WinBar.Stop :Stop<CR>
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
285 nnoremenu WinBar.Eval :Evaluate<CR>
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
286 call add(s:winbar_winids, win_getid(winnr()))
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
287 endif
13377
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
288 endfunc
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
289
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
290 " 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
291 func s:DeleteCommands()
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
292 delcommand Break
13377
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
293 delcommand Clear
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
294 delcommand Step
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
295 delcommand Over
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
296 delcommand Finish
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
297 delcommand Run
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
298 delcommand Arguments
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
299 delcommand Stop
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
300 delcommand Continue
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
301 delcommand Evaluate
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
302 delcommand Gdb
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
303 delcommand Program
13682
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
304 delcommand Source
13377
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
305 delcommand Winbar
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
306
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
307 nunmap K
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
308
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
309 if has('menu')
13377
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
310 " Remove the WinBar entries from all windows where it was added.
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
311 let curwinid = win_getid(winnr())
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
312 for winid in s:winbar_winids
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
313 if win_gotoid(winid)
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
314 aunmenu WinBar.Step
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
315 aunmenu WinBar.Next
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
316 aunmenu WinBar.Finish
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
317 aunmenu WinBar.Cont
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
318 aunmenu WinBar.Stop
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
319 aunmenu WinBar.Eval
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
320 endif
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
321 endfor
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
322 call win_gotoid(curwinid)
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
323 let s:winbar_winids = []
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
324
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
325 if exists('s:saved_mousemodel')
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
326 let &mousemodel = s:saved_mousemodel
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
327 unlet s:saved_mousemodel
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
328 aunmenu PopUp.-SEP3-
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
329 aunmenu PopUp.Set\ breakpoint
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
330 aunmenu PopUp.Clear\ breakpoint
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
331 aunmenu PopUp.Evaluate
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
332 endif
12487
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
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
335 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
336 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
337 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
338 endfor
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
339 sign undefine debugPC
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
340 sign undefine debugBreakpoint
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
341 unlet s:breakpoints
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
342 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
343
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
344 " :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
345 func s:SetBreakpoint()
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
346 " Setting a breakpoint may not work while the program is running.
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
347 " Interrupt to make it work.
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
348 let do_continue = 0
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
349 if !s:stopped
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
350 let do_continue = 1
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
351 call s:SendCommand('-exec-interrupt')
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
352 sleep 10m
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
353 endif
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
354 call s:SendCommand('-break-insert --source '
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
355 \ . fnameescape(expand('%:p')) . ' --line ' . line('.'))
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
356 if do_continue
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
357 call s:SendCommand('-exec-continue')
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
358 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
359 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
360
13377
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
361 " :Clear - Delete a breakpoint at the cursor position.
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
362 func s:ClearBreakpoint()
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
363 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
364 let lnum = line('.')
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
365 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
366 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
367 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
368 " 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
369 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
370 unlet s:breakpoints[key]
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
371 break
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
372 endif
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
373 endfor
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
374 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
375
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
376 " :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
377 func s:SendCommand(cmd)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
378 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
379 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
380
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
381 func s:Run(args)
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
382 if a:args != ''
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
383 call s:SendCommand('-exec-arguments ' . a:args)
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
384 endif
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
385 call s:SendCommand('-exec-run')
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
386 endfunc
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
387
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
388 func s:SendEval(expr)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
389 call s:SendCommand('-data-evaluate-expression "' . a:expr . '"')
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
390 let s:evalexpr = a:expr
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
391 endfunc
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
392
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
393 " :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
394 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
395 if a:arg != ''
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
396 let expr = a:arg
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
397 elseif a:range == 2
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
398 let pos = getcurpos()
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
399 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
400 let regt = getregtype('v')
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
401 normal! gv"vy
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
402 let expr = @v
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
403 call setpos('.', pos)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
404 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
405 else
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
406 let expr = expand('<cexpr>')
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
407 endif
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
408 let s:ignoreEvalError = 0
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
409 call s:SendEval(expr)
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
410 endfunc
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
411
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
412 let s:ignoreEvalError = 0
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
413 let s:evalFromBalloonExpr = 0
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
414
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
415 " 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
416 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
417 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
418 let value = substitute(value, '\\"', '"', 'g')
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
419 if s:evalFromBalloonExpr
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
420 if s:evalFromBalloonExprResult == ''
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
421 let s:evalFromBalloonExprResult = s:evalexpr . ': ' . value
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
422 else
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
423 let s:evalFromBalloonExprResult .= ' = ' . value
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
424 endif
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
425 call balloon_show(s:evalFromBalloonExprResult)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
426 else
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
427 echomsg '"' . s:evalexpr . '": ' . value
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
428 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
429
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12773
diff changeset
430 if s:evalexpr[0] != '*' && value =~ '^0x' && value != '0x0' && value !~ '"$'
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
431 " Looks like a pointer, also display what it points to.
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
432 let s:ignoreEvalError = 1
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
433 call s:SendEval('*' . s:evalexpr)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
434 else
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
435 let s:evalFromBalloonExpr = 0
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
436 endif
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
437 endfunc
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
438
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
439 " Show a balloon with information of the variable under the mouse pointer,
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
440 " if there is any.
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
441 func TermDebugBalloonExpr()
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
442 if v:beval_winid != s:startwin
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
443 return
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
444 endif
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
445 let s:evalFromBalloonExpr = 1
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
446 let s:evalFromBalloonExprResult = ''
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
447 let s:ignoreEvalError = 1
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
448 call s:SendEval(v:beval_text)
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
449 return ''
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
450 endfunc
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
451
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
452 " Handle an error.
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
453 func s:HandleError(msg)
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
454 if s:ignoreEvalError
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
455 " Result of s:SendEval() failed, ignore.
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
456 let s:ignoreEvalError = 0
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
457 let s:evalFromBalloonExpr = 0
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
458 return
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
459 endif
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
460 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
461 endfunc
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
462
13592
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
463 func s:GotoStartwinOrCreateIt()
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
464 if !win_gotoid(s:startwin)
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
465 new
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
466 let s:startwin = win_getid(winnr())
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
467 call s:InstallWinbar()
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
468 endif
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
469 endfunc
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
470
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
471 " 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
472 " 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
473 func s:HandleCursor(msg)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
474 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
475
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
476 if a:msg =~ '^\*stopped'
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
477 let s:stopped = 1
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
478 elseif a:msg =~ '^\*running'
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
479 let s:stopped = 0
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
480 endif
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
481
13592
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
482 call s:GotoStartwinOrCreateIt()
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
483
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
484 let fname = substitute(a:msg, '.*fullname="\([^"]*\)".*', '\1', '')
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
485 if a:msg =~ '^\(\*stopped\|=thread-selected\)' && filereadable(fname)
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
486 let lnum = substitute(a:msg, '.*line="\([^"]*\)".*', '\1', '')
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
487 if lnum =~ '^[0-9]*$'
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
488 if expand('%:p') != fnamemodify(fname, ':p')
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
489 if &modified
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
490 " TODO: find existing window
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
491 exe 'split ' . fnameescape(fname)
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
492 let s:startwin = win_getid(winnr())
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
493 call s:InstallWinbar()
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
494 else
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
495 exe 'edit ' . fnameescape(fname)
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
496 endif
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
497 endif
13592
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
498 exe lnum
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
499 exe 'sign unplace ' . s:pc_id
13592
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
500 exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC file=' . fname
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
501 setlocal signcolumn=yes
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
502 endif
13592
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
503 else
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
504 exe 'sign unplace ' . s:pc_id
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
505 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
506
13592
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
507 call win_gotoid(wid)
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
508 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
509
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
510 " Handle setting a breakpoint
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
511 " 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
512 func s:HandleNewBreakpoint(msg)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
513 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
514 if nr == 0
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
515 return
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
516 endif
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
517
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
518 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
519 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
520 else
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
521 let entry = {}
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
522 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
523 endif
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
524
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
525 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
526 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
527 let entry['fname'] = fname
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
528 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
529
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
530 if bufloaded(fname)
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
531 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
532 endif
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
533 endfunc
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
534
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
535 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
536 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
537 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
538 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
539
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
540 " Handle deleting a breakpoint
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
541 " 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
542 func s:HandleBreakpointDelete(msg)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
543 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
544 if nr == 0
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
545 return
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
546 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
547 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
548 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
549 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
550 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
551 unlet entry['placed']
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
552 endif
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
553 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
554 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
555 endfunc
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
556
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
557 " 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
558 func s:BufRead()
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
559 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
560 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
561 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
562 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
563 endif
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
564 endfor
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
565 endfunc
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
566
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
567 " 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
568 func s:BufUnloaded()
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
569 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
570 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
571 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
572 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
573 endif
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
574 endfor
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
575 endfunc
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
576