Setting GDB arguments with VSCode

79 Views Asked by At

I'm running GDB with through VSCode. My system runs on another target so gdbserver is being used. Because of the difference between the dev and target systems, the src files are in different places. Using the set substitute-path command has worked, but have had to wait for the GDB session to start, interrupt it, and then run the command in the VSCode terminal before GDB would connect the src on the dev machine with the target machine's src. Is there a way to set up the .vscode/launch.json file to run this command for me? My familiarity with GDB is pretty low, but I referenced gdb --help and noticed the -ex option to evaluate a single GDB command. VSCode documentation on launch.json states you can use "miDebuggerArgs" in the configuration to set the args for the debugger (gdb).

Here's my configuration file:

    "version": "0.2.0",
    "configurations": 
    [
        {
            "type": "gdb",
            "request": "attach",
            "name": "gdbserver",
            "gdbpath": "/usr/bin/gdb",
            "miDebuggerArgs": "-ex \"set substitute-path /workspace /other/dir",
            "program": "/app/bin/exe",
            "target": "target_ip:port",
            "remote": true,
            "cwd": "/"
        }
    ]
}

I can't find anywhere on a specific syntax for the miDebuggerArgs section; I also tried "miDebuggerArgs": [ "-flag input" ].

Another section in the configuration I tried was

"setupCommands": [ { "text": "-ex \"set substitute-path /workspace /path\"" } ] 

The third solution I tried was the searchPaths option within symbolOptions.

"symbolOptions":    
        {
            "searchPaths": 
                [
                    "/dir", 
                    "/another/dir", 
                    "${workspaceFolder}"
                ],
        }

The fourth thing I tried was the sourceFileMap option.

"sourceFileMap":
        {
            "/workspace": "${workspaceFolder}"
        }
0

There are 0 best solutions below