I am trying to debug a C program in Visual Studio Code.
In my directory I have 2 files test.c and Makefile along with .vscode folder which contains launch and tasks json files.
I tried configuring these files for the last three hours searching various forums and blogs but nothing seems to work.
I am able to compile and run using these two json files.
Program runs and displays output correctly but doesn't stop at breakpoints, during execution of the program I can't add breakpoints and already added breakpoints are disabled with following message.
Module containing this breakpoint has not yet loaded or the breakpoint address could not be obtained.
It seems that VSCode is not able to locate my test.c file during debugging phase even though it is in the same directory. It will be great if someone can show me the right way to do it.
Here, I am attaching contents of files in my folder.
launch.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": "gcc build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/test",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "tasks",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "tasks",
"type": "shell",
"command": "make",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Makefile
all:
gcc test.c -o ./test
test.c
#include<stdlib.h>
#include<stdio.h>
int main(){
printf("Mandar\n");
printf("Sadye\n");
return 0;
}
Thank you.