Unable to hit breakpoints on M1 mac golang in VScode - go

I've tried to debug my hello world program in go and cannot get debugging to work.
I've installed via homebrew and the google website. I've tried various online config, installed delve and breakpoints just won't stick.
Paths
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin
Configuration
{
// 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": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "hello.go"
}
]
}

Related

How do I launch/debug a project in an external console?

I am trying to debug a Go project in VSCode. I am able to debug it, but the application is running in the internal VSCode terminal. I need the application to run in an external console instead. For instance I want it to run in cmd.exe.
// .vscode/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": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
}
How can I make the debug session open a external console and run it there, rather than in the internal console of VSCode?
The developers for the Go VSCode extension are in the process of adding a launch property for this. See: https://github.com/golang/vscode-go/issues/124#issuecomment-1006122877

Debug console doesnt show any output

Im starting a python basic course and trying to run some initial code with Vscode. After watching the course videos i notice that im not seeing any output under the DEBUG CONSOLE. I do get an output under the TERMINAL section.
Also, i notice that the debug icon is different compared to the one in the videos (mine has a play arrow).
Am i missing something?
My python
C:\Users\andres>py --version
Python 3.8.3
my current launch.json 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": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"cwd": "",
"console": "integratedTerminal"
}
]
}
thanks
thanks to #tHeSiD for the initial advise. for the winerror123, i deleted and recreated the json file

Using Visual Studion Code to connect to the gdb-server of the OP-TEE which is running in the QEMU

I am setting up the op-tee in ARM-64. and I'm wondering if it is possible to debug it using visual studio code running under ubuntu 18.04.
So far I was able to compile and run the op-tee in QEMU. and also being able to connect the gdb-server using the command line gdb (following this link: https://www.op-tee.org/docs/debug/).
Now I would like to use some GUI instead of gdb. Since I was working wih visual studio code, so I was wondering if it is possible to configure vsCode to do so?
I have tried installing the cortex-debug extension (I'm not sure if that it the right one) and also tried c/c++ debug attach as well. But I cannot make them work!
Here 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) Attach",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceFolder}/optee_os/out/arm/core/tee.elf",
"miDebuggerServerAddress": "localhost:1234",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"text": "optee"
}
]
},
{
"cwd": "${workspaceRoot}",
"executable": "${workspaceFolder}/optee_os/out/arm/core/tee.elf",
"name": "Debug Microcontroller",
"request": "attach",
"type": "cortex-debug",
"servertype": "openocd"
}
]
}
I expect to be able to debug the arm application by remotely connecting to the gdb-server which is running under QEMU using the Microsoft visual code.
Any suggestion of using extensions is appreciated.
I found the solution which works for me:
First it is needed to install the Native Debug extension for VS Code.
Then Add the following configuration into the launch.json file:
{
"type": "gdb",
"request": "attach",
"name": "Attach to QEMU",
"executable": "${workspaceFolder}/optee_os/out/arm/core/tee.elf",
"target": "localhost:1234",
"remote": true,
"cwd": "${workspaceRoot}",
"gdbpath": "~/devel/optee/toolchains/aarch64/bin/aarch64-linux-gnu-gdb"
}
Notes:
You can connect to QEMU only if the app is not running:
It should either be at initial state before typing c in QEMU
or it is stopped in a breakpoint
There should be no other clients connected to it.
Reference:
http://austinhanson.com/vscode-gdb-and-debugging-an-os

"actionssdk-smart-home-nodejs" debug with VSCode

I successfully installed the "actionssdk-smart-home-nodejs" and it works well if i launch it using the command "node index.js" within the folder "...actionssdk-smart-home-nodejs\smart-home-provider".
I need now to debug some part of the code, thus i tried to debug it using VS Code as editor and with the launch.json configured like
{
// 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": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}"
}
]
}
When i launch the debugger all seems to start fine, but when i use the Google Chrome browser to access the main page (http://localhost:3000/) i get as response only "Cannot GET /".
It seems like the static route defined in the file "smart-home-provider-cloud.js" app.use('/', express.static('./frontend'));
isn't matched.
So i can't figure out why launching without debugging all works fine and if a start the debugger express returns only "Cannot GET /".
I would be grateful for any help or clue for further investigation !
After long digging i found my issue. The config file for debugging was missing a config line.
{
// 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": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}",
"cwd":"${workspaceRoot}/smart-home-provi
}
]
}

How do I debug HTML and JavaScript together in VSCode (Visual Studio Code)?

I want to run and debug an html page with a javascript file in a mini website when I hit F5.
How do I configure VSCode to open the html page in the browser and then allow me to set breakpoints in the javescript file which will be triggered by my interaction with the app in the browser?
In Visual Studio this would "just work", because it fires up its own web server, IIS Express. In VSCode I'm not sure how I set up launch.json and/or tasks.json to create a simple node.js web server and serve index.html.
I have seen some examples of debugging javascript apps, for example this launch.json:
{
"version": "0.1.0",
"configurations": [
{
"name": "Launch Bjarte's app",
"type": "node",
"program": "app.js",
"stopOnEntry": true,
"args": [],
"cwd": ".",
"runtimeExecutable": null,
"runtimeArguments": [],
"env": {},
"sourceMaps": false
},
{
"name": "Attach",
"type": "node",
"address": "localhost",
"port": 5858,
"sourceMaps": false
}
]
}
This will run the js file, but I don't understand how I can interact with the app.
It is now possible to debug Chrome web pages in vscode via Chrome remote debugging with a extension released by Microsoft.
Debugger for Chrome
As you can see from that page there are two modes of debugging, Launch and Attach. I only managed to use the Attach mode, probably because i don't have a server running. This extension has all important debug tools functional: local variables, breakpoints, console, call stack.
Another reason to revisit vscode is that it now has IntelliSense support for ECMAScript 6, which displays methods not visible in other "IntelliSense like" solutions I've tried, like SublimeCodeIntel or the latest version of WebStorm.
It seems what I want to do is not possible in VSCode (yet?). My solution at the moment, is to use the node package live-server. Install with
> npm install -g live-server
Then open VSCode, right-click any file in the root folder of your project and select "Open in Console". Then type
> live-server
to start a server with your project as root folder. Live-server will open your default browser and also monitors your project folder for any file changes, and reloads the html page every time you do any changes.
I should mention that my solution using live-server doesn't allow me to debug my app in VSCode, only run it in the browser. I am debugging in Chrome.
Like others have said you install this:
You can use https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome
And if you are not running a localhost but some HTML and JavaScript you can use this launch.json code.
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch index.html",
"type": "chrome",
"request": "launch",
"file": "${workspaceFolder}/index.html"
}
]
}
VSCode will use node to launch your app, which means your app is running on some PORT. You can interact with your app by visiting http://localhost:PORT/
If you set a breakpoint in app.js it should be hit once you visit your site that is running local via node.
Here is a nice demo https://channel9.msdn.com/Blogs/cloud-with-a-silver-lining/hello-visual-studio-code-nodejs
I didn't want to run a server just for some HTML and JavaScript (unlike a similar example) this VS Code launch configuration along with the 'Debugger for Chrome' extension did the trick on my Windows 10 machine:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch HTML file",
"type": "chrome",
"request": "launch",
"file": "${file}"
}
]
}
In case you have # in path like C:\C#\mypage.htm, you may use FF & ex. fileBasename or Similar variable - does not work in Chrome:
.vscode\launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch HTML file",
"type": "firefox",
"request": "launch",
"file": "C:/C%23/${fileBasename}"
}
]
}
Or simple full path tested with node.js:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/${fileBasename}"
}
]
}
You can use https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome
In the launch.json you just have to pu the url value of the server that you are using and then you can debug your html + js with your editor visual studio code
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://127.0.0.1:8081",
"webRoot": "${workspaceFolder}"
}
]
}

Resources