Mercurial > vim
annotate runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @ 12833:db9ffed7e1fc v8.0.1293
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
commit https://github.com/vim/vim/commit/60e73f2acc890f07056fa1bea8dbe89d26918b3e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Nov 12 18:02:06 2017 +0100
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Problem: Setting a breakpoint in the terminal debugger sometimes fails.
Solution: Interrupt the program if needed. Set the interface to async.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 12 Nov 2017 18:15:04 +0100 |
parents | f690da1b3c04 |
children | ebb4f6c93598 |
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 | 2 " |
3 " WORK IN PROGRESS - much doesn't work yet | |
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 | 6 " 1. run a pty, as with ":term NONE" |
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 | 14 " |
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 | 17 |
12499 | 18 " In case this gets loaded twice. |
19 if exists(':Termdebug') | |
20 finish | |
21 endif | |
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. |
12254 | 28 command -nargs=* -complete=file Termdebug call s:StartDebug(<q-args>) |
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 | 33 endif |
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 |
12254 | 46 func s:StartDebug(cmd) |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
47 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
|
48 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
|
49 |
12559 | 50 let s:save_columns = 0 |
51 if exists('g:termdebug_wide') | |
52 if &columns < g:termdebug_wide | |
53 let s:save_columns = &columns | |
54 let &columns = g:termdebug_wide | |
55 endif | |
12455
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
56 let vertical = 1 |
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
57 else |
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
58 let vertical = 0 |
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
59 endif |
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
60 |
12254 | 61 " 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
|
62 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
|
63 \ '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
|
64 \ '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
|
65 \ }) |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
66 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
|
67 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
|
68 return |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
69 endif |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
70 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
|
71 let s:ptywin = win_getid(winnr()) |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
72 |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
73 " 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
|
74 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
|
75 \ '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
|
76 \ '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
|
77 \ 'hidden': 1, |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
78 \ }) |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
79 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
|
80 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
|
81 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
|
82 return |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
83 endif |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
84 let commpty = job_info(term_getjob(s:commbuf))['tty_out'] |
12254 | 85 |
86 " 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
|
87 " Add -quiet to avoid the intro message causing a hit-enter prompt. |
d9067dad4ac6
patch 8.0.1264: terminal debugger gets stuck in small window
Christian Brabandt <cb@256bit.org>
parents:
12756
diff
changeset
|
88 let cmd = [g:termdebugger, '-quiet', '-tty', pty, a:cmd] |
12254 | 89 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
|
90 let s:gdbbuf = term_start(cmd, { |
12254 | 91 \ '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
|
92 \ 'term_finish': 'close', |
12254 | 93 \ }) |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
94 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
|
95 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
|
96 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
|
97 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
|
98 return |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
99 endif |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
100 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
|
101 |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
102 " Connect gdb to the communication pty, using the GDB/MI interface |
12756
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
12559
diff
changeset
|
103 " If you get an error "undefined command" your GDB is too old. |
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 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
|
105 |
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
106 " 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
|
107 " 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
|
108 " running. |
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
109 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
|
110 |
12455
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
111 " 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
|
112 " 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
|
113 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
|
114 |
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
115 " 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
|
116 " 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
|
117 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
|
118 |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
119 " 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
|
120 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
|
121 call s:InstallCommands() |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
122 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
|
123 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
124 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
|
125 |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
126 augroup TermDebug |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
127 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
|
128 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
|
129 augroup END |
12254 | 130 endfunc |
131 | |
132 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
|
133 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
|
134 exe 'bwipe! ' . s:commbuf |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
135 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
136 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
|
137 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
138 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
|
139 let &signcolumn = s:startsigncolumn |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
140 call s:DeleteCommands() |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
141 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
142 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
|
143 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
|
144 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
|
145 endif |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
146 |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
147 au! TermDebug |
12254 | 148 endfunc |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
149 |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
150 " 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
|
151 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
|
152 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
|
153 |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
154 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
|
155 " 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
|
156 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
|
157 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
|
158 endif |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
159 if msg != '' |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
160 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
|
161 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
|
162 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
|
163 call s:HandleNewBreakpoint(msg) |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
164 elseif msg =~ '^=breakpoint-deleted,' |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
165 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
|
166 elseif msg =~ '^\^done,value=' |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
167 call s:HandleEvaluate(msg) |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
168 elseif msg =~ '^\^error,msg=' |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
169 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
|
170 endif |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
171 endif |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
172 endfor |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
173 endfunc |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
174 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
175 " 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
|
176 func s:InstallCommands() |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
177 command Break call s:SetBreakpoint() |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
178 command Delete call s:DeleteBreakpoint() |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
179 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 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
|
187 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
|
188 command Program call win_gotoid(s:ptywin) |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
189 |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
190 " 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
|
191 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
|
192 |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
193 if has('menu') |
12559 | 194 nnoremenu WinBar.Step :Step<CR> |
195 nnoremenu WinBar.Next :Over<CR> | |
196 nnoremenu WinBar.Finish :Finish<CR> | |
197 nnoremenu WinBar.Cont :Continue<CR> | |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
198 nnoremenu WinBar.Stop :Stop<CR> |
12559 | 199 nnoremenu WinBar.Eval :Evaluate<CR> |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
200 endif |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
201 endfunc |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
202 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
203 " 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
|
204 func s:DeleteCommands() |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
205 delcommand Break |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
206 delcommand Delete |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
207 delcommand Step |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
208 delcommand Over |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
209 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
|
210 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
|
211 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
|
212 delcommand Stop |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
213 delcommand Continue |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
214 delcommand Evaluate |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
215 delcommand Gdb |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
216 delcommand Program |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
217 |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
218 nunmap K |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
219 |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
220 if has('menu') |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
221 aunmenu WinBar.Step |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
222 aunmenu WinBar.Next |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
223 aunmenu WinBar.Finish |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
224 aunmenu WinBar.Cont |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
225 aunmenu WinBar.Stop |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
226 aunmenu WinBar.Eval |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
227 endif |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
228 |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
229 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
|
230 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
|
231 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
|
232 endfor |
12455
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
233 sign undefine debugPC |
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
234 sign undefine debugBreakpoint |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
235 unlet s:breakpoints |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
236 endfunc |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
237 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
238 " :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
|
239 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
|
240 " 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
|
241 " 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 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
|
247 endif |
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
248 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
|
249 \ . 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
|
250 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
|
251 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
|
252 endif |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
253 endfunc |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
254 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
255 " :Delete - Delete a breakpoint at the cursor position. |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
256 func s:DeleteBreakpoint() |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
257 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
|
258 let lnum = line('.') |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
259 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
|
260 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
|
261 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
|
262 " 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
|
263 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
|
264 unlet s:breakpoints[key] |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
265 break |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
266 endif |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
267 endfor |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
268 endfunc |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
269 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
270 " :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
|
271 func s:SendCommand(cmd) |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
272 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
|
273 endfunc |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
274 |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
275 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
|
276 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
|
277 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
|
278 endif |
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
279 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
|
280 endfunc |
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
281 |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
282 " :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
|
283 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
|
284 if a:arg != '' |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
285 let expr = a:arg |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
286 elseif a:range == 2 |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
287 let pos = getcurpos() |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
288 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
|
289 let regt = getregtype('v') |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
290 normal! gv"vy |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
291 let expr = @v |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
292 call setpos('.', pos) |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
293 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
|
294 else |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
295 let expr = expand('<cexpr>') |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
296 endif |
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 call s:SendCommand('-data-evaluate-expression "' . expr . '"') |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
298 let s:evalexpr = expr |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
299 endfunc |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
300 |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
301 " 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
|
302 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
|
303 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
|
304 let value = substitute(value, '\\"', '"', 'g') |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
305 echomsg '"' . s:evalexpr . '": ' . value |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
306 |
12826 | 307 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
|
308 " Looks like a pointer, also display what it points to. |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
309 let s:evalexpr = '*' . s:evalexpr |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
310 call term_sendkeys(s:commbuf, '-data-evaluate-expression "' . s:evalexpr . "\"\r") |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
311 endif |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
312 endfunc |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
313 |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
314 " Handle an error. |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
315 func s:HandleError(msg) |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
316 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
|
317 endfunc |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
318 |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
319 " 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
|
320 " 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
|
321 func s:HandleCursor(msg) |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
322 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
|
323 |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
324 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
|
325 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
|
326 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
|
327 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
|
328 endif |
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
329 |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
330 if win_gotoid(s:startwin) |
12455
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
331 let fname = substitute(a:msg, '.*fullname="\([^"]*\)".*', '\1', '') |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
332 if a:msg =~ '^\(\*stopped\|=thread-selected\)' && filereadable(fname) |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
333 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
|
334 if lnum =~ '^[0-9]*$' |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
335 if expand('%:p') != fnamemodify(fname, ':p') |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
336 if &modified |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
337 " TODO: find existing window |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
338 exe 'split ' . fnameescape(fname) |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
339 let s:startwin = win_getid(winnr()) |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
340 else |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
341 exe 'edit ' . fnameescape(fname) |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
342 endif |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
343 endif |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
344 exe lnum |
12756
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
12559
diff
changeset
|
345 exe 'sign unplace ' . s:pc_id |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
346 exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC file=' . fname |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
347 setlocal signcolumn=yes |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
348 endif |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
349 else |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
350 exe 'sign unplace ' . s:pc_id |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
351 endif |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
352 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
353 call win_gotoid(wid) |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
354 endif |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
355 endfunc |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
356 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
357 " Handle setting a breakpoint |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
358 " 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
|
359 func s:HandleNewBreakpoint(msg) |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
360 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
|
361 if nr == 0 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
362 return |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
363 endif |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
364 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
365 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
|
366 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
|
367 else |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
368 let entry = {} |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
369 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
|
370 endif |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
371 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
372 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
|
373 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
|
374 let entry['fname'] = fname |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
375 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
|
376 |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
377 if bufloaded(fname) |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
378 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
|
379 endif |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
380 endfunc |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
381 |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
382 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
|
383 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
|
384 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
|
385 endfunc |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
386 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
387 " Handle deleting a breakpoint |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
388 " 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
|
389 func s:HandleBreakpointDelete(msg) |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
390 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
|
391 if nr == 0 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
392 return |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
393 endif |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
394 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
|
395 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
|
396 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
|
397 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
|
398 unlet entry['placed'] |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
399 endif |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
400 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
|
401 endif |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
402 endfunc |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
403 |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
404 " 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
|
405 func s:BufRead() |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
406 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
|
407 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
|
408 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
|
409 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
|
410 endif |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
411 endfor |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
412 endfunc |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
413 |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
414 " 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
|
415 func s:BufUnloaded() |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
416 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
|
417 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
|
418 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
|
419 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
|
420 endif |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
421 endfor |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
422 endfunc |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
423 |