Pydev Remote Debugging

Posted on by admin
  • Remote debugging is extremely useful, especially when you have limited access to the system used to run the application. Let us call the system where the application is to be run as rsys and the one used to debug as dsys. Install eclipse on dsys. Make sure you have the pydev and debug perspectives enabled in eclipse.
  • But PyDev includes a powerful remote debugger that can be utilized to debug a script executed by Rhino's IronPython. Remote debugging is achieved a debugging client run by the Rhino script that.

The PyDev integration module for RemodeDebugServer provides aninterface for the automation of the load and applicationof the pydevd.py module.The PyDev plugin - http://pydev.org - is the utilized embeddedcomponent for the debugging of Python based programs withinEclipse - http://eclipse.org .

I'm also noticing that the Eclipse debugger only shows ': ' instead of the actual module and method namse. Its as if the Eclipse debugger can't remember the file I've selected. This happens when pydev is not able to map the file found with an existing file (so, some place may be missing a translation step).

This includes particularly utilities for cross-process debuggingos subprocess calls by PyDev-Remote-Debugging.

Application Basics¶

Remote Debugging with PyDev within Eclipse in the raw form requires the frequentmodification of code for clear distinction of development and production systems.The PyDevRDC utilities provide an approach designed tobe kept in code from development to production systems.

The feature comprise in more detailed view:

  • PyDevRDC - PyDev Eclipse Remote Debugging

    The main class for integration into the called subprocessesand their simplified setup for debugging based on pydevd.py.

  • PYDEVD

    A predefined object for simple usage.

Interworking and Dependencies¶

The module is foreseen in particular to support the debugging ofsubprocess calls for the analysis of unit tests.

The call is performed in two basic modes, the fully headlessmode ‘cli’ where stdout and stderr are buffered only, and themode ‘dialogue’, where no buffering is in place.Thus in case of required error analysis a manual call in ‘dialogue’mode may help.

Pydev

Design¶

Process

The basic workflow for the integration of processes initially not startedunder control of ‘pydevd.py’ is depicted in the following figure.Here started by a process from PyDev within Eclipse including the ePyDevpackage for the automation of the integration and start.

The UseCase ‘UseCases.remote_debug‘is discussed here in detail, consisting of the components:

Pydev Remote Debugging
  • UseCase: CallCase.py[doc][source]
  • Subprocess-Level-0: epyunit4RDbg.py[doc][source]
  • Subprocess-Level-1: myscript.sh[doc][source]

The following details of the designed control flow contain the requiredEclipse/PyDev actions, and the resulting code fragmentsfor the main steps of the control flow for theUseCase ‘UseCases.remote_debug‘.Instead of the subprocess basically any Python based process could be startedmanually from the commandline and attaches itself to the PyDev plugin of Eclipse.

  1. Eclipse-PyDev Framework: Start Remote Debug Server

    Start the remote debug server processon the default listenning port localhost:5678.

    Copyright by PyDev.org -> Eclipse-PyDev.

  2. Parent-Process: Start main process

    Start the primary process, e.g. for tests by testCase, or a UseCase.The example uses the context menue of PyDev/PyUnit to proceed.

  3. Parent-Process: Start subprocess

    Start a process by the subprocess module.This is wrapped into the class ‘epyunit.SystemCalls’,which covers the read of the process output, and the appropriateformat transformation for ease of post-analysis of output from unit tests:

  4. Subprocess: load and init ‘pydevd.py’

    Loads and initializes the PyDev stub for the connection to the Eclipse-PyDev gateway‘pydevd.py’:

    For the default initial debug controller stub refer to:

    The main action is here to detect and/or find and load the module ‘pydevd.py’ provided by PyDev.This depends of whether the process is started under the control of the PyDev debugger, or as afree running process/subprocess.The module is located due to the PyDev manualwithin the Eclipse plugin subtree at the relative filesystem position:

    Remark: This may vary e.g. in case of a drop-in installation.

    When working with various Eclipse versions the maintenance of the path could become cumbersome.Thus the scan function automates the search and filtering by intermixed ‘re’, and ‘glob’based path search

    For additional information on search options refer to ‘scanEclipseForPydevd’[doc][source].

  5. Subprocess: startDebug

    The debug session is started by the execution of the statement:

  6. User Dialogue: start interactive session

    The debug session is performed by the inspection of an arbitrary number ofexpressions, e.g. by starting another nested subprocess:

  7. Debug Session: end debug session

    f.f.s. / a.s.a.p.

Another example with Basic Control.

Almost the same as before, but some basic parameters areset for some control.

  1. Include the following statements in the executable to bestarted by another process:

  2. Start a debugging server, see Remote Debugger @ Eclipse-PyDev.

    Copyright by PyDev.org -> Eclipse-PyDev.

  3. Set a breakpoint in the code of the remote process.

  4. Start the caller process, see Remote Debugger @ Eclipse-PyDev.

    Copyright by PyDev.org -> Eclipse-PyDev.

Setup Remote Debug In Eclipse

Examples¶

EXAMPLES:

Python Pydev Remote Debugging

  • Detailed examples in the subdirectories of the source package:
    • tests + testdata
    • UseCases