An implementation of the Debug Adapter Protocol for Python https://pypi.org/project/debugpy/
Find a file
Pavel Minaev e96275703a
Testing framework for timeline-based tests. (#857)
* Testing framework for timeline-based tests.

See pytests/helpers/timeline.md for a detailed description.

Fixes #832, and lays the groundwork for #833.

* Upgrade pip to most recent version before installing prerequisites on Travis.
2018-10-01 14:29:44 -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 Testing framework for timeline-based tests. (#857) 2018-10-01 14:29:44 -07:00
pytests Testing framework for timeline-based tests. (#857) 2018-10-01 14:29:44 -07:00
tests Add messages to error responses (#838) 2018-09-27 11:06:58 -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
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 Testing framework for timeline-based tests. (#857) 2018-10-01 14:29:44 -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 Testing framework for timeline-based tests. (#857) 2018-10-01 14:29:44 -07:00
README.md Update readme with usage details (#807) 2018-09-18 13:09:36 -07:00
setup.cfg Testing framework for timeline-based tests. (#857) 2018-10-01 14:29:44 -07:00
setup.py Test & infrastructure cleanup, stage 1 (#850) 2018-09-27 00:36:48 -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

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

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
    ]
}