-
Notifications
You must be signed in to change notification settings - Fork 68
breakpoint are not hit when debugger is attached to remote target #1093
Comments
@dim2iv Can you share the |
@karthiknadig following is content of lauch.json {
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach (nfvt-up)",
"type": "python",
"request": "attach",
"port": 3000,
"host": "10.3.72.215",
"pathMappings": [
{
"localRoot": "${workspaceFolder}/nfvtime-upgrade/orig/",
"remoteRoot": "/opt/bin/"
}
],
"logToFile": false,
"redirectOutput": true,
"subProcess": true
},
{
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "enter-your-module-name-here",
"console": "integratedTerminal"
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"console": "integratedTerminal",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"django": true
},
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "app.py"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
],
"jinja": true
},
{
"name": "Python: Current File (External Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "externalTerminal"
}
]
} |
For clarification, the full path for |
Yes. This path on remote (target) machine. |
@dim2iv I tried this, it seems to be working. Can you share your project? This might be specific to the project. |
@karthiknadig here is a file. Is it possible reason to be that some of imported modules do not exists on host (locals) system, but exists on target ( remote ) system ? |
@dim2iv if the files are missing locally, you get a message box that pops up on VS Code that says 'File not found'. Unfortunately, I am not able to repro this at all (with the source file you provided). Can you do one more thing, set |
@karthiknadig with missing files i mean, that some modules imported do not exists on host system. They are related to (like apt_pkg). They are specific for the Ubuntu (target system), while on development host they are not installed at all. Development host is Fedora. |
@karthiknadig Here You can find logs for: _#! /usr/bin/env python
import os
import sys
import ptvsd
# # Allow other computers to attach to ptvsd at this IP address and port.
ptvsd.enable_attach(address=('0.0.0.0', 3000), redirect_output=True)
# Pause the program until a remote debugger is attached
ptvsd.wait_for_attach()_ In both cases bp is set to line 1300 |
Can you try the following and see if that helps?
If either of the above steps did not help then, can you give me the location of site-packages and python installs on the remote machine? Run the code below using the same python you use to launch your remote script import sys
import site
print('SysPath:' + str(sys.path))
print('Prefix: ' + sys.prefix)
if hasattr(sys, 'base_prefix'):
print('BasePrefix: ' + sys.base_prefix)
if hasattr(sys, 'real_prefix'):
print('RealPrefix: ' + sys.real_prefix)
if hasattr(sys, 'exec_prefix'):
print('ExecPrefix: ' + sys.exec_prefix)
if hasattr(site, 'getusersitepackages'):
print('User pkg: ' + str(site.getusersitepackages()))
if hasattr(site, 'getsitepackages'):
print('Site pkg: ' + str(site.getsitepackages())) Let me know how this goes. |
@karthiknadig i notice something very interesting. Here is also output for site-packeges: SysPath:['/root', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages'] Sorry for the long post but since we have big time shift i think it can help You if all information is available. |
Thanks you for the logs. It looks like the breakpoint event is not getting triggered in the second case. Can you run the debugger with following env variable on the remote machine? You should see some output like this. Please capture that output for the good and bad case.
|
@karthiknadig You can find logs attached. As i see on bad case ptvsd complains that file is unknown. Looks like mappings are not set second ( and following ) run(s). |
@fabioz have you seen this issue. Looks like path mapping, fails often, in this scenario. good case:
bad case:
I see a success response from DAP logs for both cases. Any idea where this might be breaking? |
Unfortunately the log seems to be incomplete as there's no info on the file translation being set -- and it really seems like the translation is set on one case but not in the other... @dim2iv, can you do the following:
Then put a
|
@fabioz i do not have installed pydevd installed on host or on target machine.
In VScode is not mentioned that i have to install it in order to able to debug. |
@dim2iv
then, the location of |
Hi @fabioz and @karthiknadig, I think there is a race condition (look at bold)
|
@karthiknadig it really seems like ptvsd is sending breakpoints before setting up the translation in this case (which wasn't expected in
If the requests are expected to be sent in order by the @dim2iv I think a workaround for you for now is updating the method Put |
@fabioz proposed workaround is too hard coded, since will work just for one script in project. I able to debug for now and will wait for real fix. |
…to remote target Do not allow 'setBreakpoints' request until either 'launch' or 'attach' request is received. Wait for 'launch' or 'attach' request to process path mappings before handling 'setBreakpoints'.
…to remote target Do not allow 'setBreakpoints' request until either 'launch' or 'attach' request is received. Wait for 'launch' or 'attach' request to process path mappings before handling 'setBreakpoints'.
Environment data
Version: 1.30.2
Commit: 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8
Date: 2019-01-07T22:49:48.319Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
OS: Linux x64 4.19.13-300.fc29.x86_64
Target machine:
Actual behavior
I try to debug remotely python script with vscode. In my launch.json i have proper configuration including pathMappings.
I have try following cases:
Run script on target machine like:
python -m ptvsd --single-session --host 10.3.72.215 --port 3000 --wait --multiprocess script-debug
On vscode i put break point and attach to target. As result script-debug is executed without hitting break point and on target machine i see message:
pydev debugger: warning: trying to add breakpoint to file that does not exist: "settings from localRoot /script-debug"
Some times i can manage to start debugging - i.e. debugger stops at BP, but this is less than 1% of all attempts.
Run script on target but modified:
_script-debug_
Same behavior like p.1
_script-debug_
In this case 100% of attempts as successful if i remove/disable all BP from vscode and add/enable them once debugger is attached.
If i start debugger with breakpoints, that are set before attachment to remote target, again see message on remote site:
pydev debugger: warning: trying to add breakpoint to file that does not exist: "settings from localRoot /script-debug"
So each time before debug session i have to disable BP, attach to target and re-enable them in order to use debugger.
Looks like some kind of race condition when debugger is attached and pathMappings, and BP are set to remote side.
Expected behavior
To be possible to run target like 'python -m ptvsd --single-session --host 10.3.72.215 --port 3000 --wait --multiprocess script-debug" and not to be forced to use ptvsd.break_into_debugger() in order to set BP
Already configured BP to work without needs to be re-enabled.
The text was updated successfully, but these errors were encountered: