Reputation: 2047
When debugging in vscode I'd like to make some "blackboxing" and do not enter into code I didn't write. How can I do this?
Upvotes: 66
Views: 26475
Reputation: 50551
It depends on the language/debug-support extension. VS Code does not have a generalized way to do this because languages differ in the ways that they describe programs in source and object/binary formats, and in the ways that their backing debug tooling support skipping things in debugging.
For node
launch configurations, use the skipFiles
property of the launch config. Related user documentation can be found at https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_skipping-uninteresting-code.
You can also use the skipFiles
property of the debug.javascript.terminalOptions
setting for auto-attach and JS debug terminals.
For Python debugging, use the justMyCode
property of the launch configuration. See also Visual Studio Code - Python debugging - How to step into external functions/packages?. There's also a debugpy.debugJustMyCode
contributed by the debugpy extension.
For Jupyter notebook debugging, use the jupyter.debugJustMyCode
setting. See also How to debug external libraries in vscode-jupyter cell debugger?.
For Java debugging with the vscode-java-debug extension, use the java.debug.settings.stepping.skipClasses
user setting. It takes an array of patterns and supports special values like $JDK
, $Libraries
, and java.lang.ClassLoader
, and also supports wildcards.
For C/C++ when using a debugger like GDB with the cppdbg
launch config type, use GDB's skip
command in the setupCommands
property of the launch config. See also Exclude files from vscode C++ debug step into?, Tell gdb to skip standard files, and GDB C++ How to Stop Stepping Inside Standard Libraries.
C# debugging supports justMyCode
in launch configs via the justMyCode
property, and in settings via the csharp.debug.justMyCode
setting.
For Flutter/Dart, use the dart.debugSdkLibraries
and dart.debugExternalPackageLibraries
settings.
For Go, I don't know. But you can at least use the go.delveConfig
setting's hideSystemGoroutines
to hide system goroutines from the call-stack view.
Upvotes: 1
Reputation: 1983
For flutter apps, add to your user settings the following:
"debugExternalPackageLibraries": false,
"dart.debugSdkLibraries": false,
Upvotes: 1
Reputation: 1948
For Typescript built with Webpack, I had to put the exclusions in launch.json - putting them in settings.json/terminalOptions had no effect.
Also, I had to exclude the pattern of the generated files, not the source files. In my case it looks like:
"skipFiles": [
"<node_internals>/**",
"**/vendors-*",
],
Upvotes: 2
Reputation: 2798
For some reason, I've needed to add both types of skip file entries,
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js",
"<node_internals>/**"
],
This seems to have resolved the issue.
Upvotes: 1
Reputation: 1075
Just to amplify on Mauro Aguilar's correct answer, here are the complete contents of my launch.json file. Note that I am debugging a ReactJS app (circa 2021) with VS Code 1.60.2 on Windows 10 using Chrome v.94. If you're using a Linux machine or a Mac, YMMV.
{
// 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": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}",
"skipFiles": ["<node_internals>/**/*.js", "${workspaceFolder}/node_modules/**/*.js"]
},
]
}
Upvotes: 0
Reputation: 1467
Only this worked for me.
"debug.javascript.terminalOptions": {
"skipFiles": [
"<node_internals>/**"
]
}
Upvotes: 4
Reputation: 181429
In your launch or attach debug task you can enter a
"skipfiles"
option which is
"An array of file or folder names, or path globs, to skip when debugging."
For example, from skipping node internals during debugging
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js",
"${workspaceFolder}/yourLibToSkip/**/*.js"
]
Also, there is a "magic reference" to the built-in core node modules you can use:
"skipFiles": [
"<node_internals>/**/*.js"
]
Upvotes: 82
Reputation: 1338
I was confused on where to put the setting, so just in case, if you want to skip both node_modules
deps and node_internals
files, your .vscode/launch.json
file should look something like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Tests",
"type": "node",
"request": "launch",
...
"skipFiles": ["<node_internals>/**", "${workspaceFolder}/node_modules/**/*.js"]
}
]
}
Upvotes: 17
Reputation: 19
this is my launch.json file (it works for me):
{
"version": "0.2.0",
"configurations": [
{
"type": "edge",
"request": "launch",
"name": "Launch Edge against localhost",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}",
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js"
]
}
]
}
Upvotes: 0