vimspector icon indicating copy to clipboard operation
vimspector copied to clipboard

No example configuration for bash debugger

Open vimpostor opened this issue 5 years ago • 18 comments

Bash debugging does not work, I don't really understand how to make it work.

I put let g:vimspector_enable_mappings = 'VISUAL_STUDIO' at the top of my vimrc, then later I call Plug 'puremourning/vimspector', my vimspector config is pasted below. Now when I press F9 to toggle breakpoint nothing happens, however :call vimspector#ToggleBreakpoint() successfully toggles the breakpoint. At least the F5 shortcut works and opens something, but the program does not halt at my breakpoint, instead I get:

From client: initialize({"adapterID":"bashdb","clientID":"vimspector","clientName":"vimspector","linesStartAt1":true,"columnsStartAt1":true,"locale":"en_GB","pathFormat":"path","supportsVariableType":true,"supportsVariablePaging":false,"supportsRunInTerminalRequest":true})
To client: {"seq":0,"type":"response","request_seq":0,"command":"initialize","success":true,"body":{"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":false,"supportsEvaluateForHovers":true,"supportsStepBack":false,"supportsSetVariable":false}}
From client: launch({"type":"bashdb","request":"launch","name":"Bash-Debug (simple)","program":"./link.sh","args":[],"cwd":"/home/magnus/.dotfiles","pathBash":"bash","pathBashdb":"/home/magnus/.vim/plugged/vimspector/gadgets/linux/vscode-bash-debug/bashdb_dir/bashdb","pathCat":"cat","pathMkfifo":"mkfifo","pathPkill":"pkill","showDebugOutput":true,"trace":true})
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stderr","output":"::PROXYID::31567\n"}}

Vimspector config file:

{
	"adapters": {
		"bashdb": {
			"name": "bashdb",
			"command": [
				"node",
				"$HOME/.vim/plugged/vimspector/gadgets/linux/vscode-bash-debug/out/bashDebug.js"
			]
		}
	},
	"configurations": {
		"bashdb": {
			"adapter": "bashdb",
			"configuration": {
				"type": "bashdb",
				"request": "launch",
				"name": "Bash-Debug (simple)",
				"program": "./link.sh",
				"args": [],
				"cwd": "$HOME/.dotfiles",
				"pathBash": "bash",
				"pathBashdb": "~/.vim/plugged/vimspector/gadgets/linux/vscode-bash-debug/bashdb_dir/bashdb",
				"pathCat": "cat",
				"pathMkfifo": "mkfifo",
				"pathPkill": "pkill",
				"showDebugOutput": true,
				"trace": true
			}
		}
	}
}

Vimspector log:

2020-01-30 21:02:45,670 - INFO - **** INITIALISING NEW VIMSPECTOR SESSION ****
2020-01-30 21:02:45,670 - INFO - API is: 
2020-01-30 21:02:45,670 - INFO - VIMSPECTOR_HOME = /home/magnus/.vim/plugged/vimspector
2020-01-30 21:02:45,673 - INFO - gadgetDir = /home/magnus/.vim/plugged/vimspector/gadgets/linux
2020-01-30 21:02:45,673 - DEBUG - Toggle found bp at /home/magnus/.dotfiles/link.sh:76 ? False (New)
2020-01-30 21:02:51,710 - INFO - User requested start debug session with {}
2020-01-30 21:02:51,711 - DEBUG - Reading gadget config: /home/magnus/.vim/plugged/vimspector/gadgets/linux/.gadgets.json
2020-01-30 21:02:51,712 - DEBUG - Reading gadget config: None
2020-01-30 21:02:51,714 - INFO - Configuration: {"adapter": "bashdb", "configuration": {"type": "bashdb", "request": "launch", "name": "Bash-Debug (simple)", "program": "./link.sh", "args": [], "cwd": "/home/magnus/.dotfiles", "pathBash": "bash", "pathBashdb": "/home/magnus/.vim/plugged/vimspector/gadgets/linux/vscode-bash-debug/bashdb_dir/bashdb", "pathCat": "cat", "pathMkfifo": "mkfifo", "pathPkill": "pkill", "showDebugOutput": true, "trace": true}}
2020-01-30 21:02:51,714 - INFO - Adapter: {"name": "bashdb", "command": ["node", "/home/magnus/.vim/plugged/vimspector/gadgets/linux/vscode-bash-debug/out/bashDebug.js"]}
2020-01-30 21:02:51,740 - INFO - Starting debug adapter with: {"name": "bashdb", "command": ["node", "/home/magnus/.vim/plugged/vimspector/gadgets/linux/vscode-bash-debug/out/bashDebug.js"]}
2020-01-30 21:02:51,744 - INFO - Debug Adapter Started
2020-01-30 21:02:51,744 - DEBUG - Sending Message: {"command": "initialize", "arguments": {"adapterID": "bashdb", "clientID": "vimspector", "clientName": "vimspector", "linesStartAt1": true, "columnsStartAt1": true, "locale": "en_GB", "pathFormat": "path", "supportsVariableType": true, "supportsVariablePaging": false, "supportsRunInTerminalRequest": true}, "seq": 0, "type": "request"}
2020-01-30 21:02:51,745 - DEBUG - Calling: vimspector#internal#job#Send(g:vimspector_internal_arg_0)
2020-01-30 21:02:51,811 - DEBUG - Message received: {'seq': 1, 'type': 'response', 'request_seq': 0, 'command': 'initialize', 'success': True, 'body': {'supportsConditionalBreakpoints': True, 'supportsConfigurationDoneRequest': False, 'supportsEvaluateForHovers': True, 'supportsStepBack': False, 'supportsSetVariable': False}}
2020-01-30 21:02:51,811 - DEBUG - LAUNCH!
2020-01-30 21:02:51,811 - DEBUG - Sending Message: {"command": "launch", "arguments": {"type": "bashdb", "request": "launch", "name": "Bash-Debug (simple)", "program": "./link.sh", "args": [], "cwd": "/home/magnus/.dotfiles", "pathBash": "bash", "pathBashdb": "/home/magnus/.vim/plugged/vimspector/gadgets/linux/vscode-bash-debug/bashdb_dir/bashdb", "pathCat": "cat", "pathMkfifo": "mkfifo", "pathPkill": "pkill", "showDebugOutput": true, "trace": true}, "seq": 1, "type": "request"}
2020-01-30 21:02:51,811 - DEBUG - Calling: vimspector#internal#job#Send(g:vimspector_internal_arg_0)
2020-01-30 21:02:51,823 - DEBUG - Message received: {'seq': 2, 'type': 'event', 'event': 'output', 'body': {'category': 'stdout', 'output': 'From client: initialize({"adapterID":"bashdb","clientID":"vimspector","clientName":"vimspector","linesStartAt1":true,"columnsStartAt1":true,"locale":"en_GB","pathFormat":"path","supportsVariableType":true,"supportsVariablePaging":false,"supportsRunInTerminalRequest":true})\n'}}
2020-01-30 21:02:51,824 - DEBUG - Message received: {'seq': 3, 'type': 'event', 'event': 'output', 'body': {'category': 'stdout', 'output': 'To client: {"seq":0,"type":"response","request_seq":0,"command":"initialize","success":true,"body":{"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":false,"supportsEvaluateForHovers":true,"supportsStepBack":false,"supportsSetVariable":false}}\n'}}
2020-01-30 21:02:51,824 - DEBUG - Message received: {'seq': 4, 'type': 'event', 'event': 'output', 'body': {'category': 'stdout', 'output': 'From client: launch({"type":"bashdb","request":"launch","name":"Bash-Debug (simple)","program":"./link.sh","args":[],"cwd":"/home/magnus/.dotfiles","pathBash":"bash","pathBashdb":"/home/magnus/.vim/plugged/vimspector/gadgets/linux/vscode-bash-debug/bashdb_dir/bashdb","pathCat":"cat","pathMkfifo":"mkfifo","pathPkill":"pkill","showDebugOutput":true,"trace":true})\n'}}
2020-01-30 21:02:51,825 - INFO - Server stderr: (node:31657) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at BashDebugSession.launchRequest (/home/magnus/.vim/plugged/vimspector/gadgets/linux/download/vscode-bash-debug/v0.3.6/root/extension/out/bashDebug.js:83:30)
    at BashDebugSession.dispatchRequest (/home/magnus/.vim/plugged/vimspector/gadgets/linux/download/vscode-bash-debug/v0.3.6/root/extension/node_modules/vscode-debugadapter/lib/debugSession.js:342:22)
    at BashDebugSession.dispatchRequest (/home/magnus/.vim/plugged/vimspector/gadgets/linux/download/vscode-bash-debug/v0.3.6/root/extension/node_modules/vscode-debugadapter/lib/loggingDebugSession.js:48:15)
    at BashDebugSession._handleData (/home/magnus/.vim/plugged/vimspector/gadgets/linux/download/vscode-bash-debug/v0.3.6/root/extension/node_modules/vscode-debugadapter/lib/protocol.js:97:38)
    at Socket.<anonymous> (/home/magnus/.vim/plugged/vimspector/gadgets/linux/download/vscode-bash-debug/v0.3.6/root/extension/node_modules/vscode-debugadapter/lib/protocol.js:18:44)
    at Socket.emit (events.js:321:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:273:9)
    at Socket.Readable.push (_stream_readable.js:214:10)

2020-01-30 21:02:51,827 - DEBUG - Message received: {'seq': 5, 'type': 'event', 'event': 'output', 'body': {'category': 'stdout', 'output': 'To client: {"seq":0,"type":"event","event":"output","body":{"category":"stderr","output":"::PROXYID::31674\\n"}}\n'}}
2020-01-30 21:02:51,827 - DEBUG - Message received: {'seq': 6, 'type': 'event', 'event': 'output', 'body': {'category': 'stderr', 'output': '::PROXYID::31674\n'}}
2020-01-30 21:02:51,829 - INFO - Server stderr: (node:31657) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:31657) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

2020-01-30 21:03:06,823 - DEBUG - Timeout: Aborting request {'command': 'launch', 'arguments': {'type': 'bashdb', 'request': 'launch', 'name': 'Bash-Debug (simple)', 'program': './link.sh', 'args': [], 'cwd': '/home/magnus/.dotfiles', 'pathBash': 'bash', 'pathBashdb': '/home/magnus/.vim/plugged/vimspector/gadgets/linux/vscode-bash-debug/bashdb_dir/bashdb', 'pathCat': 'cat', 'pathMkfifo': 'mkfifo', 'pathPkill': 'pkill', 'showDebugOutput': True, 'trace': True}, 'seq': 1, 'type': 'request'}
2020-01-30 21:03:06,824 - INFO - User Msg: Request for launch aborted: Timeout

Environemnt

  • Version of Vimspector: c1851a38e5368d0d6f40820f6f844f5a4faf0d0d

  • Output of vim --version:

VIM - Vi IMproved 8.2 (2019 Dec 12 kompiliert am Jan 26 2020 11:45:38)
Inklusive der Patches: 1-148
Übersetzt von Arch Linux
Riesige Version mit GTK3 GUI.
 Ein- (+) oder ausschließlich (-) der Eigenschaften:
+acl               -farsi             -mouse_sysmouse    -tag_old_static
+arabic            +file_in_path      +mouse_urxvt       -tag_any_white
+autocmd           +find_in_path      +mouse_xterm       +tcl/dyn
+autochdir         +float             +multi_byte        +termguicolors
-autoservername    +folding           +multi_lang        +terminal
+balloon_eval      -footer            -mzscheme          +terminfo
+balloon_eval_term +fork()            +netbeans_intg     +termresponse
+browse            +gettext           +num64             +textobjects
++builtin_terms    -hangul_input      +packages          +textprop
+byte_offset       +iconv             +path_extra        +timers
+channel           +insert_expand     +perl/dyn          +title
+cindent           +job               +persistent_undo   +toolbar
+clientserver      +jumplist          +popupwin          +user_commands
+clipboard         +keymap            +postscript        +vartabs
+cmdline_compl     +lambda            +printer           +vertsplit
+cmdline_hist      +langmap           +profile           +virtualedit
+cmdline_info      +libcall           +python/dyn        +visual
+comments          +linebreak         +python3/dyn       +visualextra
+conceal           +lispindent        +quickfix          +viminfo
+cryptv            +listcmds          +reltime           +vreplace
+cscope            +localmap          +rightleft         +wildignore
+cursorbind        +lua/dyn           +ruby/dyn          +wildmenu
+cursorshape       +menu              +scrollbind        +windows
+dialog_con_gui    +mksession         +signs             +writebackup
+diff              +modify_fname      +smartindent       +X11
+digraphs          +mouse             +sound             -xfontset
+dnd               +mouseshape        +spell             +xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        +mouse_gpm         +statusline        +xsmp_interact
+eval              -mouse_jsbterm     -sun_workshop      +xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary        
          System-vimrc-Datei: "/etc/vimrc"
        Benutzer-vimrc-Datei: "$HOME/.vimrc"
 zweite Benutzer-vimrc-Datei: "~/.vim/vimrc"
         Benutzer-exrc-Datei: "$HOME/.exrc"
         System-gvimrc-Datei: "/etc/gvimrc"
       Benutzer-gvimrc-Datei: "$HOME/.gvimrc"
zweite Benutzer-gvimrc-Datei: "~/.vim/gvimrc"
      defaults Datei: "$VIMRUNTIME/defaults.vim"
           System-Menü-Datei: "$VIMRUNTIME/menu.vim"
     Voreinstellung für $VIM: "/usr/share/vim"
Übersetzt: 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/lib/libffi-3.2.1/include -I/usr/include/harfbuzz -I/usr/include/fribidi -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -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 -D_REENTRANT  -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linken: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0  -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lelf -lnsl    -lcanberra  -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/5.30/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm     

  • Output of which vim or which nvim:
vim: aliased to vim --servername vim
(system vim)
  • Operating system: Arch Linux latest

I guess the error in the log might have something to do with it.

vimpostor avatar Jan 30 '20 20:01 vimpostor

Looks like the adapter threw an exception.

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at BashDebugSession.launchRequest (/home/magnus/.vim/plugged/vimspector/gadgets/linux/download/vscode-bash-debug/v0.3.6/root/extension/out/bashDebug.js:83:30)
    at 

Probably means your launch config is missing some mandatory item

Is there a reason your not using the adapter config that’s written by installer?

puremourning avatar Jan 30 '20 21:01 puremourning

No, where can I find that config that is written by the installer?

vimpostor avatar Jan 30 '20 21:01 vimpostor

Try removing your adapter block. Then it will use the installer one.

puremourning avatar Jan 30 '20 21:01 puremourning

That's what I did first, but then I get:

Traceback (most recent call last):                                                                                                                           
  File "<string>", line 1, in <module>                                                                                                                       
  File "/home/magnus/.vim/plugged/vimspector/python3/vimspector/debug_session.py", line 362, in Continue                                                     
    self.Start()                                                                                                                                             
  File "/home/magnus/.vim/plugged/vimspector/python3/vimspector/debug_session.py", line 175, in Start                                                        
    utils.ParseVariables( adapter.get( 'variables', {} ),                                                                                                    
AttributeError: 'NoneType' object has no attribute 'get'

vimpostor avatar Jan 30 '20 21:01 vimpostor

Did you run ./install_gadget.py —enable-bash ?

puremourning avatar Jan 30 '20 21:01 puremourning

Yes, I did. Does debugging bash work on your system? Maybe you could post your config and I could try it out.

vimpostor avatar Jan 30 '20 21:01 vimpostor

Yes it works for me with the following:

{
  "configurations": {
    "BASH - Run Current Script": {
        "adapter": "vscode-bash",
        "configuration": {
            "program": "${file}"
        }
    }
  }
}

puremourning avatar Jan 31 '20 10:01 puremourning

need to add an example to README.md and a basic test to support/test/bash

puremourning avatar Jan 31 '20 10:01 puremourning

Now when I press F9 to toggle breakpoint nothing happens

I expect that's a problem with your system, terminal, vim or termcap. If you enter insert mode and type <C-v><F9> does it print <F9> or something else ?

puremourning avatar Jan 31 '20 10:01 puremourning

I can confirm that your config is also working for me too, thanks! So I guess this issue is now just about adding the documentation.

Also I no longer have the problem with <F9>, but I didn't change anything.

vimpostor avatar Feb 02 '20 19:02 vimpostor

So I guess this issue is now just about adding the documentation.

That's right.

puremourning avatar Feb 02 '20 21:02 puremourning

I actually have 0-config bash debugging working locally, so i think we'l go with that instead. I'm thining of moving more towards having default configs that work for simple things.

puremourning avatar Feb 06 '20 12:02 puremourning

when enabling the bash debugger, we actually default almost all of the required config now: https://github.com/puremourning/vimspector/blob/master/install_gadget.py#L274

puremourning avatar Mar 24 '20 08:03 puremourning

Sounds great, but it isnt working for me. I updated the repo, and I set a breakpoint and pressed F5, but I got this message:

Unable to find any debug configurations. You need to tell vimspector how to launch your application.

Do I have to run anything else to update vimspector?

vimpostor avatar Mar 24 '20 13:03 vimpostor

we actually default almost all

almost all.

you still need a simple debug config. If you want to just "run the current file", then you can put this in /path/to/vimspector/configurations/linux/bash/bash.json:

{
  "configurations": {
    "BASH - Run Current Script": {
      "adapter": "vscode-bash",
      "configuration": {
        "program": "${file}"
      }
    }
}

Then it will appear as option in any bash file.

https://puremourning.github.io/vimspector/configuration.html#debug-configurations

puremourning avatar Mar 24 '20 14:03 puremourning

Would it be possible to ship this simple config within the plugin? It would be really cool to make this zero-configuration and it looks like that config is very generic or am I misunderstanding something?

vimpostor avatar Mar 24 '20 17:03 vimpostor

why use the simple debug config like : { "configurations": { "BASH - Run Current Script": { "adapter": "vscode-bash", "configuration": { "program": "${file}" } } } F5,then debug go to the bashdb file "~/.vim/plugged/vimspector/gadgets/linux/vscode-bash-debug/bashdb_dir/bashdb" is there something extra configs?

srillia avatar Nov 26 '20 04:11 srillia

solved! because ,the script:


function Test() { echo $1 }

for i in "$@"; do Test $i done


if you don't pass params to it you may meet the issue like me; "Bash - Launch": { "adapter": "vscode-bash", "configuration": { "program": "${file}", "args": [ "*${CommandLineArgs}" ] }

   }

srillia avatar Nov 26 '20 08:11 srillia