eclipse-cdt-cloud / cdt-gdb-adapter

CDT GDB Debug Adapter
Eclipse Public License 2.0
27 stars 40 forks source link

how to specify custom gdb path to Adapter #301

Open wss29 opened 10 months ago

wss29 commented 10 months ago

Hi, I use cdt-gdb-vscode in eclipse theia application in linux. it is ok when I debug c++ code by default gdb. debug config as follows { "name": "c++ test", "types": "gdb", "request": "launch", "program": "my c++ a.out", "cwd": "${workspaceFolder}" } now I want to use my custom gdb to debug some specific c++ code. I set miDebuggerPath in configuration, but it seems that debugger still use default gdb, not my custom gdb. I am not sure whether miDebuggerPath is the right param. config as follow { "name": "custom gdb c++ test", "types": "gdb", "request": "launch", "program": "my c++ a.out", "cwd": "${workspaceFolder}", "MIMode": "gdb", "miDebuggerPath": "path/to/my/custom gdb" }

jonahgraham commented 10 months ago

The right option is "gdb". Try the autocomplete in the launch.json editor to explore the options and feel free to ask follow ups.

wss29 commented 10 months ago

The right option is "gdb". Try the autocomplete in the launch.json editor to explore the options and feel free to ask follow ups.

Hi, I use the gdb option, but it seems that still use Linux default gdb, not the sparc-gdb I specify. Am I missing something? image

jonahgraham commented 10 months ago

That's weird the error says ENOENT which means it couldn't find the path. I'm surprised it displayed an error like that and still started a different gdb. Is the path passed as "gdb" work in the terminal? I wonder if you are experiencing a bug with encoding. Does it work if you put sparc gdb in /tmp?

wss29 commented 10 months ago

That's weird the error says ENOENT which means it couldn't find the path. I'm surprised it displayed an error like that and still started a different gdb. Is the path passed as "gdb" work in the terminal? I wonder if you are experiencing a bug with encoding. Does it work if you put sparc gdb in /tmp?

hi before using cdt-gdt-vscode, we use ms-vscode.cpptools as the adapter for debug gdb, in cpptools the path works. We will try to test it in /tmp next Monday.

jonahgraham commented 10 months ago

I look forward to your analysis. Your use case should work and if we find an issue in the adapter I'll be pleased to fix or help fix it.

wss29 commented 9 months ago

hi, I tried copying spac-gdb to the tmp folder, and it still does not work. As you can see in the terminal spac-gdb works, but not by launch.json options. image image image image image

jonahgraham commented 9 months ago

The error message certainly matches up with the adapter not being able to find sparc-gdb - however I can't see why sparc-gdb isn't working.

I will point out that while you copied sparc-gdb to your /tmp, you didn't screenshot an updated launch.json that pointed at that gdb.

In addition I see this in your screenshots.

In this screenshot where you show sparc-gdb working:

image

the directory that contains sparc-gdb is different that what you entered in the "gdb" field of the launch.json:

image

Can you confirm that the paths are all correct?

wss29 commented 9 months ago

hi I set the gdb path to tmp in launch.json. it works okay now, but I have another option that needs to be set. in cpp-tools it is 'miDebuggerServerAddress'. I look at options in cdt-gdb-vscode, and it seems that debuggerServer is , I try to give it value. but it is not work. image

jonahgraham commented 9 months ago

For remote connections use "type" --> gdbtarget and fill out the target section which has all the settings you expect, like host, port, server. If you use type = gdbtarget and request = launch, then the adapter will automatically start the gdbserver you specify in server - if you are launching the gdbserver manually (perhaps on another machine via ssh), you will probably want to use type = gdbtarget and request = attach

BTW Are you an end user or an extender?