Mercurial > vim
annotate runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @ 28808:0f0fed554cdc
Update runtime files, translations
Commit: https://github.com/vim/vim/commit/921bde88804663a7cb825d7f7e8a5d8ae6b58650
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon May 9 19:50:35 2022 +0100
Update runtime files, translations
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 09 May 2022 21:00:05 +0200 |
parents | b96ceb97e896 |
children | ad63d6a8ed21 |
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 " |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
3 " Author: Bram Moolenaar |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
4 " Copyright: Vim license applies, see ":help license" |
28808
0f0fed554cdc
Update runtime files, translations
Bram Moolenaar <Bram@vim.org>
parents:
28777
diff
changeset
|
5 " Last Change: 2022 May 09 |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
6 " |
28141 | 7 " WORK IN PROGRESS - The basics works stable, more to come |
8 " Note: In general you need at least GDB 7.12 because this provides the | |
9 " frame= response in MI thread-selected events we need to sync stack to file. | |
10 " The one included with "old" MingW is too old (7.6.1), you may upgrade it or | |
11 " use a newer version from http://www.equation.com/servlet/equation.cmd?fa=gdb | |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
12 " |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
13 " There are two ways to run gdb: |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
14 " - In a terminal window; used if possible, does not work on MS-Windows |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
15 " Not used when g:termdebug_use_prompt is set to 1. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
16 " - Using a "prompt" buffer; may use a terminal window for the program |
12254 | 17 " |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
18 " For both the current window is used to view source code and shows the |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
19 " current statement from gdb. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
20 " |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
21 " USING A TERMINAL WINDOW |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
22 " |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
23 " Opens two visible terminal windows: |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
24 " 1. runs a pty for the debugged program, as with ":term NONE" |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
25 " 2. runs gdb, passing the pty of 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
|
26 " 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
|
27 " |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
28 " USING A PROMPT BUFFER |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
29 " |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
30 " Opens a window with a prompt buffer to communicate with gdb. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
31 " Gdb is run as a job with callbacks for I/O. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
32 " On Unix another terminal window is opened to run the debugged program |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
33 " On MS-Windows a separate console is opened to run the debugged program |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
34 " |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
35 " 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
|
36 " https://sourceware.org/gdb/current/onlinedocs/gdb/GDB_002fMI.html |
12254 | 37 |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
38 " In case this gets sourced twice. |
12499 | 39 if exists(':Termdebug') |
40 finish | |
41 endif | |
42 | |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
43 " Need either the +terminal feature or +channel and the prompt buffer. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
44 " The terminal feature does not work with gdb on win32. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
45 if has('terminal') && !has('win32') |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
46 let s:way = 'terminal' |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
47 elseif has('channel') && exists('*prompt_setprompt') |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
48 let s:way = 'prompt' |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
49 else |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
50 if has('terminal') |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
51 let s:err = 'Cannot debug, missing prompt buffer support' |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
52 else |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
53 let s:err = 'Cannot debug, +channel feature is not supported' |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
54 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
55 command -nargs=* -complete=file -bang Termdebug echoerr s:err |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
56 command -nargs=+ -complete=file -bang TermdebugCommand echoerr s:err |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
57 finish |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
58 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
|
59 |
14356
9339e4dbf6bf
patch 8.1.0193: terminal debugger buttons don't always work
Christian Brabandt <cb@256bit.org>
parents:
14165
diff
changeset
|
60 let s:keepcpo = &cpo |
9339e4dbf6bf
patch 8.1.0193: terminal debugger buttons don't always work
Christian Brabandt <cb@256bit.org>
parents:
14165
diff
changeset
|
61 set cpo&vim |
9339e4dbf6bf
patch 8.1.0193: terminal debugger buttons don't always work
Christian Brabandt <cb@256bit.org>
parents:
14165
diff
changeset
|
62 |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
63 " 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
|
64 " To end type "quit" in the gdb window. |
13706
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
65 command -nargs=* -complete=file -bang Termdebug call s:StartDebug(<bang>0, <f-args>) |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
66 command -nargs=+ -complete=file -bang TermdebugCommand call s:StartDebugCommand(<bang>0, <f-args>) |
12254 | 67 |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
68 " Name of the gdb command, defaults to "gdb". |
18217
40344f717010
patch 8.1.2103: wrong error message if "termdebugger" is not executable
Bram Moolenaar <Bram@vim.org>
parents:
18130
diff
changeset
|
69 if !exists('g:termdebugger') |
40344f717010
patch 8.1.2103: wrong error message if "termdebugger" is not executable
Bram Moolenaar <Bram@vim.org>
parents:
18130
diff
changeset
|
70 let g:termdebugger = 'gdb' |
12254 | 71 endif |
72 | |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
73 let s:pc_id = 12 |
23573 | 74 let s:asm_id = 13 |
75 let s:break_id = 14 " breakpoint number is added to this | |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
76 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
|
77 |
23573 | 78 let s:parsing_disasm_msg = 0 |
79 let s:asm_lines = [] | |
80 let s:asm_addr = '' | |
81 | |
15093
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
82 " Take a breakpoint number as used by GDB and turn it into an integer. |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
83 " The breakpoint may contain a dot: 123.4 -> 123004 |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
84 " The main breakpoint has a zero subid. |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
85 func s:Breakpoint2SignNumber(id, subid) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
86 return s:break_id + a:id * 1000 + a:subid |
15093
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
87 endfunction |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
88 |
14127
d2b14df7e439
patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents:
14126
diff
changeset
|
89 func s:Highlight(init, old, new) |
d2b14df7e439
patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents:
14126
diff
changeset
|
90 let default = a:init ? 'default ' : '' |
d2b14df7e439
patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents:
14126
diff
changeset
|
91 if a:new ==# 'light' && a:old !=# 'light' |
d2b14df7e439
patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents:
14126
diff
changeset
|
92 exe "hi " . default . "debugPC term=reverse ctermbg=lightblue guibg=lightblue" |
d2b14df7e439
patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents:
14126
diff
changeset
|
93 elseif a:new ==# 'dark' && a:old !=# 'dark' |
d2b14df7e439
patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents:
14126
diff
changeset
|
94 exe "hi " . default . "debugPC term=reverse ctermbg=darkblue guibg=darkblue" |
d2b14df7e439
patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents:
14126
diff
changeset
|
95 endif |
d2b14df7e439
patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents:
14126
diff
changeset
|
96 endfunc |
d2b14df7e439
patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents:
14126
diff
changeset
|
97 |
d2b14df7e439
patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents:
14126
diff
changeset
|
98 call s:Highlight(1, '', &background) |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
99 hi default debugBreakpoint term=reverse ctermbg=red guibg=red |
26304 | 100 hi default debugBreakpointDisabled term=reverse ctermbg=gray guibg=gray |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
101 |
26708 | 102 func s:GetCommand() |
103 return type(g:termdebugger) == v:t_list ? copy(g:termdebugger) : [g:termdebugger] | |
104 endfunc | |
105 | |
13706
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
106 func s:StartDebug(bang, ...) |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
107 " First argument is the command to debug, second core file or process ID. |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
108 call s:StartDebug_internal({'gdb_args': a:000, 'bang': a:bang}) |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
109 endfunc |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
110 |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
111 func s:StartDebugCommand(bang, ...) |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
112 " First argument is the command to debug, rest are run arguments. |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
113 call s:StartDebug_internal({'gdb_args': [a:1], 'proc_args': a:000[1:], 'bang': a:bang}) |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
114 endfunc |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
115 |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
116 func s:StartDebug_internal(dict) |
13682
fc660a6ef37d
patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents:
13592
diff
changeset
|
117 if exists('s:gdbwin') |
18217
40344f717010
patch 8.1.2103: wrong error message if "termdebugger" is not executable
Bram Moolenaar <Bram@vim.org>
parents:
18130
diff
changeset
|
118 echoerr 'Terminal debugger already running, cannot run two' |
13682
fc660a6ef37d
patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents:
13592
diff
changeset
|
119 return |
fc660a6ef37d
patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents:
13592
diff
changeset
|
120 endif |
26708 | 121 let gdbcmd = s:GetCommand() |
122 if !executable(gdbcmd[0]) | |
123 echoerr 'Cannot execute debugger program "' .. gdbcmd[0] .. '"' | |
18217
40344f717010
patch 8.1.2103: wrong error message if "termdebugger" is not executable
Bram Moolenaar <Bram@vim.org>
parents:
18130
diff
changeset
|
124 return |
40344f717010
patch 8.1.2103: wrong error message if "termdebugger" is not executable
Bram Moolenaar <Bram@vim.org>
parents:
18130
diff
changeset
|
125 endif |
40344f717010
patch 8.1.2103: wrong error message if "termdebugger" is not executable
Bram Moolenaar <Bram@vim.org>
parents:
18130
diff
changeset
|
126 |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
127 let s:ptywin = 0 |
14147
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
128 let s:pid = 0 |
23573 | 129 let s:asmwin = 0 |
13682
fc660a6ef37d
patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents:
13592
diff
changeset
|
130 |
25619 | 131 if exists('#User#TermdebugStartPre') |
132 doauto <nomodeline> User TermdebugStartPre | |
133 endif | |
134 | |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
135 " Uncomment this line to write logging in "debuglog". |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
136 " call ch_logfile('debuglog', 'w') |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
137 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
138 let s:sourcewin = win_getid(winnr()) |
22723 | 139 |
140 " Remember the old value of 'signcolumn' for each buffer that it's set in, so | |
141 " that we can restore the value for all buffers. | |
142 let b:save_signcolumn = &signcolumn | |
143 let s:signcolumn_buflist = [bufnr()] | |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
144 |
12559 | 145 let s:save_columns = 0 |
16808 | 146 let s:allleft = 0 |
12559 | 147 if exists('g:termdebug_wide') |
148 if &columns < g:termdebug_wide | |
149 let s:save_columns = &columns | |
150 let &columns = g:termdebug_wide | |
27036 | 151 " If we make the Vim window wider, use the whole left half for the debug |
16808 | 152 " windows. |
153 let s:allleft = 1 | |
12559 | 154 endif |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
155 let s:vertical = 1 |
12455
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
156 else |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
157 let s:vertical = 0 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
158 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
159 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
160 " Override using a terminal window by setting g:termdebug_use_prompt to 1. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
161 let use_prompt = exists('g:termdebug_use_prompt') && g:termdebug_use_prompt |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
162 if has('terminal') && !has('win32') && !use_prompt |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
163 let s:way = 'terminal' |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
164 else |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
165 let s:way = 'prompt' |
12455
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
166 endif |
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
167 |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
168 if s:way == 'prompt' |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
169 call s:StartDebug_prompt(a:dict) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
170 else |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
171 call s:StartDebug_term(a:dict) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
172 endif |
23573 | 173 |
174 if exists('g:termdebug_disasm_window') | |
175 if g:termdebug_disasm_window | |
176 let curwinid = win_getid(winnr()) | |
177 call s:GotoAsmwinOrCreateIt() | |
178 call win_gotoid(curwinid) | |
179 endif | |
180 endif | |
25619 | 181 |
182 if exists('#User#TermdebugStartPost') | |
183 doauto <nomodeline> User TermdebugStartPost | |
184 endif | |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
185 endfunc |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
186 |
15223
0e7615548cef
patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents:
15129
diff
changeset
|
187 " Use when debugger didn't start or ended. |
0e7615548cef
patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents:
15129
diff
changeset
|
188 func s:CloseBuffers() |
0e7615548cef
patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents:
15129
diff
changeset
|
189 exe 'bwipe! ' . s:ptybuf |
0e7615548cef
patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents:
15129
diff
changeset
|
190 exe 'bwipe! ' . s:commbuf |
0e7615548cef
patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents:
15129
diff
changeset
|
191 unlet! s:gdbwin |
0e7615548cef
patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents:
15129
diff
changeset
|
192 endfunc |
0e7615548cef
patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents:
15129
diff
changeset
|
193 |
24751 | 194 func s:CheckGdbRunning() |
195 let gdbproc = term_getjob(s:gdbbuf) | |
196 if gdbproc == v:null || job_status(gdbproc) !=# 'run' | |
26708 | 197 echoerr string(s:GetCommand()[0]) . ' exited unexpectedly' |
24751 | 198 call s:CloseBuffers() |
199 return '' | |
200 endif | |
201 return 'ok' | |
202 endfunc | |
203 | |
28808
0f0fed554cdc
Update runtime files, translations
Bram Moolenaar <Bram@vim.org>
parents:
28777
diff
changeset
|
204 " Open a terminal window without a job, to run the debugged program in. |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
205 func s:StartDebug_term(dict) |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
206 let s:ptybuf = term_start('NONE', { |
18130 | 207 \ 'term_name': 'debugged program', |
208 \ 'vertical': s:vertical, | |
209 \ }) | |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
210 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
|
211 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
|
212 return |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
213 endif |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
214 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
|
215 let s:ptywin = win_getid(winnr()) |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
216 if s:vertical |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
217 " 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
|
218 " 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
|
219 exe (&columns / 2 - 1) . "wincmd |" |
16808 | 220 if s:allleft |
221 " use the whole left column | |
222 wincmd H | |
223 endif | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
224 endif |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
225 |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
226 " 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
|
227 let s:commbuf = term_start('NONE', { |
18130 | 228 \ 'term_name': 'gdb communication', |
229 \ 'out_cb': function('s:CommOutput'), | |
230 \ 'hidden': 1, | |
231 \ }) | |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
232 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
|
233 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
|
234 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
|
235 return |
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 let commpty = job_info(term_getjob(s:commbuf))['tty_out'] |
12254 | 238 |
13706
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
239 let gdb_args = get(a:dict, 'gdb_args', []) |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
240 let proc_args = get(a:dict, 'proc_args', []) |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
241 |
26708 | 242 let gdb_cmd = s:GetCommand() |
26304 | 243 " Add -quiet to avoid the intro message causing a hit-enter prompt. |
244 let gdb_cmd += ['-quiet'] | |
245 " Disable pagination, it causes everything to stop at the gdb | |
246 let gdb_cmd += ['-iex', 'set pagination off'] | |
247 " Interpret commands while the target is running. This should usually only | |
248 " be exec-interrupt, since many commands don't work properly while the | |
249 " target is running (so execute during startup). | |
250 let gdb_cmd += ['-iex', 'set mi-async on'] | |
251 " Open a terminal window to run the debugger. | |
252 let gdb_cmd += ['-tty', pty] | |
253 " Command executed _after_ startup is done, provides us with the necessary feedback | |
254 let gdb_cmd += ['-ex', 'echo startupdone\n'] | |
255 | |
256 " Adding arguments requested by the user | |
257 let gdb_cmd += gdb_args | |
258 | |
259 call ch_log('executing "' . join(gdb_cmd) . '"') | |
260 let s:gdbbuf = term_start(gdb_cmd, { | |
18130 | 261 \ 'term_finish': 'close', |
262 \ }) | |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
263 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
|
264 echoerr 'Failed to open the gdb terminal window' |
15223
0e7615548cef
patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents:
15129
diff
changeset
|
265 call s:CloseBuffers() |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
266 return |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
267 endif |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
268 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
|
269 |
24751 | 270 " Wait for the "startupdone" message before sending any commands. |
271 let try_count = 0 | |
272 while 1 | |
273 if s:CheckGdbRunning() != 'ok' | |
274 return | |
275 endif | |
276 | |
277 for lnum in range(1, 200) | |
278 if term_getline(s:gdbbuf, lnum) =~ 'startupdone' | |
26304 | 279 let try_count = 9999 |
280 break | |
24751 | 281 endif |
282 endfor | |
283 let try_count += 1 | |
284 if try_count > 300 | |
285 " done or give up after five seconds | |
286 break | |
287 endif | |
288 sleep 10m | |
289 endwhile | |
290 | |
291 " Set arguments to be run. | |
13706
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
292 if len(proc_args) |
26304 | 293 call term_sendkeys(s:gdbbuf, 'server set args ' . join(proc_args) . "\r") |
13706
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
294 endif |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
295 |
26219 | 296 " Connect gdb to the communication pty, using the GDB/MI interface. |
297 " Prefix "server" to avoid adding this to the history. | |
298 call term_sendkeys(s:gdbbuf, 'server new-ui mi ' . commpty . "\r") | |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
299 |
13450
a7a88403ccb1
patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents:
13377
diff
changeset
|
300 " 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
|
301 " 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
|
302 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
|
303 while 1 |
24751 | 304 if s:CheckGdbRunning() != 'ok' |
15223
0e7615548cef
patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents:
15129
diff
changeset
|
305 return |
0e7615548cef
patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents:
15129
diff
changeset
|
306 endif |
0e7615548cef
patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents:
15129
diff
changeset
|
307 |
13450
a7a88403ccb1
patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents:
13377
diff
changeset
|
308 let response = '' |
17962
58bebe21f0ef
patch 8.1.1977: terminal debugger plugin may hang
Bram Moolenaar <Bram@vim.org>
parents:
17909
diff
changeset
|
309 for lnum in range(1, 200) |
58bebe21f0ef
patch 8.1.1977: terminal debugger plugin may hang
Bram Moolenaar <Bram@vim.org>
parents:
17909
diff
changeset
|
310 let line1 = term_getline(s:gdbbuf, lnum) |
58bebe21f0ef
patch 8.1.1977: terminal debugger plugin may hang
Bram Moolenaar <Bram@vim.org>
parents:
17909
diff
changeset
|
311 let line2 = term_getline(s:gdbbuf, lnum + 1) |
58bebe21f0ef
patch 8.1.1977: terminal debugger plugin may hang
Bram Moolenaar <Bram@vim.org>
parents:
17909
diff
changeset
|
312 if line1 =~ 'new-ui mi ' |
26304 | 313 " response can be in the same line or the next line |
314 let response = line1 . line2 | |
315 if response =~ 'Undefined command' | |
316 echoerr 'Sorry, your gdb is too old, gdb 7.12 is required' | |
28141 | 317 " CHECKME: possibly send a "server show version" here |
26304 | 318 call s:CloseBuffers() |
319 return | |
320 endif | |
321 if response =~ 'New UI allocated' | |
322 " Success! | |
323 break | |
324 endif | |
17962
58bebe21f0ef
patch 8.1.1977: terminal debugger plugin may hang
Bram Moolenaar <Bram@vim.org>
parents:
17909
diff
changeset
|
325 elseif line1 =~ 'Reading symbols from' && line2 !~ 'new-ui mi ' |
26304 | 326 " Reading symbols might take a while, try more times |
327 let try_count -= 1 | |
13450
a7a88403ccb1
patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents:
13377
diff
changeset
|
328 endif |
a7a88403ccb1
patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents:
13377
diff
changeset
|
329 endfor |
a7a88403ccb1
patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents:
13377
diff
changeset
|
330 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
|
331 break |
a7a88403ccb1
patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents:
13377
diff
changeset
|
332 endif |
a7a88403ccb1
patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents:
13377
diff
changeset
|
333 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
|
334 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
|
335 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
|
336 break |
a7a88403ccb1
patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents:
13377
diff
changeset
|
337 endif |
a7a88403ccb1
patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents:
13377
diff
changeset
|
338 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
|
339 endwhile |
a7a88403ccb1
patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents:
13377
diff
changeset
|
340 |
24751 | 341 call job_setoptions(term_getjob(s:gdbbuf), {'exit_cb': function('s:EndTermDebug')}) |
25700 | 342 |
343 " Set the filetype, this can be used to add mappings. | |
344 set filetype=termdebug | |
345 | |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
346 call s:StartDebugCommon(a:dict) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
347 endfunc |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
348 |
28808
0f0fed554cdc
Update runtime files, translations
Bram Moolenaar <Bram@vim.org>
parents:
28777
diff
changeset
|
349 " Open a window with a prompt buffer to run gdb in. |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
350 func s:StartDebug_prompt(dict) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
351 if s:vertical |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
352 vertical new |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
353 else |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
354 new |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
355 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
356 let s:gdbwin = win_getid(winnr()) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
357 let s:promptbuf = bufnr('') |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
358 call prompt_setprompt(s:promptbuf, 'gdb> ') |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
359 set buftype=prompt |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
360 file gdb |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
361 call prompt_setcallback(s:promptbuf, function('s:PromptCallback')) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
362 call prompt_setinterrupt(s:promptbuf, function('s:PromptInterrupt')) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
363 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
364 if s:vertical |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
365 " Assuming the source code window will get a signcolumn, use two more |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
366 " columns for that, thus one less for the terminal window. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
367 exe (&columns / 2 - 1) . "wincmd |" |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
368 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
369 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
370 let gdb_args = get(a:dict, 'gdb_args', []) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
371 let proc_args = get(a:dict, 'proc_args', []) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
372 |
26708 | 373 let gdb_cmd = s:GetCommand() |
26304 | 374 " Add -quiet to avoid the intro message causing a hit-enter prompt. |
375 let gdb_cmd += ['-quiet'] | |
376 " Disable pagination, it causes everything to stop at the gdb, needs to be run early | |
377 let gdb_cmd += ['-iex', 'set pagination off'] | |
378 " Interpret commands while the target is running. This should usually only | |
379 " be exec-interrupt, since many commands don't work properly while the | |
380 " target is running (so execute during startup). | |
381 let gdb_cmd += ['-iex', 'set mi-async on'] | |
382 " directly communicate via mi2 | |
383 let gdb_cmd += ['--interpreter=mi2'] | |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
384 |
26304 | 385 " Adding arguments requested by the user |
386 let gdb_cmd += gdb_args | |
387 | |
388 call ch_log('executing "' . join(gdb_cmd) . '"') | |
389 let s:gdbjob = job_start(gdb_cmd, { | |
18130 | 390 \ 'exit_cb': function('s:EndPromptDebug'), |
391 \ 'out_cb': function('s:GdbOutCallback'), | |
392 \ }) | |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
393 if job_status(s:gdbjob) != "run" |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
394 echoerr 'Failed to start gdb' |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
395 exe 'bwipe! ' . s:promptbuf |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
396 return |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
397 endif |
14147
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
398 " Mark the buffer modified so that it's not easy to close. |
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
399 set modified |
28141 | 400 let s:gdb_channel = job_getchannel(s:gdbjob) |
13564
a036c2cf4024
patch 8.0.1655: outdated gdb message in terminal debugger unclear
Christian Brabandt <cb@256bit.org>
parents:
13450
diff
changeset
|
401 |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
402 let s:ptybuf = 0 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
403 if has('win32') |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
404 " MS-Windows: run in a new console window for maximum compatibility |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
405 call s:SendCommand('set new-console on') |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
406 elseif has('terminal') |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
407 " Unix: Run the debugged program in a terminal window. Open it below the |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
408 " gdb window. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
409 belowright let s:ptybuf = term_start('NONE', { |
18130 | 410 \ 'term_name': 'debugged program', |
411 \ }) | |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
412 if s:ptybuf == 0 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
413 echoerr 'Failed to open the program terminal window' |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
414 call job_stop(s:gdbjob) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
415 return |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
416 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
417 let s:ptywin = win_getid(winnr()) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
418 let pty = job_info(term_getjob(s:ptybuf))['tty_out'] |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
419 call s:SendCommand('tty ' . pty) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
420 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
421 " Since GDB runs in a prompt window, the environment has not been set to |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
422 " match a terminal window, need to do that now. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
423 call s:SendCommand('set env TERM = xterm-color') |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
424 call s:SendCommand('set env ROWS = ' . winheight(s:ptywin)) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
425 call s:SendCommand('set env LINES = ' . winheight(s:ptywin)) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
426 call s:SendCommand('set env COLUMNS = ' . winwidth(s:ptywin)) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
427 call s:SendCommand('set env COLORS = ' . &t_Co) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
428 call s:SendCommand('set env VIM_TERMINAL = ' . v:version) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
429 else |
27036 | 430 " TODO: open a new terminal, get the tty name, pass on to gdb |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
431 call s:SendCommand('show inferior-tty') |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
432 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
433 call s:SendCommand('set print pretty on') |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
434 call s:SendCommand('set breakpoint pending on') |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
435 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
436 " Set arguments to be run |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
437 if len(proc_args) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
438 call s:SendCommand('set args ' . join(proc_args)) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
439 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
440 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
441 call s:StartDebugCommon(a:dict) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
442 startinsert |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
443 endfunc |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
444 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
445 func s:StartDebugCommon(dict) |
12455
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
446 " 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
|
447 " There can be only one. |
28517 | 448 call sign_define('debugPC', #{linehl: 'debugPC'}) |
12455
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
449 |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
450 " Install debugger commands in the text window. |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
451 call win_gotoid(s:sourcewin) |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
452 call s:InstallCommands() |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
453 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
|
454 |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
455 " 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
|
456 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
|
457 set balloonexpr=TermDebugBalloonExpr() |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
458 if has("balloon_eval") |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
459 set ballooneval |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
460 endif |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
461 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
|
462 set balloonevalterm |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
463 endif |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
464 endif |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
465 |
15093
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
466 " Contains breakpoints that have been placed, key is a string with the GDB |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
467 " breakpoint number. |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
468 " Each entry is a dict, containing the sub-breakpoints. Key is the subid. |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
469 " For a breakpoint that is just a number the subid is zero. |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
470 " For a breakpoint "123.4" the id is "123" and subid is "4". |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
471 " Example, when breakpoint "44", "123", "123.1" and "123.2" exist: |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
472 " {'44': {'0': entry}, '123': {'0': entry, '1': entry, '2': entry}} |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
473 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
|
474 |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
475 " Contains breakpoints by file/lnum. The key is "fname:lnum". |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
476 " Each entry is a list of breakpoint IDs at that position. |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
477 let s:breakpoint_locations = {} |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
478 |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
479 augroup TermDebug |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
480 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
|
481 au BufUnload * call s:BufUnloaded() |
14127
d2b14df7e439
patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents:
14126
diff
changeset
|
482 au OptionSet background call s:Highlight(0, v:option_old, v:option_new) |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
483 augroup END |
13706
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
484 |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
485 " Run the command if the bang attribute was given and got to the debug |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
486 " window. |
13706
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
487 if get(a:dict, 'bang', 0) |
26438 | 488 call s:SendResumingCommand('-exec-run') |
13706
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
489 call win_gotoid(s:ptywin) |
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
490 endif |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
491 endfunc |
13706
bfd9249f72e0
patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents:
13682
diff
changeset
|
492 |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
493 " Send a command to gdb. "cmd" is the string without line terminator. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
494 func s:SendCommand(cmd) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
495 call ch_log('sending to gdb: ' . a:cmd) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
496 if s:way == 'prompt' |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
497 call ch_sendraw(s:gdb_channel, a:cmd . "\n") |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
498 else |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
499 call term_sendkeys(s:commbuf, a:cmd . "\r") |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
500 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
501 endfunc |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
502 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
503 " This is global so that a user can create their mappings with this. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
504 func TermDebugSendCommand(cmd) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
505 if s:way == 'prompt' |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
506 call ch_sendraw(s:gdb_channel, a:cmd . "\n") |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
507 else |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
508 let do_continue = 0 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
509 if !s:stopped |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
510 let do_continue = 1 |
26219 | 511 Stop |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
512 sleep 10m |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
513 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
514 call term_sendkeys(s:gdbbuf, a:cmd . "\r") |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
515 if do_continue |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
516 Continue |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
517 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
518 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
519 endfunc |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
520 |
26438 | 521 " Send a command that resumes the program. If the program isn't stopped the |
522 " command is not sent (to avoid a repeated command to cause trouble). | |
523 " If the command is sent then reset s:stopped. | |
524 func s:SendResumingCommand(cmd) | |
26304 | 525 if s:stopped |
26438 | 526 " reset s:stopped here, it may take a bit of time before we get a response |
527 let s:stopped = 0 | |
528 call ch_log('assume that program is running after this command') | |
26304 | 529 call s:SendCommand(a:cmd) |
530 else | |
531 call ch_log('dropping command, program is running: ' . a:cmd) | |
532 endif | |
533 endfunc | |
534 | |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
535 " Function called when entering a line in the prompt buffer. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
536 func s:PromptCallback(text) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
537 call s:SendCommand(a:text) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
538 endfunc |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
539 |
14147
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
540 " Function called when pressing CTRL-C in the prompt buffer and when placing a |
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
541 " breakpoint. |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
542 func s:PromptInterrupt() |
14151
2404459a8639
patch 8.1.0093: non-MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14147
diff
changeset
|
543 call ch_log('Interrupting gdb') |
2404459a8639
patch 8.1.0093: non-MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14147
diff
changeset
|
544 if has('win32') |
2404459a8639
patch 8.1.0093: non-MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14147
diff
changeset
|
545 " Using job_stop() does not work on MS-Windows, need to send SIGTRAP to |
2404459a8639
patch 8.1.0093: non-MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14147
diff
changeset
|
546 " the debugger program so that gdb responds again. |
2404459a8639
patch 8.1.0093: non-MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14147
diff
changeset
|
547 if s:pid == 0 |
2404459a8639
patch 8.1.0093: non-MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14147
diff
changeset
|
548 echoerr 'Cannot interrupt gdb, did not find a process ID' |
2404459a8639
patch 8.1.0093: non-MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14147
diff
changeset
|
549 else |
2404459a8639
patch 8.1.0093: non-MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14147
diff
changeset
|
550 call debugbreak(s:pid) |
2404459a8639
patch 8.1.0093: non-MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14147
diff
changeset
|
551 endif |
14147
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
552 else |
14151
2404459a8639
patch 8.1.0093: non-MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14147
diff
changeset
|
553 call job_stop(s:gdbjob, 'int') |
14147
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
554 endif |
12254 | 555 endfunc |
556 | |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
557 " Function called when gdb outputs text. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
558 func s:GdbOutCallback(channel, text) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
559 call ch_log('received from gdb: ' . a:text) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
560 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
561 " Drop the gdb prompt, we have our own. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
562 " Drop status and echo'd commands. |
14143
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
563 if a:text == '(gdb) ' || a:text == '^done' || a:text[0] == '&' |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
564 return |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
565 endif |
26100 | 566 if a:text =~ '^\^error,msg=' |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
567 let text = s:DecodeMessage(a:text[11:]) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
568 if exists('s:evalexpr') && text =~ 'A syntax error in expression, near\|No symbol .* in current context' |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
569 " Silently drop evaluation errors. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
570 unlet s:evalexpr |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
571 return |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
572 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
573 elseif a:text[0] == '~' |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
574 let text = s:DecodeMessage(a:text[1:]) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
575 else |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
576 call s:CommOutput(a:channel, a:text) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
577 return |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
578 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
579 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
580 let curwinid = win_getid(winnr()) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
581 call win_gotoid(s:gdbwin) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
582 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
583 " Add the output above the current prompt. |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
584 call append(line('$') - 1, text) |
14147
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
585 set modified |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
586 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
587 call win_gotoid(curwinid) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
588 endfunc |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
589 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
590 " Decode a message from gdb. quotedText starts with a ", return the text up |
26304 | 591 " to the next ", unescaping characters: |
592 " - remove line breaks | |
593 " - change \\t to \t | |
26591 | 594 " - change \0xhh to \xhh (disabled for now) |
26304 | 595 " - change \ooo to octal |
596 " - change \\ to \ | |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
597 func s:DecodeMessage(quotedText) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
598 if a:quotedText[0] != '"' |
14143
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
599 echoerr 'DecodeMessage(): missing quote in ' . a:quotedText |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
600 return |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
601 endif |
26304 | 602 return a:quotedText |
26591 | 603 \ ->substitute('^"\|".*\|\\n', '', 'g') |
604 \ ->substitute('\\t', "\t", 'g') | |
605 " multi-byte characters arrive in octal form | |
606 " NULL-values must be kept encoded as those break the string otherwise | |
607 \ ->substitute('\\000', s:NullRepl, 'g') | |
608 \ ->substitute('\\\o\o\o', {-> eval('"' .. submatch(0) .. '"')}, 'g') | |
609 " Note: GDB docs also mention hex encodings - the translations below work | |
610 " but we keep them out for performance-reasons until we actually see | |
611 " those in mi-returns | |
612 " \ ->substitute('\\0x\(\x\x\)', {-> eval('"\x' .. submatch(1) .. '"')}, 'g') | |
613 " \ ->substitute('\\0x00', s:NullRepl, 'g') | |
614 \ ->substitute('\\\\', '\', 'g') | |
615 \ ->substitute(s:NullRepl, '\\000', 'g') | |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
616 endfunc |
26591 | 617 const s:NullRepl = 'XXXNULLXXX' |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
618 |
14143
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
619 " Extract the "name" value from a gdb message with fullname="name". |
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
620 func s:GetFullname(msg) |
15093
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
621 if a:msg !~ 'fullname' |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
622 return '' |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
623 endif |
14143
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
624 let name = s:DecodeMessage(substitute(a:msg, '.*fullname=', '', '')) |
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
625 if has('win32') && name =~ ':\\\\' |
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
626 " sometimes the name arrives double-escaped |
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
627 let name = substitute(name, '\\\\', '\\', 'g') |
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
628 endif |
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
629 return name |
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
630 endfunc |
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
631 |
23573 | 632 " Extract the "addr" value from a gdb message with addr="0x0001234". |
633 func s:GetAsmAddr(msg) | |
634 if a:msg !~ 'addr=' | |
635 return '' | |
636 endif | |
637 let addr = s:DecodeMessage(substitute(a:msg, '.*addr=', '', '')) | |
638 return addr | |
639 endfunc | |
25619 | 640 |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
641 func s:EndTermDebug(job, status) |
25619 | 642 if exists('#User#TermdebugStopPre') |
643 doauto <nomodeline> User TermdebugStopPre | |
644 endif | |
645 | |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
646 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
|
647 unlet s:gdbwin |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
648 |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
649 call s:EndDebugCommon() |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
650 endfunc |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
651 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
652 func s:EndDebugCommon() |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
653 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
|
654 |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
655 if exists('s:ptybuf') && s:ptybuf |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
656 exe 'bwipe! ' . s:ptybuf |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
657 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
658 |
22723 | 659 " Restore 'signcolumn' in all buffers for which it was set. |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
660 call win_gotoid(s:sourcewin) |
22723 | 661 let was_buf = bufnr() |
662 for bufnr in s:signcolumn_buflist | |
663 if bufexists(bufnr) | |
664 exe bufnr .. "buf" | |
665 if exists('b:save_signcolumn') | |
28141 | 666 let &signcolumn = b:save_signcolumn |
667 unlet b:save_signcolumn | |
22723 | 668 endif |
669 endif | |
670 endfor | |
28517 | 671 if bufexists(was_buf) |
672 exe was_buf .. "buf" | |
673 endif | |
22723 | 674 |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
675 call s:DeleteCommands() |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
676 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
677 call win_gotoid(curwinid) |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
678 |
12455
85ddf8e00595
patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents:
12425
diff
changeset
|
679 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
|
680 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
|
681 endif |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
682 |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
683 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
|
684 set balloonexpr= |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
685 if has("balloon_eval") |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
686 set noballooneval |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
687 endif |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
688 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
|
689 set noballoonevalterm |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
690 endif |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
691 endif |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
692 |
25619 | 693 if exists('#User#TermdebugStopPost') |
694 doauto <nomodeline> User TermdebugStopPost | |
695 endif | |
696 | |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
697 au! TermDebug |
12254 | 698 endfunc |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
699 |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
700 func s:EndPromptDebug(job, status) |
25619 | 701 if exists('#User#TermdebugStopPre') |
702 doauto <nomodeline> User TermdebugStopPre | |
703 endif | |
704 | |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
705 let curwinid = win_getid(winnr()) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
706 call win_gotoid(s:gdbwin) |
14147
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
707 set nomodified |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
708 close |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
709 if curwinid != s:gdbwin |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
710 call win_gotoid(curwinid) |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
711 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
712 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
713 call s:EndDebugCommon() |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
714 unlet s:gdbwin |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
715 call ch_log("Returning from EndPromptDebug()") |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
716 endfunc |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
717 |
23573 | 718 " Disassembly window - added by Michael Sartain |
719 " | |
720 " - CommOutput: disassemble $pc | |
721 " - CommOutput: &"disassemble $pc\n" | |
722 " - CommOutput: ~"Dump of assembler code for function main(int, char**):\n" | |
723 " - CommOutput: ~" 0x0000555556466f69 <+0>:\tpush rbp\n" | |
724 " ... | |
725 " - CommOutput: ~" 0x0000555556467cd0:\tpop rbp\n" | |
726 " - CommOutput: ~" 0x0000555556467cd1:\tret \n" | |
727 " - CommOutput: ~"End of assembler dump.\n" | |
728 " - CommOutput: ^done | |
729 | |
730 " - CommOutput: disassemble $pc | |
731 " - CommOutput: &"disassemble $pc\n" | |
732 " - CommOutput: &"No function contains specified address.\n" | |
733 " - CommOutput: ^error,msg="No function contains specified address." | |
734 func s:HandleDisasmMsg(msg) | |
735 if a:msg =~ '^\^done' | |
736 let curwinid = win_getid(winnr()) | |
737 if win_gotoid(s:asmwin) | |
738 silent normal! gg0"_dG | |
739 call setline(1, s:asm_lines) | |
740 set nomodified | |
741 set filetype=asm | |
742 | |
743 let lnum = search('^' . s:asm_addr) | |
744 if lnum != 0 | |
28517 | 745 call sign_unplace('TermDebug', #{id: s:asm_id}) |
746 call sign_place(s:asm_id, 'TermDebug', 'debugPC', '%', #{lnum: lnum}) | |
23573 | 747 endif |
748 | |
749 call win_gotoid(curwinid) | |
750 endif | |
751 | |
752 let s:parsing_disasm_msg = 0 | |
753 let s:asm_lines = [] | |
754 elseif a:msg =~ '^\^error,msg=' | |
755 if s:parsing_disasm_msg == 1 | |
756 " Disassemble call ran into an error. This can happen when gdb can't | |
757 " find the function frame address, so let's try to disassemble starting | |
758 " at current PC | |
759 call s:SendCommand('disassemble $pc,+100') | |
760 endif | |
761 let s:parsing_disasm_msg = 0 | |
762 elseif a:msg =~ '\&\"disassemble \$pc' | |
763 if a:msg =~ '+100' | |
764 " This is our second disasm attempt | |
765 let s:parsing_disasm_msg = 2 | |
766 endif | |
767 else | |
768 let value = substitute(a:msg, '^\~\"[ ]*', '', '') | |
769 let value = substitute(value, '^=>[ ]*', '', '') | |
26100 | 770 let value = substitute(value, '\\n\"\r$', '', '') |
23573 | 771 let value = substitute(value, '\\n\"$', '', '') |
26100 | 772 let value = substitute(value, '\r', '', '') |
23573 | 773 let value = substitute(value, '\\t', ' ', 'g') |
774 | |
775 if value != '' || !empty(s:asm_lines) | |
776 call add(s:asm_lines, value) | |
777 endif | |
778 endif | |
779 endfunc | |
780 | |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
781 " 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
|
782 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
|
783 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
|
784 |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
785 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
|
786 " 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
|
787 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
|
788 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
|
789 endif |
23573 | 790 |
791 if s:parsing_disasm_msg | |
792 call s:HandleDisasmMsg(msg) | |
793 elseif msg != '' | |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
794 if msg =~ '^\(\*stopped\|\*running\|=thread-selected\)' |
28141 | 795 call s:HandleCursor(msg) |
26304 | 796 elseif msg =~ '^\^done,bkpt=' || msg =~ '^=breakpoint-created,' |
797 call s:HandleNewBreakpoint(msg, 0) | |
798 elseif msg =~ '^=breakpoint-modified,' | |
799 call s:HandleNewBreakpoint(msg, 1) | |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
800 elseif msg =~ '^=breakpoint-deleted,' |
28141 | 801 call s:HandleBreakpointDelete(msg) |
14147
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
802 elseif msg =~ '^=thread-group-started' |
28141 | 803 call s:HandleProgramRun(msg) |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
804 elseif msg =~ '^\^done,value=' |
28141 | 805 call s:HandleEvaluate(msg) |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
806 elseif msg =~ '^\^error,msg=' |
28141 | 807 call s:HandleError(msg) |
23573 | 808 elseif msg =~ '^disassemble' |
28141 | 809 let s:parsing_disasm_msg = 1 |
810 let s:asm_lines = [] | |
12395
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
811 endif |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
812 endif |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
813 endfor |
39e1087e7094
patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12254
diff
changeset
|
814 endfunc |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
815 |
18130 | 816 func s:GotoProgram() |
817 if has('win32') | |
818 if executable('powershell') | |
819 call system(printf('powershell -Command "add-type -AssemblyName microsoft.VisualBasic;[Microsoft.VisualBasic.Interaction]::AppActivate(%d);"', s:pid)) | |
820 endif | |
821 else | |
18878
ef90e5bbb971
Minor runtime file updates.
Bram Moolenaar <Bram@vim.org>
parents:
18750
diff
changeset
|
822 call win_gotoid(s:ptywin) |
18130 | 823 endif |
824 endfunc | |
825 | |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
826 " 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
|
827 func s:InstallCommands() |
14360
e91659ae6614
patch 8.1.0195: terminal debugger commands don't always work
Christian Brabandt <cb@256bit.org>
parents:
14356
diff
changeset
|
828 let save_cpo = &cpo |
e91659ae6614
patch 8.1.0195: terminal debugger commands don't always work
Christian Brabandt <cb@256bit.org>
parents:
14356
diff
changeset
|
829 set cpo&vim |
e91659ae6614
patch 8.1.0195: terminal debugger commands don't always work
Christian Brabandt <cb@256bit.org>
parents:
14356
diff
changeset
|
830 |
18130 | 831 command -nargs=? Break call s:SetBreakpoint(<q-args>) |
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
|
832 command Clear call s:ClearBreakpoint() |
26438 | 833 command Step call s:SendResumingCommand('-exec-step') |
834 command Over call s:SendResumingCommand('-exec-next') | |
28517 | 835 command -nargs=? Until call s:Until(<q-args>) |
26438 | 836 command Finish call s:SendResumingCommand('-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
|
837 command -nargs=* Run call s:Run(<q-args>) |
26438 | 838 command -nargs=* Arguments call s:SendResumingCommand('-exec-arguments ' . <q-args>) |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
839 |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
840 if s:way == 'prompt' |
26219 | 841 command Stop call s:PromptInterrupt() |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
842 command Continue call s:SendCommand('continue') |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
843 else |
26219 | 844 command Stop call s:SendCommand('-exec-interrupt') |
845 " using -exec-continue results in CTRL-C in the gdb window not working, | |
846 " communicating via commbuf (= use of SendCommand) has the same result | |
847 "command Continue call s:SendCommand('-exec-continue') | |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
848 command Continue call term_sendkeys(s:gdbbuf, "continue\r") |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
849 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
850 |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
851 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
|
852 command Gdb call win_gotoid(s:gdbwin) |
18130 | 853 command Program call s:GotoProgram() |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
854 command Source call s:GotoSourcewinOrCreateIt() |
23573 | 855 command Asm call s:GotoAsmwinOrCreateIt() |
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
|
856 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
|
857 |
20552 | 858 if !exists('g:termdebug_map_K') || g:termdebug_map_K |
859 let s:k_map_saved = maparg('K', 'n', 0, 1) | |
860 nnoremap K :Evaluate<CR> | |
861 endif | |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
862 |
13051 | 863 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
|
864 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
|
865 |
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
|
866 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
|
867 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
|
868 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
|
869 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
|
870 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
|
871 an 1.220 PopUp.Clear\ breakpoint :Clear<CR> |
28517 | 872 an 1.230 PopUp.Run\ until :Until<CR> |
873 an 1.240 PopUp.Evaluate :Evaluate<CR> | |
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
|
874 endif |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
875 endif |
14360
e91659ae6614
patch 8.1.0195: terminal debugger commands don't always work
Christian Brabandt <cb@256bit.org>
parents:
14356
diff
changeset
|
876 |
e91659ae6614
patch 8.1.0195: terminal debugger commands don't always work
Christian Brabandt <cb@256bit.org>
parents:
14356
diff
changeset
|
877 let &cpo = save_cpo |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
878 endfunc |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
879 |
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
|
880 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
|
881 |
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
|
882 " 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
|
883 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
|
884 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
|
885 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
|
886 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
|
887 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
|
888 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
|
889 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
|
890 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
|
891 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
|
892 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
|
893 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
|
894 |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
895 " 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
|
896 func s:DeleteCommands() |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
897 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
|
898 delcommand Clear |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
899 delcommand Step |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
900 delcommand Over |
28517 | 901 delcommand Until |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
902 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
|
903 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
|
904 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
|
905 delcommand Stop |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
906 delcommand Continue |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
907 delcommand Evaluate |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
908 delcommand Gdb |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
909 delcommand Program |
13682
fc660a6ef37d
patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents:
13592
diff
changeset
|
910 delcommand Source |
23573 | 911 delcommand Asm |
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
|
912 delcommand Winbar |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
913 |
23164 | 914 if exists('s:k_map_saved') |
915 if empty(s:k_map_saved) | |
916 nunmap K | |
917 else | |
28777 | 918 call mapset(s:k_map_saved) |
23164 | 919 endif |
20552 | 920 unlet s:k_map_saved |
921 endif | |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
922 |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
923 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
|
924 " 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
|
925 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
|
926 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
|
927 if win_gotoid(winid) |
18130 | 928 aunmenu WinBar.Step |
929 aunmenu WinBar.Next | |
930 aunmenu WinBar.Finish | |
931 aunmenu WinBar.Cont | |
932 aunmenu WinBar.Stop | |
933 aunmenu WinBar.Eval | |
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
|
934 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
|
935 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
|
936 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
|
937 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
|
938 |
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
|
939 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
|
940 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
|
941 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
|
942 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
|
943 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
|
944 aunmenu PopUp.Clear\ breakpoint |
28517 | 945 aunmenu PopUp.Run\ until |
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
|
946 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
|
947 endif |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
948 endif |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
949 |
28517 | 950 call sign_unplace('TermDebug') |
14143
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
951 unlet s:breakpoints |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
952 unlet s:breakpoint_locations |
14143
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
953 |
28517 | 954 call sign_undefine('debugPC') |
955 call sign_undefine(s:BreakpointSigns->map("'debugBreakpoint' .. v:val")) | |
14147
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
956 let s:BreakpointSigns = [] |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
957 endfunc |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
958 |
28517 | 959 " :Until - Execute until past a specified position or current line |
960 func s:Until(at) | |
961 if s:stopped | |
962 " reset s:stopped here, it may take a bit of time before we get a response | |
963 let s:stopped = 0 | |
964 call ch_log('assume that program is running after this command') | |
965 " Use the fname:lnum format | |
966 let at = empty(a:at) ? | |
967 \ fnameescape(expand('%:p')) . ':' . line('.') : a:at | |
968 call s:SendCommand('-exec-until ' . at) | |
969 else | |
970 call ch_log('dropping command, program is running: exec-until') | |
971 endif | |
972 endfunc | |
973 | |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
974 " :Break - Set a breakpoint at the cursor position. |
18130 | 975 func s:SetBreakpoint(at) |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
976 " 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
|
977 " 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
|
978 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
|
979 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
|
980 let do_continue = 1 |
26219 | 981 Stop |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
982 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
|
983 endif |
18130 | 984 |
14143
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
985 " Use the fname:lnum format, older gdb can't handle --source. |
18130 | 986 let at = empty(a:at) ? |
26219 | 987 \ fnameescape(expand('%:p')) . ':' . line('.') : a:at |
18130 | 988 call s:SendCommand('-break-insert ' . at) |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
989 if do_continue |
26219 | 990 Continue |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
991 endif |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
992 endfunc |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
993 |
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
|
994 " :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
|
995 func s:ClearBreakpoint() |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
996 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
|
997 let lnum = line('.') |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
998 let bploc = printf('%s:%d', fname, lnum) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
999 if has_key(s:breakpoint_locations, bploc) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1000 let idx = 0 |
26219 | 1001 let nr = 0 |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1002 for id in s:breakpoint_locations[bploc] |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1003 if has_key(s:breakpoints, id) |
28141 | 1004 " Assume this always works, the reply is simply "^done". |
1005 call s:SendCommand('-break-delete ' . id) | |
1006 for subid in keys(s:breakpoints[id]) | |
28517 | 1007 call sign_unplace('TermDebug', |
1008 \ #{id: s:Breakpoint2SignNumber(id, subid)}) | |
28141 | 1009 endfor |
1010 unlet s:breakpoints[id] | |
1011 unlet s:breakpoint_locations[bploc][idx] | |
1012 let nr = id | |
1013 break | |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1014 else |
28141 | 1015 let idx += 1 |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1016 endif |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1017 endfor |
26219 | 1018 if nr != 0 |
1019 if empty(s:breakpoint_locations[bploc]) | |
28141 | 1020 unlet s:breakpoint_locations[bploc] |
26219 | 1021 endif |
1022 echomsg 'Breakpoint ' . id . ' cleared from line ' . lnum . '.' | |
1023 else | |
1024 echoerr 'Internal error trying to remove breakpoint at line ' . lnum . '!' | |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1025 endif |
26219 | 1026 else |
1027 echomsg 'No breakpoint to remove at line ' . lnum . '.' | |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1028 endif |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1029 endfunc |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1030 |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
1031 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
|
1032 if a:args != '' |
26438 | 1033 call s:SendResumingCommand('-exec-arguments ' . a:args) |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
1034 endif |
26438 | 1035 call s:SendResumingCommand('-exec-run') |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
1036 endfunc |
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
1037 |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1038 func s:SendEval(expr) |
26219 | 1039 " check for "likely" boolean expressions, in which case we take it as lhs |
1040 if a:expr =~ "[=!<>]=" | |
1041 let exprLHS = a:expr | |
1042 else | |
1043 " remove text that is likely an assignment | |
1044 let exprLHS = substitute(a:expr, ' *=.*', '', '') | |
1045 endif | |
28141 | 1046 |
26219 | 1047 " encoding expression to prevent bad errors |
26100 | 1048 let expr = a:expr |
26219 | 1049 let expr = substitute(expr, '\\', '\\\\', 'g') |
1050 let expr = substitute(expr, '"', '\\"', 'g') | |
26100 | 1051 call s:SendCommand('-data-evaluate-expression "' . expr . '"') |
26219 | 1052 let s:evalexpr = exprLHS |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1053 endfunc |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1054 |
28141 | 1055 " :Evaluate - evaluate what is specified / under the cursor |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1056 func s:Evaluate(range, arg) |
26219 | 1057 let expr = s:GetEvaluationExpression(a:range, a:arg) |
1058 let s:ignoreEvalError = 0 | |
1059 call s:SendEval(expr) | |
1060 endfunc | |
1061 | |
28141 | 1062 " get what is specified / under the cursor |
26219 | 1063 func s:GetEvaluationExpression(range, arg) |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1064 if a:arg != '' |
26219 | 1065 " user supplied evaluation |
1066 let expr = s:CleanupExpr(a:arg) | |
1067 " DSW: replace "likely copy + paste" assignment | |
1068 let expr = substitute(expr, '"\([^"]*\)": *', '\1=', 'g') | |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1069 elseif a:range == 2 |
26219 | 1070 " no evaluation but provided but range set |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1071 let pos = getcurpos() |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1072 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
|
1073 let regt = getregtype('v') |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1074 normal! gv"vy |
26219 | 1075 let expr = s:CleanupExpr(@v) |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1076 call setpos('.', pos) |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1077 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
|
1078 else |
26219 | 1079 " no evaluation provided: get from C-expression under cursor |
1080 " TODO: allow filetype specific lookup #9057 | |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1081 let expr = expand('<cexpr>') |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1082 endif |
26219 | 1083 return expr |
1084 endfunc | |
1085 | |
27036 | 1086 " clean up expression that may get in because of range |
26219 | 1087 " (newlines and surrounding whitespace) |
26304 | 1088 " As it can also be specified via ex-command for assignments this function |
27036 | 1089 " may not change the "content" parts (like replacing contained spaces) |
26219 | 1090 func s:CleanupExpr(expr) |
1091 " replace all embedded newlines/tabs/... | |
26304 | 1092 let expr = substitute(a:expr, '\_s', ' ', 'g') |
26219 | 1093 |
1094 if &filetype ==# 'cobol' | |
26304 | 1095 " extra cleanup for COBOL: |
1096 " - a semicolon nmay be used instead of a space | |
1097 " - a trailing comma or period is ignored as it commonly separates/ends | |
1098 " multiple expr | |
26219 | 1099 let expr = substitute(expr, ';', ' ', 'g') |
26304 | 1100 let expr = substitute(expr, '[,.]\+ *$', '', '') |
26219 | 1101 endif |
1102 | |
26304 | 1103 " get rid of leading and trailing spaces |
1104 let expr = substitute(expr, '^ *', '', '') | |
1105 let expr = substitute(expr, ' *$', '', '') | |
26219 | 1106 return expr |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1107 endfunc |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1108 |
13341
acd7eaa13d2b
Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
1109 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
|
1110 let s:evalFromBalloonExpr = 0 |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1111 |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1112 " 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
|
1113 func s:HandleEvaluate(msg) |
26591 | 1114 let value = a:msg |
1115 \ ->substitute('.*value="\(.*\)"', '\1', '') | |
1116 \ ->substitute('\\"', '"', 'g') | |
1117 \ ->substitute('\\\\', '\\', 'g') | |
27036 | 1118 "\ multi-byte characters arrive in octal form, replace everything but NULL values |
26591 | 1119 \ ->substitute('\\000', s:NullRepl, 'g') |
1120 \ ->substitute('\\\o\o\o', {-> eval('"' .. submatch(0) .. '"')}, 'g') | |
1121 "\ Note: GDB docs also mention hex encodings - the translations below work | |
1122 "\ but we keep them out for performance-reasons until we actually see | |
1123 "\ those in mi-returns | |
1124 "\ ->substitute('\\0x00', s:NullRep, 'g') | |
1125 "\ ->substitute('\\0x\(\x\x\)', {-> eval('"\x' .. submatch(1) .. '"')}, 'g') | |
1126 \ ->substitute(s:NullRepl, '\\000', 'g') | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1127 if s:evalFromBalloonExpr |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1128 if s:evalFromBalloonExprResult == '' |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1129 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
|
1130 else |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1131 let s:evalFromBalloonExprResult .= ' = ' . value |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1132 endif |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1133 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
|
1134 else |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1135 echomsg '"' . s:evalexpr . '": ' . value |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1136 endif |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
1137 |
12826 | 1138 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
|
1139 " Looks like a pointer, also display what it points to. |
13341
acd7eaa13d2b
Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
1140 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
|
1141 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
|
1142 else |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1143 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
|
1144 endif |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1145 endfunc |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1146 |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1147 " 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
|
1148 " if there is any. |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1149 func TermDebugBalloonExpr() |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
1150 if v:beval_winid != s:sourcewin |
17372 | 1151 return '' |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
1152 endif |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
1153 if !s:stopped |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
1154 " Only evaluate when stopped, otherwise setting a breakpoint using the |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
1155 " mouse triggers a balloon. |
17372 | 1156 return '' |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1157 endif |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1158 let s:evalFromBalloonExpr = 1 |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1159 let s:evalFromBalloonExprResult = '' |
13341
acd7eaa13d2b
Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
1160 let s:ignoreEvalError = 1 |
26219 | 1161 let expr = s:CleanupExpr(v:beval_text) |
1162 call s:SendEval(expr) | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1163 return '' |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1164 endfunc |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1165 |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1166 " Handle an error. |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1167 func s:HandleError(msg) |
13341
acd7eaa13d2b
Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
1168 if s:ignoreEvalError |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1169 " Result of s:SendEval() failed, ignore. |
13341
acd7eaa13d2b
Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
1170 let s:ignoreEvalError = 0 |
acd7eaa13d2b
Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
1171 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
|
1172 return |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12833
diff
changeset
|
1173 endif |
26100 | 1174 let msgVal = substitute(a:msg, '.*msg="\(.*\)"', '\1', '') |
1175 echoerr substitute(msgVal, '\\"', '"', 'g') | |
12425
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1176 endfunc |
29d21591ad6b
patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents:
12411
diff
changeset
|
1177 |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
1178 func s:GotoSourcewinOrCreateIt() |
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
1179 if !win_gotoid(s:sourcewin) |
13592
a64485061f75
patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents:
13564
diff
changeset
|
1180 new |
14107
274c9f1fbfd2
patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents:
13706
diff
changeset
|
1181 let s:sourcewin = win_getid(winnr()) |
13592
a64485061f75
patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents:
13564
diff
changeset
|
1182 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
|
1183 endif |
a64485061f75
patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents:
13564
diff
changeset
|
1184 endfunc |
a64485061f75
patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents:
13564
diff
changeset
|
1185 |
23573 | 1186 func s:GotoAsmwinOrCreateIt() |
1187 if !win_gotoid(s:asmwin) | |
1188 if win_gotoid(s:sourcewin) | |
1189 exe 'rightbelow new' | |
1190 else | |
1191 exe 'new' | |
1192 endif | |
1193 | |
1194 let s:asmwin = win_getid(winnr()) | |
1195 | |
1196 setlocal nowrap | |
1197 setlocal number | |
1198 setlocal noswapfile | |
1199 setlocal buftype=nofile | |
26148 | 1200 setlocal modifiable |
23573 | 1201 |
1202 let asmbuf = bufnr('Termdebug-asm-listing') | |
1203 if asmbuf > 0 | |
1204 exe 'buffer' . asmbuf | |
1205 else | |
1206 exe 'file Termdebug-asm-listing' | |
1207 endif | |
1208 | |
1209 if exists('g:termdebug_disasm_window') | |
1210 if g:termdebug_disasm_window > 1 | |
28141 | 1211 exe 'resize ' . g:termdebug_disasm_window |
23573 | 1212 endif |
1213 endif | |
1214 endif | |
1215 | |
1216 if s:asm_addr != '' | |
1217 let lnum = search('^' . s:asm_addr) | |
1218 if lnum == 0 | |
1219 if s:stopped | |
28141 | 1220 call s:SendCommand('disassemble $pc') |
23573 | 1221 endif |
1222 else | |
28517 | 1223 call sign_unplace('TermDebug', #{id: s:asm_id}) |
1224 call sign_place(s:asm_id, 'TermDebug', 'debugPC', '%', #{lnum: lnum}) | |
23573 | 1225 endif |
1226 endif | |
1227 endfunc | |
1228 | |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1229 " 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
|
1230 " 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
|
1231 func s:HandleCursor(msg) |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1232 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
|
1233 |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
1234 if a:msg =~ '^\*stopped' |
14147
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
1235 call ch_log('program stopped') |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
1236 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
|
1237 elseif a:msg =~ '^\*running' |
14147
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
1238 call ch_log('program running') |
12833
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
1239 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
|
1240 endif |
db9ffed7e1fc
patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents:
12826
diff
changeset
|
1241 |
14143
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
1242 if a:msg =~ 'fullname=' |
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
1243 let fname = s:GetFullname(a:msg) |
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
1244 else |
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
1245 let fname = '' |
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
1246 endif |
23573 | 1247 |
1248 if a:msg =~ 'addr=' | |
1249 let asm_addr = s:GetAsmAddr(a:msg) | |
1250 if asm_addr != '' | |
1251 let s:asm_addr = asm_addr | |
1252 | |
1253 let curwinid = win_getid(winnr()) | |
1254 if win_gotoid(s:asmwin) | |
28141 | 1255 let lnum = search('^' . s:asm_addr) |
1256 if lnum == 0 | |
1257 call s:SendCommand('disassemble $pc') | |
1258 else | |
28517 | 1259 call sign_unplace('TermDebug', #{id: s:asm_id}) |
1260 call sign_place(s:asm_id, 'TermDebug', 'debugPC', '%', #{lnum: lnum}) | |
28141 | 1261 endif |
23573 | 1262 |
28141 | 1263 call win_gotoid(curwinid) |
23573 | 1264 endif |
1265 endif | |
1266 endif | |
1267 | |
13592
a64485061f75
patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents:
13564
diff
changeset
|
1268 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
|
1269 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
|
1270 if lnum =~ '^[0-9]*$' |
27162 | 1271 call s:GotoSourcewinOrCreateIt() |
13592
a64485061f75
patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents:
13564
diff
changeset
|
1272 if expand('%:p') != fnamemodify(fname, ':p') |
27321 | 1273 echomsg 'different fname: "' .. expand('%:p') .. '" vs "' .. fnamemodify(fname, ':p') .. '"' |
27162 | 1274 augroup Termdebug |
1275 " Always open a file read-only instead of showing the ATTENTION | |
1276 " prompt, since we are unlikely to want to edit the file. | |
1277 " The file may be changed but not saved, warn for that. | |
1278 au SwapExists * echohl WarningMsg | |
1279 \ | echo 'Warning: file is being edited elsewhere' | |
1280 \ | echohl None | |
1281 \ | let v:swapchoice = '0' | |
28141 | 1282 augroup END |
1283 if &modified | |
1284 " TODO: find existing window | |
1285 exe 'split ' . fnameescape(fname) | |
1286 let s:sourcewin = win_getid(winnr()) | |
1287 call s:InstallWinbar() | |
1288 else | |
1289 exe 'edit ' . fnameescape(fname) | |
1290 endif | |
1291 augroup Termdebug | |
1292 au! SwapExists | |
1293 augroup END | |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1294 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
|
1295 exe lnum |
26148 | 1296 normal! zv |
28517 | 1297 call sign_unplace('TermDebug', #{id: s:pc_id}) |
1298 call sign_place(s:pc_id, 'TermDebug', 'debugPC', fname, | |
1299 \ #{lnum: lnum, priority: 110}) | |
22723 | 1300 if !exists('b:save_signcolumn') |
28141 | 1301 let b:save_signcolumn = &signcolumn |
1302 call add(s:signcolumn_buflist, bufnr()) | |
22723 | 1303 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
|
1304 setlocal signcolumn=yes |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1305 endif |
14147
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
1306 elseif !s:stopped || fname != '' |
28517 | 1307 call sign_unplace('TermDebug', #{id: 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
|
1308 endif |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1309 |
13592
a64485061f75
patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents:
13564
diff
changeset
|
1310 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
|
1311 endfunc |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1312 |
14143
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
1313 let s:BreakpointSigns = [] |
2aec369c4fc3
patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14127
diff
changeset
|
1314 |
26304 | 1315 func s:CreateBreakpoint(id, subid, enabled) |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1316 let nr = printf('%d.%d', a:id, a:subid) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1317 if index(s:BreakpointSigns, nr) == -1 |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1318 call add(s:BreakpointSigns, nr) |
26304 | 1319 if a:enabled == "n" |
1320 let hiName = "debugBreakpointDisabled" | |
1321 else | |
1322 let hiName = "debugBreakpoint" | |
1323 endif | |
28517 | 1324 call sign_define('debugBreakpoint' .. nr, |
1325 \ #{text: substitute(nr, '\..*', '', ''), | |
1326 \ texthl: hiName}) | |
14126
1ce45478cbf1
patch 8.1.0080: can't see the breakpoint number in the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14107
diff
changeset
|
1327 endif |
1ce45478cbf1
patch 8.1.0080: can't see the breakpoint number in the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14107
diff
changeset
|
1328 endfunc |
1ce45478cbf1
patch 8.1.0080: can't see the breakpoint number in the terminal debugger
Christian Brabandt <cb@256bit.org>
parents:
14107
diff
changeset
|
1329 |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1330 func! s:SplitMsg(s) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1331 return split(a:s, '{.\{-}}\zs') |
15093
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1332 endfunction |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1333 |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1334 " Handle setting a breakpoint |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1335 " Will update the sign that shows the breakpoint |
26304 | 1336 func s:HandleNewBreakpoint(msg, modifiedFlag) |
14165
5b5364d0729d
patch 8.1.0100: terminal debugger: error when setting a watch point
Christian Brabandt <cb@256bit.org>
parents:
14151
diff
changeset
|
1337 if a:msg !~ 'fullname=' |
26219 | 1338 " a watch or a pending breakpoint does not have a file name |
1339 if a:msg =~ 'pending=' | |
1340 let nr = substitute(a:msg, '.*number=\"\([0-9.]*\)\".*', '\1', '') | |
1341 let target = substitute(a:msg, '.*pending=\"\([^"]*\)\".*', '\1', '') | |
1342 echomsg 'Breakpoint ' . nr . ' (' . target . ') pending.' | |
1343 endif | |
14165
5b5364d0729d
patch 8.1.0100: terminal debugger: error when setting a watch point
Christian Brabandt <cb@256bit.org>
parents:
14151
diff
changeset
|
1344 return |
5b5364d0729d
patch 8.1.0100: terminal debugger: error when setting a watch point
Christian Brabandt <cb@256bit.org>
parents:
14151
diff
changeset
|
1345 endif |
15093
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1346 for msg in s:SplitMsg(a:msg) |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1347 let fname = s:GetFullname(msg) |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1348 if empty(fname) |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1349 continue |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1350 endif |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1351 let nr = substitute(msg, '.*number="\([0-9.]*\)\".*', '\1', '') |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1352 if empty(nr) |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1353 return |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1354 endif |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1355 |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1356 " If "nr" is 123 it becomes "123.0" and subid is "0". |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1357 " If "nr" is 123.4 it becomes "123.4.0" and subid is "4"; "0" is discarded. |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1358 let [id, subid; _] = map(split(nr . '.0', '\.'), 'v:val + 0') |
26304 | 1359 let enabled = substitute(msg, '.*enabled="\([yn]\)".*', '\1', '') |
1360 call s:CreateBreakpoint(id, subid, enabled) | |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1361 |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1362 if has_key(s:breakpoints, id) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1363 let entries = s:breakpoints[id] |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1364 else |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1365 let entries = {} |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1366 let s:breakpoints[id] = entries |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1367 endif |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1368 if has_key(entries, subid) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1369 let entry = entries[subid] |
15093
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1370 else |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1371 let entry = {} |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1372 let entries[subid] = entry |
15093
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1373 endif |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1374 |
15093
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1375 let lnum = substitute(msg, '.*line="\([^"]*\)".*', '\1', '') |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1376 let entry['fname'] = fname |
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1377 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
|
1378 |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1379 let bploc = printf('%s:%d', fname, lnum) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1380 if !has_key(s:breakpoint_locations, bploc) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1381 let s:breakpoint_locations[bploc] = [] |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1382 endif |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1383 let s:breakpoint_locations[bploc] += [id] |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1384 |
15093
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1385 if bufloaded(fname) |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1386 call s:PlaceSign(id, subid, entry) |
26304 | 1387 let posMsg = ' at line ' . lnum . '.' |
1388 else | |
1389 let posMsg = ' in ' . fname . ' at line ' . lnum . '.' | |
15093
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1390 endif |
26304 | 1391 if !a:modifiedFlag |
1392 let actionTaken = 'created' | |
1393 elseif enabled == 'n' | |
1394 let actionTaken = 'disabled' | |
1395 else | |
1396 let actionTaken = 'enabled' | |
1397 endif | |
1398 echomsg 'Breakpoint ' . nr . ' ' . actionTaken . posMsg | |
15093
8690318105ee
patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
1399 endfor |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
1400 endfunc |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
1401 |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1402 func s:PlaceSign(id, subid, entry) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1403 let nr = printf('%d.%d', a:id, a:subid) |
28517 | 1404 call sign_place(s:Breakpoint2SignNumber(a:id, a:subid), 'TermDebug', |
1405 \ 'debugBreakpoint' .. nr, a:entry['fname'], | |
1406 \ #{lnum: a:entry['lnum'], priority: 110}) | |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
1407 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
|
1408 endfunc |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1409 |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1410 " Handle deleting a breakpoint |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1411 " 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
|
1412 func s:HandleBreakpointDelete(msg) |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1413 let id = substitute(a:msg, '.*id="\([0-9]*\)\".*', '\1', '') + 0 |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1414 if empty(id) |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1415 return |
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1416 endif |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1417 if has_key(s:breakpoints, id) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1418 for [subid, entry] in items(s:breakpoints[id]) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1419 if has_key(entry, 'placed') |
28517 | 1420 call sign_unplace('TermDebug', |
1421 \ #{id: s:Breakpoint2SignNumber(id, subid)}) | |
28141 | 1422 unlet entry['placed'] |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1423 endif |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1424 endfor |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1425 unlet s:breakpoints[id] |
26219 | 1426 echomsg 'Breakpoint ' . id . ' cleared.' |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1427 endif |
12411
5d4d744151c2
patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents:
12395
diff
changeset
|
1428 endfunc |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
1429 |
14147
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
1430 " Handle the debugged program starting to run. |
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
1431 " Will store the process ID in s:pid |
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
1432 func s:HandleProgramRun(msg) |
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
1433 let nr = substitute(a:msg, '.*pid="\([0-9]*\)\".*', '\1', '') + 0 |
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
1434 if nr == 0 |
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
1435 return |
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
1436 endif |
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
1437 let s:pid = nr |
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
1438 call ch_log('Detected process ID: ' . s:pid) |
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
1439 endfunc |
de75c249723d
patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents:
14143
diff
changeset
|
1440 |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
1441 " 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
|
1442 func s:BufRead() |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
1443 let fname = expand('<afile>:p') |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1444 for [id, entries] in items(s:breakpoints) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1445 for [subid, entry] in items(entries) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1446 if entry['fname'] == fname |
28141 | 1447 call s:PlaceSign(id, subid, entry) |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1448 endif |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1449 endfor |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
1450 endfor |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
1451 endfunc |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
1452 |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
1453 " 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
|
1454 func s:BufUnloaded() |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
1455 let fname = expand('<afile>:p') |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1456 for [id, entries] in items(s:breakpoints) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1457 for [subid, entry] in items(entries) |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1458 if entry['fname'] == fname |
28141 | 1459 let entry['placed'] = 0 |
15129
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1460 endif |
2090f267b311
patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents:
15093
diff
changeset
|
1461 endfor |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
1462 endfor |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12455
diff
changeset
|
1463 endfunc |
14356
9339e4dbf6bf
patch 8.1.0193: terminal debugger buttons don't always work
Christian Brabandt <cb@256bit.org>
parents:
14165
diff
changeset
|
1464 |
9339e4dbf6bf
patch 8.1.0193: terminal debugger buttons don't always work
Christian Brabandt <cb@256bit.org>
parents:
14165
diff
changeset
|
1465 let &cpo = s:keepcpo |
9339e4dbf6bf
patch 8.1.0193: terminal debugger buttons don't always work
Christian Brabandt <cb@256bit.org>
parents:
14165
diff
changeset
|
1466 unlet s:keepcpo |