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

Ignore "justMyCode" flag when doing a step into target #564

Closed
ewerybody opened this issue Mar 17, 2021 · 9 comments
Closed

Ignore "justMyCode" flag when doing a step into target #564

ewerybody opened this issue Mar 17, 2021 · 9 comments
Labels
enhancement New feature or request pydevd

Comments

@ewerybody
Copy link

Issue Type: Feature Request

The "justMyCode": true feature is great! But sometimes I DO like to see what's going on in a built-in module. Of course:

• I can go into my launch.json
• turn "justMyCode": false
• save it
• go back to where I was
• restart debugging
• jump into the spot I was looking for ...

And when I'm done roll it all back again :/ that's quite some work...
I'd rather have the debugger see that there is currently NONE of "MyCode" at a current line anyway and "Step Into" DOES go into and not just skip.

As a workaround a Force Step Into would be nice that one could pack onto another shortcut.

Contrary to microsoft/vscode-python#13719 I'd not appreciate to maintain an white- or blacklist for this.

Extension version: 2021.3.658691958
VS Code version: Code 1.54.3 (2b9aebd5354a3629c3aba0a5f5df49f43d6689f8, 2021-03-15T10:55:45.459Z)
OS version: Windows_NT x64 10.0.19042

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Mar 17, 2021
@fabioz
Copy link
Collaborator

fabioz commented Mar 18, 2021

Having the debugger see that there's currently only stdlib code in a step into is pretty hard to do in practice... one feature that's being currently integrated is a step into target (#563), where the target functions are listed and then the debugger stops at the proper call site, so, maybe one option would be having the step into target ignore the just my code (this doesn't currently happen, but it does seem like it'd make sense in this case).

What do you think @int19h @karthiknadig? It may make sense to add this right after that pull request is integrated since this seems like a good use case for that (thinking about it, it may be a bit weird having the user go through the process of selecting the target and having it skipped because of the justMyCode).

@ewerybody
Copy link
Author

Hey @fabioz! Nice to read you here!! 👋

But what do you mean?

Having the debugger see that there's currently only stdlib code in a step into is pretty hard to do in practice

Isn't that the entire purpose of the justMyCode feature? I have no idea about the logic behind it but I'd be so naive 😄 to think it would be like ... This line for example:

• self.assertFalse(os.path.isfile(test_file))
  • justMyCode: true > step into:
    • there is none of "my code" > step over
  • now "smart justMyCode: true" > step into:
    • there is none of "my code" > step into nonetheless

@fabioz
Copy link
Collaborator

fabioz commented Mar 19, 2021

But that kind of defeats the purpose of the justMyCode then...

Usually you'd have:

userCode(os.path.isfile(test_file))

and you want to skip the isfile call and just step into the userCode.

So, what I said that is hard is identifying that when you're stepping in a line, all the targets from that line will only enter library code and there'd never be user code called from that line.

@fabioz
Copy link
Collaborator

fabioz commented Mar 19, 2021

As a note, I still think that the step into target would be a good solution to this problem (because you'll pre-identify where you're stepping).

I didn't really fiddle with the justMyCode semantics in it right now, but after #563 is integrated, I think it'd be a good addition to not use the justMyCode when doing that step into target, so, I'll rename this issue accordingly.

@fabioz fabioz changed the title Launch setting "justMyCode": smart Step Into when there is ONLY foreign code Ignore "justMyCode" flage when doing a step into target Mar 19, 2021
@fabioz fabioz changed the title Ignore "justMyCode" flage when doing a step into target Ignore "justMyCode" flag when doing a step into target Mar 25, 2021
@zhanko73
Copy link

zhanko73 commented Apr 7, 2021

I'm sorry for the question but I have not found any instruction so far about what count as "MyCode"? How the debugger decide what is my code and what is not?

@ewerybody
Copy link
Author

https://code.visualstudio.com/docs/python/debugging#_justmycode

When omitted or set to true (the default), restricts debugging to user-written code only. Set to false to also enable debugging of standard library functions.

How the decision is made? I dunno. Maybe just anything that isn't in your workspace? 🤔

@fabioz
Copy link
Collaborator

fabioz commented Apr 7, 2021

How the decision is made? I dunno. Maybe just anything that isn't in your workspace? 🤔

The actual code to compute the defaults is in: https://github.com/microsoft/debugpy/blob/main/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_filtering.py#L154 (i.e.: it's based on sysconfig.get_path to calculate library code and some additional heuristics -- so, it's the other way around, anything not in a library is user code... as a note, I created #581 to also force workspace contents to be user code -- if the client actually passes it, as the Debug Adapter Protocol doesn't really specify that workspaceFolder is required for the launch, so, it can't always be relied upon).

As a note, the debugger does allow setting environment variables named IDE_PROJECT_ROOTS and LIBRARY_ROOTS (both as list of paths separated by the path separator -- ; on Windows : on Linux) to override the default heuristics computed by the debugger.

@zhanko73
Copy link

@fabioz , @ewerybody Thank you.

@int19h int19h added the enhancement New feature or request label Aug 10, 2021
@int19h int19h added the pydevd label Feb 1, 2023
@judej
Copy link

judej commented Jan 3, 2024

Thank you for the report. Given our current resources are working on the Python 3.12 debugger, we will not be fixing this issues in the pre Python 3.12 debugger.

@judej judej closed this as completed Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pydevd
Projects
None yet
Development

No branches or pull requests

5 participants