VSCode Cloud Code - breakpoints are pointing unexpected file path - visual-studio-code

I am trying to debug remotely a .NET Core pod on GKE.
Everything work fine, but after starting debugging, breakpoints point different file path from the original source.
Before debugging:
Breakpoint is shown, and both its path and path of source code are same.
While debugging:
But after starts, breakpoint(red dot) disappears, and its path is changed into \src\WebApplication1\Controllers\.
My launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Kubernetes Pod (.NET Core)",
"type": "cloudcode.kubernetes",
"request": "attach",
"language": "NETCore",
"podSelector": {
"type": "webapp"
},
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
]
}

Related

How can I change the capitalization of the project directory VS Code passes when debugging?

I'm running a Next.JS project in VS Code. My launch.json has the following configuration:
{
// ...
"configurations": [
{
"name": "Frontend: Dev Server",
"request": "launch",
"runtimeArgs": [
"run-script",
"dev",
"--preserve-symlinks", // To debug linked
],
"runtimeExecutable": "npm",
"skipFiles": [
"<node_internals>/**"
],
"type": "node",
}
],
}
When I run this configuration from VS Code, I get an error like the following:
C:\Program Files\nodejs\npm.cmd run-script dev --preserve-symlinks
> web-client#0.1.0 dev
> next dev -p 5555
warn - Invalid casing detected for project dir, received c:\etcetc actual path C:\etcetc, see more info here https://nextjs.org/docs/messages/invalid-project-dir-casing
I know that I want VS Code to pass in the drive letter in upper case instead of lower case, but I don't see any option to set that and I tried opening the project using code C:\etcetc directly.
How can I change the capitalization of the directory that VS Code applies to the launch configuration?
Add a current working directory to your launch.json configuration:
{
// ...
"configurations": [
{
"cwd": "${workspaceFolder}",
"name": "Frontend: Dev Server",
// ...
}
]
}
This passed an upper case drive letter to Node for me. You may also want to check that VS Code is opening the folder with the right case, i.e. node C:\etcetc.
If you still have casing errors, try deleting the .next directory.

VSCode - How to specify which project to debug - Azure Functions

My question is a noobie question.
I have an azure function app project, along with a test project. Initially, I start with just the function application project and then I just recently re-org the project folders and added the associated test.csproj
The folder structure I have right now looks like this:
Since moving the function app into the "src" folder, when I want to just run locally, I make sure that from my powershell terminal, I do the following:
cd src
func start
And everything works really well. But if I want to step through the code / debug, hitting F5 doesn't work because it doesn't know which project I'm trying to debug.
Can you tell me how I can debug either project from the parent folder that I'm in ?
I've tried to change my launch.json from this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
]
}
To this:
{
"version": "0.2.0",
"configurations": [
{
"name": "FunctionApp",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}",
"program": "${workspaceFolder}/src/bin/Debug/net6.0/bin/widgets.dll",
"cwd": "${workspaceFolder}/src"
}
]
}
And now I see a Green play button with the name "FunctionApp" in my "Run and Debug" bar across the top, but when I try to run it, I get an error that says:
Executing task: C:\Program Files\dotnet\dotnet.exe clean /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary <
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET Copyright
(C) Microsoft Corporation. All rights reserved.
MSBUILD : error MSB1003: Specify a project or solution file. The
current working directory does not contain a project or solution file.
The terminal process "C:\Program Files\dotnet\dotnet.exe 'clean',
'/property:GenerateFullPaths=true',
'/consoleloggerparameters:NoSummary'" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
EDIT 1
I tried to follow this example:
https://i.stack.imgur.com/a7ZVk.png
I also changed all references in my task.json from "process" to "shell" based on this post: Debugging Azure Function with vscode
So presently, this is what the two files look like:
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
]
}
tasks.json
Just showing what I understand is the relevant section...
{
"version": "2.0.0",
"tasks": [
{
"label": "host function",
"command": "func host start",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}/src"
}
},
But the error I'm getting is this:
Failed to detect running Functions host within "60" seconds. You may
want to adjust the "azureFunctions.pickProcessTimeout" setting.
When I try Run -> Start with debugging, the application starts, and I can trigger my API... but it doesn't stop at any of the breakpoints.
So the complete solution was to
a) Revert my launch.json back to the original version which looks like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
]
}
b) added new section to my tasks.json:
{
"label": "host function",
"command": "func host start",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}/src"
}
},
c) Then I changed ALL references to "process" to "shell" in the tasks.json.
d) Lastly, to fix the error with azureFunctions.pickProcessTimeout, I did the following:
File -> Preferences -> Settings -> search for the specific setting and increased from 60 seconds to 180

How to change default action on debug visual studio code

here is the problem: I want to debug and run vue 3 vite on lan, so to do the second I just have to run vite --host but when I press F5 by default it runs vite. How can I change the default command that visual studio code is running so instead of vite it runs vite --host?
My launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:4000",
"webRoot": "${workspaceFolder}/app",
}
]
}
EDIT:
I made another question where I explain how I fixed some of the problems In here, still cant get it to debug from external device
How to debug Vue 3 Vite while on lan --host
You can pass arguments with either args or runtimeArgs attributes. Here is more information on this. I think in your case this should work:
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:4000",
"webRoot": "${workspaceFolder}/app",
"args": ["host"],
}
]
}

Remote debugging C++ with VsCode

I have gdbserver attached to a process and working fine on a remote machine, port 9999. On my local machine, from command line:
$ gdb
(gdb) target remote localhost:9999
works just fine. I am trying to configure Vs Code debugger so that I can have a GDB frontend for this case. Here is my launch JSON.
"version": "0.2.0",
"configurations": [
{
"name": "GDB",
"type": "cppdbg",
"request": "attach",
"miDebuggerServerAddress": "localhost:9999",
"program": "path-to-cross-compiled-binary-with-same-debug-symbols",
"linux": {
"MIMode": "gdb",
},
}
]
There are couple of issues here. First of all, why "program"? In this case, gdb doesn't need any program name to start. Program is already running on remote, gdbserver is already attached to it. I just want gdb client to connect to port 9999. But anyways, moving on.
It wants me to give a processId. This also does not make sense, I am already attached on remote. The fun part is:
If you leave out processId, Vs Code says "unable to parse the process id"
If you specify a processId, Vs Code says "processId cannot be used with miDebuggerServerAddress"
Of course, if I am using a debugger server address, server is already attached to PID and it makes sense that processId can't be used in this case. But if I leave it out, VS Code gives the 1. error. This is cyclic in a way.
Anyone is able to attach to a remote process in VS Code C++ debugger with gdbserver address, that is my question. What is wrong with my launch file?
You need to use the "launch" request instead of "attach". I also needed to add the default "cwd" option.
"request": "launch",
"cwd": "${workspaceFolder}",
You may also need to define "additionalSOLibSearchPath".
My launch config now looks like this:
{
// 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": [
{
// "processId": "${command:pickProcess}",
"name": "(gdb) Remote Attach",
"type": "cppdbg",
"request": "launch",
"program": ".\\src\\binaryfolder\\app.nostrip",
"additionalSOLibSearchPath": "arm-none-linux-gnueabi/libc/lib;./lib;C:\\DeviceSDK\\win-2.8.15\\sdk\\toolchains\\arm-4.4.1\\arm-none-linux-gnueabi\\libc\\lib;C:\\DeviceSDK\\win-2.8.15\\sdk\\platforms\\201205\\lib",
// "processId": "${command:pickProcess}",
"MIMode": "gdb",
"cwd": "${workspaceFolder}",
"miDebuggerPath": "C:\\DeviceSDK\\win-2.8.15\\sdk\\toolchains\\arm-4.4.1\\bin\\arm-none-linux-gnueabi-gdb.exe",
"miDebuggerServerAddress": "192.168.205.88:51000",
"miDebuggerArgs": " -ex 'handle all print nostop noignore'",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true,
}
]
},
]
}
See CppTools issue 321

VS Code debug in Chrome - This site can’t be reached error

I know this question has been asked before, but after reading a lot of the threads, I still haven't found my answer...
I am trying to debug a very simple html app with Chrome, but when I get to my localhost I get an error that says "This site can’t be reached". My launch.json code looks like this:
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome against localhost, with sourcemaps",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
},
{
"name": "Attach to Chrome, with sourcemaps",
"type": "chrome",
"request": "attach",
"port": 9222,
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
}
]
}
Any help would really be appreciated as I have been struggling for quite a while with this now.
As #Rob-Lourens has mentioned you need to start your own local server to host your HTML/Javascript/CSS and images.
You can use a VS code plugin Live Server to create a local development server for you. Please make sure your URL("url": "http://localhost:3000") in your configuration file matches the URL of Live Server.
If you are on Windows and want to use IIS or IIS Express you can read up on IIS and IISExpress
Just change the value in launch.Json and remove unwanted and paste the html file location in the file attribute.
{
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Open index.html",
"file": "C:\\Users\\xyz\\projects\\PracticeProjects\\jsbasics\\index.html"
}
]
}