|Non-Confidential||PDF version||ARM DUI0446Z|
|Home > Debug and Trace Services Layer (DTSL) > Debugging DTSL Jython code within DS-5 Debugger > Preparing the DTSL script for debug|
When a Jython script is being debugged, it is normally launched by PyDev, and PyDev can optionally create a debug session for the script. When DS-5 launches the Jython script, however, this does not happen. This is not a problem, however, because the script itself can register with the PyDev debugger after it is launched. To do this in your script:
import pydevdIf you are using another Eclipse (non-DS-5) to host the PyDev debugger, then import the pydevd from that Eclipse instance. Locate the pydev plugin pysrc directory and add its path to the import path before importing pydevd. For example, if the Eclipse is installed in C:\Users\john\eclipse, then the code would be as follows:
import sys; sys.path.append(r'C:\Users\john\eclipse\plugins\org.python.pydev_18.104.22.1683051601\pysrc') import pydevdwhere
pydev_depends on the version of pydev installed within Eclipse.
pydevd.settrace(stdoutToServer=True, stderrToServer=True)This causes a break into the debugger at that location, and redirects all standard output from the script to the debugger console. This allows you to place print statements into the script and see them in the debugger, whereas normally DS-5 would discard any such print output. Good places to insert this statement are:
__init__) for the DTSL configuration class.
The function documentation for the
call in pydev 2.7.4 is as follows:
def settrace(host=None, stdoutToServer=False, stderrToServer=False, port=5678, suspend=True, trace_only_current_thread=True): '''Sets the tracing function with the pydev debug function and initializes needed facilities. @param host: the user may specify another host, if the debug server is not in the same machine (default is the local host) @param stdoutToServer: when this is true, the stdout is passed to the debug server @param stderrToServer: when this is true, the stderr is passed to the debug server so that they are printed in its console and not in this process console. @param port: specifies which port to use for communicating with the server (note that the server must be started in the same port). @note: currently it's hard-coded at 5678 in the client @param suspend: whether a breakpoint should be emulated as soon as this function is called. @param trace_only_current_thread: determines if only the current thread will be traced or all future threads will also have the tracing enabled. '''