code-debug icon indicating copy to clipboard operation
code-debug copied to clipboard

convert from type=cppdbg to type=gdb

Open fensoft opened this issue 6 years ago • 7 comments

Hello,

Because I want an automatic run of gdb, I want to use this plugin's gdb.

I'm on macos 10.12.6 and compiled gdb with all targets to debug remote linux code.

Here's what I have that works (I need to run gdbserver manualy):

            "name": "hello",
            "type": "cppdbg",
            "request": "launch",
            "program": "./hello",
            "cwd": "/Volumes/share/hello",
            "stopAtEntry": false,
            "MIMode": "gdb",
            "miDebuggerPath": "/Users/fensoft/gdb-8.1.1/bin/gdb",
            "miDebuggerServerAddress": "server"

Here's what I have converted to use this plugin:

            "type": "gdb",
            "request": "launch",
            "name": "hello",
            "target": "./hello",
            "cwd": "/Volumes/share/hello",
            "gdbpath": "/Users/fensoft/gdb-8.1.1/bin/gdb",
            "printCalls": true,
            "showDevDebugOutput": true,
            "ssh": {
                "host": "server",
                "cwd": "/data/hello",
                "keyfile": "/tmp/.id_rsa",
                "user": "root"
            }

The problem is, when I start debugging, it simply briefly show the debug buttons and that's all. No error messages, nothing. Any idea ?

fensoft avatar Dec 05 '18 14:12 fensoft

try making target an absolute path. Does the ssh.keyfile exist? Otherwise I don't really know what could be the issue. Is there no log at all in the debug output panel?

WebFreak001 avatar Dec 05 '18 16:12 WebFreak001

I got it working. Several problems here: The first looks like a bug in VSCode. To view the debug console, I need to switch to another debug console then switch back to the main debug console again.

The second is that the local machine does not need a local gdb version nor using gdbserver. So, specifying a gdbpath is useless.

Third problem was the target (putting it as an absolute path is mandatory here)

Fourth problem is that forwardX11 is true by default.

fensoft avatar Dec 05 '18 16:12 fensoft

target will be relative to cwd. If you want it relative to your project workspace, use ${workspaceRoot}/path/to/executable

You are right, X11 forwarding defaulting to true seems wrong as it most likely always needs some configuration to make it work.

WebFreak001 avatar Dec 05 '18 16:12 WebFreak001

also, tagging gdb-server for this repo and not using it makes me doing wrong guess on how it's working. Maybe claryfing it in the documentation can be a good idea (i thought it was creating a gdbserver and tunnel it through ssh but it's not the case)

fensoft avatar Dec 05 '18 16:12 fensoft

Using gdb server works differently, see https://github.com/WebFreak001/code-debug#using-gdbserver-for-remote-debugging-gdb-only

If you want to use it over SSH, use SSH tunneling to connect to it

WebFreak001 avatar Dec 05 '18 16:12 WebFreak001

Oh, yeah, sorry. So it can also be used to connect to an existing gdbserver. Is it possible to add a feature to automaticaly run the gdbserver (and managing the ssh tunnel) on the other side ?

fensoft avatar Dec 05 '18 16:12 fensoft

you can use a preLaunchTask to run a command

WebFreak001 avatar Dec 05 '18 18:12 WebFreak001