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

Debugger under Python in a remote server: debugger stops on the first breakpoint, but not in another one putside the current .py file #237005

Open
paul18frr opened this issue Dec 27, 2024 · 0 comments
Assignees

Comments

@paul18frr
Copy link

Hi

All inputs have and a test case have been detailled in the following Stackoverflow post (see https://stackoverflow.com/questions/79293816/vscode-remote-debugging-missing-breakpoints.

I digged in internet, but none of the solutions fixes this issue

Thanks for your support

Paul

Version: 1.96.2 (user setup)
Commit: fabdb6a
Date: 2024-12-19T10:22:47.216Z
Electron: 32.2.6
ElectronBuildId: 10629634
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.19045

################################################################################################
In preamble, please note I'm a very new user in VScode.

In a current project i'm involved, the workflow is more of less the following one:

  • A main bash script is run to load modules and specific variables
  • The previous script loads a "main.py" python file: its role is to chain different external softs and python codes
  • The external softs ask as well python scripts on his own

The script is run in a remote server (under Linux os whereas i'm under Windows one), but now difficulty now on this topic.

I'm using the Python debugger "attach" and i'm facing the current difficulty

  1. if the first break point is set in the "main.py" file, it's ok; i can add another ones in the same file tu use continue and so on
  2. however if i add a breakpoint in another python file (python file (2) here after) using either vscode idle (red point) or even a "debugpy.breakpoint()", it is simply bypassed
  3. if my first breakpoint is set to python file 2, the debugging stops BUT it is waiting for the debugger attach (i've no control to run it)

1rst breakpoint add:

    import debugpy
    debugpy.listen(5678)
    print("Waiting for debugger attach")
    debugpy.wait_for_client()
    debugpy.breakpoint()

i guess i should additional information, but which ones ? what am i missing

To summary the program workflow:

bash script   ------> main.py ----------> external soft1 ----> etc
			             |		  	             |
			             |		  	             |
		           external soft2	       python file (2)

Thanks

Paul

######################################################################
UPDATE
######################################################################

I've made a basic example that should reproduce the issue (breakpoints are also missied) - note the main advantage here it prints some information's i missed in my real program.

The example is composed of 4 files:

  • 2 bash files
  • 2 python files

In practice, type "sh start.sh"

  • File 1: start.sh
#!/bin/bash
python test_breakpoint.py
  • File 2: run_python.sh
#!/bin/bash
python inside_file.py
  • File 3: test_breakpoint.py
import os, subprocess, debugpy

path = os.getcwd()
shfile = "run_python.sh"

# /// DEBUGGING
debugpy.listen(5678)
print("Waiting for Python debugger: attach")
debugpy.wait_for_client()
debugpy.breakpoint()
# /// DEBUGGING

command_line = f"sh {shfile}"
args = command_line.split()
run = subprocess.run(args)
  • File 4: inside_file.py
import debugpy
print("\n*** here is a breakpoint ***\n")
debugpy.breakpoint()

  • the launch.json file is:
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Attach",
            "type": "debugpy",
            "request": "attach",
            "port": 5678,
            "host": "localhost",
            "justMyCode": true,
            "pythonArgs": [
                "-Xfrozen_modules=off"
            ],
            "env": {
                "PYDEVD_DISABLE_FILE_VALIDATION": "1"
            }
          }
    ]
}

Whatever I implement, the following warning appears and any breakpoint ouside the main python file (test_breakpoint.py here) is ignored ...
... what am i missing?

Thanks for your help

0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Waiting for Python debugger: attach

*** here is a breakpoint ***

0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants