'How to load symbol while debugging with GDB in VSCODE

Environment: WSL Ubuntu20.04 on Windows 10

GDB: gdb-multiarch (GNU gdb 9.2)

VSCODE version: 1.67.0

I'm trying to debug with GDB on VSCODE. If I use command-line in Ubuntu to connect with GDB server and load symboal to my target device. It works normally.

$gdb-multiarch main
$(gdb)target remote:2331
$(gdb)load
$(gdb)c

Screenshot on Ubuntu command-line (Works normally)

However, I wanna do the same thing on VSCODE.

After modifying my launch.json file, the GDB debugger in VSCODE can only "attach" to my target device. There is no any symbol loaded. Here is my launch.json.

"configurations": [
    {
        "name": "GDB Launch",
        "type": "cppdbg",
        "request": "launch",
        "cwd": "${workspaceFolder}",
        "program": "${workspaceFolder}/main",
        "stopAtEntry": true,
        "linux": {
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/bin/gdb-multiarch",
            "miDebuggerServerAddress": "localhost:2331"
        },
    }
]

Did I miss any propertey which needs to be filled in the configurations?

Thanks for any comments and helping:)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source