Closed xave closed 7 months ago
So I understand, your issue is specifically with the test? Well the actual regression tests in ci use this so I’m certain it works. My guess is you didn’t compile the test binary or something (it’s not noted in your repro step)
the error from the adapter is:
2024-01-19 07:21:31,131 - INFO - debug_session.py:2047 - 0 - The server has terminated with status 122
Sorry I misunderstood. You seem to be trying to launch a test from the tests dir and this is set up to use a debug adapter ‘custom-cpptools’ which is hard coded to a path that won’t exist on your system.
You are likely better off trying the other tests in tests/testdata/cpp/simple as these are the ones used in CI.
Or test your own project of course.
I have tried other directories as well and get similar errors. Ultimately, that the debug does not work. The instructions on the main page of this website point one to the very directories you have told me not to use.
Also, I tried the vim debug tutorial verbatim and that also did not work. There might be a subtle python3
bug.
From the main page of the repo:
Trying it out
If you just want to try out vimspector without changing your vim config, there are example projects for a number of languages in support/test, including:
Python (support/test/python/simple_python) Go (support/test/go/hello_world and support/test/go/name-starts-with-vowel) Nodejs (support/test/node/simple) Chrome/Firefox (support/test/web/) etc. To test one of these out, cd to the directory and run:
vim -Nu /path/to/vimspector/tests/vimrc --cmd "let g:vimspector_enable_mappings='HUMAN'" Then press \<F5>.
There's also a C++ project in tests/testdata/cpp/simple/ with a Makefile which can be used to check everything is working. This is used by the regression tests in CI so should always work, and is a good way to check if the problem is your configuration rather than a bug.
I did exactly this.
Also, I did compile the test binary
clang -g -o tiny tiny.c
Ultimately, I am looking for a simple clang setup to test on a minimal project. I have read through the entire manual and have tried various combinations of things, which if I had to detail in the level that I detailed this one attempt would create a very long post. I think there should be a minimal, no-frills working example to be run in the repo.
I'm thinking it should use CodeLLDB
as you have recommended with no "extensions". Just a simple, local compiling option that uses directory setups that most people would use by default. Then people can use the other examples to make a more complicated version.
Everything I have tried thus far, to include modifying paths, trying various sample c.json
and .vimspector.json
, setting gadget directory, not setting it and letting it install into the plugin repo. They all result in the same outcome. Vim errors and no working debugger.
I have verified that I can debug with pure lldb
so it is not that I don't have a working debugger at all. How many arm64 macOS
users do you have? Things vary subtly between that and Linux
.
Because these minimal examples do not work on a clean install, it is difficult to try out the remaining concepts and functionality. This seems like a bug to me.
I use macOS arm64 so I’m confident that it works.
Here's some "proof" - me doing it on arm64 Mac from clean install.
What files are you using for that example?
I have .vimspector.json
{
"configurations": {
"launch": {
"adapter": "CodeLLDB",
"filetypes": [ "rust", "c" , "cpp" ],
"configuration": {
"request": "launch",
"program": "${workspaceRoot}/${fileBasenameNoExtension}"
}
},
"attach": {
"adapter": "CodeLLDB",
"filetypes": [ "rust", "c", "cpp", "jai" ],
"configuration": {
"request": "attach",
"program": "${workspaceRoot}/${fileBasenameNoExtension}",
"PID": "${PID}"
}
}
}
}
For this dir structure:
tiny_c/
├── .vimspector.json
├── tiny
└── tiny.c
Have you needed to do anything to set Python?
I have also gotten lots of Python-related errors such as messages starting with:
File "<string>", line 1, in <module>
and messages that are variations on:
Error detected while processing function vimspector#Launch:
line 4:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/barbaz/.vim/pack/foobar-plugins/start/vimspector/python3/vimspector/debug_session.py", line 71, in wrapper
return fct( self, *args, **kwargs )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/barbaz/.vim/pack/foobar-plugins/start/vimspector/python3/vimspector/debug_session.py", line 239, in Start
all_configurations ) = self.GetConfigurations( adapters )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/barbaz/.vim/pack/foobar-plugins/start/vimspector/python3/vimspector/debug_session.py", line 192, in GetConfigurations
database = json.loads( minify( f.read() ) )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/z0nnwdh4p692yvf3qgwgj3bn78w99q6y-python3-3.11.6/lib/python3.11/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/z0nnwdh4p692yvf3qgwgj3bn78w99q6y-python3-3.11.6/lib/python3.11/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 17 (char 16)
I have python3
installed globally via nix
. My vim is +python3
.
EDIT: Just installed python3Full
. No change to behavior. It is 3.11.6
.
To add some information:
I can get the workspace UI to show up and I can toggle breakpoints. Something with actually doing the debugging part is not working for me.
I am often getting errors about not being able to connect to a port, which I don't think I need to do unless I make a .json asking for one, and it seems that you have a handy thing that searches for open ports automatically. Many examples use that functionality when they use it at all.
From your second video, I get the "Connecting... Waiting 10 seconds" message, then immediately error messages.
Occasionally, errors with text including
Error detected while processing function
...
File "<string>", line 1, in <module>
point to plugin clashing. I uninstalled all plugins except this one and they persist.
Switching gears a bit...
Error E902 in vim -- https://vimhelp.org/channel.txt.html
When the channel can't be opened you will get an error message. There is a difference between MS-Windows and Unix: On Unix when the port doesn't exist ch_open() fails quickly. On MS-Windows "waittime" applies. E898 E901 E902
Did some more sleuthing using the code from here.
CodeLLDB
is the thing giving issues. The following is placed into the vimspector base directory:
in .vimrc
let g:vimspector_base_dir=expand( '$HOME/.vim/vimspector-config' )
in ${HOME}/.vim/vimspector-config/configurations/<os>/c/c.json
This c.json
works (using vscode-cpptools
):
"configurations": {
"C": {
// Local C debugging
"adapter": "vscode-cpptools",
"configuration": {
"request": "launch",
"program": "${workspaceRoot}/${fileBasenameNoExtension}",
"StopAtEntry": true,
"MIMode": "lldb",
"setupCommands": [
{
"description": "Enable pretty-printing for lldb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
}
This c.json
does not work (using CodeLLDB
) and gives the errors mentioned in this BUG REPORT:
"C-CodeLLDB": {
// Local C debugging
"adapter": "CodeLLDB",
"configuration": {
"request": "launch",
"program": "${workspaceRoot}/${fileBasenameNoExtension}",
"StopAtEntry": true,
"MIMode": "lldb",
"setupCommands": [
{
"description": "Enable pretty-printing for lldb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
}
Description
On a fresh plugin install with
vim -Nu /the/path/to/my/install/vimspector/tests/vimrc --cmd "let g:vimspector_enable_mappings='HUMAN'" tiny.c
in the directory
/path/to/install/vimspector/support/test/cpp/tiny_c
after hittingF5
, installing the gadget, choosing a debug confguration from one of the three preconfigured ones, and then trying to set a breakpoint, choosing an error flashes.Vimspector not connected, start a debug session first
Is it reproducible in vim?
Reproducible in Vim
Works with clean config?
Yes
Sample project works?
Reproducible with sample project
Minimal Reproduction
See above.
Expected Behaviour
Expected behavior is that the debug session would start as soon as I choose the debug configuration, as per the docs.
Actual Behaviour
No debugging of the program itself occurs.
Additional information
I find it a bit suspicious that the sample
.vimspector.json
in thetiny.c
has a hardcoded path$Home/Developer/foo/bar
as that is not standard and is thus specialized to one person's workflow. Regardless, changing that path does not allow this plugin to function.Installation Type
Vim packages (git clone)
Vimspector version
703df4d948957105fe056dec9b106fbebf25ca66
Debug Info
Log file
Vim version
Python version
3.11.6 (main, Oct 2 2023, 13:45:54) [Clang 16.0.6]
Neovim diagnostics
No response
Operating System
macOS arm64
Declaration