How to fix gdb : Giving weird error message - json

After debugging this C++ code:
#include <iostream>
int main() {
std::cout << "Checking Debugging Progress!";
return 0;
}
I'm getting a weird message.
Aborted (core dumped) [1] + Aborted (core dumped) "/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-ua1ohquu.lr2" 1>"/tmp/Microsoft-MIEngine-Out-s1zccpii.3ja"
Interestingly enough that, not always I'm getting this message in the terminal. Is there any specific thing I'm doing wrong that I'm facing this error ? Note that I'm debugging in Visual Studio Code, using Linux and using the following .json file to build the code :
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}

The problem is with the "command" and "args" in the .json file. The command should be "/usr/bin/gdb" and the args should be ["-fdiagnostics-color=always", "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}"]

Related

Gradle: Task not found in root project (+ weird tasks.json error)

I'm getting a Task 'run' not found in root project 'Project-Name' whenever I try to do gradle run.
It was built successfully. I did see however, in my tasks.json file it does contain the run task.
In the documentation visual studio has this:
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": ["$tsc"],
"group": {
"kind": "build",
"isDefault": true
}
I have something similar, but there is a yellow line under:
"group": {
"kind": "build",
"isDefault": true
}
With the error showing up as
"Incorrect type. Expected "string".
Documentation shows this is correct - could this be the issue on why it can't locate the Run task or is it something else?
Thank you

VSCode Linux tasks.json MQL4 Compilation

I am switching to VSCode from MetaEditor to develop for MetaTrader4.
I'm using MetaTrader4 and MetaEditor in Linux via Wine.
(and MetaEditor runs quite terribly in Wine)
I would like to create a task to compile the code, and hopefully return the same error log to VSCode to further debug the code as if I was using MetaEditor.
I've used this post to figure out what CLI command has been used to compile MQL4:
Compiling MQL4 via command line through wine metaeditor.exe
/usr/bin/wine /path/to/MT4/metaeditor.exe /compile:"Z:\path\to\MT4\MQL4\Experts\Foo\Bar_EA.mq4" /include:"Z:\path\to\MT4\MQL4" /log
My issue is that I don't understand and cannot find any resource that explains what the "commands" inside the tasks.json file does or list of available variables. Like "/include:" or "presentation":, ${file}, etc.
So I took some guesses and I pieced it together to look something like this so far:
{
"version": "2.0.0",
"tasks": [
{
"label": "MQL4 Compile",
"type": "shell",
"command": "/usr/bin/wine /.wine/drive_c/Program Files (x86)/FXChoice MetaTrader 4/metaeditor.exe",
"args": [
"/compile:${file}"
]
}
]
}
Its probably not quite right.
I appreciate your help, thank you
{
"version": "2.0.0",
"tasks":
[
{
"label": "MQL4-Compile",
"group":
{
"kind" : "build",
"isDefault" : true
},
"presentation":
{
"echo" : true,
"reveal": "always",
"focus" : true,
"panel" : "shared"
},
"promptOnClose" : true,
"type" : "process",
"osx" :
{
"command" : "wine",
"args" :
[
"/Users/SVG/.wine/drive_c/Program Files/MetaTrader/metaeditor.exe",
"/compile:${fileBasename}",
"/log:${fileBasenameNoExtension}.log",
]
},
"windows" :
{
"command" : "C:\\Program Files (x86)\\MetaTrader\\metaeditor.exe",
"args" :
[
"/compile:${fileBasename}",
"/log:${fileBasenameNoExtension}.log",
]
},
}
]
}

tasks.json exists but 'No task defined'

I have a tasks.json open in VSCode. When I try to 'Run Task' I get 'No task to be run. Configure Tasks'.
Trying to Configure Tasks I get 'Open tasks.json'. But tasks.json is already open in VSCode. Closing tasks.json and reopening it gives the same result.
Help appreciated. tasks.json shown below.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"label": "GnuCOBOL - Compile (single file)",
"type": "shell",
"options": {
"env": {
"PATH":"\\gnucobol3\\bin",
"COB_CONFIG_DIR": "c:\\gnucobol3\\config",
"COB_COPY_DIR": "c:\\gnucobol3\\copy",
"COB_INCLUDE_PATH": "c:\\gnucobol3\\include",
"COB_LIB_PATH": "c:\\gnucobol3\\lib",
},
"command": "cobc",
"args": [
"-x",
"-std=mf",
"-t${fileBasenameNoExtension}.LST",
"${file}"
]
},
}
It looks like your tasks.json file got changed. It should be of this form:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
// "global" options can go here
"options": {
"env": {
"APP_NAME": "Nice"
}
},
// you are missing the tasks array
"tasks": [
{ // task 1
"label": "Task A",
"type": "shell",
"command": "echo A2",
"problemMatcher": [],
"presentation": {
"group": "groupA"
}
// or task-specific options can go here
},
{ // task 2
"label": "Task B",
"type": "shell",
"command": "echo B",
"problemMatcher": [],
"presentation": {
"group": "groupA"
}
}
]
}
So with your code:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"options": {
"env": {
"PATH":"\\gnucobol3\\bin",
"COB_CONFIG_DIR": "c:\\gnucobol3\\config",
"COB_COPY_DIR": "c:\\gnucobol3\\copy",
"COB_INCLUDE_PATH": "c:\\gnucobol3\\include",
"COB_LIB_PATH": "c:\\gnucobol3\\lib",
}
},
"tasks": [
{
"label": "GnuCOBOL - Compile (single file)",
"type": "shell",
"command": "cobc",
"args": [
"-x",
"-std=mf",
"-t${fileBasenameNoExtension}.LST",
"${file}"
]
}
]
}
}
}
Not sure how to respond - my response is too big for a comment.
Mark: I've modified tasks.json thus but still get same errors:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
{
"label": "GnuCOBOL - Compile (single file)",
"type": "shell",
"options": {
"env": {
"PATH":"\\gnucobol3\\bin",
"COB_CONFIG_DIR": "c:\\gnucobol3\\config",
"COB_COPY_DIR": "c:\\gnucobol3\\copy",
"COB_INCLUDE_PATH": "c:\\gnucobol3\\include",
"COB_LIB_PATH": "c:\\gnucobol3\\lib",
},
"tasks": [
{"command": "cobc",
"args": [
"-x",
"-std=mf",
"-t${fileBasenameNoExtension}.LST",
"${file}"
]
}
]
}
}
}
Mark: your mods now run but with errors:
> Executing task: cobc -x -std=mf -ttasks.LST c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json <
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:2: error: invalid indicator 'e' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:3: error: invalid indicator 'o' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:4: error: invalid indicator 's' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:5: error: invalid indicator 'i' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:6: error: invalid indicator 'n' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:7: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:8: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:9: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:10: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:11: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:14: error: invalid indicator 'k' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:16: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:17: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:18: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:19: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:24: error: invalid indicator ']' at column 7

g++ not detected in VS Code

I'm trying to compile c++ inside VS Code.
I have MinGW installed.
I've followed the steps in this video: https://www.youtube.com/watch?v=rFdJ68WbkdQ
And the steps at the "getting started" docs https://code.visualstudio.com/docs/languages/cpp
Actually, my config shows like this:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
]
},
{
"name": "Linux",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
},
{
"name": "Win32",
"includePath": [
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/include/*",
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/atlmfc/include/*",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/winrt",
"${workspaceRoot}"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"${workspaceRoot}",
"C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++",
"C:\\MinGW\\bin"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 3
}
And the "tasks.json" file has the following:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "‪‪g++",
"args": [
"-g", "Calculator.cpp", "-o","Calculator"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher":"$gcc"
}
]
}
But when I hit "run main task" it prompts:
"> Executing task: ‪‪g++ -g Calculator.cpp -o Calculator <
'‪‪g++' is not recognized as an internal or external command,
operable program or batch file.
The terminal process terminated with exit code: 1"
How can I get gcc detected?
I'm using VS Code with Windows 10 machine BTW.
If you have not added the folder path to windows, try that first.
If that still does not work try adding the full path in "task.json" instead of just g++.
Something like this:
C:/MinGW/bin/g++

Capturing Visual Stadio Command Line Compilier (CL.EXE) Output With Regular Expressions

I've been trying to set up VS command line compiler to use in VS code IDE. I have read the examples and can use GCC with no problem but need to use VS compiler now too.
I have tried a single line problem matcher and I multiple one. Yet VC code seems to capture nothing.
Here is an example of output with error from the compiler:
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.40629 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
helloWorld.c
..\Code\helloWorld.c(7) : error C2143: syntax error : missing ';' before '}'
Using the regExpr Expression:
(.*\n){2,3}\S+(\d+)\W+:\s(\bwarning|error\b\s\w+):\s(\w+\s\w+)\s+:\s(.*)$
It captures all the info I need (checked my work here: https://regex101.com/)
but when I put it in a Tasks.json file for VS code it doesn't work.
{
"version": "0.1.0",
"command": "Build",
"args": [
"${fileBasename}"
],
"isShellCommand": true,
"tasks": [
{
"taskName": "Build",
// Make this the default build command.
"isBuildCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "always",
// No args
"args": [
"all"
],
// Use the standard less compilation problem matcher.
"problemMatcher": {
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "(.*\n){2,3}\\S+(\\d+)\\W+:\\s(\bwarning|error\b\\s\\w+):\\s(\\w+\\s\\w+)\\s+:\\s(.*)$",
"file": 1,
"line": 2,
"severity": 3,
"code": 4,
"message": 5
}
}
}
]
}
Anyone know how to setup VS Code IDE to use VS command line compiler? Any help would be greatly appreciated
The first two lines in your output can be avoided by adding /nologo flag to the compiler. So your tasks.json should be:
"tasks": [
{
"taskName": "Build",
"isBuildCommand": true,
"showOutput": "always",
"args": [
"all"
],
"problemMatcher": {
"owner": "cpp",
"severity": "info", // treat note as info
"fileLocation": "absolute",
"pattern": {
"regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error|note)\\s*(\\w+)?:\\s+(.*)$",
"file": 1,
"location": 2,
"severity": 3,
"code": 4,
"message": 5
}
}
}
]