I am getting this error in visual studio code:
The above error shows whenever I launch my progam due to this launch.json script:
{
// 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": "Python: Attach using Process Id",
"type": "python",
"request": "attach",
"processId": "${command:pickProcess}",
"justMyCode": true,
"preLaunchTask": "kill_process"
},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"preLaunchTask": "kill_process"
}
]
}
And here is my tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": "build",
"label": "tsc: build - tsconfig.json"
},
{
"label": "kill_process",
"type": "shell",
"command": ".\\script\\kill_process.bat"
}
]
}
This is the content of kill_process.bat file:
npx kill-port 8000
However, when I run the script from powershell it executes without any problem, here is the proof:
Does someone perhaps know how I can run the kill_process.bat file without any error in visual studio code?
Strangely it is now fixed but I don't know how because now I am reading this in my console in visual studio code:
* Executing task: .\script\kill_process.bat
D:\documents\leerplek\python\Wpark>npx kill-port 8000
Process on port 8000 killed
* Terminal will be reused by tasks, press any key to close it.
Related
I want to enable "justMyCode" option in Visual Studio Code to debug just my code in React. Currently when I debug debugger steps also in files like;
fmkadmapgofadopljbjfkapdkoienihi/build/injectGlobalHook.js
\\node_modules\\scheduler\\cjs\\scheduler.development.js
\\node_modules\\lottie-web\\build\\player\\lottie.js
ect...
I have already tried;
{
"version": "0.2.0",
"configurations": [
{
"name": "React",
"type": "chrome",
"request": "launch",
"justMyCode":true,
"url": "http://localhost:5173",
"webRoot": "${workspaceFolder}",
"sourceMapPathOverrides":
{
"webpack:///src*": "${webroot}/*",
},
]
},
]
}
This throws "Property justMyCode is not allowed." error.
Then I tried;
{
"version": "0.2.0",
"configurations": \[
{
"name": "React",
"type": "chrome",
"request": "launch",
"url": "http://localhost:5173",
"webRoot": "${workspaceFolder}",
"sourceMapPathOverrides":
{
"webpack:///src*": "${webroot}/*",
},
"skipFiles": [
"${workspaceFolder}/bvars/<node_internals>/**",
"${workspaceFolder}/bvars/node_modules/**",
]
},
]
}
This seems to skip node files but this time an;
<eval>\VM4697589
file appeared as well as;
\src\client\client.ts
fmkadmapgofadopljbjfkapdkoienihi/build/injectGlobalHook.js
files ect...
How can I bypass all these system files and debug step only my code ?
Also is there a way to even not open any external files at all (including my own files) and debug only current file ?
I am quite new so sorry if these are too basic. Thank you in advance...
this is my launch.json
{
"version": "0.2.0",
"program": "${workspaceFolder}/pc",
"configurations": []
}
this is my task.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: cpp 生成活动文件",
"command": "/usr/bin/cpp",
"args": [
"-fdiagnostics-color=always",
"-g",
"${workspaceFolder}/*.c", //这里是我修改的位置,修改后便提示如题所述的错误
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-lpthread"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
In the args of the task, I changed "${file}" to "${workspaceFolder}/*. c", and tried to use the command line to include all c files under the folder
In the launch, I added the setting option of "program" according to the guidance file, but I don't understand what it is for
Unable to use IDE due to course requirements
In addition, it should be mentioned that the code will disappear and display as two lines of address after the code reports an error (too low reputation to send a picture)
HeIIo. This is my first post on Stackoverflow.
I like computer programming and after some experience with Python and VBA I'm trying to learn the C.
Since I took up with it I use Visual Studio Code for training in order to learn how to use modern programming tools at the same time.
I've never had any problem until now, but at the moment I want to compile multiple files.
When I try to compile a file with a warning the terminal shows it
Executing task: C:/mingw-w64/mingw64/bin/gcc.exe -Wall -W -pedantic -ansi -std=c99 -O -g 'd:\OneDrive\Programmi\C\Kim_N_King-Programmazione_in_C\Capitolo 19\stackADT\stackclient.c' 'd:\OneDrive\Programmi\C\Kim_N_King-Programmazione_in_C\Capitolo 19\stackADT\stackADT3.c' -o 'd:\OneDrive\Programmi\C\Kim_N_King-Programmazione_in_C\Capitolo 19\stackADT\stackADT.exe'
d:\OneDrive\Programmi\C\Kim_N_King-Programmazione_in_C\Capitolo 19\stackADT\stackADT3.c: In function 'is_full':
d:\OneDrive\Programmi\C\Kim_N_King-Programmazione_in_C\Capitolo 19\stackADT\stackADT3.c:41:20: warning: unused parameter 's' [-Wunused-parameter]
bool is_full(Stack s) {
~~~~~~^
but in the "Problems" tab it's not shown
(see the screenshot).
In every other folder where there is only a .c file to compile it works flawlessly.
The followings are my jsons file from which you can easily understand my VSC configuration and platform.
Thank you for reading.
c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/mingw-w64/mingw64/bin/gcc.exe",
"cStandard": "c99",
"cppStandard": "c++17",
"intelliSenseMode": "${default}"
}
],
"version": 4
}
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.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\stackADT.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\mingw-w64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "gcc.exe build active file"
}
]
}
tasks.json
{
"tasks": [
{
"type": "shell",
"label": "gcc.exe build active file",
"command": "C:/mingw-w64/mingw64/bin/gcc.exe",
"args": [
"-Wall",
"-W",
"-pedantic",
"-ansi",
"-std=c99",
"-O",
"-g",
"${file}",
"${fileDirname}\\stackADT3.c",
"-o",
"${fileDirname}\\stackADT.exe"
],
"options": {
"cwd": "C:/mingw-w64/mingw64/bin"
}
}
],
"version": "2.0.0"
}
It happens because you compile with flag "-Wall". It means that all warnings will be considered errors. You should use this variable.
for instance
(void*) &s;
I downloaded the gcc compiler into my linux environment and used ssh to get into vscode to simulate a linux environment on my windows machine. The files I have created compile and the makefile my professor gave me works fine, however whenever I go to debug using the gdb debugger my professor also provided, which is formatted correctly, the debugger hangs and doesnt allow me to step through my code with break points. I'm providing the code for the debugger as well as the cpp properties and the task files.
debugger code:
{
// 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 debug stacks",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/runner",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "make stack runner"
}
]
}
cpp properties:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
tasks:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "make stack runner",
"command": "make -f makefile DEBUG=1",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": [
"$gcc"
]
},
]
}
I don't think you require the tasks as cpp_properties. I'm able to use debug perfectly fine on WSL with only the launch.json file (The debugger code you mentioned) which I will give but I'm sure your problem will be solved if
1) Set externalConsole option as false. For some reason, it is not working in windows when set to "true". With this option, your program will run in the integrated console so you can be tricked into thinking that your program is not running if your program has no outputs before the first scanf() or cin command and your breakpoints are after them. So to be sure, have your breakpoints at the first line of your main() function, so that you don't make this classic newbie mistake.
2) Make sure when you compile the program you are using the -g switch. So your compile command should look like
gcc -g path\to\prog.cpp -o a.out
3) Make sure your program is set to the path of this executable file. If this a.out is generated at the root folder of your workspace, then your setting will be
"program":"${workspaceFolder}/a.out"
That should do.
My launch.json setting is
{
// 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": "WSL debugging",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
I started to learn angular and created a simple project in Visual Studio and it ran fine there. It is only one html file and a separate JS file. I decided to try Visual Studio Code as this looks like a better environment to code in for front end work.
But for the life of me I cannot get the Chrome debugger to display the page.
Here is the current launch.json (tried several changes to url and webroot to no luck):
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:9222/index.html",
"webRoot": "${workspaceRoot}"
},
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 9222,
"webRoot": "${workspaceRoot}"
}
]
}
I can get chrome to launch and connect but I get a completely blank page. I can then go to Localhost/json which gives me this:
[ {
"description": "",
"id": "2c0aed08-5bf3-4186-9ad6-9af1bc9e500c",
"title": "localhost:9222/index.html",
"type": "page",
"url": "http://localhost:9222/json"
}, {
"description": "",
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/ccfbea86-ec75-434e-9ae0-749eba4cbf2b",
"id": "ccfbea86-ec75-434e-9ae0-749eba4cbf2b",
"title": "Chrome Media Router",
"type": "background_page",
"url": "chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm/_generated_background_page.html",
"webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/ccfbea86-ec75-434e-9ae0-749eba4cbf2b"
} ]
I have no clue at this point what to try or really how to debug or look at what might be causing this. Any help or direction would be greatly appreciated.
I am not sure this is the correct answer. But changing the launch.json to include the file itself worked. I can now debug and view my pager in the browser window. Also turning on the diagnosticLogging allowed me to see the how it was doing some of the mapping.
{
"name": "Launch Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:9222/",
"webRoot": "${workspaceRoot}\\",
"file": "${workspaceRoot}/index.html",
"diagnosticLogging": true
}