VSCode Debugger on Jupyter Notebook doesn't stop running - debugging

I want to debug a Jupiter notebook in VSCode, that access multiple other .py scripts with class methods. I've set a breaking point in the respective cell, but the debugger keeps running infinitely and I got no results neither in variables section nor in call stack section and my debug console just remains empty.
I would be grateful if there is any idea why the debugger is stuck.
This is what I have in my 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": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Debug Unit Test",
"type": "python",
"request": "launch", //launch or attach
"justMyCode": false,
}
]
}
VSCode Info:
Version: 1.64.2 (Universal)
Commit: f80445acd5a3dadef24aa209168452a3d97cc326
Date: 2022-02-09T22:00:58.347Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin arm64 20.6.0

Related

vscode can't find delve even though environment variables are set in launch.json

My 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 test function",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${workspaceFolder}/checkers/x/checkers/keeper",
"args": [
],
"env": {"GOPATH":"/home/alain/go", "PATH":"/home/alain/go/bin", "GO15VENDOREXPERIMENT": 1}
}
]
}
The dlv binary is in /home/alain/go/bin and works perfectly. Even outside of that directory it works.
However, when trying to launch debuggin in vscode, I am still getting the error:
Failed to continue "Cannot find delve debugger. Install from https://github.com/go-delve/delve & ensure it is in your Go tools path, "GOPATH/bin" or "PATH"
For reference: I did install delve from https://github.com/go-delve/delve

VSCode Debugger: Debugger could not find file .go file

I'm trying to debug my program in VSCode. My Launch.json file looks as follows:
{
// 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": "${workspaceFolder}/DS_PA1/srunner/",
"cwd" : "${workspaceFolder}/DS_PA1/srunner/"
}
]
}
My folder hierarchy is:
The debugger is set in the function main():
On launching, it starts the server and without stopping at the breakpoint it just printed the statement "Started KeyValueServer..."
Any pointers as to how I can make it stop at func main() so that I can debug manually?

How do you configure visual studio code to run compiled Go code when using Run/Run&Debug (F5/CTRL+F5) VS code options?

I have installed the following task to compile my Go project following this blog post: https://robertbasic.com/blog/build-and-run-golang-projects-in-vs-code/
tasks.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build Go",
"type": "shell",
"command": "go build",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Now I can compile the project using Terminal>Run build task
For running and debugging, I have created:
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",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"cwd": "${workspaceRoot}",
"args": [],
"env": {}
}
]
}
But it does not work, I get the following message:
package .: no Go files in /usr/home/username/projects/my_app/.vscode
Process exiting with code: 1 signal: false
Visual Studio Code under FreeBSD12.1 (probably not relevant).
What do I have to do to get the program running when using F5/CTRL+F5?
Any tip including recommended help section or blog entry is welcomed.
Assuming my main package is at the root folder of the workspace, I always define the same .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",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"env": {},
"args": []
}
]
}
From there, I can press F5 from anywhere/any file, and the debug session simply starts.

How to add user input while debugging C++ on vscode on macOS

How does one add user input when debugging on VScode?
I have tried the following
Edited my launch.json to set externalConsole : true
Tried giving input as a command line argument as mentioned here
Irrespective of following step by step the above methods, something was off.
I kept getting a window where I couldn't do anything. The step up / down / in buttons went inactive.
Here in 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": "g++-10 - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
"preLaunchTask": "C/C++: g++-10 build active file"
}
]
}
and here is my tasks.json file
{
"tasks": [
{
"type": "shell",
"label": "C/C++: g++-10 build active file",
"command": "g++",
"args": [
"-g",
"${file}",
"-std=c++17",
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}
System details
Version: 1.48.1
Commit: 3dd905126b34dcd4de81fa624eb3a8cbe7485f13
Date: 2020-08-19T17:09:41.484Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 20.0.0
The resolve is given in a gist here
The issue is when VSCode launches the debug adapter, then the debug adapter launches lldb-mi, then lldb-mi launches Terminal. There is a prompt that should appear, but somehow the DebugAdapter is not forwarding this permissions request.
The work around is to have VS Code launch the terminal once. You can do this by adding and running this tasks in your tasks.json:
{
"label": "Open Terminal",
"type": "shell",
"command": "osascript -e 'tell application \"Terminal\"\ndo script \"echo hello\"\nend tell'",
"problemMatcher": []
}
You can run this specific task using Command + Shift + p. Type Tasks and look for Tasks: Run Tasks then select Open Terminal.
I have written a small blog post about the same, detailing each and every step with images which can be found here.

VSCode debugging C++ launches external terminal, but doesn't run program

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

Resources