microsoft / debugpy

An implementation of the Debug Adapter Protocol for Python
https://pypi.org/project/debugpy/
Other
1.88k stars 139 forks source link

Breakpoints on secondary threads don't trigger when using PyQt5 #1041

Open keenox opened 2 years ago

keenox commented 2 years ago

Environment data

Actual behavior

Expected behavior

Steps to reproduce:

See this issue https://github.com/microsoft/ptvsd/issues/1189

fabioz commented 2 years ago

Please provide the logs for this (they include information on whether you're using frame eval mode).

Frame eval mode is a mode which uses breakpoints by using the CPython https://peps.python.org/pep-0523/ API along with breakpoints added by changing the bytecode. The logs help to identify whether it's being used and other information on your system.

See: https://github.com/microsoft/debugpy/wiki/Enable-debugger-logs for details on how to collect the logs.

keenox commented 2 years ago

@fabioz Here are the logs debugpy.adapter-18492.log debugpy.launcher-15556.log debugpy.pydevd.3328.log debugpy.server-3328.log

fabioz commented 2 years ago

The logs say that compiled extensions aren't being used ({"usingCython": false, "usingFrameEval": false}}).

@int19h @karthiknadig the logs show that the extension being used is the one shipped with VSCode:

i.e.: c:\Users\<username>\.vscode\extensions\ms-python.python-2022.14.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\pydevd.py

I took a look at it and at least on my machine the compiled libraries there are only the ones available for CPython 3.9.

i.e.: under C:\Users\<username>\.vscode\extensions\ms-python.python-2022.14.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle I can see pydevd_cython.cp39-win_amd64.pyd and the related variants for other platforms supporting Python 3.9 but not the variants for other Python versions.

Is this some packaging issue in the vscode-python side?

@keenox you should be able to get compiled extensions in the meanwhile by compiling them locally. You can do that by running:

python C:\Users\keenox\.vscode\extensions\ms-python.python-2022.14.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\setup_pydevd_cython.py build_ext --inplace

If it worked you should have something as pydevd_cython.cp310-win_amd64.pyd in the directory: C:\Users\keenox\.vscode\extensions\ms-python.python-2022.14.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle.

fabioz commented 2 years ago

@int19h @karthiknadig maybe we should go back to showing the message on how to compile it when compiled versions aren't available... we stopped doing it because it was going to sys.stderr at the time, but I guess that if we change it to be an OutputEvent with a category of console it could be interesting to reenable it. What do you think?

keenox commented 2 years ago

@fabioz Indeed I use the extension from the VS Code marketplace. I confirm that the breakpoints triggered after building the extensions

int19h commented 2 years ago

IIRC the intent on the extension side was to ship precompiled binaries for all Python versions once it allows for arch-specific packages, by making separate packages for the debugger bits (otherwise the sheer size of all those DLLs dominates the extension size).

judej commented 1 year ago

@int19h needs to check if disabling frame evaluator would also prevent the threads from being detected by design.