Visual Studio Code debugging - Jest breakpoints not working as expected - reactjs

Recently I have upgraded to Jest 23.x.x, using the same VSCode debugging configuration as in Jest 22.x.x, I get weird behaviors: breakpoints are moved, and you cannot really debug (not hitting the real line of code). If I downgrade to 22 everything works as expected.
Is there any breaking change or update from 22 to 23 to be aware of for this case?
My vscode debug launch configuration
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest All",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"--runInBand",
"--no-cache"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"${relativeFile}",
"--runInBand",
"--no-cache"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
]
}

Related

Passing arguments to the C debugger in Visual Studio Code

As the title says, I'm not able to pass arguments to the Visual Studio Code debugger.
I'm in MacOS, and I'm using gcc.
When I use the auto-generated launch.json and tasks.json everything's fine, but when I add the arguments everything crashes.
auto-generated 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 - Compilar y depurar el archivo activo",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "C/C++: gcc build active file"
}
]
}
auto-generated tasks.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc build active file",
"command": "/usr/bin/gcc",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
When I first execute it, I can debug freely, but as I'm adding (to launch.json):
"args": [
"-c",
"1",
"file1"
],
everything's crashes with the message:
The preLaunchTask 'C/C++: gcc build active file' terminated with exit code -1.
and if I click Debug Anyway the message becomes:
launch: program '/Users/.../.vscode/launch' does not exist*
At that point I can't do anything else but click on Open launch.json
Could you help me?
Thanks

VScode's debugger not working [MacOS - Clang - C]

My problem is generated when trying to debug C (the programming language) in vscode using the latest MacOS version with command line tools installed.
The error appears when the external terminal is launched in order to debug. I'm using the clang compiler with the following configuration files for the debugger in 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": "clang - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
"preLaunchTask": "C/C++: clang build active file"
}
]
}
tasks.json:
{
"tasks": [
{
"label": "Open Terminal",
"type": "shell",
"command": "osascript -e 'tell application \"Terminal\"\ndo script \"echo hello\"\nend tell'",
"problemMatcher": []
},
{
"type": "cppbuild",
"label": "C/C++: clang build active file",
"command": "/usr/bin/clang",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
The error that appears in the terminal:
username#Martins-MBP ~ % cd ''; env 'USER=Martin' '__CFBundleIdentifier=com.microsoft.VSCode' 'COMMAND_MODE=unix2003' 'LOGNAME=Martin' 'PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' 'SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.ABVM6fu0pS/Listeners' 'SHELL=/bin/zsh' 'HOME=/Users/Martin' '__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x2' 'TMPDIR=/var/folders/zb/b62pl9hd43n4chv3k7jg5cxr0000gn/T/' 'XPC_SERVICE_NAME=application.com.microsoft.VSCode.142509.142515' 'XPC_FLAGS=0x0' 'ORIGINAL_XDG_CURRENT_DESKTOP=undefined' 'SHLVL=0' 'PWD=/' 'OLDPWD=/' '_=/Applications/Visual Studio Code.app/Contents/MacOS/Electron' 'APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL=true' '/bin/sh' '/var/folders/zb/b62pl9hd43n4chv3k7jg5cxr0000gn/T/Microsoft-MIEngine-Cmd-ukaihz0n.2gz'

How can I run my debugger commands while the program is running?

I've configured my launch.json & tasks.json then return to my file.c and click the green arrow.
I see 'attached image'. Click OK to allow access then I am left with my Debugger but no variables exist and my options like step_into, step_over disappear then I find myself in the same loop.
Below is the JSON for launch and tasks.
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": "clang - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "clang build active file"
}
]
}
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",
"type": "shell",
"command": "msbuild",
"args": [
"/property:GenerateFullPaths=true",
"/t:build",
"/consoleloggerparameters:NoSummary"
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"type": "shell",
"label": "clang build active file",
"command": "/usr/bin/clang",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
It looks like the code is not "paused", so the debugger will not activate while the code is actively running. Try to set a breakpoint and see if that fixes the issue.

Debugging C using Visual Studio Code on Windows

I'm trying to debug a C program using Visual Studio Code on Windows 10,
which I have the C/C++ extension installed in.
My problem is that when I create Source.c in my workspace ( E:\Docs\c ), write some code then hit F5, it shows an error message launch: program 'E:\Docs\c\a.exe' does not exist, which means VSCode doesn't do the compiling thing.
Meanwhile when I go to the console and type gcc source.c, which creates a.exe in the same folder, and hit F5 again it starts with no problems, but doing that every time I want to run the code is annoying.
So, is there a way to compile the code from inside VSCode ?
Here is my c_cpp_properties.json :
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}",
"C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\lib\\gcc\\i686-w64-mingw32\\8.1.0\\include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
And this is launch.json :
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
I think you should add prelaunched task with label of your build task to launch.json like this:
"preLaunchTask": "build" // label of your build task
This means you should have in your tasks.json following task with label build e.g.
"tasks": [
{
"label": "build",
"type": "shell",
"command": "gcc -g source.c"
"group": {
"kind": "build",
"isDefault": true
}
}
]
Also "-g" flag is important for enabling debugging

how to debug revel framework(golang) application in visual studio code(vscode)

{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "attach",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "revel.exe",
"env": {},
"args": [],
"showLog": true
},
]
}
how to debug revel framework(golang) application in visual studio code(vscode)
how to write the configuration file(launch.json)
Here are the steps to debug a revel framework (golang) app in vscode.
Import revel project folder into vscode
Edit ~/.vscode/launch.json so that it looks like the following: (replace values in <> with values for your own local env.
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"mode": "debug",
"program": "${workspaceRoot}/app/tmp/",
"env": {},
"args": ["-importPath", "<project folder name>", "-srcPath", "C:\\Users\\<username>\\go\\src", "-runMode", "dev"]
}
]
}
Note that -importPath should be the directory (relative to $GOPATH\src where your project lives)
Note that the value for -srcPath should match your $GOPATH\src directory (I'm running on Windows)
Once your launch.json is set up as so, you can start the app in deb mode and put breakpoints wherever you wish.

Categories

Resources