An implementation of the Debug Adapter Protocol for Python https://pypi.org/project/debugpy/
Find a file
2018-10-11 14:01:39 -07:00
.github github issue template (#517) 2018-06-25 11:14:23 -07:00
debugger_protocol Updating DAP schema (#785) 2018-09-06 14:10:49 -07:00
ptvsd Refactor timeline: 2018-10-11 14:01:39 -07:00
pytests Remove unnecessary proceed() calls. 2018-10-11 14:01:39 -07:00
tests Fix #810: Sub-Process: monkey patch pydevd to start process using ptvsd (#862) 2018-10-11 14:01:39 -07:00
win Fix build paths in sign project (#458) 2018-06-01 12:00:07 -07:00
.flake8 Test & infrastructure cleanup, stage 1 (#850) 2018-09-27 00:36:48 -07:00
.flake8.ci Update for VSTS-based CI process (#431) 2018-06-21 17:09:53 -07:00
.gitattributes Set up versioneer to auto-generate version numbers from git. 2018-04-11 14:00:48 -07:00
.gitignore Test & infrastructure cleanup, stage 1 (#850) 2018-09-27 00:36:48 -07:00
.pylintrc Test & infrastructure cleanup, stage 1 (#850) 2018-09-27 00:36:48 -07:00
.travis.yml Testing framework for timeline-based tests. (#857) 2018-10-01 14:29:44 -07:00
CODE_OF_CONDUCT.md Updating contribution details (#860) 2018-10-01 18:16:04 -07:00
CONTRIBUTING.md Updating contribution details (#860) 2018-10-01 18:16:04 -07:00
DESCRIPTION.md Update pypi info (#480) 2018-06-15 12:59:01 -07:00
LICENSE Updates LICENSE file with correct text and includes it in distributions 2018-02-21 16:10:22 -08:00
Makefile Fix #811: new socket server to receive pid and port for subprocesses (#871) 2018-10-11 14:01:39 -07:00
MANIFEST.in Fix for missing Description.md (#493) 2018-06-17 19:31:15 -07:00
ptvsd.code-workspace Test & infrastructure cleanup, stage 1 (#850) 2018-09-27 00:36:48 -07:00
pytest.ini Refactor timeline framework to properly enforce concurrency-safe observations, and fix various issues discovered in the implementation of expectation algebra. 2018-10-11 14:01:39 -07:00
README.md fix json comments syntax highlight (#881) 2018-10-06 22:15:21 -07:00
setup.cfg Testing framework for timeline-based tests. (#857) 2018-10-01 14:29:44 -07:00
setup.py Refactor timeline: 2018-10-11 14:01:39 -07:00
test_requirements.txt Refactor timeline: 2018-10-11 14:01:39 -07:00
versioneer.py Disable 'dirty' flag for version numbers. 2018-04-19 16:45:20 -07:00

Python Tools for Visual Studio debug server

Build Status Build Status GitHub PyPI

ptvsd CLI Usage

Debug a script file

Use this to launch your script file. Launch script file without waiting for debugger to attach.

-m ptvsd --port 5678 myfile.py

If you want the debugger to attach before running your code use --wait flag.

-m ptvsd --port 5678 --wait myfile.py

Debug a module

Use this to launch your module. Launch script file without waiting for debugger to attach.

-m ptvsd --port 5678 -m mymodule

If you want the debugger to attach before running your code use --wait flag.

-m ptvsd --port 5678 --wait -m mymodule

Debug a process by id

Attach to a process running python code.

-m ptvsd --host 0.0.0.0 --port 5678 --pid 12345

ptvsd Import usage

Enable debugging

In your script import ptvsd and call enable_attach to enable the process to attach to the debugger. The default port is 5678. You can configure this while calling enable_attach.

import ptvsd

ptvsd.enable_attach()

# your code

Wait for attach

Use the wait_for_attach() function to block execution until debugger is attached.

import ptvsd

ptvsd.enable_attach()
# script execution will stop here till debugger is attached
ptvsd.wait_for_attach()

# your code

breakpoint() function

In python >= 3.7, ptvsd supports the breakpoint() function. Use break_into_debugger() function for similar behavior and compatibility with older versions of python (2.7 and >= 3.4). These functions will block only if the debugger is attached.

import ptvsd

ptvsd.enable_attach()

while True:
    # your code
    breakpoint() # ptvsd.break_into_debugger()
    # your code

Custom Protocol arguments

Launch request arguments

{
    "debugOptions":  [
            "RedirectOutput",       // Whether to redirect stdout and stderr (see pydevd_comm.CMD_REDIRECT_OUTPUT)
            "WaitOnNormalExit",     // Wait for user input after user code exits normally
            "WaitOnAbnormalExit",   // Wait for user input after user code exits with error
            "Django",               // Enables Django Template debugging
            "Jinja",                // Enables Jinja (Flask) Template debugging
            "FixFilePathCase",      // See FIX_FILE_PATH_CASE in wrapper.py
            "DebugStdLib",          // Whether to enable debugging of standard library functions
            "StopOnEntry",          // Whether to stop at first line of user code
            "ShowReturnValue",      // Show return values of functions
    ]
}

Attach request arguments

{
    "debugOptions":  [
            "RedirectOutput",       // Whether to redirect stdout and stderr (see pydevd_comm.CMD_REDIRECT_OUTPUT)
            "Django",               // Enables Django Template debugging
            "Jinja",                // Enables Jinja (Flask) Template debugging
            "FixFilePathCase",      // See FIX_FILE_PATH_CASE in wrapper.py
            "DebugStdLib",          // Whether to enable debugging of standard library functions
            "WindowsClient",        // Whether client OS is Windows
            "UnixClient",           // Whether client OS is Unix
            "ShowReturnValue",      // Show return values of functions
    ],
    "pathMappings": [
        {
            "localRoot": "C:\\Project\\src",   // Local root  (where source and debugger running)
            "remoteRoot": "/home/smith/proj"   // Remote root (where remote code is running)
        },
        // Add more path mappings
    ]
}