I downloaded the Visual Studio Code, but I don't know how to configure the debugger.
I am learning programming and i don't know how to configure it?
someone help me with this problem?
This is what you need to configure.
{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Launch app.js",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
// Workspace relative or absolute path to the program.
"program": "app.js",
// Automatically stop program after launch.
"stopOnEntry": true,
// Command line arguments passed to the program.
"args": [],
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
"cwd": ".",
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
"runtimeExecutable": null,
// Environment variables passed to the program.
"env": { }
},
{
"name": "Attach",
"type": "node",
// TCP/IP address. Default is "localhost".
"address": "localhost",
// Port to attach to.
"port": 5858
}
]
}
You need to be more specific with your question.
What kind of code are you debugging?
Right now Visual Studio Code has debugging support for Node.js (JavaScript and TypeScript) on all platforms, experimental support for mono (C# and F#) on OS X and Linux, and soon ASP.NET 5.
If you are using one of those, you should be able to start using debugging features.
For more information, here is a direct link to the official debugging documentation: https://code.visualstudio.com/Docs/debugging
If you are coding with php you can follow these step
You can copy and paste code:
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
Related
I'm using only the Visual Studio Code. From CLI I created a solution with 2 projects.
Api
Acceptane tests
Debugging it separately work perfect, but in case when I want to debug a test and an endpoint in the same time - doesn't work.
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": ".NET Core Launch (API)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/ContentDownloader.API/bin/Debug/net6.0/ContentDownloader.API.dll",
"args": [],
"cwd": "${workspaceFolder}/ContentDownloader.API",
"stopAtEntry": false,
"requireExactSource": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
I try do it like:
dotnet run at solution/API/ here
via a Debug Test button I run debugger for particular test (this is an acceptance test, it request to the api and check the results)
at output I have:
...\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(5100,5): warning MSB3026: can't copy "SomeSolution\API\obj\Debug\net6.0\apphost.exe" do "bin\Debug\net6.0\API.exe". The process cannot access the file '...\SomeSolution\API\bin\Debug\net6.0\API.exe' because it is being used by another process. [...\SomeSolution\API\API.csproj]
...because it is being used by another process.
I understand what it means :) but I have no idea or found a way to solve my problem,
I tried to write my own task / launch.json, but all without success
Please advise
I am a reccent deno user. Been using node for a long time, switched to deno and am very happy with it. It's really good
However, I have an issue.
Whenever I try to debug a deno file, the vscode debugger starts running for like half a second and then stops, and nothing happens.
It doesnt freeze or anything, it just starts for a moment and stops.
I am using this as launch configuration
{
"version": "0.2.0",
"configurations": [
{
"name": "Deno1",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"outputCapture": "std",
"runtimeArgs": ["run", "--inspect-brk", "-A", "${fileName}"],
"port": 9229,
}
]
}
I took it from this post
I should add that I was able to debug this file already, but one day it just started showing this issue i just described without (to my knowledge) any change on my part.
I am trying to debug this file
How can I fix this issue?
To make it work you need to add a "program" field to launch.json and move the path of the file there, which is briefly mentioned in this answer from the post you linked to. But also you need to change "port" to "attachSimplePort":
{
"version": "0.2.0",
"configurations": [
{
"request": "launch",
"name": "Launch Program",
"type": "node",
"program": "${workspaceFolder}/tests/grammar.test.ts",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": [
"run",
"--inspect-brk",
"--allow-all"
],
"attachSimplePort": 9229,
"outputCapture": "std",
}
]
}
To debug another part of the application just change the path in program, for example to an entrypoint file like main.ts. With --inspect-brk the debugger will first break at the first line of the program and then you can for example continue to a breakpoint with F5 or the continue button in the debugger panel.
(Deno v1.14)
I've set up a launch.json file such that a C++ program uses an external console (so that it can receive user inputs), but when launching, VSCode simply opens a terminal window without running the program in it. If "externalConsole": true, is set to false, the program runs and can be debugged fine, just can't take inputs.
Note: No task.json file is used, CMake is used to create the executable binary.
Launch 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": "g++ - Debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/program_bin",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build/bin",
"environment": [],
"MIMode": "lldb",
"externalConsole": true,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true,
}
]
}
]
}
Is it possible that VSCode doesn't have 'permission' to run an external terminal? Using on MacOS.
I have the same issue. This may not be the working answer, but hopefully it will get us farther down the correct path.
I did some digging and found the following:
VS Code Documentation mentioned that it opens an external console via lldb-mi.
A search for lldb-mi led to this post on the Apple Developer forums.
...which leads to an open source Github Repo with a build of lldb-mi
I need to read through the documentation for that build first, and then I'll give it a shot. I'll post results if it solves the issue.
I've tried to use standard (recomended ways of debugging from vscode documentation) and ran into the same issues with external terminal.
I'm also using mac and switching to CodeLLDB plugin to use LLDB for debugging helped
https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb
just follow documentation: https://github.com/vadimcn/vscode-lldb/blob/v1.8.1/MANUAL.md
But as a hint here is my working setup:
(I couldn't though make it work on windows, but I'm running windows via Parallel II, so maybe natively this plugin will work too)
tasks.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang build active file",
"command": "/usr/bin/g++",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-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"
}
launch.json
{
"configurations": [
{
"name": "(lldb) Launch",
"type": "lldb",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
// "stdio": ["input.txt", null, null], // https://github.com/vadimcn/vscode-lldb/blob/v1.8.1/MANUAL.md#stdio-redirection
"cwd": "${fileDirname}",
"preLaunchTask": "C/C++: clang build active file" // this have to be the same as "label" in tasks.json
}
],
"version": "2.0.0"
}
just make sure you have all tools available, check by running in cli:
/usr/bin/clang --version
# and
lldb --version
good luck
I'm just learning VS Code and Angular, I've been following a tutorial online and trying to debug. After I start the debugger it asks me what process to attach too from a drop down list it provides.
According to the debugger, I should see a 'DatingApp.API.dll' process like the one in the tutorial here, as I've named my project the same as in the tutorial.
but what I see below doesn't have the .dll name, just -bash id
now I get this when I select .Net Core Attach in the debug section, instead of the .Net Core Launch (web) option
When I select .Net Core Launch (web) it automatically attaches to the app, but my question is why don't I see the process name 'DatingApp.API.dll' as an option and see '-bash 1730' instead?
'-bash 1730' is the process so I can connect using it, I'm just curious why it doesn't name it 'DatingApp.API.dll'?
Here is my launch.json file
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/DatingApp.API/bin/Debug/netcoreapp2.2/DatingApp.API.dll",
"args": [],
"cwd": "${workspaceFolder}/DatingApp.API",
"stopAtEntry": false,
"launchBrowser": {
"enabled": true
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]}
It's a little tricky, if you type in the search DatingApp.API it will show you DatingApp.API.exe as the only result, or at least that's what I got when tried. You can attached to it too.
And Voilá! Now you can debug your C# app.
I'm trying to debug a revel app with visual studio but I can't get it to work.
I've seen this question how to debug revel framework(golang) application in visual studio code(vscode) but no answers yet...
I've tried with this config:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "~/code/go/bin/revel",
"env": {},
"args": [],
"showLog": true
}
]
}
But I'm getting this error:
Failed to continue: "The program attribute must point to valid directory, .go file or executable."
I think it must be the rebel binary the one to be run here, but I don't know how to pass the app path, should it go in "args"?
Yes it's possible.
Suppose that the GOPATH is C:\Work\golang
Revel project name is myapp, thus the location of the project (workspace) will be C:\Work\golang\src\myapp.
Make some changes to the controllers etc...
Run the application with revel run myapp, then press CTRL+C to exit. This step is necessary to generate corresponding go files. The generated file, i.e. the main package will be available under ${workspaceRoot}/app/tmp/main.go
Configure launch.json as follows:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"env": {},
"showLog": true,
"program": "${workspaceRoot}/app/tmp/",
"args": ["-importPath", "myapp", "-srcPath", "c:\\work\\golang\\src", "-runMode", "dev"]
}
]
}
The important parts are program and args parameters, while the other parameters are unmodified.
Set breakpoint and start the delve debugger...
EDIT:
Setting args parameter to ["-importPath", "myapp", "-srcPath", "${workspaceRoot}/..", "-runMode", "dev"] also work, and I think this should work in other platforms (Mac, Linux) too.
The error message is related to delve issue. See https://github.com/Microsoft/vscode-go/issues/986