How to setup correct path for VSCode Debug?

Viewed 485

I am developing an embedded application and currently working on setting up debugging in VisualStudioCode. The extension I am using is called cortex-debug.

Problem: The vscode debug view shows only disassembly when it meets a breakpoint

Problem overview:

  • The .elf file is located in ./build/product/
  • From debug symbols the main.c file is located in ../../src/
  • GDB console view correctly locates the line in main.c file
  • VSCode cannot find file ../../src/main.c because this relative path is pointing outside of the workspace.

Filestructure:

.
├── Repositories
│   ├── Workspace
│   │   ├── build
│   │   │   └── product
│   │   │       └── product.elf
│   │   └── src
│   │       └── main.c
│   └── src (*) //non-existent src directory outside of Workspace
│       └── main.c (*) //non-existent file that vscode is pointing to
[...]

Debugger Configuration:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "cortex-debug",
            "request": "attach",
            "name": "Attach to gdbserver",
            "servertype": "external",
            "gdbTarget": "localhost:2331",
            "gdbPath": "arm-none-eabi-gdb.exe",
            "cwd": "${workspaceFolder}",
            "preLaunchTask": "/*START THE DEBUG SERVER*/",
            "executable": "${workspaceFolder}/build/product/product.elf",
            "svdFile": "/*REDACTED*/",
            "runToMain": true,
        }
    ]
}

Output:

  • GDB console:

Breakpoint 1, main () at ../../src/main.c:210 210 /*some code that matches the contents of the file - which means it correctly finds the main.c file

  • VSCode debugger:

Unable to open 'main.c': Unable to read file '/home/username/Repositories/src/main.c' (Error: Unable to resolve non-existing file '/home/username/Repositories/src/main.c')

Possible Cause:

  • The current path of vscode debugger is set to ./build or ./.vscode.

How to make vscode find the correct path to the main.c file?

0 Answers
Related