0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.0.1562: the terminal debugger can't set a breakpoint with the mouse

Problem:    The terminal debugger can't set a breakpoint with the mouse.
Solution:   Add popup menu entries.
This commit is contained in:
Bram Moolenaar 2018-03-03 20:47:21 +01:00
parent 069dafc1de
commit 71137fed4d
3 changed files with 103 additions and 43 deletions

View File

@ -7,8 +7,6 @@
Terminal window support *terminal* Terminal window support *terminal*
WARNING: THIS IS ONLY PARTLY IMPLEMENTED, ANYTHING CAN STILL CHANGE
The terminal feature is optional, use this to check if your Vim has it: > The terminal feature is optional, use this to check if your Vim has it: >
echo has('terminal') echo has('terminal')
If the result is "1" you have it. If the result is "1" you have it.
@ -40,7 +38,6 @@ If the result is "1" you have it.
{Vi does not have any of these commands} {Vi does not have any of these commands}
{only available when compiled with the |+terminal| feature} {only available when compiled with the |+terminal| feature}
The terminal feature requires the |+multi_byte|, |+job| and |+channel| features. The terminal feature requires the |+multi_byte|, |+job| and |+channel| features.
============================================================================== ==============================================================================
@ -481,7 +478,7 @@ program window A terminal window for the executed program. When "run" is
The current window is used to show the source code. When gdb pauses the The current window is used to show the source code. When gdb pauses the
source file location will be displayed, if possible. A sign is used to source file location will be displayed, if possible. A sign is used to
highlight the current position (using highlight group debugPC). highlight the current position, using highlight group debugPC.
If the buffer in the current window is modified, another window will be opened If the buffer in the current window is modified, another window will be opened
to display the current gdb position. to display the current gdb position.
@ -506,6 +503,7 @@ You should now have three windows:
source - where you started, has a window toolbar with buttons source - where you started, has a window toolbar with buttons
gdb - you can type gdb commands here gdb - you can type gdb commands here
program - the executed program will use this window program - the executed program will use this window
You can use CTRL-W CTRL-W or the mouse to move focus between windows. You can use CTRL-W CTRL-W or the mouse to move focus between windows.
Put focus on the gdb window and type: > Put focus on the gdb window and type: >
break ex_help break ex_help
@ -526,6 +524,8 @@ displayed:
This way you can inspect the value of local variables. You can also focus the This way you can inspect the value of local variables. You can also focus the
gdb window and use a "print" command, e.g.: > gdb window and use a "print" command, e.g.: >
print *eap print *eap
If mouse pointer movements are working, Vim will also show a balloon when the
mouse rests on text that can be evaluated by gdb.
Now go back to the source window and put the cursor on the first line after Now go back to the source window and put the cursor on the first line after
the for loop, then type: > the for loop, then type: >
@ -561,38 +561,42 @@ Put focus on the gdb window to type commands there. Some common ones are:
- frame N go to the Nth stack frame - frame N go to the Nth stack frame
- continue continue execution - continue continue execution
In the window showing the source code these commands can used to control gdb: In the window showing the source code these commands can be used to control gdb:
:Run [args] run the program with [args] or the previous arguments `:Run` [args] run the program with [args] or the previous arguments
:Arguments {args} set arguments for the next :Run `:Arguments` {args} set arguments for the next `:Run`
:Break set a breakpoint at the current line; a sign will be displayed `:Break` set a breakpoint at the current line; a sign will be displayed
:Delete delete a breakpoint at the current line `:Clear` delete the breakpoint at the current line
:Step execute the gdb "step" command `:Step` execute the gdb "step" command
:Over execute the gdb "next" command (:Next is a Vim command) `:Over` execute the gdb "next" command (`:Next` is a Vim command)
:Finish execute the gdb "finish" command `:Finish` execute the gdb "finish" command
:Continue execute the gdb "continue" command `:Continue` execute the gdb "continue" command
:Stop interrupt the program `:Stop` interrupt the program
If 'mouse' is set the plugin adds a window toolbar with these entries: If 'mouse' is set the plugin adds a window toolbar with these entries:
Step :Step Step `:Step`
Next :Over Next `:Over`
Finish :Finish Finish `:Finish`
Cont :Continue Cont `:Continue`
Stop :Stop Stop `:Stop`
Eval :Evaluate Eval `:Evaluate`
This way you can use the mouse to perform the most common commands. You need This way you can use the mouse to perform the most common commands. You need
to have the 'mouse' option set to enable mouse clicks. to have the 'mouse' option set to enable mouse clicks.
You can add the window toolbar in other windows you open with: >
:Winbar
Inspecting variables ~ Inspecting variables ~
*termdebug-variables* *termdebug-variables*
:Evaluate evaluate the expression under the cursor `:Evaluate` evaluate the expression under the cursor
K same `K` same
:Evaluate {expr} evaluate {expr} `:Evaluate` {expr} evaluate {expr}
:'<,'>Evaluate evaluate the Visually selected text `:'<,'>Evaluate` evaluate the Visually selected text
This is similar to using "print" in the gdb window. This is similar to using "print" in the gdb window.
You can usually shorten `:Evaluate` to `:Ev`.
Other commands ~ Other commands ~
@ -609,17 +613,21 @@ will break the debugger.
Customizing ~ Customizing ~
*termdebug-customizing*
GDB command *termdebug-customizing*
To change the name of the gdb command, set the "termdebugger" variable before To change the name of the gdb command, set the "termdebugger" variable before
invoking `:Termdebug`: > invoking `:Termdebug`: >
let termdebugger = "mygdb" let termdebugger = "mygdb"
< *gdb-version* < *gdb-version*
Only debuggers fully compatible with gdb will work. Vim uses the GDB/MI Only debuggers fully compatible with gdb will work. Vim uses the GDB/MI
interface. This probably requires gdb version 7.12. if you get this error: interface. This probably requires gdb version 7.12. if you get this error:
Undefined command: "new-ui". Try "help".~ Undefined command: "new-ui". Try "help".~
Then your gdb is too old. Then your gdb is too old.
*hl-debugPC* *hl-debugBreakpoint*
Colors *hl-debugPC* *hl-debugBreakpoint*
The color of the signs can be adjusted with these highlight groups: The color of the signs can be adjusted with these highlight groups:
- debugPC the current position - debugPC the current position
- debugBreakpoint a breakpoint - debugBreakpoint a breakpoint
@ -632,6 +640,20 @@ When 'background' is "dark":
hi debugPC term=reverse ctermbg=darkblue guibg=darkblue hi debugPC term=reverse ctermbg=darkblue guibg=darkblue
hi debugBreakpoint term=reverse ctermbg=red guibg=red hi debugBreakpoint term=reverse ctermbg=red guibg=red
Popup menu *termdebug_popup*
By default the Termdebug plugin sets 'mousemodel' to "popup_setpos" and adds
these entries to the popup menu:
Set breakpoint `:Break`
Clear breakpoint `:Clear`
Evaluate `:Evaluate`
If you don't want this then disable it with: >
let g:termdebug_popup = 0
Vim window width *termdebug_wide*
To change the width of the Vim window when debugging starts, and use a To change the width of the Vim window when debugging starts, and use a
vertical split: > vertical split: >
let g:termdebug_wide = 163 let g:termdebug_wide = 163

View File

@ -201,7 +201,7 @@ endfunc
" Install commands in the current window to control the debugger. " Install commands in the current window to control the debugger.
func s:InstallCommands() func s:InstallCommands()
command Break call s:SetBreakpoint() command Break call s:SetBreakpoint()
command Delete call s:DeleteBreakpoint() command Clear call s:ClearBreakpoint()
command Step call s:SendCommand('-exec-step') command Step call s:SendCommand('-exec-step')
command Over call s:SendCommand('-exec-next') command Over call s:SendCommand('-exec-next')
command Finish call s:SendCommand('-exec-finish') command Finish call s:SendCommand('-exec-finish')
@ -212,24 +212,42 @@ func s:InstallCommands()
command -range -nargs=* Evaluate call s:Evaluate(<range>, <q-args>) command -range -nargs=* Evaluate call s:Evaluate(<range>, <q-args>)
command Gdb call win_gotoid(s:gdbwin) command Gdb call win_gotoid(s:gdbwin)
command Program call win_gotoid(s:ptywin) command Program call win_gotoid(s:ptywin)
command Winbar call s:InstallWinbar()
" TODO: can the K mapping be restored? " TODO: can the K mapping be restored?
nnoremap K :Evaluate<CR> nnoremap K :Evaluate<CR>
if has('menu') && &mouse != '' if has('menu') && &mouse != ''
nnoremenu WinBar.Step :Step<CR> call s:InstallWinbar()
nnoremenu WinBar.Next :Over<CR>
nnoremenu WinBar.Finish :Finish<CR> if !exists('g:termdebug_popup') || g:termdebug_popup != 0
nnoremenu WinBar.Cont :Continue<CR> let s:saved_mousemodel = &mousemodel
nnoremenu WinBar.Stop :Stop<CR> let &mousemodel = 'popup_setpos'
nnoremenu WinBar.Eval :Evaluate<CR> an 1.200 PopUp.-SEP3- <Nop>
an 1.210 PopUp.Set\ breakpoint :Break<CR>
an 1.220 PopUp.Clear\ breakpoint :Clear<CR>
an 1.230 PopUp.Evaluate :Evaluate<CR>
endif
endif endif
endfunc endfunc
let s:winbar_winids = []
" Install the window toolbar in the current window.
func s:InstallWinbar()
nnoremenu WinBar.Step :Step<CR>
nnoremenu WinBar.Next :Over<CR>
nnoremenu WinBar.Finish :Finish<CR>
nnoremenu WinBar.Cont :Continue<CR>
nnoremenu WinBar.Stop :Stop<CR>
nnoremenu WinBar.Eval :Evaluate<CR>
call add(s:winbar_winids, win_getid(winnr()))
endfunc
" Delete installed debugger commands in the current window. " Delete installed debugger commands in the current window.
func s:DeleteCommands() func s:DeleteCommands()
delcommand Break delcommand Break
delcommand Delete delcommand Clear
delcommand Step delcommand Step
delcommand Over delcommand Over
delcommand Finish delcommand Finish
@ -240,16 +258,34 @@ func s:DeleteCommands()
delcommand Evaluate delcommand Evaluate
delcommand Gdb delcommand Gdb
delcommand Program delcommand Program
delcommand Winbar
nunmap K nunmap K
if has('menu') if has('menu')
aunmenu WinBar.Step " Remove the WinBar entries from all windows where it was added.
aunmenu WinBar.Next let curwinid = win_getid(winnr())
aunmenu WinBar.Finish for winid in s:winbar_winids
aunmenu WinBar.Cont if win_gotoid(winid)
aunmenu WinBar.Stop aunmenu WinBar.Step
aunmenu WinBar.Eval aunmenu WinBar.Next
aunmenu WinBar.Finish
aunmenu WinBar.Cont
aunmenu WinBar.Stop
aunmenu WinBar.Eval
endif
endfor
call win_gotoid(curwinid)
let s:winbar_winids = []
if exists('s:saved_mousemodel')
let &mousemodel = s:saved_mousemodel
unlet s:saved_mousemodel
aunmenu PopUp.-SEP3-
aunmenu PopUp.Set\ breakpoint
aunmenu PopUp.Clear\ breakpoint
aunmenu PopUp.Evaluate
endif
endif endif
exe 'sign unplace ' . s:pc_id exe 'sign unplace ' . s:pc_id
@ -278,8 +314,8 @@ func s:SetBreakpoint()
endif endif
endfunc endfunc
" :Delete - Delete a breakpoint at the cursor position. " :Clear - Delete a breakpoint at the cursor position.
func s:DeleteBreakpoint() func s:ClearBreakpoint()
let fname = fnameescape(expand('%:p')) let fname = fnameescape(expand('%:p'))
let lnum = line('.') let lnum = line('.')
for [key, val] in items(s:breakpoints) for [key, val] in items(s:breakpoints)

View File

@ -778,6 +778,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1562,
/**/ /**/
1561, 1561,
/**/ /**/