2

I am trying to run a debugger in VS Code but every time I hit a breakpoint instead source file I am presented with a source file in a path that repeats to times, see blow: Source file + path, Source file it tries to open during debug

As you can see on the second image the path to the source file debugger is trying to open is:

C:\Users\user\Documents\AdvancedC\S2\C\Users\user\Documents\AdvancedC\S2\main.c

and of course, it doesn't exist.

converting the undefined symbol after C to ascii I get that  = "&#61498";

tasks.json:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc.exe build active file",
            "command": "C:\\cygwin64\\bin\\gcc.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

lanch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/main.exe",
            "args": [],
            "logging": {
                "moduleLoad": false,
                "trace": true
            },
            "stopAtEntry": true,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:/cygwin64/bin/gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }

    ]
}

1 Answer 1

1

I had the same issue as you, and probably have a similar setup (I also use gcc and gdb from Cygwin). After some research and trial-and-error, I was able to get debugging working by using a different configuration, as explained here: https://stackoverflow.com/a/69684819/17376152

However, I slightly modified my configuration files.

  • Use gdb version 9.2-1, as the newer versions don't seem to be working for this environment
  • For my tasks.json, I just used the label "gcc.exe build active file" instead of "C/C++: ..." at the beginning.
  • In launch.json, I left the environment variable empty: "environment": [],

With these changes, my debug process is now working without errors just by pressing F5.

I hope this helps you as well (I see you have the flag -gdb-set disassembly-flavor intel set, so this might be slightly different). Let me know if it works for you.

Sign up to request clarification or add additional context in comments.

1 Comment

It is definitely something going on with gdb.exe. I changed to gdb.exe from Mingw and debugging woks very well. Codeblocks experieneced the same issue and with Mingw gdb.exe it works without any issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.