microsoft / debugpy

An implementation of the Debug Adapter Protocol for Python

Home Page:https://pypi.org/project/debugpy/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot set remote breakpoints in Visual Studio Community 2022 (Version 17.10.3)

github-shamada opened this issue · comments

Symptoms

Remote debugging using VS2022+debugpy does not work properly.
The remote connection is successful, but Breakpoint cannot be set.

Environmental Data

Client environment

  • Windows-10
  • Visual Studio 2022 (ver 17.10.3)
  • debugpy 1.8.1
  • workdir: \10.123.36.238\shamada\debug\

Server environment

  • Ubuntu-22.0.4
  • Python 3.11.5
  • debugpy 1.8.1
  • workdir: /home/shamada/debug/

Execution steps and results

Execution steps

[server side]
export DEBUGPY_LOG_DIR="/home/shamada/debug"
export DEBUG_PYDEVD_PATHS_TRANSLATION=1
export PATHS_FROM_ECLIPSE_TO_PYTHON='[["\\10.123.36.238\shamada\", "/home/shamada/"]]'
python -Xfrozen_modules=off -m debugpy --wait-for-client --listen 0.0.0.0:5678 b.py

[cliennt side]
execute [debug]/[attach to process] menu
set connection type "python remote (debugpy)"
set connection target "tcp://10.177.36.238:5678/"

Results

Process attachment succeeds.
Pre-set breakpoints are disabled.
Breakpoints set after connection are also disabled.
Followings are their error messages:
the breakpoit will not currently be hit. breakpoint in file that does not exist.

devenv_TON24RzrbZ

Investigation

debugpy.pydevd.log contains logs like the following.

0.00s - Request for breakpoint in: \\10.123.36.238\shamada\debug\b.py line: 3
0.00s - pydev debugger: replacing to server: \\10.123.36.238\shamada\debug\b.py
0.00s - pydev debugger: sent to server: /home/shamada/debug\b.py - matched prefix: \\10.123.36.238\shamada\
0.00s - Breakpoint (after path translation) in: /home/shamada/debug\b.py line: 3
0.00s - os.path.exists('/home/shamada/debug\\b.py') returned False.

It seems that the cause is that slashes and backslashes are not converted properly in path mapping.
Please see the attached file for all logs.

debugpy.adapter-270155.log
debugpy.pydevd.269778.log
debugpy.server-269778.log

This is a dupe of the bug you logged earlier:
#1541

I'm guessing it needs the hack that Fabio mentioned here:
#307 (comment)

I tried Fabioz's method, but unfortunately it didn't work.

pydevd_file_utils.py exists on both the server side and the client side.
I tried all combinations of modifying and not modifying, but in all cases the problem was not solved.

server-side:modified + client-side:modified -> doesn't work
server-side:not-modified + client-side:modified -> doesn't work
server-side:modified + client-side:not-modified -> doesn't work

client side: C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\Python\Core\debugpy_vendored\pydevd\pydevd_file_utils.py
server side: ~/miniconda3/envs/py311a/lib/python3.11/site-packages/debugpy/_vendored/pydevd\pydevd_file_utils.py

The attached is the modified source at line 381.

pydevd_file_utils_mod.zip

Thanks anyway, @rchiodo!