annotate runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @ 23573:e2e2cc5d0856

Update runtime files. Commit: https://github.com/vim/vim/commit/82be4849eed0b8fbee45bc8da99b685ec89af59a Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jan 11 19:40:15 2021 +0100 Update runtime files.
author Bram Moolenaar <Bram@vim.org>
date Mon, 11 Jan 2021 19:45:05 +0100
parents 99ef85ff1af4
children 840665e74421
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"
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
5 " Last Change: 2021 Jan 03
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
6 "
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
7 " WORK IN PROGRESS - Only the basics work
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
8 " Note: On MS-Windows you need a recent version of gdb. The one included with
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
9 " MingW is too old (7.6.1).
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
10 " I used version 7.12 from http://www.equation.com/servlet/equation.cmd?fa=gdb
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
11 "
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
12 " 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
13 " - 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
14 " 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
15 " - 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
16 "
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
17 " 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
18 " 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
19 "
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
20 " 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
21 "
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
22 " 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
23 " 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
24 " 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
25 " 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
26 "
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
27 " 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
28 "
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
29 " 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
30 " 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
31 " 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
32 " 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
33 "
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
34 " 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
35 " https://sourceware.org/gdb/current/onlinedocs/gdb/GDB_002fMI.html
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
37 " In case this gets sourced twice.
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
38 if exists(':Termdebug')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
39 finish
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
40 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12487
diff changeset
41
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
42 " 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
43 " 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
44 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
45 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
46 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
47 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
48 else
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
49 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
50 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
51 else
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
52 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
53 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
54 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
55 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
56 finish
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
57 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
58
14356
9339e4dbf6bf patch 8.1.0193: terminal debugger buttons don't always work
Christian Brabandt <cb@256bit.org>
parents: 14165
diff changeset
59 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
60 set cpo&vim
9339e4dbf6bf patch 8.1.0193: terminal debugger buttons don't always work
Christian Brabandt <cb@256bit.org>
parents: 14165
diff changeset
61
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
62 " 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
63 " 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
64 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
65 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
66
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
67 " Name of the gdb command, defaults to "gdb".
18217
40344f717010 patch 8.1.2103: wrong error message if "termdebugger" is not executable
Bram Moolenaar <Bram@vim.org>
parents: 18130
diff changeset
68 if !exists('g:termdebugger')
40344f717010 patch 8.1.2103: wrong error message if "termdebugger" is not executable
Bram Moolenaar <Bram@vim.org>
parents: 18130
diff changeset
69 let g:termdebugger = 'gdb'
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 endif
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
72 let s:pc_id = 12
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
73 let s:asm_id = 13
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
74 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
75 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
76
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
77 let s:parsing_disasm_msg = 0
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
78 let s:asm_lines = []
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
79 let s:asm_addr = ''
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
80
15093
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
81 " 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
82 " 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
83 " 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
84 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
85 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
86 endfunction
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
87
14127
d2b14df7e439 patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents: 14126
diff changeset
88 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
89 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
90 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
91 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
92 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
93 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
94 endif
d2b14df7e439 patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents: 14126
diff changeset
95 endfunc
d2b14df7e439 patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents: 14126
diff changeset
96
d2b14df7e439 patch 8.1.0081: the terminal debugger doesn't adjust to changed 'background'
Christian Brabandt <cb@256bit.org>
parents: 14126
diff changeset
97 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
98 hi default debugBreakpoint term=reverse ctermbg=red guibg=red
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
99
13706
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
100 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
101 " 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
102 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
103 endfunc
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
104
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
105 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
106 " 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
107 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
108 endfunc
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
109
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_internal(dict)
13682
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
111 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
112 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
113 return
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
114 endif
18217
40344f717010 patch 8.1.2103: wrong error message if "termdebugger" is not executable
Bram Moolenaar <Bram@vim.org>
parents: 18130
diff changeset
115 if !executable(g:termdebugger)
40344f717010 patch 8.1.2103: wrong error message if "termdebugger" is not executable
Bram Moolenaar <Bram@vim.org>
parents: 18130
diff changeset
116 echoerr 'Cannot execute debugger program "' .. g:termdebugger .. '"'
40344f717010 patch 8.1.2103: wrong error message if "termdebugger" is not executable
Bram Moolenaar <Bram@vim.org>
parents: 18130
diff changeset
117 return
40344f717010 patch 8.1.2103: wrong error message if "termdebugger" is not executable
Bram Moolenaar <Bram@vim.org>
parents: 18130
diff changeset
118 endif
40344f717010 patch 8.1.2103: wrong error message if "termdebugger" is not executable
Bram Moolenaar <Bram@vim.org>
parents: 18130
diff changeset
119
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
120 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
121 let s:pid = 0
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
122 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
123
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
124 " 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
125 " 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
126
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
127 let s:sourcewin = win_getid(winnr())
22723
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
128
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
129 " 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
130 " that we can restore the value for all buffers.
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
131 let b:save_signcolumn = &signcolumn
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
132 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
133
12559
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
134 let s:save_columns = 0
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
135 let s:allleft = 0
12559
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
136 if exists('g:termdebug_wide')
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
137 if &columns < g:termdebug_wide
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
138 let s:save_columns = &columns
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
139 let &columns = g:termdebug_wide
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
140 " If we make the Vim window wider, use the whole left halve for the debug
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
141 " windows.
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
142 let s:allleft = 1
12559
34c8ec888122 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12499
diff changeset
143 endif
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
144 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
145 else
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
146 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
147 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
148
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
149 " Override using a terminal window by setting g:termdebug_use_prompt to 1.
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
150 let use_prompt = exists('g:termdebug_use_prompt') && g:termdebug_use_prompt
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
151 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
152 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
153 else
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
154 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
155 endif
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
156
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
157 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
158 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
159 else
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
160 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
161 endif
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
162
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
163 if exists('g:termdebug_disasm_window')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
164 if g:termdebug_disasm_window
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
165 let curwinid = win_getid(winnr())
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
166 call s:GotoAsmwinOrCreateIt()
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
167 call win_gotoid(curwinid)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
168 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
169 endif
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
170 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
171
15223
0e7615548cef patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents: 15129
diff changeset
172 " 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
173 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
174 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
175 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
176 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
177 endfunc
0e7615548cef patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents: 15129
diff changeset
178
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
179 func s:StartDebug_term(dict)
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
180 " Open a terminal window without a job, to run the debugged program in.
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
181 let s:ptybuf = term_start('NONE', {
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
182 \ 'term_name': 'debugged program',
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
183 \ 'vertical': s:vertical,
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
184 \ })
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
185 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
186 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
187 return
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
188 endif
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
189 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
190 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
191 if s:vertical
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
192 " 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
193 " 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
194 exe (&columns / 2 - 1) . "wincmd |"
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
195 if s:allleft
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
196 " use the whole left column
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
197 wincmd H
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15223
diff changeset
198 endif
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
199 endif
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
200
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
201 " 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
202 let s:commbuf = term_start('NONE', {
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
203 \ 'term_name': 'gdb communication',
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
204 \ 'out_cb': function('s:CommOutput'),
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
205 \ 'hidden': 1,
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
206 \ })
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
207 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
208 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
209 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
210 return
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
211 endif
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
212 let commpty = job_info(term_getjob(s:commbuf))['tty_out']
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214 " Open a terminal window to run the debugger.
12773
d9067dad4ac6 patch 8.0.1264: terminal debugger gets stuck in small window
Christian Brabandt <cb@256bit.org>
parents: 12756
diff changeset
215 " Add -quiet to avoid the intro message causing a hit-enter prompt.
13706
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
216 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
217 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
218
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
219 let cmd = [g:termdebugger, '-quiet', '-tty', pty] + gdb_args
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
220 call ch_log('executing "' . join(cmd) . '"')
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
221 let s:gdbbuf = term_start(cmd, {
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
222 \ 'term_finish': 'close',
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
223 \ })
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
224 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
225 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
226 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
227 return
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
228 endif
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
229 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
230
13706
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
231 " Set arguments to be run
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
232 if len(proc_args)
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
233 call term_sendkeys(s:gdbbuf, 'set args ' . join(proc_args) . "\r")
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
234 endif
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
235
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
236 " Connect gdb to the communication pty, using the GDB/MI interface
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
237 call term_sendkeys(s:gdbbuf, 'new-ui mi ' . commpty . "\r")
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
238
13450
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
239 " 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
240 " 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
241 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
242 while 1
15223
0e7615548cef patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents: 15129
diff changeset
243 let gdbproc = term_getjob(s:gdbbuf)
0e7615548cef patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents: 15129
diff changeset
244 if gdbproc == v:null || job_status(gdbproc) !=# 'run'
0e7615548cef patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents: 15129
diff changeset
245 echoerr string(g:termdebugger) . ' exited unexpectedly'
0e7615548cef patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents: 15129
diff changeset
246 call s:CloseBuffers()
0e7615548cef patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents: 15129
diff changeset
247 return
0e7615548cef patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents: 15129
diff changeset
248 endif
0e7615548cef patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents: 15129
diff changeset
249
13450
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
250 let response = ''
17962
58bebe21f0ef patch 8.1.1977: terminal debugger plugin may hang
Bram Moolenaar <Bram@vim.org>
parents: 17909
diff changeset
251 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
252 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
253 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
254 if line1 =~ 'new-ui mi '
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
255 " response can be in the same line or the next line
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
256 let response = line1 . line2
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
257 if response =~ 'Undefined command'
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
258 echoerr 'Sorry, your gdb is too old, gdb 7.12 is required'
15223
0e7615548cef patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents: 15129
diff changeset
259 call s:CloseBuffers()
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
260 return
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
261 endif
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
262 if response =~ 'New UI allocated'
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
263 " Success!
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
264 break
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
265 endif
17962
58bebe21f0ef patch 8.1.1977: terminal debugger plugin may hang
Bram Moolenaar <Bram@vim.org>
parents: 17909
diff changeset
266 elseif line1 =~ 'Reading symbols from' && line2 !~ 'new-ui mi '
58bebe21f0ef patch 8.1.1977: terminal debugger plugin may hang
Bram Moolenaar <Bram@vim.org>
parents: 17909
diff changeset
267 " Reading symbols might take a while, try more times
58bebe21f0ef patch 8.1.1977: terminal debugger plugin may hang
Bram Moolenaar <Bram@vim.org>
parents: 17909
diff changeset
268 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
269 endif
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
270 endfor
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
271 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
272 break
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
273 endif
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
274 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
275 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
276 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
277 break
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
278 endif
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
279 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
280 endwhile
a7a88403ccb1 patch 8.0.1599: no error message when gdb does not support debugger
Christian Brabandt <cb@256bit.org>
parents: 13377
diff changeset
281
18750
82a28df1e2d5 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18217
diff changeset
282 " Interpret commands while the target is running. This should usually only be
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
283 " exec-interrupt, since many commands don't work properly while the target is
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
284 " running.
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
285 call s:SendCommand('-gdb-set mi-async on')
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
286 " Older gdb uses a different command.
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
287 call s:SendCommand('-gdb-set target-async on')
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
288
13564
a036c2cf4024 patch 8.0.1655: outdated gdb message in terminal debugger unclear
Christian Brabandt <cb@256bit.org>
parents: 13450
diff changeset
289 " Disable pagination, it causes everything to stop at the gdb
a036c2cf4024 patch 8.0.1655: outdated gdb message in terminal debugger unclear
Christian Brabandt <cb@256bit.org>
parents: 13450
diff changeset
290 " "Type <return> to continue" prompt.
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
291 call s:SendCommand('set pagination off')
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
292
15223
0e7615548cef patch 8.1.0621: terminal debugger does not handle unexpected debugger exit
Bram Moolenaar <Bram@vim.org>
parents: 15129
diff changeset
293 call job_setoptions(gdbproc, {'exit_cb': function('s:EndTermDebug')})
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
294 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
295 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
296
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
297 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
298 " Open a window with a prompt buffer to run gdb in.
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
299 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
300 vertical new
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
301 else
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
302 new
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
303 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
304 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
305 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
306 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
307 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
308 file gdb
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
309 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
310 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
311
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
312 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
313 " 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
314 " 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
315 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
316 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
317
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
318 " Add -quiet to avoid the intro message causing a hit-enter prompt.
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
319 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
320 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
321
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
322 let cmd = [g:termdebugger, '-quiet', '--interpreter=mi2'] + gdb_args
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
323 call ch_log('executing "' . join(cmd) . '"')
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
324
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
325 let s:gdbjob = job_start(cmd, {
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
326 \ 'exit_cb': function('s:EndPromptDebug'),
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
327 \ 'out_cb': function('s:GdbOutCallback'),
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
328 \ })
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
329 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
330 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
331 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
332 return
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
333 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
334 " 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
335 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
336 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
337
18750
82a28df1e2d5 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18217
diff changeset
338 " Interpret commands while the target is running. This should usually only
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
339 " be exec-interrupt, since many commands don't work properly while the
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
340 " target is running.
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
341 call s:SendCommand('-gdb-set mi-async on')
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
342 " Older gdb uses a different command.
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
343 call s:SendCommand('-gdb-set target-async on')
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
344
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
345 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
346 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
347 " 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
348 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
349 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
350 " 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
351 " gdb window.
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
352 belowright let s:ptybuf = term_start('NONE', {
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
353 \ 'term_name': 'debugged program',
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
354 \ })
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
355 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
356 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
357 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
358 return
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
359 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
360 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
361 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
362 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
363
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
364 " 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
365 " 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
366 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
367 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
368 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
369 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
370 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
371 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
372 else
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
373 " TODO: open a new terminal get get the tty name, pass on to gdb
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
374 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
375 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
376 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
377 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
378 " Disable pagination, it causes everything to stop at the gdb
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
379 call s:SendCommand('set pagination off')
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
380
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
381 " 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
382 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
383 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
384 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
385
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
386 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
387 startinsert
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
388 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
389
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
390 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
391 " 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
392 " There can be only one.
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
393 sign define debugPC linehl=debugPC
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
394
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
395 " 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
396 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
397 call s:InstallCommands()
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
398 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
399
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
400 " 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
401 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
402 set balloonexpr=TermDebugBalloonExpr()
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
403 if has("balloon_eval")
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
404 set ballooneval
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
405 endif
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
406 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
407 set balloonevalterm
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
408 endif
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
409 endif
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
410
15093
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
411 " 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
412 " breakpoint number.
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
413 " 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
414 " 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
415 " 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
416 " 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
417 " {'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
418 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
419
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
420 " 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
421 " 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
422 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
423
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
424 augroup TermDebug
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
425 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
426 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
427 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
428 augroup END
13706
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
429
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
430 " 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
431 " window.
13706
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
432 if get(a:dict, 'bang', 0)
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
433 call s:SendCommand('-exec-run')
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
434 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
435 endif
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
436 endfunc
13706
bfd9249f72e0 patch 8.0.1725: terminal debugger doesn't handle command arguments
Christian Brabandt <cb@256bit.org>
parents: 13682
diff changeset
437
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
438 " 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
439 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
440 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
441 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
442 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
443 else
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
444 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
445 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
446 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
447
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
448 " 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
449 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
450 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
451 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
452 else
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
453 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
454 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
455 let do_continue = 1
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('-exec-interrupt')
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
457 sleep 10m
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
458 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
459 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
460 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
461 Continue
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 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
464 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
465
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
466 " 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
467 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
468 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
469 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
470
14147
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14143
diff changeset
471 " 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
472 " breakpoint.
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
473 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
474 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
475 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
476 " 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
477 " 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
478 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
479 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
480 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
481 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
482 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
483 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
484 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
485 endif
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
486 endfunc
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
487
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
488 " 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
489 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
490 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
491
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
492 " 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
493 " 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
494 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
495 return
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
496 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
497 if a:text =~ '^^error,msg='
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
498 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
499 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
500 " 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
501 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
502 return
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
503 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
504 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
505 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
506 else
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
507 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
508 return
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
509 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
510
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
511 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
512 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
513
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
514 " 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
515 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
516 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
517
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
518 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
519 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
520
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
521 " Decode a message from gdb. quotedText starts with a ", return the text up
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
522 " to the next ", unescaping characters.
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
523 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
524 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
525 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
526 return
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
527 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
528 let result = ''
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
529 let i = 1
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
530 while a:quotedText[i] != '"' && i < len(a:quotedText)
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
531 if a:quotedText[i] == '\'
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
532 let i += 1
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
533 if a:quotedText[i] == 'n'
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
534 " drop \n
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
535 let i += 1
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
536 continue
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
537 elseif a:quotedText[i] == 't'
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
538 " append \t
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
539 let i += 1
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
540 let result .= "\t"
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
541 continue
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
542 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
543 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
544 let result .= a:quotedText[i]
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
545 let i += 1
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
546 endwhile
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
547 return result
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
548 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
549
14143
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
550 " 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
551 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
552 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
553 return ''
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
554 endif
14143
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
555 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
556 if has('win32') && name =~ ':\\\\'
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
557 " 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
558 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
559 endif
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
560 return name
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
561 endfunc
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
562
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
563 " Extract the "addr" value from a gdb message with addr="0x0001234".
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
564 func s:GetAsmAddr(msg)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
565 if a:msg !~ 'addr='
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
566 return ''
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
567 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
568 let addr = s:DecodeMessage(substitute(a:msg, '.*addr=', '', ''))
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
569 return addr
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
570 endfunc
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
571 func s:EndTermDebug(job, status)
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
572 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
573 unlet s:gdbwin
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
574
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
575 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
576 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
577
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
578 func s:EndDebugCommon()
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
579 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
580
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
581 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
582 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
583 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
584
22723
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
585 " 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
586 call win_gotoid(s:sourcewin)
22723
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
587 let was_buf = bufnr()
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
588 for bufnr in s:signcolumn_buflist
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
589 if bufexists(bufnr)
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
590 exe bufnr .. "buf"
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
591 if exists('b:save_signcolumn')
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
592 let &signcolumn = b:save_signcolumn
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
593 unlet b:save_signcolumn
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
594 endif
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
595 endif
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
596 endfor
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
597 exe was_buf .. "buf"
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
598
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
599 call s:DeleteCommands()
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
600
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
601 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
602
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
603 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
604 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
605 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
606
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
607 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
608 set balloonexpr=
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
609 if has("balloon_eval")
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
610 set noballooneval
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
611 endif
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
612 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
613 set noballoonevalterm
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
614 endif
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
615 endif
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
616
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
617 au! TermDebug
12254
8d76a56861ec Update runtime files
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
618 endfunc
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
619
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:EndPromptDebug(job, status)
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
621 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
622 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
623 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
624 close
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
625 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
626 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
627 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
628
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
629 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
630 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
631 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
632 endfunc
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
633
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
634 " Disassembly window - added by Michael Sartain
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
635 "
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
636 " - CommOutput: disassemble $pc
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
637 " - CommOutput: &"disassemble $pc\n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
638 " - CommOutput: ~"Dump of assembler code for function main(int, char**):\n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
639 " - CommOutput: ~" 0x0000555556466f69 <+0>:\tpush rbp\n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
640 " ...
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
641 " - CommOutput: ~" 0x0000555556467cd0:\tpop rbp\n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
642 " - CommOutput: ~" 0x0000555556467cd1:\tret \n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
643 " - CommOutput: ~"End of assembler dump.\n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
644 " - CommOutput: ^done
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
645
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
646 " - CommOutput: disassemble $pc
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
647 " - CommOutput: &"disassemble $pc\n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
648 " - CommOutput: &"No function contains specified address.\n"
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
649 " - CommOutput: ^error,msg="No function contains specified address."
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
650 func s:HandleDisasmMsg(msg)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
651 if a:msg =~ '^\^done'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
652 let curwinid = win_getid(winnr())
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
653 if win_gotoid(s:asmwin)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
654 silent normal! gg0"_dG
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
655 call setline(1, s:asm_lines)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
656 set nomodified
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
657 set filetype=asm
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
658
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
659 let lnum = search('^' . s:asm_addr)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
660 if lnum != 0
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
661 exe 'sign unplace ' . s:asm_id
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
662 exe 'sign place ' . s:asm_id . ' line=' . lnum . ' name=debugPC'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
663 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
664
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
665 call win_gotoid(curwinid)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
666 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
667
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
668 let s:parsing_disasm_msg = 0
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
669 let s:asm_lines = []
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
670 elseif a:msg =~ '^\^error,msg='
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
671 if s:parsing_disasm_msg == 1
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
672 " 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
673 " 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
674 " at current PC
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
675 call s:SendCommand('disassemble $pc,+100')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
676 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
677 let s:parsing_disasm_msg = 0
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
678 elseif a:msg =~ '\&\"disassemble \$pc'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
679 if a:msg =~ '+100'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
680 " This is our second disasm attempt
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
681 let s:parsing_disasm_msg = 2
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
682 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
683 else
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
684 let value = substitute(a:msg, '^\~\"[ ]*', '', '')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
685 let value = substitute(value, '^=>[ ]*', '', '')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
686 let value = substitute(value, '\\n\" $', '', '')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
687 let value = substitute(value, '\\n\"$', '', '')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
688 let value = substitute(value, ' ', '', '')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
689 let value = substitute(value, '\\t', ' ', 'g')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
690
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
691 if value != '' || !empty(s:asm_lines)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
692 call add(s:asm_lines, value)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
693 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
694 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
695 endfunc
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
696
12395
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
697 " 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
698 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
699 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
700
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
701 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
702 " 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
703 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
704 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
705 endif
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
706
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
707 if s:parsing_disasm_msg
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
708 call s:HandleDisasmMsg(msg)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
709 elseif msg != ''
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
710 if msg =~ '^\(\*stopped\|\*running\|=thread-selected\)'
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
711 call s:HandleCursor(msg)
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
712 elseif msg =~ '^\^done,bkpt=' || msg =~ '^=breakpoint-created,'
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
713 call s:HandleNewBreakpoint(msg)
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
714 elseif msg =~ '^=breakpoint-deleted,'
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
715 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
716 elseif msg =~ '^=thread-group-started'
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
717 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
718 elseif msg =~ '^\^done,value='
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
719 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
720 elseif msg =~ '^\^error,msg='
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
721 call s:HandleError(msg)
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
722 elseif msg =~ '^disassemble'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
723 let s:parsing_disasm_msg = 1
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
724 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
725 endif
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
726 endif
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
727 endfor
39e1087e7094 patch 8.0.1077: no debugger making use of the terminal window
Christian Brabandt <cb@256bit.org>
parents: 12254
diff changeset
728 endfunc
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
729
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
730 func s:GotoProgram()
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
731 if has('win32')
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
732 if executable('powershell')
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
733 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
734 endif
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
735 else
18878
ef90e5bbb971 Minor runtime file updates.
Bram Moolenaar <Bram@vim.org>
parents: 18750
diff changeset
736 call win_gotoid(s:ptywin)
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
737 endif
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
738 endfunc
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
739
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
740 " 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
741 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
742 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
743 set cpo&vim
e91659ae6614 patch 8.1.0195: terminal debugger commands don't always work
Christian Brabandt <cb@256bit.org>
parents: 14356
diff changeset
744
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
745 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
746 command Clear call s:ClearBreakpoint()
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
747 command Step call s:SendCommand('-exec-step')
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
748 command Over call s:SendCommand('-exec-next')
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
749 command Finish call s:SendCommand('-exec-finish')
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
750 command -nargs=* Run call s:Run(<q-args>)
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
751 command -nargs=* Arguments call s:SendCommand('-exec-arguments ' . <q-args>)
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
752 command Stop call s:SendCommand('-exec-interrupt')
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
753
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
754 " using -exec-continue results in CTRL-C in gdb window not working
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
755 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
756 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
757 else
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
758 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
759 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
760
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
761 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
762 command Gdb call win_gotoid(s:gdbwin)
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
763 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
764 command Source call s:GotoSourcewinOrCreateIt()
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
765 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
766 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
767
20552
74e3316c1d5a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 19523
diff changeset
768 if !exists('g:termdebug_map_K') || g:termdebug_map_K
74e3316c1d5a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 19523
diff changeset
769 let s:k_map_saved = maparg('K', 'n', 0, 1)
74e3316c1d5a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 19523
diff changeset
770 nnoremap K :Evaluate<CR>
74e3316c1d5a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 19523
diff changeset
771 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
772
13051
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12883
diff changeset
773 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
774 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
775
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
776 if !exists('g:termdebug_popup') || g:termdebug_popup != 0
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
777 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
778 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
779 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
780 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
781 an 1.220 PopUp.Clear\ breakpoint :Clear<CR>
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
782 an 1.230 PopUp.Evaluate :Evaluate<CR>
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
783 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
784 endif
14360
e91659ae6614 patch 8.1.0195: terminal debugger commands don't always work
Christian Brabandt <cb@256bit.org>
parents: 14356
diff changeset
785
e91659ae6614 patch 8.1.0195: terminal debugger commands don't always work
Christian Brabandt <cb@256bit.org>
parents: 14356
diff changeset
786 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
787 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
788
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
789 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
790
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
791 " 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
792 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
793 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
794 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
795 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
796 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
797 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
798 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
799 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
800 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
801 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
802 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
803
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
804 " 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
805 func s:DeleteCommands()
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
806 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
807 delcommand Clear
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
808 delcommand Step
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
809 delcommand Over
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
810 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
811 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
812 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
813 delcommand Stop
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
814 delcommand Continue
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
815 delcommand Evaluate
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
816 delcommand Gdb
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
817 delcommand Program
13682
fc660a6ef37d patch 8.0.1713: terminal debugger doesn't handle arguments
Christian Brabandt <cb@256bit.org>
parents: 13592
diff changeset
818 delcommand Source
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
819 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
820 delcommand Winbar
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
821
23164
99ef85ff1af4 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22824
diff changeset
822 if exists('s:k_map_saved')
99ef85ff1af4 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22824
diff changeset
823 if empty(s:k_map_saved)
99ef85ff1af4 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22824
diff changeset
824 nunmap K
99ef85ff1af4 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22824
diff changeset
825 else
99ef85ff1af4 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22824
diff changeset
826 call mapset('n', 0, s:k_map_saved)
99ef85ff1af4 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22824
diff changeset
827 endif
20552
74e3316c1d5a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 19523
diff changeset
828 unlet s:k_map_saved
74e3316c1d5a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 19523
diff changeset
829 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
830
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
831 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
832 " 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
833 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
834 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
835 if win_gotoid(winid)
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
836 aunmenu WinBar.Step
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
837 aunmenu WinBar.Next
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
838 aunmenu WinBar.Finish
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
839 aunmenu WinBar.Cont
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
840 aunmenu WinBar.Stop
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
841 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
842 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
843 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
844 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
845 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
846
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
847 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
848 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
849 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
850 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
851 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
852 aunmenu PopUp.Clear\ breakpoint
1ffba37fd222 patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse
Christian Brabandt <cb@256bit.org>
parents: 13341
diff changeset
853 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
854 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
855 endif
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
856
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
857 exe 'sign unplace ' . s:pc_id
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
858 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
859 for subid in keys(entries)
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
860 exe 'sign unplace ' . 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
861 endfor
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
862 endfor
14143
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
863 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
864 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
865
12455
85ddf8e00595 patch 8.0.1107: terminal debugger jumps to non-existing file
Christian Brabandt <cb@256bit.org>
parents: 12425
diff changeset
866 sign undefine debugPC
14143
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
867 for val in s:BreakpointSigns
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
868 exe "sign undefine debugBreakpoint" . val
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
869 endfor
14147
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14143
diff changeset
870 let s:BreakpointSigns = []
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
871 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
872
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
873 " :Break - Set a breakpoint at the cursor position.
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
874 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
875 " 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
876 " 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
877 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
878 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
879 let do_continue = 1
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
880 if s:way == 'prompt'
14147
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14143
diff changeset
881 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
882 else
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
883 call s:SendCommand('-exec-interrupt')
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
884 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
885 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
886 endif
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
887
14143
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
888 " 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
889 let at = empty(a:at) ?
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
890 \ fnameescape(expand('%:p')) . ':' . line('.') : a:at
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
891 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
892 if do_continue
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
893 call s:SendCommand('-exec-continue')
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
894 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
895 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
896
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
897 " :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
898 func s:ClearBreakpoint()
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
899 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
900 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
901 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
902 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
903 let idx = 0
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
904 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
905 if has_key(s:breakpoints, id)
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
906 " Assume this always works, the reply is simply "^done".
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
907 call s:SendCommand('-break-delete ' . id)
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
908 for subid in keys(s:breakpoints[id])
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
909 exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid)
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
910 endfor
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
911 unlet s:breakpoints[id]
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
912 unlet s:breakpoint_locations[bploc][idx]
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
913 break
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
914 else
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
915 let idx += 1
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
916 endif
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
917 endfor
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
918 if empty(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
919 unlet s:breakpoint_locations[bploc]
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
920 endif
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
921 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
922 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
923
12833
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
924 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
925 if a:args != ''
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
926 call s:SendCommand('-exec-arguments ' . a:args)
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
927 endif
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
928 call s:SendCommand('-exec-run')
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
929 endfunc
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
930
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
931 func s:SendEval(expr)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
932 call s:SendCommand('-data-evaluate-expression "' . a:expr . '"')
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
933 let s:evalexpr = a:expr
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
934 endfunc
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
935
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
936 " :Evaluate - evaluate what is under the cursor
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
937 func s:Evaluate(range, arg)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
938 if a:arg != ''
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
939 let expr = a:arg
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
940 elseif a:range == 2
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
941 let pos = getcurpos()
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
942 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
943 let regt = getregtype('v')
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
944 normal! gv"vy
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
945 let expr = @v
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
946 call setpos('.', pos)
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
947 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
948 else
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
949 let expr = expand('<cexpr>')
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
950 endif
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
951 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
952 call s:SendEval(expr)
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
953 endfunc
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
954
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
955 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
956 let s:evalFromBalloonExpr = 0
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
957
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
958 " 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
959 func s:HandleEvaluate(msg)
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
960 let value = substitute(a:msg, '.*value="\(.*\)"', '\1', '')
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
961 let value = substitute(value, '\\"', '"', 'g')
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
962 if s:evalFromBalloonExpr
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
963 if s:evalFromBalloonExprResult == ''
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
964 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
965 else
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
966 let s:evalFromBalloonExprResult .= ' = ' . value
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
967 endif
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
968 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
969 else
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
970 echomsg '"' . s:evalexpr . '": ' . value
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
971 endif
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
972
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12773
diff changeset
973 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
974 " Looks like a pointer, also display what it points to.
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
975 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
976 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
977 else
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
978 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
979 endif
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
980 endfunc
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
981
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
982 " 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
983 " if there is any.
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
984 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
985 if v:beval_winid != s:sourcewin
17372
b9bc47742df6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
986 return ''
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
987 endif
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
988 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
989 " 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
990 " mouse triggers a balloon.
17372
b9bc47742df6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
991 return ''
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
992 endif
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
993 let s:evalFromBalloonExpr = 1
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
994 let s:evalFromBalloonExprResult = ''
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
995 let s:ignoreEvalError = 1
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
996 call s:SendEval(v:beval_text)
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
997 return ''
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
998 endfunc
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
999
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1000 " Handle an error.
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1001 func s:HandleError(msg)
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
1002 if s:ignoreEvalError
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1003 " Result of s:SendEval() failed, ignore.
13341
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
1004 let s:ignoreEvalError = 0
acd7eaa13d2b Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
1005 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
1006 return
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12833
diff changeset
1007 endif
12425
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1008 echoerr substitute(a:msg, '.*msg="\(.*\)"', '\1', '')
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1009 endfunc
29d21591ad6b patch 8.0.1092: terminal debugger can't evaluate expressions
Christian Brabandt <cb@256bit.org>
parents: 12411
diff changeset
1010
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
1011 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
1012 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
1013 new
14107
274c9f1fbfd2 patch 8.1.0071: terminal debugger only works with the terminal feature
Christian Brabandt <cb@256bit.org>
parents: 13706
diff changeset
1014 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
1015 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
1016 endif
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
1017 endfunc
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
1018
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1019 func s:GotoAsmwinOrCreateIt()
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1020 if !win_gotoid(s:asmwin)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1021 if win_gotoid(s:sourcewin)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1022 exe 'rightbelow new'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1023 else
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1024 exe 'new'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1025 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1026
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1027 let s:asmwin = win_getid(winnr())
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1028
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1029 setlocal nowrap
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1030 setlocal number
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1031 setlocal noswapfile
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1032 setlocal buftype=nofile
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1033
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1034 let asmbuf = bufnr('Termdebug-asm-listing')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1035 if asmbuf > 0
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1036 exe 'buffer' . asmbuf
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1037 else
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1038 exe 'file Termdebug-asm-listing'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1039 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1040
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1041 if exists('g:termdebug_disasm_window')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1042 if g:termdebug_disasm_window > 1
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1043 exe 'resize ' . g:termdebug_disasm_window
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1044 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1045 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1046 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1047
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1048 if s:asm_addr != ''
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1049 let lnum = search('^' . s:asm_addr)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1050 if lnum == 0
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1051 if s:stopped
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1052 call s:SendCommand('disassemble $pc')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1053 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1054 else
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1055 exe 'sign unplace ' . s:asm_id
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1056 exe 'sign place ' . s:asm_id . ' line=' . lnum . ' name=debugPC'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1057 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1058 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1059 endfunc
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1060
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1061 " 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
1062 " 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
1063 func s:HandleCursor(msg)
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1064 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
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 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
1067 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
1068 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
1069 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
1070 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
1071 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
1072 endif
db9ffed7e1fc patch 8.0.1293: setting a breakpoint in the terminal debugger sometimes fails
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
1073
14143
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
1074 if a:msg =~ 'fullname='
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
1075 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
1076 else
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
1077 let fname = ''
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
1078 endif
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1079
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1080 if a:msg =~ 'addr='
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1081 let asm_addr = s:GetAsmAddr(a:msg)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1082 if asm_addr != ''
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1083 let s:asm_addr = asm_addr
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1084
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1085 let curwinid = win_getid(winnr())
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1086 if win_gotoid(s:asmwin)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1087 let lnum = search('^' . s:asm_addr)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1088 if lnum == 0
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1089 call s:SendCommand('disassemble $pc')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1090 else
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1091 exe 'sign unplace ' . s:asm_id
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1092 exe 'sign place ' . s:asm_id . ' line=' . lnum . ' name=debugPC'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1093 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1094
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1095 call win_gotoid(curwinid)
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1096 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1097 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1098 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23164
diff changeset
1099
13592
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
1100 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
1101 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
1102 if lnum =~ '^[0-9]*$'
14147
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14143
diff changeset
1103 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
1104 if expand('%:p') != fnamemodify(fname, ':p')
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1105 if &modified
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1106 " TODO: find existing window
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1107 exe 'split ' . fnameescape(fname)
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1108 let s:sourcewin = win_getid(winnr())
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1109 call s:InstallWinbar()
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1110 else
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1111 exe 'edit ' . fnameescape(fname)
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1112 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1113 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
1114 exe lnum
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1115 exe 'sign unplace ' . s:pc_id
22013
125051dff419 patch 8.2.1556: cursorline highlighting always overrules sign highlighting
Bram Moolenaar <Bram@vim.org>
parents: 21499
diff changeset
1116 exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC priority=110 file=' . fname
22723
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
1117 if !exists('b:save_signcolumn')
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
1118 let b:save_signcolumn = &signcolumn
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
1119 call add(s:signcolumn_buflist, bufnr())
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22013
diff changeset
1120 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
1121 setlocal signcolumn=yes
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1122 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
1123 elseif !s:stopped || fname != ''
13592
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
1124 exe 'sign unplace ' . s:pc_id
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
1125 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1126
13592
a64485061f75 patch 8.0.1668: terminal debugger: can't re-open source code window
Christian Brabandt <cb@256bit.org>
parents: 13564
diff changeset
1127 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
1128 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1129
14143
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
1130 let s:BreakpointSigns = []
2aec369c4fc3 patch 8.1.0089: error when ending the terminal debugger
Christian Brabandt <cb@256bit.org>
parents: 14127
diff changeset
1131
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1132 func s:CreateBreakpoint(id, subid)
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1133 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
1134 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
1135 call add(s:BreakpointSigns, nr)
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1136 exe "sign define debugBreakpoint" . nr . " text=" . substitute(nr, '\..*', '', '') . " texthl=debugBreakpoint"
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
1137 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
1138 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
1139
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1140 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
1141 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
1142 endfunction
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1143
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1144 " Handle setting a breakpoint
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1145 " Will update the sign that shows the breakpoint
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1146 func s:HandleNewBreakpoint(msg)
14165
5b5364d0729d patch 8.1.0100: terminal debugger: error when setting a watch point
Christian Brabandt <cb@256bit.org>
parents: 14151
diff changeset
1147 if a:msg !~ 'fullname='
5b5364d0729d patch 8.1.0100: terminal debugger: error when setting a watch point
Christian Brabandt <cb@256bit.org>
parents: 14151
diff changeset
1148 " a watch does not have a file name
5b5364d0729d patch 8.1.0100: terminal debugger: error when setting a watch point
Christian Brabandt <cb@256bit.org>
parents: 14151
diff changeset
1149 return
5b5364d0729d patch 8.1.0100: terminal debugger: error when setting a watch point
Christian Brabandt <cb@256bit.org>
parents: 14151
diff changeset
1150 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
1151 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
1152 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
1153 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
1154 continue
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1155 endif
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1156 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
1157 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
1158 return
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1159 endif
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1160
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1161 " 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
1162 " 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
1163 let [id, subid; _] = map(split(nr . '.0', '\.'), 'v:val + 0')
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1164 call s:CreateBreakpoint(id, subid)
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1165
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1166 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
1167 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
1168 else
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1169 let entries = {}
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1170 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
1171 endif
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1172 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
1173 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
1174 else
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1175 let entry = {}
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1176 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
1177 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1178
15093
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1179 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
1180 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
1181 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
1182
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1183 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
1184 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
1185 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
1186 endif
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1187 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
1188
15093
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1189 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
1190 call s:PlaceSign(id, 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
1191 endif
8690318105ee patch 8.1.0557: Termdebug: gdb may use X.Y for breakpoint number
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
1192 endfor
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1193 endfunc
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1194
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1195 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
1196 let nr = printf('%d.%d', a:id, a:subid)
22824
8dad79c661d1 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 22723
diff changeset
1197 exe 'sign place ' . s:Breakpoint2SignNumber(a:id, a:subid) . ' line=' . a:entry['lnum'] . ' name=debugBreakpoint' . nr . ' priority=110 file=' . a:entry['fname']
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1198 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
1199 endfunc
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1200
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1201 " Handle deleting a breakpoint
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1202 " 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
1203 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
1204 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
1205 if empty(id)
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1206 return
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1207 endif
15129
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1208 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
1209 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
1210 if has_key(entry, 'placed')
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1211 exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid)
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1212 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
1213 endif
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1214 endfor
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1215 unlet s:breakpoints[id]
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1216 endif
12411
5d4d744151c2 patch 8.0.1085: terminal debugger can't set breakpoints
Christian Brabandt <cb@256bit.org>
parents: 12395
diff changeset
1217 endfunc
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1218
14147
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14143
diff changeset
1219 " 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
1220 " 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
1221 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
1222 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
1223 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
1224 return
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14143
diff changeset
1225 endif
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14143
diff changeset
1226 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
1227 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
1228 endfunc
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14143
diff changeset
1229
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1230 " 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
1231 func s:BufRead()
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1232 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
1233 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
1234 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
1235 if entry['fname'] == fname
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1236 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
1237 endif
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1238 endfor
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1239 endfor
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1240 endfunc
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1241
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1242 " 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
1243 func s:BufUnloaded()
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1244 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
1245 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
1246 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
1247 if entry['fname'] == fname
18130
1e5672da6a69 Updte runtime files
Bram Moolenaar <Bram@vim.org>
parents: 17962
diff changeset
1248 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
1249 endif
2090f267b311 patch 8.1.0575: Termdebug: clearing multi-breakpoint does not work
Bram Moolenaar <Bram@vim.org>
parents: 15093
diff changeset
1250 endfor
12487
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1251 endfor
3f16cf18386c patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents: 12455
diff changeset
1252 endfunc
14356
9339e4dbf6bf patch 8.1.0193: terminal debugger buttons don't always work
Christian Brabandt <cb@256bit.org>
parents: 14165
diff changeset
1253
9339e4dbf6bf patch 8.1.0193: terminal debugger buttons don't always work
Christian Brabandt <cb@256bit.org>
parents: 14165
diff changeset
1254 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
1255 unlet s:keepcpo