annotate runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @ 28976:ad63d6a8ed21 v8.2.5010

patch 8.2.5010: the terminal debugger uses various global variables Commit: https://github.com/vim/vim/commit/c9a431c7638ecebb6f2cb3eabd0e1b2b5e269c1e Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 23 21:49:41 2022 +0100 patch 8.2.5010: the terminal debugger uses various global variables Problem: The terminal debugger uses various global variables. Solution: Add a dictionary to hold the terminal debugger preferences.
author Bram Moolenaar <Bram@vim.org>
date Mon, 23 May 2022 23:00:04 +0200
parents 0f0fed554cdc
children 0fdf36de4018
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
1 " Debugger plugin using gdb.
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 "
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"
28976
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
5 " Last Change: 2022 May 23
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
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
7 " WORK IN PROGRESS - The basics works stable, more to come
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
8 " Note: In general you need at least GDB 7.12 because this provides the
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
9 " frame= response in MI thread-selected events we need to sync stack to file.
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
10 " The one included with "old" MingW is too old (7.6.1), you may upgrade it or
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
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
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
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
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
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
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
39 if exists(':Termdebug')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
40 finish
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
41 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
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
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
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
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
69 let s:asm_id = 13
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
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
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
73 let s:parsing_disasm_msg = 0
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
74 let s:asm_lines = []
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
75 let s:asm_addr = ''
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
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
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
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
f0d7cb510ce3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26591
diff changeset
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
f0d7cb510ce3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26591
diff changeset
108 endfunc
f0d7cb510ce3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26591
diff changeset
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
f0d7cb510ce3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26591
diff changeset
125 let gdbcmd = s:GetCommand()
f0d7cb510ce3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26591
diff changeset
126 if !executable(gdbcmd[0])
f0d7cb510ce3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26591
diff changeset
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
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
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
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
135 if exists('#User#TermdebugStartPre')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
136 doauto <nomodeline> User TermdebugStartPre
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
137 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
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
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
143
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
144 " Remember the old value of 'signcolumn' for each buffer that it's set in, so
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
145 " that we can restore the value for all buffers.
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
146 let b:save_signcolumn = &signcolumn
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
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
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
149 let s:save_columns = 0
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
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
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
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
3e661b0cf500 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
161 " If we make the Vim window wider, use the whole left half for the debug
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
162 " windows.
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
163 let s:allleft = 1
12559
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
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
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
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
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
193 endif
25619
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
194
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
195 if exists('#User#TermdebugStartPost')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
196 doauto <nomodeline> User TermdebugStartPost
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
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
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
207 func s:CheckGdbRunning()
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
208 let gdbproc = term_getjob(s:gdbbuf)
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
209 if gdbproc == v:null || job_status(gdbproc) !=# 'run'
26708
f0d7cb510ce3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26591
diff changeset
210 echoerr string(s:GetCommand()[0]) . ' exited unexpectedly'
24751
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
211 call s:CloseBuffers()
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
212 return ''
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
213 endif
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
214 return 'ok'
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
215 endfunc
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
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
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
220 \ 'term_name': 'debugged program',
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
221 \ 'vertical': s:vertical,
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
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
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
233 if s:allleft
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
234 " use the whole left column
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
235 wincmd H
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
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
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
241 \ 'term_name': 'gdb communication',
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
242 \ 'out_cb': function('s:CommOutput'),
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
243 \ 'hidden': 1,
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
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
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
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
f0d7cb510ce3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26591
diff changeset
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
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
278
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
279 " Adding arguments requested by the user
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
280 let gdb_cmd += gdb_args
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
281
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
282 call ch_log('executing "' . join(gdb_cmd) . '"')
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
283 let s:gdbbuf = term_start(gdb_cmd, {
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
284 \ 'term_finish': 'close',
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
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
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
293 " Wait for the "startupdone" message before sending any commands.
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
294 let try_count = 0
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
295 while 1
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
296 if s:CheckGdbRunning() != 'ok'
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
297 return
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
298 endif
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
299
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
300 for lnum in range(1, 200)
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
301 if term_getline(s:gdbbuf, lnum) =~ 'startupdone'
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
302 let try_count = 9999
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
303 break
24751
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
304 endif
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
305 endfor
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
306 let try_count += 1
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
307 if try_count > 300
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
308 " done or give up after five seconds
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
309 break
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
310 endif
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
311 sleep 10m
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
312 endwhile
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
313
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
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
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
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
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
319 " Connect gdb to the communication pty, using the GDB/MI interface.
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
320 " Prefix "server" to avoid adding this to the history.
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
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
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
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
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
336 " response can be in the same line or the next line
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
337 let response = line1 . line2
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
338 if response =~ 'Undefined command'
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
339 echoerr 'Sorry, your gdb is too old, gdb 7.12 is required'
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
340 " CHECKME: possibly send a "server show version" here
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
341 call s:CloseBuffers()
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
342 return
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
343 endif
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
344 if response =~ 'New UI allocated'
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
345 " Success!
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
346 break
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
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
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
349 " Reading symbols might take a while, try more times
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
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
e69e7133c9cf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24636
diff changeset
364 call job_setoptions(term_getjob(s:gdbbuf), {'exit_cb': function('s:EndTermDebug')})
25700
d4faa2c5211b Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
365
d4faa2c5211b Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
366 " Set the filetype, this can be used to add mappings.
d4faa2c5211b Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
367 set filetype=termdebug
d4faa2c5211b Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
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
f0d7cb510ce3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26591
diff changeset
396 let gdb_cmd = s:GetCommand()
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
397 " Add -quiet to avoid the intro message causing a hit-enter prompt.
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
398 let gdb_cmd += ['-quiet']
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
399 " Disable pagination, it causes everything to stop at the gdb, needs to be run early
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
400 let gdb_cmd += ['-iex', 'set pagination off']
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
401 " Interpret commands while the target is running. This should usually only
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
402 " be exec-interrupt, since many commands don't work properly while the
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
403 " target is running (so execute during startup).
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
404 let gdb_cmd += ['-iex', 'set mi-async on']
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
405 " directly communicate via mi2
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
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
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
408 " Adding arguments requested by the user
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
409 let gdb_cmd += gdb_args
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
410
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
411 call ch_log('executing "' . join(gdb_cmd) . '"')
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
412 let s:gdbjob = job_start(gdb_cmd, {
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
413 \ 'exit_cb': function('s:EndPromptDebug'),
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
414 \ 'out_cb': function('s:GdbOutCallback'),
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
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
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
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
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
433 \ 'term_name': 'debugged program',
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
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
3e661b0cf500 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
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
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
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
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26304
diff changeset
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
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
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
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
537 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
538 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
539 Continue
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
540 endif
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 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
543
26438
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26304
diff changeset
544 " Send a command that resumes the program. If the program isn't stopped the
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26304
diff changeset
545 " command is not sent (to avoid a repeated command to cause trouble).
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26304
diff changeset
546 " If the command is sent then reset s:stopped.
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26304
diff changeset
547 func s:SendResumingCommand(cmd)
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
548 if s:stopped
26438
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26304
diff changeset
549 " reset s:stopped here, it may take a bit of time before we get a response
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26304
diff changeset
550 let s:stopped = 0
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26304
diff changeset
551 call ch_log('assume that program is running after this command')
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
552 call s:SendCommand(a:cmd)
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
553 else
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
554 call ch_log('dropping command, program is running: ' . a:cmd)
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
555 endif
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
556 endfunc
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
557
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
558 " 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
559 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
560 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
561 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
562
14147
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14143
diff changeset
563 " 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
564 " breakpoint.
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
565 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
566 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
567 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
568 " 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
569 " 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
570 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
571 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
572 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
573 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
574 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
575 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
576 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
577 endif
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
578 endfunc
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
579
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
580 " 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
581 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
582 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
583
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
584 " 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
585 " 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
586 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
587 return
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
588 endif
26100
babd9f1dbe12 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25700
diff changeset
589 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
590 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
591 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
592 " 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
593 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
594 return
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
595 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
596 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
597 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
598 else
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
599 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
600 return
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
601 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
602
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
603 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
604 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
605
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
606 " 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
607 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
608 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
609
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
610 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
611 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
612
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
613 " Decode a message from gdb. quotedText starts with a ", return the text up
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
614 " to the next ", unescaping characters:
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
615 " - remove line breaks
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
616 " - change \\t to \t
26591
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
617 " - change \0xhh to \xhh (disabled for now)
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
618 " - change \ooo to octal
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
619 " - 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
620 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
621 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
622 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
623 return
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
624 endif
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
625 return a:quotedText
26591
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
626 \ ->substitute('^"\|".*\|\\n', '', 'g')
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
627 \ ->substitute('\\t', "\t", 'g')
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
628 " multi-byte characters arrive in octal form
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
629 " NULL-values must be kept encoded as those break the string otherwise
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
630 \ ->substitute('\\000', s:NullRepl, 'g')
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
631 \ ->substitute('\\\o\o\o', {-> eval('"' .. submatch(0) .. '"')}, 'g')
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
632 " Note: GDB docs also mention hex encodings - the translations below work
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
633 " but we keep them out for performance-reasons until we actually see
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
634 " those in mi-returns
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
635 " \ ->substitute('\\0x\(\x\x\)', {-> eval('"\x' .. submatch(1) .. '"')}, 'g')
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
636 " \ ->substitute('\\0x00', s:NullRepl, 'g')
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
637 \ ->substitute('\\\\', '\', 'g')
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
638 \ ->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
639 endfunc
26591
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
640 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
641
14143
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
642 " 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
643 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
644 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
645 return ''
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
646 endif
14143
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
647 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
648 if has('win32') && name =~ ':\\\\'
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
649 " 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
650 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
651 endif
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
652 return name
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
653 endfunc
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
654
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
655 " Extract the "addr" value from a gdb message with addr="0x0001234".
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
656 func s:GetAsmAddr(msg)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
657 if a:msg !~ 'addr='
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
658 return ''
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
659 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
660 let addr = s:DecodeMessage(substitute(a:msg, '.*addr=', '', ''))
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
661 return addr
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
662 endfunc
25619
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
663
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
664 func s:EndTermDebug(job, status)
25619
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
665 if exists('#User#TermdebugStopPre')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
666 doauto <nomodeline> User TermdebugStopPre
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
667 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
668
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
669 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
670 unlet s:gdbwin
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
671
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
672 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
673 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
674
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
675 func s:EndDebugCommon()
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
676 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
677
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
678 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
679 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
680 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
681
22723
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
682 " 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
683 call win_gotoid(s:sourcewin)
22723
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
684 let was_buf = bufnr()
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
685 for bufnr in s:signcolumn_buflist
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
686 if bufexists(bufnr)
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
687 exe bufnr .. "buf"
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
688 if exists('b:save_signcolumn')
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
689 let &signcolumn = b:save_signcolumn
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
690 unlet b:save_signcolumn
22723
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
691 endif
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
692 endif
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
693 endfor
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
694 if bufexists(was_buf)
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
695 exe was_buf .. "buf"
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
696 endif
22723
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
697
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
698 call s:DeleteCommands()
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
699
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
700 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
701
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
702 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
703 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
704 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
705
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
706 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
707 set balloonexpr=
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
708 if has("balloon_eval")
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
709 set noballooneval
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
710 endif
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
711 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
712 set noballoonevalterm
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
713 endif
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
25619
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
716 if exists('#User#TermdebugStopPost')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
717 doauto <nomodeline> User TermdebugStopPost
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
718 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
719
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
720 au! TermDebug
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
721 endfunc
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
722
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
723 func s:EndPromptDebug(job, status)
25619
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
724 if exists('#User#TermdebugStopPre')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
725 doauto <nomodeline> User TermdebugStopPre
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
726 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24751
diff changeset
727
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
728 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
729 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
730 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
731 close
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
732 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
733 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
734 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
735
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
736 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
737 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
738 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
739 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
740
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
741 " Disassembly window - added by Michael Sartain
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
742 "
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
743 " - CommOutput: disassemble $pc
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
744 " - CommOutput: &"disassemble $pc\n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
745 " - CommOutput: ~"Dump of assembler code for function main(int, char**):\n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
746 " - CommOutput: ~" 0x0000555556466f69 <+0>:\tpush rbp\n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
747 " ...
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
748 " - CommOutput: ~" 0x0000555556467cd0:\tpop rbp\n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
749 " - CommOutput: ~" 0x0000555556467cd1:\tret \n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
750 " - CommOutput: ~"End of assembler dump.\n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
751 " - CommOutput: ^done
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
752
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
753 " - CommOutput: disassemble $pc
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
754 " - CommOutput: &"disassemble $pc\n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
755 " - CommOutput: &"No function contains specified address.\n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
756 " - CommOutput: ^error,msg="No function contains specified address."
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
757 func s:HandleDisasmMsg(msg)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
758 if a:msg =~ '^\^done'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
759 let curwinid = win_getid(winnr())
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
760 if win_gotoid(s:asmwin)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
761 silent normal! gg0"_dG
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
762 call setline(1, s:asm_lines)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
763 set nomodified
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
764 set filetype=asm
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
765
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
766 let lnum = search('^' . s:asm_addr)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
767 if lnum != 0
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
768 call sign_unplace('TermDebug', #{id: s:asm_id})
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
769 call sign_place(s:asm_id, 'TermDebug', 'debugPC', '%', #{lnum: lnum})
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
770 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
771
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
772 call win_gotoid(curwinid)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
773 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
774
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
775 let s:parsing_disasm_msg = 0
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
776 let s:asm_lines = []
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
777 elseif a:msg =~ '^\^error,msg='
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
778 if s:parsing_disasm_msg == 1
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
779 " Disassemble call ran into an error. This can happen when gdb can't
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
780 " find the function frame address, so let's try to disassemble starting
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
781 " at current PC
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
782 call s:SendCommand('disassemble $pc,+100')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
783 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
784 let s:parsing_disasm_msg = 0
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
785 elseif a:msg =~ '\&\"disassemble \$pc'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
786 if a:msg =~ '+100'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
787 " This is our second disasm attempt
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
788 let s:parsing_disasm_msg = 2
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
789 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
790 else
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
791 let value = substitute(a:msg, '^\~\"[ ]*', '', '')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
792 let value = substitute(value, '^=>[ ]*', '', '')
26100
babd9f1dbe12 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25700
diff changeset
793 let value = substitute(value, '\\n\"\r$', '', '')
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
794 let value = substitute(value, '\\n\"$', '', '')
26100
babd9f1dbe12 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25700
diff changeset
795 let value = substitute(value, '\r', '', '')
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
796 let value = substitute(value, '\\t', ' ', 'g')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
797
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
798 if value != '' || !empty(s:asm_lines)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
799 call add(s:asm_lines, value)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
800 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
801 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
802 endfunc
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
803
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
804 " 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
805 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
806 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
807
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
808 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
809 " 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
810 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
811 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
812 endif
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
813
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
814 if s:parsing_disasm_msg
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
815 call s:HandleDisasmMsg(msg)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
816 elseif msg != ''
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
817 if msg =~ '^\(\*stopped\|\*running\|=thread-selected\)'
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
818 call s:HandleCursor(msg)
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
819 elseif msg =~ '^\^done,bkpt=' || msg =~ '^=breakpoint-created,'
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
820 call s:HandleNewBreakpoint(msg, 0)
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
821 elseif msg =~ '^=breakpoint-modified,'
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
822 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
823 elseif msg =~ '^=breakpoint-deleted,'
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
824 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
825 elseif msg =~ '^=thread-group-started'
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
826 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
827 elseif msg =~ '^\^done,value='
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
828 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
829 elseif msg =~ '^\^error,msg='
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
830 call s:HandleError(msg)
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
831 elseif msg =~ '^disassemble'
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
832 let s:parsing_disasm_msg = 1
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
833 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
834 endif
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 endfor
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
837 endfunc
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
838
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
839 func s:GotoProgram()
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
840 if has('win32')
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
841 if executable('powershell')
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
842 call system(printf('powershell -Command "add-type -AssemblyName microsoft.VisualBasic;[Microsoft.VisualBasic.Interaction]::AppActivate(%d);"', s:pid))
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
843 endif
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
844 else
18878
ef90e5bbb971 Minor runtime file updates.
Bram Moolenaar <Bram@vim.org>
parents: 18750
diff changeset
845 call win_gotoid(s:ptywin)
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
846 endif
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
847 endfunc
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
848
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
849 " 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
850 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
851 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
852 set cpo&vim
e91659ae6614 patch 8.1.0195: terminal debugger commands don't always work
Christian Brabandt <cb@256bit.org>
parents: 14356
diff changeset
853
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
854 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
855 command Clear call s:ClearBreakpoint()
26438
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26304
diff changeset
856 command Step call s:SendResumingCommand('-exec-step')
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26304
diff changeset
857 command Over call s:SendResumingCommand('-exec-next')
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
858 command -nargs=? Until call s:Until(<q-args>)
26438
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26304
diff changeset
859 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
860 command -nargs=* Run call s:Run(<q-args>)
26438
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26304
diff changeset
861 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
862
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
863 if s:way == 'prompt'
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
864 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
865 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
866 else
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
867 command Stop call s:SendCommand('-exec-interrupt')
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
868 " using -exec-continue results in CTRL-C in the gdb window not working,
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
869 " communicating via commbuf (= use of SendCommand) has the same result
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
870 "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
871 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
872 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
873
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
874 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
875 command Gdb call win_gotoid(s:gdbwin)
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
876 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
877 command Source call s:GotoSourcewinOrCreateIt()
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
878 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
879 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
880
28976
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
881 let map = 1
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
882 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
883 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
884 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
885 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
886 endif
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
887 if map
20552
74e3316c1d5a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 19523
diff changeset
888 let s:k_map_saved = maparg('K', 'n', 0, 1)
74e3316c1d5a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 19523
diff changeset
889 nnoremap K :Evaluate<CR>
74e3316c1d5a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 19523
diff changeset
890 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
891
13051
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12883
diff changeset
892 if has('menu') && &mouse != ''
13377
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
893 call s:InstallWinbar()
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
894
28976
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
895 let popup = 1
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
896 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
897 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
898 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
899 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
900 endif
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
901 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
902 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
903 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
904 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
905 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
906 an 1.220 PopUp.Clear\ breakpoint :Clear<CR>
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
907 an 1.230 PopUp.Run\ until :Until<CR>
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
908 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
909 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
910 endif
14360
e91659ae6614 patch 8.1.0195: terminal debugger commands don't always work
Christian Brabandt <cb@256bit.org>
parents: 14356
diff changeset
911
e91659ae6614 patch 8.1.0195: terminal debugger commands don't always work
Christian Brabandt <cb@256bit.org>
parents: 14356
diff changeset
912 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
913 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
914
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
915 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
916
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 " 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
918 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
919 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
920 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
921 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
922 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
923 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
924 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
925 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
926 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
927 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
928 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
929
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
930 " 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
931 func s:DeleteCommands()
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
932 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
933 delcommand Clear
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
934 delcommand Step
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
935 delcommand Over
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
936 delcommand Until
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
937 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
938 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
939 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
940 delcommand Stop
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
941 delcommand Continue
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
942 delcommand Evaluate
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
943 delcommand Gdb
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
944 delcommand Program
13682
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
945 delcommand Source
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
946 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
947 delcommand Winbar
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
948
23164
99ef85ff1af4 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22824
diff changeset
949 if exists('s:k_map_saved')
99ef85ff1af4 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22824
diff changeset
950 if empty(s:k_map_saved)
99ef85ff1af4 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22824
diff changeset
951 nunmap K
99ef85ff1af4 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22824
diff changeset
952 else
28777
b96ceb97e896 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28517
diff changeset
953 call mapset(s:k_map_saved)
23164
99ef85ff1af4 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22824
diff changeset
954 endif
20552
74e3316c1d5a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 19523
diff changeset
955 unlet s:k_map_saved
74e3316c1d5a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 19523
diff changeset
956 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
957
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
958 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
959 " 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
960 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
961 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
962 if win_gotoid(winid)
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
963 aunmenu WinBar.Step
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
964 aunmenu WinBar.Next
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
965 aunmenu WinBar.Finish
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
966 aunmenu WinBar.Cont
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
967 aunmenu WinBar.Stop
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
968 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
969 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
970 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
971 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
972 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
973
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
974 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
975 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
976 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
977 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
978 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
979 aunmenu PopUp.Clear\ breakpoint
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
980 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
981 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
982 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
983 endif
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
984
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
985 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
986 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
987 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
988
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
989 call sign_undefine('debugPC')
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
990 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
991 let s:BreakpointSigns = []
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
992 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
993
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
994 " :Until - Execute until past a specified position or current line
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
995 func s:Until(at)
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
996 if s:stopped
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
997 " reset s:stopped here, it may take a bit of time before we get a response
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
998 let s:stopped = 0
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
999 call ch_log('assume that program is running after this command')
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1000 " Use the fname:lnum format
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1001 let at = empty(a:at) ?
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1002 \ fnameescape(expand('%:p')) . ':' . line('.') : a:at
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1003 call s:SendCommand('-exec-until ' . at)
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1004 else
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1005 call ch_log('dropping command, program is running: exec-until')
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1006 endif
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1007 endfunc
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1008
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1009 " :Break - Set a breakpoint at the cursor position.
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1010 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
1011 " 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
1012 " 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
1013 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
1014 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
1015 let do_continue = 1
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1016 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
1017 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
1018 endif
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1019
14143
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
1020 " Use the fname:lnum format, older gdb can't handle --source.
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1021 let at = empty(a:at) ?
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1022 \ fnameescape(expand('%:p')) . ':' . line('.') : a:at
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1023 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
1024 if do_continue
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1025 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
1026 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1027 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1028
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
1029 " :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
1030 func s:ClearBreakpoint()
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1031 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
1032 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
1033 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
1034 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
1035 let idx = 0
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1036 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
1037 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
1038 if has_key(s:breakpoints, id)
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1039 " Assume this always works, the reply is simply "^done".
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1040 call s:SendCommand('-break-delete ' . id)
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1041 for subid in keys(s:breakpoints[id])
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1042 call sign_unplace('TermDebug',
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1043 \ #{id: s:Breakpoint2SignNumber(id, subid)})
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1044 endfor
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1045 unlet s:breakpoints[id]
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1046 unlet s:breakpoint_locations[bploc][idx]
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1047 let nr = id
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1048 break
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1049 else
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1050 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
1051 endif
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1052 endfor
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1053 if nr != 0
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1054 if empty(s:breakpoint_locations[bploc])
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1055 unlet s:breakpoint_locations[bploc]
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1056 endif
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1057 echomsg 'Breakpoint ' . id . ' cleared from line ' . lnum . '.'
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1058 else
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1059 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
1060 endif
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1061 else
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1062 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
1063 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1064 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1065
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
1066 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
1067 if a:args != ''
26438
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26304
diff changeset
1068 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
1069 endif
26438
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26304
diff changeset
1070 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
1071 endfunc
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
1072
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1073 func s:SendEval(expr)
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1074 " check for "likely" boolean expressions, in which case we take it as lhs
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1075 if a:expr =~ "[=!<>]="
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1076 let exprLHS = a:expr
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1077 else
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1078 " remove text that is likely an assignment
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1079 let exprLHS = substitute(a:expr, ' *=.*', '', '')
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1080 endif
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1081
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1082 " encoding expression to prevent bad errors
26100
babd9f1dbe12 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25700
diff changeset
1083 let expr = a:expr
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1084 let expr = substitute(expr, '\\', '\\\\', 'g')
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1085 let expr = substitute(expr, '"', '\\"', 'g')
26100
babd9f1dbe12 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25700
diff changeset
1086 call s:SendCommand('-data-evaluate-expression "' . expr . '"')
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1087 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
1088 endfunc
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1089
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1090 " :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
1091 func s:Evaluate(range, arg)
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1092 let expr = s:GetEvaluationExpression(a:range, a:arg)
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1093 let s:ignoreEvalError = 0
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1094 call s:SendEval(expr)
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1095 endfunc
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1096
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1097 " get what is specified / under the cursor
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1098 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
1099 if a:arg != ''
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1100 " user supplied evaluation
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1101 let expr = s:CleanupExpr(a:arg)
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1102 " DSW: replace "likely copy + paste" assignment
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1103 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
1104 elseif a:range == 2
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1105 " 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
1106 let pos = getcurpos()
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1107 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
1108 let regt = getregtype('v')
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1109 normal! gv"vy
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1110 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
1111 call setpos('.', pos)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1112 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
1113 else
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1114 " no evaluation provided: get from C-expression under cursor
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1115 " 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
1116 let expr = expand('<cexpr>')
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1117 endif
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1118 return expr
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1119 endfunc
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1120
27036
3e661b0cf500 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
1121 " clean up expression that may get in because of range
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1122 " (newlines and surrounding whitespace)
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1123 " As it can also be specified via ex-command for assignments this function
27036
3e661b0cf500 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
1124 " may not change the "content" parts (like replacing contained spaces)
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1125 func s:CleanupExpr(expr)
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1126 " replace all embedded newlines/tabs/...
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1127 let expr = substitute(a:expr, '\_s', ' ', 'g')
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1128
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1129 if &filetype ==# 'cobol'
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1130 " extra cleanup for COBOL:
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1131 " - a semicolon nmay be used instead of a space
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1132 " - a trailing comma or period is ignored as it commonly separates/ends
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1133 " multiple expr
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1134 let expr = substitute(expr, ';', ' ', 'g')
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1135 let expr = substitute(expr, '[,.]\+ *$', '', '')
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1136 endif
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1137
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1138 " get rid of leading and trailing spaces
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1139 let expr = substitute(expr, '^ *', '', '')
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1140 let expr = substitute(expr, ' *$', '', '')
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1141 return expr
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1142 endfunc
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1143
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
1144 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
1145 let s:evalFromBalloonExpr = 0
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1146
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1147 " 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
1148 func s:HandleEvaluate(msg)
26591
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
1149 let value = a:msg
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
1150 \ ->substitute('.*value="\(.*\)"', '\1', '')
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
1151 \ ->substitute('\\"', '"', 'g')
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
1152 \ ->substitute('\\\\', '\\', 'g')
27036
3e661b0cf500 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
1153 "\ multi-byte characters arrive in octal form, replace everything but NULL values
26591
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
1154 \ ->substitute('\\000', s:NullRepl, 'g')
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
1155 \ ->substitute('\\\o\o\o', {-> eval('"' .. submatch(0) .. '"')}, 'g')
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
1156 "\ Note: GDB docs also mention hex encodings - the translations below work
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
1157 "\ but we keep them out for performance-reasons until we actually see
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
1158 "\ those in mi-returns
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
1159 "\ ->substitute('\\0x00', s:NullRep, 'g')
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
1160 "\ ->substitute('\\0x\(\x\x\)', {-> eval('"\x' .. submatch(1) .. '"')}, 'g')
3a63b1e4a6f4 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
1161 \ ->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
1162 if s:evalFromBalloonExpr
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1163 if s:evalFromBalloonExprResult == ''
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1164 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
1165 else
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1166 let s:evalFromBalloonExprResult .= ' = ' . value
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1167 endif
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1168 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
1169 else
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1170 echomsg '"' . s:evalexpr . '": ' . value
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1171 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1172
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12773
diff changeset
1173 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
1174 " Looks like a pointer, also display what it points to.
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
1175 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
1176 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
1177 else
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1178 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
1179 endif
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1180 endfunc
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1181
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1182 " 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
1183 " if there is any.
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1184 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
1185 if v:beval_winid != s:sourcewin
17372
b9bc47742df6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
1186 return ''
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
1187 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
1188 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
1189 " 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
1190 " mouse triggers a balloon.
17372
b9bc47742df6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
1191 return ''
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1192 endif
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1193 let s:evalFromBalloonExpr = 1
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1194 let s:evalFromBalloonExprResult = ''
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
1195 let s:ignoreEvalError = 1
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1196 let expr = s:CleanupExpr(v:beval_text)
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1197 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
1198 return ''
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1199 endfunc
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1200
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1201 " Handle an error.
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1202 func s:HandleError(msg)
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
1203 if s:ignoreEvalError
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1204 " Result of s:SendEval() failed, ignore.
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
1205 let s:ignoreEvalError = 0
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
1206 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
1207 return
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1208 endif
26100
babd9f1dbe12 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25700
diff changeset
1209 let msgVal = substitute(a:msg, '.*msg="\(.*\)"', '\1', '')
babd9f1dbe12 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25700
diff changeset
1210 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
1211 endfunc
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1212
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
1213 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
1214 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
1215 new
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
1216 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
1217 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
1218 endif
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
1219 endfunc
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
1220
28976
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
1221 func s:GetDisasmWindow()
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
1222 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
1223 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
1224 endif
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
1225 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
1226 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
1227 endif
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
1228 return 0
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
1229 endfunc
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
1230
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
1231 func s:GetDisasmWindowHeight()
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
1232 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
1233 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
1234 endif
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
1235 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
1236 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
1237 endif
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
1238 return 0
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
1239 endfunc
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
1240
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1241 func s:GotoAsmwinOrCreateIt()
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1242 if !win_gotoid(s:asmwin)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1243 if win_gotoid(s:sourcewin)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1244 exe 'rightbelow new'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1245 else
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1246 exe 'new'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1247 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1248
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1249 let s:asmwin = win_getid(winnr())
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1250
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1251 setlocal nowrap
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1252 setlocal number
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1253 setlocal noswapfile
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1254 setlocal buftype=nofile
26148
624439a39432 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26100
diff changeset
1255 setlocal modifiable
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1256
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1257 let asmbuf = bufnr('Termdebug-asm-listing')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1258 if asmbuf > 0
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1259 exe 'buffer' . asmbuf
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1260 else
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1261 exe 'file Termdebug-asm-listing'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1262 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1263
28976
ad63d6a8ed21 patch 8.2.5010: the terminal debugger uses various global variables
Bram Moolenaar <Bram@vim.org>
parents: 28808
diff changeset
1264 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
1265 exe 'resize ' .. s:GetDisasmWindowHeight()
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1266 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1267 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1268
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1269 if s:asm_addr != ''
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1270 let lnum = search('^' . s:asm_addr)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1271 if lnum == 0
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1272 if s:stopped
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1273 call s:SendCommand('disassemble $pc')
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1274 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1275 else
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1276 call sign_unplace('TermDebug', #{id: s:asm_id})
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1277 call sign_place(s:asm_id, 'TermDebug', 'debugPC', '%', #{lnum: lnum})
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1278 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1279 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1280 endfunc
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1281
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1282 " 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
1283 " 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
1284 func s:HandleCursor(msg)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1285 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
1286
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
1287 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
1288 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
1289 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
1290 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
1291 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
1292 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
1293 endif
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
1294
14143
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
1295 if a:msg =~ 'fullname='
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
1296 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
1297 else
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
1298 let fname = ''
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
1299 endif
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1300
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1301 if a:msg =~ 'addr='
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1302 let asm_addr = s:GetAsmAddr(a:msg)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1303 if asm_addr != ''
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1304 let s:asm_addr = asm_addr
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1305
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1306 let curwinid = win_getid(winnr())
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1307 if win_gotoid(s:asmwin)
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1308 let lnum = search('^' . s:asm_addr)
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1309 if lnum == 0
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1310 call s:SendCommand('disassemble $pc')
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1311 else
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1312 call sign_unplace('TermDebug', #{id: s:asm_id})
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1313 call sign_place(s:asm_id, 'TermDebug', 'debugPC', '%', #{lnum: lnum})
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1314 endif
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1315
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1316 call win_gotoid(curwinid)
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1317 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1318 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1319 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1320
13592
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
1321 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
1322 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
1323 if lnum =~ '^[0-9]*$'
27162
b19230a8d40a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27036
diff changeset
1324 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
1325 if expand('%:p') != fnamemodify(fname, ':p')
27321
3649b5a6b1b6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
1326 echomsg 'different fname: "' .. expand('%:p') .. '" vs "' .. fnamemodify(fname, ':p') .. '"'
27162
b19230a8d40a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27036
diff changeset
1327 augroup Termdebug
b19230a8d40a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27036
diff changeset
1328 " Always open a file read-only instead of showing the ATTENTION
b19230a8d40a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27036
diff changeset
1329 " prompt, since we are unlikely to want to edit the file.
b19230a8d40a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27036
diff changeset
1330 " The file may be changed but not saved, warn for that.
b19230a8d40a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27036
diff changeset
1331 au SwapExists * echohl WarningMsg
b19230a8d40a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27036
diff changeset
1332 \ | echo 'Warning: file is being edited elsewhere'
b19230a8d40a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27036
diff changeset
1333 \ | echohl None
b19230a8d40a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27036
diff changeset
1334 \ | let v:swapchoice = '0'
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1335 augroup END
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1336 if &modified
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1337 " TODO: find existing window
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1338 exe 'split ' . fnameescape(fname)
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1339 let s:sourcewin = win_getid(winnr())
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1340 call s:InstallWinbar()
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1341 else
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1342 exe 'edit ' . fnameescape(fname)
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1343 endif
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1344 augroup Termdebug
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1345 au! SwapExists
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1346 augroup END
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1347 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
1348 exe lnum
26148
624439a39432 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26100
diff changeset
1349 normal! zv
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1350 call sign_unplace('TermDebug', #{id: s:pc_id})
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1351 call sign_place(s:pc_id, 'TermDebug', 'debugPC', fname,
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1352 \ #{lnum: lnum, priority: 110})
22723
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
1353 if !exists('b:save_signcolumn')
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1354 let b:save_signcolumn = &signcolumn
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1355 call add(s:signcolumn_buflist, bufnr())
22723
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
1356 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
1357 setlocal signcolumn=yes
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1358 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
1359 elseif !s:stopped || fname != ''
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1360 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
1361 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1362
13592
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
1363 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
1364 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1365
14143
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
1366 let s:BreakpointSigns = []
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
1367
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1368 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
1369 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
1370 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
1371 call add(s:BreakpointSigns, nr)
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1372 if a:enabled == "n"
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1373 let hiName = "debugBreakpointDisabled"
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1374 else
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1375 let hiName = "debugBreakpoint"
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1376 endif
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1377 call sign_define('debugBreakpoint' .. nr,
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1378 \ #{text: substitute(nr, '\..*', '', ''),
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1379 \ 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
1380 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
1381 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
1382
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1383 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
1384 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
1385 endfunction
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1386
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1387 " Handle setting a breakpoint
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1388 " Will update the sign that shows the breakpoint
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1389 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
1390 if a:msg !~ 'fullname='
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1391 " a watch or a pending breakpoint does not have a file name
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1392 if a:msg =~ 'pending='
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1393 let nr = substitute(a:msg, '.*number=\"\([0-9.]*\)\".*', '\1', '')
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1394 let target = substitute(a:msg, '.*pending=\"\([^"]*\)\".*', '\1', '')
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1395 echomsg 'Breakpoint ' . nr . ' (' . target . ') pending.'
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1396 endif
14165
5b5364d0729d patch 8.1.0100: terminal debugger: error when setting a watch point
Christian Brabandt <cb@256bit.org>
parents: 14151
diff changeset
1397 return
5b5364d0729d patch 8.1.0100: terminal debugger: error when setting a watch point
Christian Brabandt <cb@256bit.org>
parents: 14151
diff changeset
1398 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
1399 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
1400 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
1401 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
1402 continue
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1403 endif
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1404 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
1405 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
1406 return
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1407 endif
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1408
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1409 " 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
1410 " 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
1411 let [id, subid; _] = map(split(nr . '.0', '\.'), 'v:val + 0')
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1412 let enabled = substitute(msg, '.*enabled="\([yn]\)".*', '\1', '')
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1413 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
1414
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1415 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
1416 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
1417 else
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1418 let entries = {}
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1419 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
1420 endif
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1421 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
1422 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
1423 else
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1424 let entry = {}
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1425 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
1426 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1427
15093
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1428 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
1429 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
1430 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
1431
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1432 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
1433 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
1434 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
1435 endif
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1436 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
1437
15093
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1438 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
1439 call s:PlaceSign(id, subid, entry)
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1440 let posMsg = ' at line ' . lnum . '.'
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1441 else
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1442 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
1443 endif
26304
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1444 if !a:modifiedFlag
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1445 let actionTaken = 'created'
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1446 elseif enabled == 'n'
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1447 let actionTaken = 'disabled'
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1448 else
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1449 let actionTaken = 'enabled'
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1450 endif
bb2175e5ccee Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26219
diff changeset
1451 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
1452 endfor
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1453 endfunc
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1454
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1455 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
1456 let nr = printf('%d.%d', a:id, a:subid)
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1457 call sign_place(s:Breakpoint2SignNumber(a:id, a:subid), 'TermDebug',
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1458 \ 'debugBreakpoint' .. nr, a:entry['fname'],
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1459 \ #{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
1460 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
1461 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1462
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1463 " Handle deleting a breakpoint
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1464 " 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
1465 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
1466 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
1467 if empty(id)
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1468 return
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1469 endif
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1470 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
1471 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
1472 if has_key(entry, 'placed')
28517
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1473 call sign_unplace('TermDebug',
f73a9bdff3a3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28141
diff changeset
1474 \ #{id: s:Breakpoint2SignNumber(id, subid)})
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1475 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
1476 endif
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1477 endfor
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1478 unlet s:breakpoints[id]
26219
786b2a8ec970 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26148
diff changeset
1479 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
1480 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1481 endfunc
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1482
14147
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14143
diff changeset
1483 " 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
1484 " 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
1485 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
1486 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
1487 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
1488 return
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14143
diff changeset
1489 endif
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14143
diff changeset
1490 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
1491 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
1492 endfunc
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14143
diff changeset
1493
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1494 " 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
1495 func s:BufRead()
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1496 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
1497 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
1498 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
1499 if entry['fname'] == fname
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1500 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
1501 endif
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1502 endfor
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1503 endfor
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1504 endfunc
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1505
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1506 " 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
1507 func s:BufUnloaded()
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1508 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
1509 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
1510 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
1511 if entry['fname'] == fname
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27321
diff changeset
1512 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
1513 endif
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1514 endfor
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1515 endfor
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1516 endfunc
14356
9339e4dbf6bf patch 8.1.0193: terminal debugger buttons don't always work
Christian Brabandt <cb@256bit.org>
parents: 14165
diff changeset
1517
9339e4dbf6bf patch 8.1.0193: terminal debugger buttons don't always work
Christian Brabandt <cb@256bit.org>
parents: 14165
diff changeset
1518 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
1519 unlet s:keepcpo