Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to disable "justMyCode" when debugging through extension #938

Closed
johschmitz opened this issue May 18, 2022 · 10 comments
Closed

No way to disable "justMyCode" when debugging through extension #938

johschmitz opened this issue May 18, 2022 · 10 comments

Comments

@johschmitz
Copy link

Environment data

  • debugpy version: 1.6.0
  • OS and version: Linux Mint 20.3
  • Python version (& distribution if applicable, e.g. Anaconda): 3.10
  • Using VS Code or Visual Studio: VS Code

Actual behavior

There seems to be currently no way to disable the "justMyCode" debug option when debugging through an extension.

I am using the Blender Development extension (https://marketplace.visualstudio.com/items?itemName=JacquesLucke.blender-development) and this just breaks debugging into Python libraries that my Blender add-on code uses.

Expected behavior

Either justMyCode should be ignored for such use-cases or it should be possible to disable it in a kind of global way when using the debuger with "No Configurations".

Steps to reproduce:

  1. Install "Blender Development" add-on
  2. Create a dummy add-on
  3. Press Ctrl+Shift+P and run "Blender: Build and Start"
  4. Set a breakpoint in the Python code in VS Code at a line which calls into a Python library outside the workspace
  5. Now it is impossible to "Step into"
  6. Frustration
@karthiknadig
Copy link
Member

@johschmitz This should probably be filed as a feature request on the blander extension. They are passing a configuration directly without setting justMyCode. They should probably make it easier for you to modify the configuration if needed.

https://github.com/JacquesLucke/blender_vscode/blob/979dada1e63d5e5f0d4ba7a039bf70d8b97caf8c/src/python_debugging.ts#L19-L26

@johschmitz
Copy link
Author

johschmitz commented May 18, 2022

@karthiknadig So you are saying you just break lots of working extensions from the market place by introducing this new behavior and just making it the new default? And now all extension authors need to become active instantly? Kind of uncool...
Why not making it possible to disable this in the global settings to give extension authors more time to deliver a fix?

Edit: Thanks for the hint though. Will submit a pull request to get it fixed.

@int19h
Copy link
Contributor

int19h commented May 18, 2022

The behavior is not new - this feature has been around for a very long time now. The only thing we've changed about it is renaming it from "debugStdLib" to "justMyCode" over two years ago, and even then debugpy still supports the legacy name for compatibility reasons. The default value also hasn't changed since the name was changed. So, I would rather look at the Blender extension for any recent changes that might affect this.

I must also add that new config properties are going to appear from time to time along with new features, and those new features will sometimes change observable behavior in various ways (e.g. the way variables are formatted has changed over time). The expected behavior from anything that wraps debugpy is to provide the end user the ability to change the debug configuration, or at least those parts of it that can be changed without breaking the scenario.

My recommendation for the Blender extension would be to register a custom debugger for "type": "python-blender", and rewrite it into "type": "python" while adding all the necessary properties like "request": "attach", ports etc in their implementation of DebugConfigurationProvider. This exposes the config in a way consistent with other VSCode extensions, and allows them to provide their own schema for it with only the properties that they want to support.

@karthiknadig
Copy link
Member

To add to what @int19h said. We haven't changed the default for justMyCode since it was introduced (two years ago). In fact, in the python extension, we made it more explicit, so that users know what the default is.

Extensions registering their own configuration provider can greatly improve the user experience in this case. Especially, if you want to use some of the advanced features. Or, if you even just wat to enable logging or set some environment variable. The way blender extension is doing it right now limits the capabilities of the debugger.

@johschmitz
Copy link
Author

I just don't understand why it then worked for me until recently. There must have been some kind of change. Otherwise I would have researched this earlier like it did now. Are you guys really sure about that? I have no idea when this option was introduced but I am pretty sure I did debug into external code this year without knowing about it. Anyway I guess it can be fixed based on the information you provided. So thanks a lot for the prompt support.

@int19h
Copy link
Contributor

int19h commented May 18, 2022

Perhaps the location of the code itself changed? The heuristics behind "justMyCode" basically try to determine whether a given file is under your prefix path. If Blender used to do something weird with its stdlib, but now packages it as a regular Python install (Lib, site-packages etc), that could account for the difference.

@johschmitz
Copy link
Author

johschmitz commented May 18, 2022

I don't know, I also used to debug into C++ code at work without setting this, that just can't be two years ago.
Independent of the Blender extension issue I still believe it would be nice to have a global option in the VS Code settings to turn off justMyCode globally. For people who work on many projects it can be a bit annoying to often turn this off using the JSON way. I believe there is another issue asking for a quick and easy way to turn this on and off.

@int19h
Copy link
Contributor

int19h commented May 18, 2022

VSCode has a notion of global debug configurations - it's basically a global launch.json that lives inside settings.json:

"launch": {
  "configurations": [
     { type: "python", ... }
  ]
}

However, this isn't quite it, because it's still a separate configuration - if you use another one, that other one fully overrides everything.

It sounds like what's needed here is some facility in VSCode that enables stacking debug configs in a layered way instead - that is, a global config like above, but one that is automatically used as a basis for any other configuration of the same type/request. Then you could set such things globally, but also override them on a per-config basis, in a consistent way.

@johschmitz
Copy link
Author

How about instead of using the layers, letting the user manipulate certain settings via the GUI or via some commands while the debugger is already running? Like a little toggle switch to turn justMyCode (and other things) on and off on the fly.

@karthiknadig
Copy link
Member

Like a little toggle switch to turn justMyCode

Please upvote this: microsoft/vscode-python-debugger#116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants