puremourning / vimspector

vimspector - A multi-language debugging system for Vim
http://puremourning.github.io/vimspector-web
Apache License 2.0
4.11k stars 175 forks source link

Executing twice <Plug>VimspectorRunToCursor on a line with a breakpoint removes the breakpoint #719

Closed Aster89 closed 1 year ago

Aster89 commented 1 year ago

Description

Say the debugger is paused on line 10 (e.g. on a breakpoint) and that a breakpoint is at line 20. Calling <Plug>VimspectorRunToCursor once on line 20 does nothing (apparently) calling it a second time makes the program continue to line 20, but also removes the breakpoint.

Works in vim?

Reproducable in Vim

Works with clean config?

Yes

Sample project works?

Not reproducable with sample project

Minimal Reproduction

asciicast

List of steps to reproduce:

  1. Run vim ---clean Nu /path/to/vimspector/support/minimal_vimrc a_file_of_your_choice (I've tried with C++ file, but I think it's irrelevant)
  2. Put two breakpoints
  3. Start the debugging -> the cursor will stop on the first breakpoint
  4. Move the cursor to the second breakpoint
  5. execute the <Plug>VimspectorRunToCursor -> nothing will happen
  6. execute the <Plug>VimspectorRunToCursor again -> the program will get there but the breakpoint is gone

Expected Behaviour

Program should continue to that line upon the first call to <Plug>VimspectorRunToCursor.

Actual Behaviour

The program doesn't continue upon the first call to <Plug>VimspectorRunToCursor; it does so on the second call, but also removes the breakpoint.

Additional information

As regards Sample project works?, I've tried opening the test_c.cpp file with the minimal vimrc for vimspector, but upon starting the debugger I get

 Unable to start or connect to debug adapter

 Check :messages and :VimspectorToggleLog for more information.

 :VimspectorReset to close down vimspector

and here's the log:

2023-02-11 10:19:25,151 - INFO - **** INITIALISING NEW VIMSPECTOR SESSION ****
2023-02-11 10:19:25,151 - INFO - API is: 
2023-02-11 10:19:25,151 - INFO - VIMSPECTOR_HOME = /home/me/.vim/plugged/vimspector/python3/vimspector/../..
2023-02-11 10:19:25,151 - INFO - gadgetDir = /home/me/.vim/plugged/vimspector/gadgets/linux
2023-02-11 10:19:26,458 - INFO - User requested start debug session with {}
2023-02-11 10:19:26,460 - DEBUG - Reading configurations from: None
2023-02-11 10:19:26,460 - DEBUG - Reading configurations from: /home/me/.vim/plugged/vimspector/support/test/cpp/simple_c_program/.vimspector.json
2023-02-11 10:19:26,494 - DEBUG - Reading gadget config: /home/me/.vim/plugged/vimspector/gadgets/linux/.gadgets.json
2023-02-11 10:19:26,525 - DEBUG - Reading gadget config: None
2023-02-11 10:19:28,073 - INFO - Configuration: {"adapter": "custom-codelldb", "configuration": {"request": "launch", "program": "/home/me/.vim/plugged/vimspector/support/test/cpp/simple_c_program/test"}}
2023-02-11 10:19:28,073 - INFO - Adapter: {"command": ["/home/me/Development/vimspector/CodeLLDB/build/adapter/codelldb", "--port", "46607"], "configuration": {"args": [], "cargo": {}, "cwd": "/home/me/.vim/plugged/vimspector/support/test/cpp/simple_c_program", "env": {}, "name": "lldb", "terminal": "integrated", "type": "lldb"}, "name": "CodeLLDB", "port": "46607", "type": "CodeLLDB"}
2023-02-11 10:19:28,074 - DEBUG - min_width/height: 149/50, actual: 232/74 - result: horizontal
2023-02-11 10:19:28,100 - DEBUG - LAUNCH!
2023-02-11 10:19:28,102 - INFO - Starting debug adapter with: {"command": ["/home/me/Development/vimspector/CodeLLDB/build/adapter/codelldb", "--port", "46607"], "configuration": {"args": [], "cargo": {}, "cwd": "/home/me/.vim/plugged/vimspector/support/test/cpp/simple_c_program", "env": {}, "name": "lldb", "terminal": "integrated", "type": "lldb"}, "name": "CodeLLDB", "port": "46607", "type": "CodeLLDB"}
2023-02-11 10:19:28,102 - DEBUG - Connection Type: channel
2023-02-11 10:19:38,191 - ERROR - Unable to start debug server
2023-02-11 10:19:38,192 - INFO - Failed to launch or attach to the debug adapter

Installation Type

Plugin Manager (git clone)

Vimspector version

4deaffdec34508621934fa4532748ee9deb1f55c

Debug Info

No response

Log file

No response

Vim version

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Jan 12 2023 11:41:18)
Included patches: 1-1182
Compiled by Arch Linux
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               +cindent           +cursorshape       +file_in_path      +job               +menu              +mouse_urxvt       +popupwin          +signs             -tag_any_white     +user_commands     +windows
+arabic            +clientserver      +dialog_con_gui    +find_in_path      +jumplist          +mksession         +mouse_xterm       +postscript        +smartindent       +tcl/dyn           +vartabs           +writebackup
+autocmd           +clipboard         +diff              +float             +keymap            +modify_fname      +multi_byte        +printer           -sodium            +termguicolors     +vertsplit         +X11
+autochdir         +cmdline_compl     +digraphs          +folding           +lambda            +mouse             +multi_lang        +profile           +sound             +terminal          +vim9script        -xfontset
-autoservername    +cmdline_hist      +dnd               -footer            +langmap           +mouseshape        -mzscheme          -python            +spell             +terminfo          +viminfo           +xim
+balloon_eval      +cmdline_info      -ebcdic            +fork()            +libcall           +mouse_dec         +netbeans_intg     +python3/dyn       +startuptime       +termresponse      +virtualedit       -xpm
+balloon_eval_term +comments          +emacs_tags        +gettext           +linebreak         +mouse_gpm         +num64             +quickfix          +statusline        +textobjects       +visual            +xsmp_interact
+browse            +conceal           +eval              -hangul_input      +lispindent        -mouse_jsbterm     +packages          +reltime           -sun_workshop      +textprop          +visualextra       +xterm_clipboard
++builtin_terms    +cryptv            +ex_extra          +iconv             +listcmds          +mouse_netterm     +path_extra        +rightleft         +syntax            +timers            +vreplace          -xterm_save
+byte_offset       +cscope            +extra_search      +insert_expand     +localmap          +mouse_sgr         +perl/dyn          +ruby/dyn          +tag_binary        +title             +wildignore
+channel           +cursorbind        -farsi             +ipv6              +lua/dyn           -mouse_sysmouse    +persistent_undo   +scrollbind        -tag_old_static    +toolbar           +wildmenu
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/harfbuzz -I/usr/include/freet
ype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/includ
e/cloudproviders -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -pthread -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wformat -Wer
ror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/vim/src=/usr/src/debug/vim -flto=auto -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.36/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto -L/usr/local/lib -o vim -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gob
ject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lelf -lcanberra -lacl -lattr -lgpm -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.36/core_perl/CORE -Wl,-O1,--sort-common,--a
s-needed,-z,relro,-z,now -flto=auto -fstack-protector-strong -L/usr/local/lib -L/usr/lib/perl5/5.36/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm

Python version

No response

Neovim diagnostics

No response

Operating System

up-to-date ArchLinux

Declaration

puremourning commented 1 year ago

Thanks for the report. This doesn't entirely surprise me (as the run-to-cursor implementation is quite hacky).

puremourning commented 1 year ago

As regards Sample project works?, I've tried opening the test_c.cpp file with the minimal vimrc for vimspector, but upon starting the debugger I get

probably you have to build the binary first

puremourning commented 1 year ago

I can't repro this. Is it still an issue?

Aster89 commented 1 year ago

I can't repro this. Is it still an issue?

Yes, with precisely the repro steps I provided. I've tried again (now Included patches: 1-1420 and I'm on 6c346fb) and recorded via q. Here's the content of the register (I've manually changed Enter to a literal ^M and the likes):

:VimspectorBreakpoints^Mi^M21^M^M^M^Mi^M25^M^M^M^M^Wk:call vimspector#Launch()^M3^M25gg:call vimspector#RunToCursor()^M:^P^M:call vimspector#Continue()^M
puremourning commented 1 year ago

ah ok thanks, I can repro. not sure what I was doing yesterday.

SO there are 2 issues here:

  1. the first run-to-cursor does nothing. This is a bug (easy to fix)
  2. the act of doing "run-to-cursor" replaces a line-breakpoint on the target line with a 'temporary' breakpoint and is thus deleted when it's hit (this is a bit trickier to fix)

I have a fix for this and will see how badly the tests break :p