&"warning: GDB: Failed to set controlling terminal: Operation not permitted\n" - c

I'm currently using vscode on ubuntu to write and debug a simple c program.
I've updated gdb to the newest version(9.2-0ubuntu1~20.04.1). Whenever I click the debug button a "Permission Denied" error is shown.
Here's a screenshot of the error message
How do I resolve this error so that I can debug my C program with GDB and VSCode? I would appreciate it. The problem has bothered me for days and I can't figure it out myself.
This code snippet below is my launch.json file.
// 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}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"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
}
]
}
]
}

Related

VSCode Debugger ignores breakpoints and runs whole program in C

My vscode debugger runs my whole program without stopping at breakpoints.
This is the message it outputs
[1] + Done "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-grb2h0oc.w5x" 1>"/tmp/Microsoft-MIEngine-Out-mbd0kqti.hj3"
Here is my launch.json:
{
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/project",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"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
}
]
}
]
}
I am using C to program.
Thanks for the help.
I can mitigate this issue by deleting my launch.json and remaking it and that seems to work for some reason but only the first time I am using the debugger, after that I get the same issue.

VScode configuration causes code to not execute

I am returning to learning C and was trying to get a basic code to print something to run, and for some reason, after debugging, and writing in the terminal ./{filename}.exe, I get no output at all, and a message in the terminal that says bash: ./test.exe: No such file or directory. attached below is the configuration of the launch.json
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/c_projects.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:/cygwin64/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
Thanks in advance!

Unable to start debugging. Unexpected GDB output from command"-environment-cd path to my c folder". -environment-cd: Usage DIRECTORY

So i wanted to learn c and got this error after trying to debug it:
Unable to start debugging. Unexpected GDB output from command"-environment-cd path to my c folder". -environment-cd: Usage DIRECTORY
My 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": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "C:\\Users\\Šimon\\Desktop\\Cfiles\\HelloWorld.c",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Users\\Šimon\\Desktop\\migw64\\mingw64\\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
}
]
}
]
}
If you want more stuff then ask me.
I'm using visual studio code.

Visual Studio Code Property Console not allowed error

i am new to programming and i was doing some of these questions of a book.And got stuck in this question about area of a triangle."Property console is not allowed".Is it due to the math.h?
Because the same code is fully functional on online-gdb.
here is content of lauch.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": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"console": "externalTerminal",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
Replace
"console": "externalTerminal"
with
"externalConsole": true
Seems like "console" property is not supported in this version of auto-generated launch.json. However this does the trick to get rid of the warning message for me.
Hmm, now I'm getting "Property externalConsole is not allowed"

How to use GCC for compilation and debug on VSCode

I have found out a few different ways to debug C with the GCC compiler, however I want to have debugging on by default. Is there any way I can do this with a setting in my launch.json in VSCode?
Here is my 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": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Add these to your CFLAGS: -gdwarf-4 -g3
To do that, run this command:
export CFLAGS="${CFLAGS} -gdwarf-4 -g3"
See this link for more information and this link for running commands in launch.json.

Resources