microsoft / PTVS

Python Tools for Visual Studio
https://aka.ms/PTVS
Apache License 2.0
2.52k stars 675 forks source link

Python 3.10 fails to hit breakpoints when "Native Code Debugging" is enabled. #6900

Open ttSpace opened 2 years ago

ttSpace commented 2 years ago

Describe the bug

image

Install Python 3.10 from https://www.python.org/

Steps to Reproduce

  1. Create a Python Application project, add simple Python code.
    
    from math import cos, radians

Create a string with spaces proportional to a cosine of x in degrees

def make_dot_string(x): rad = radians(x) # cos works with radians numspaces = int(20 cos(radians(x)) + 20) # scale to 0-40 spaces st = ' ' numspaces + 'o' # place 'o' after the spaces return st

def main(): for i in range(0, 1800, 12): s = make_dot_string(i) print(s) main()

2. Enable "Native Code Debugging" in project settings / debug page.
3. Set breakpoint and start debugging.

**Expected behavior**

Breakpoint should be hit.

**Additional context and screenshots**

Breakpoint can not be hit.

**Output info**
<details>
<p>

'python.exe' (Win32): Loaded 'C:\Python310-64\python.exe'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase.dll'. 'python.exe' (Win32): Loaded 'C:\Python310-64\vcruntime140.dll'. 'python.exe' (Win32): Loaded 'C:\Python310-64\python310.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\ws2_32.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\version.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\cryptsp.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\rsaenh.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\bcrypt.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\cryptbase.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\bcryptprimitives.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'. The thread 0xa58 has exited with code 0 (0x0). The thread 0x18bc has exited with code 0 (0x0). The thread 0x4ebc has exited with code 0 (0x0). The program '[12416] python.exe' has exited with code 0 (0x0).



</p>
</details>
int19h commented 2 years ago

Can you check if Python symbols were loaded correctly for python310.dll? You should be able to see it in the Modules window (under Debug -> Windows).

ttSpace commented 2 years ago

The Module window is shown below.

image

linette-zyy commented 2 years ago

image This issue also can reproduce on Python3.8. Python3 8

int19h commented 2 years ago

We need to figure out whether we're planning to support 3.10 for this feature.

AdamYoblick commented 1 year ago

@judej @cwebster-99 We need some PM guidance on this. Are we planning on supporting mixed mode debugging for 3.10?

ttSpace commented 1 month ago

In today's build Microsoft Visual Studio Enterprise 2022 (64-bit) - Int Preview Version 17.12.0 Preview 1.0 [35119.171.main] , Python Package: 17.0.24203.1 . Python installed from Microsoft Store. Follow the instruction to download symbols. Breakpoint can not be hit, and python_uwp.pdb not included appears.

image

Logs

Output for Debug in the Output panel

``` 'python3.9.exe' (Win32): Loaded 'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\python3.9.exe'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\combase.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\shell32.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\msvcp_win.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\win32u.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\gdi32full.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\oleaut32.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\python39.dll'. Symbols loaded. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\ws2_32.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\version.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\bcrypt.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\vcruntime140.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\Extensions\Microsoft\Python\Core\Microsoft.PythonTools.Debugger.Helper.x64.dll'. Symbols loaded. 'python3.9.exe' (Python): Loaded ''. Module was built without symbols. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'. Symbol loading disabled by Include/Exclude setting. The thread 5548 has exited with code 486670336 (0x1d020000). 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\bcryptprimitives.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\clbcatq.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\Windows.ApplicationModel.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\SHCore.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\twinapi.appcore.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\windows.storage.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\wldp.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\ole32.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\shlwapi.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\cfgmgr32.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\propsys.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\uxtheme.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\profapi.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\RpcRtRemote.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\mssprxy.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\Windows.Storage.ApplicationData.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\WinTypes.dll'. Symbol loading disabled by Include/Exclude setting. onecoreuap\base\appmodel\statemanager\winrt\lib\windows.storage.applicationdatafactory.server.cpp(235)\Windows.Storage.ApplicationData.dll!00007FFB181B8483: (caller: 00007FFB181C8CDB) ReturnHr(1) tid(57b4) 8000000B The operation attempted to access data outside the valid range Msg:[User S-1-5-21-3092367648-3550124423-2311139719-500] 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\cryptsp.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\rsaenh.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Win32): Loaded 'C:\Windows\System32\cryptbase.dll'. Symbol loading disabled by Include/Exclude setting. 'python3.9.exe' (Python): Loaded ''. Module was built without symbols. 'python3.9.exe' (Python): Loaded ''. Module was built without symbols. 'python3.9.exe' (Python): Loaded ''. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/encodings\__init__.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/codecs.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/encodings\aliases.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/encodings\utf_8.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/encodings\cp1252.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/encodings\latin_1.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/io.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/abc.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/site.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/os.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/stat.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/_collections_abc.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/ntpath.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/genericpath.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/_sitebuiltins.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'Lib/_bootlocale.py'. Module was built without symbols. 'python3.9.exe' (Python): Loaded ''. Module was built without symbols. 'python3.9.exe' (Python): Loaded 'C:\Users\vting\source\repos\PythonApplication2\PythonApplication2\PythonApplication2.py'. Module was built without symbols. ```

int19h commented 4 weeks ago

The fact that it shows messages like "Loaded Lib/...py" in the console indicates that the mixed-mode debugging is in effect, meaning that it already loaded all the symbols that it needed.