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