Coder Social home page Coder Social logo

rozuur / ptvsd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/ptvsd

0.0 2.0 0.0 5.45 MB

Python debugger package for use with Visual Studio and Visual Studio Code.

License: Other

Makefile 0.08% Python 97.43% Shell 0.03% C++ 2.13% C 0.27% Batchfile 0.01% HTML 0.02% PowerShell 0.03%

ptvsd's Introduction

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

ptvsd's People

Contributors

ericsnowcurrently avatar karthiknadig avatar donjayamanne avatar int19h avatar fabioz avatar zooba avatar d3r3kk avatar microsoftopensource avatar igornovozhilov avatar msftgits avatar rozuur avatar ahaslam avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.