# eric6.Debugger.DebuggerInterfacePython

Module implementing the Python3 debugger interface for the debug server.

### Global Attributes

ClientDefaultCapabilities

### Classes

DebuggerInterfacePython | Class implementing the debugger interface for the debug server for Python 2 and Python 3.

### Functions

createDebuggerInterfacePython2 | Module function to create a debugger interface instance.
createDebuggerInterfacePython3 | Module function to create a debugger interface instance.
getRegistryData | Module function to get characterizing data for the supported debugger interfaces.

## DebuggerInterfacePython

Class implementing the debugger interface for the debug server for Python 2 and Python 3.

### Derived from

QObject

### Class Attributes

None

### Class Methods

None

### Methods

DebuggerInterfacePython | Constructor
__askForkTo | Private method to ask the user which branch of a fork to follow.
__handleJsonCommand | Private method to handle a command or response serialized as a JSON string.
__identityTranslation | Private method to perform the identity path translation.
__parseClientLine | Private method to handle data from the client.
__remoteTranslation | Private method to perform the path translation.
__sendJsonCommand | Private method to send a single command to the client.
__startProcess | Private method to start the debugger client process.
__writeJsonCommandToSocket | Private method to write a JSON command to the socket.
flush | Public slot to flush the queue.
getClientCapabilities | Public method to retrieve the debug clients capabilities.
isConnected | Public method to test, if a debug client has connected.
newConnection | Public slot to handle a new connection.
remoteBanner | Public slot to get the banner info of the remote client.
remoteBreakpoint | Public method to set or clear a breakpoint.
remoteBreakpointEnable | Public method to enable or disable a breakpoint.
remoteBreakpointIgnore | Public method to ignore a breakpoint the next couple of occurrences.
remoteCapabilities | Public slot to get the debug clients capabilities.
remoteClientSetFilter | Public method to set a variables filter list.
remoteClientVariable | Public method to request the variables of the debugged program.
remoteClientVariables | Public method to request the variables of the debugged program.
remoteCompletion | Public slot to get the a list of possible commandline completions from the remote client.
remoteContinue | Public method to continue the debugged program.
remoteCoverage | Public method to load a new program to collect coverage data.
remoteEnvironment | Public method to set the environment for a program to debug, run, ...
remoteLoad | Public method to load a new program to debug.
remoteMoveIP | Public method to move the instruction pointer to a different line.
remoteProfile | Public method to load a new program to collect profiling data.
remoteRawInput | Public method to send the raw input to the debugged program.
remoteRun | Public method to load a new program to run.
remoteSetThread | Public method to request to set the given thread as current thread.
remoteStatement | Public method to execute a Python statement.
remoteStep | Public method to single step the debugged program.
remoteStepOut | Public method to step out the debugged program.
remoteStepOver | Public method to step over the debugged program.
remoteStepQuit | Public method to stop the debugged program.
remoteThreadList | Public method to request the list of threads from the client.
remoteUTDiscover | Public method to perform a test case discovery.
remoteUTPrepare | Public method to prepare a new unittest run.
remoteUTRun | Public method to start a unittest run.
remoteUTStop | Public method to stop a unittest run.
remoteWatchpoint | Public method to set or clear a watch expression.
remoteWatchpointEnable | Public method to enable or disable a watch expression.
remoteWatchpointIgnore | Public method to ignore a watch expression the next couple of occurrences.
setCallTraceEnabled | Public method to set the call trace state.
shutdown | Public method to cleanly shut down.
startRemote | Public method to start a remote Python interpreter.
startRemoteForProject | Public method to start a remote Python interpreter for a project.

### Static Methods

None

#### DebuggerInterfacePython (Constructor)

DebuggerInterfacePython(debugServer, passive, pythonVariant)

Constructor

debugServer (DebugServer)
  reference to the debug server
passive (bool)
  flag indicating passive connection mode
pythonVariant (str (one of Python2 or Python3))
  Python variant to instantiate for

#### DebuggerInterfacePython.__askForkTo

__askForkTo()

Private method to ask the user which branch of a fork to follow.

#### DebuggerInterfacePython.__handleJsonCommand

__handleJsonCommand(jsonStr)

Private method to handle a command or response serialized as a JSON string.

jsonStr (str)
  string containing the command or response received from the debug backend

#### DebuggerInterfacePython.__identityTranslation

__identityTranslation(fn, remote2local=True)

Private method to perform the identity path translation.

fn
  filename to be translated (string)
remote2local
  flag indicating the direction of translation (False = local to remote, True = remote to local [default])

Returns:
  translated filename (string)

#### DebuggerInterfacePython.__parseClientLine

__parseClientLine()

Private method to handle data from the client.

#### DebuggerInterfacePython.__remoteTranslation

__remoteTranslation(fn, remote2local=True)

Private method to perform the path translation.

fn
  filename to be translated (string)
remote2local
  flag indicating the direction of translation (False = local to remote, True = remote to local [default])

Returns:
  translated filename (string)

#### DebuggerInterfacePython.__sendJsonCommand

__sendJsonCommand(command, params)

Private method to send a single command to the client.

command (str)
  command name to be sent
params (dict)
  dictionary of named parameters for the command

#### DebuggerInterfacePython.__startProcess

__startProcess(program, arguments, environment=None, workingDir=None)

Private method to start the debugger client process.

program (str)
  name of the executable to start
arguments (list of str)
  arguments to be passed to the program
environment (dict of str)
  dictionary of environment settings to pass
workingDir (str)
  directory to start the debugger client in

Returns:
  the process object

Return Type:
  QProcess or None

#### DebuggerInterfacePython.__writeJsonCommandToSocket

__writeJsonCommandToSocket(cmd)

Private method to write a JSON command to the socket.

cmd (str)
  JSON command to be sent

#### DebuggerInterfacePython.flush

flush()

Public slot to flush the queue.

#### DebuggerInterfacePython.getClientCapabilities

getClientCapabilities()

Public method to retrieve the debug clients capabilities.

Returns:
  debug client capabilities (integer)

#### DebuggerInterfacePython.isConnected

isConnected()

Public method to test, if a debug client has connected.

Returns:
  flag indicating the connection status (boolean)

#### DebuggerInterfacePython.newConnection

newConnection(sock)

Public slot to handle a new connection.

sock
  reference to the socket object (QTcpSocket)

Returns:
  flag indicating success (boolean)

#### DebuggerInterfacePython.remoteBanner

remoteBanner()

Public slot to get the banner info of the remote client.

#### DebuggerInterfacePython.remoteBreakpoint

remoteBreakpoint(fn, line, setBreakpoint, cond=None, temp=False)

Public method to set or clear a breakpoint.

fn
  filename the breakpoint belongs to (string)
line
  linenumber of the breakpoint (int)
setBreakpoint
  flag indicating setting or resetting a breakpoint (boolean)
cond
  condition of the breakpoint (string)
temp
  flag indicating a temporary breakpoint (boolean)

#### DebuggerInterfacePython.remoteBreakpointEnable

remoteBreakpointEnable(fn, line, enable)

Public method to enable or disable a breakpoint.

fn
  filename the breakpoint belongs to (string)
line
  linenumber of the breakpoint (int)
enable
  flag indicating enabling or disabling a breakpoint (boolean)

#### DebuggerInterfacePython.remoteBreakpointIgnore

remoteBreakpointIgnore(fn, line, count)

Public method to ignore a breakpoint the next couple of occurrences.

fn
  filename the breakpoint belongs to (string)
line
  linenumber of the breakpoint (int)
count
  number of occurrences to ignore (int)

#### DebuggerInterfacePython.remoteCapabilities

remoteCapabilities()

Public slot to get the debug clients capabilities.

#### DebuggerInterfacePython.remoteClientSetFilter

remoteClientSetFilter(scope, filterStr)

Public method to set a variables filter list.

scope
  the scope of the variables (0 = local, 1 = global)
filterStr
  regexp string for variable names to filter out (string)

#### DebuggerInterfacePython.remoteClientVariable

remoteClientVariable(scope, filterList, var, framenr=0, maxSize=0)

Public method to request the variables of the debugged program.

scope (int)
  the scope of the variables (0 = local, 1 = global)
filterList (list of int)
  list of variable types to filter out
var (list of str)
  list encoded name of variable to retrieve
framenr (int)
  framenumber of the variables to retrieve
maxSize (int)
  maximum size the formatted value of a variable will be shown. If it is bigger than that, a 'too big' indication will be given (@@TOO_BIG_TO_SHOW@@).

#### DebuggerInterfacePython.remoteClientVariables

remoteClientVariables(scope, filterList, framenr=0, maxSize=0)

Public method to request the variables of the debugged program.

scope (int)
  the scope of the variables (0 = local, 1 = global)
filterList (list of int)
  list of variable types to filter out
framenr (int)
  framenumber of the variables to retrieve
maxSize (int)
  maximum size the formatted value of a variable will be shown. If it is bigger than that, a 'too big' indication will be given (@@TOO_BIG_TO_SHOW@@).

#### DebuggerInterfacePython.remoteCompletion

remoteCompletion(text)

Public slot to get the a list of possible commandline completions from the remote client.

text
  the text to be completed (string)

#### DebuggerInterfacePython.remoteContinue

remoteContinue(special=False)

Public method to continue the debugged program.

special
  flag indicating a special continue operation

#### DebuggerInterfacePython.remoteCoverage

remoteCoverage(fn, argv, wd, erase=False)

Public method to load a new program to collect coverage data.

fn
  the filename to run (string)
argv
  the commandline arguments to pass to the program (string)
wd
  the working directory for the program (string)
erase=
  flag indicating that coverage info should be cleared first (boolean)

#### DebuggerInterfacePython.remoteEnvironment

remoteEnvironment(env)

Public method to set the environment for a program to debug, run, ...

env
  environment settings (dictionary)

#### DebuggerInterfacePython.remoteLoad

remoteLoad(fn, argv, wd, traceInterpreter=False, autoContinue=True, autoFork=False, forkChild=False)

Public method to load a new program to debug.

fn
  the filename to debug (string)
argv
  the commandline arguments to pass to the program (string)
wd
  the working directory for the program (string)
traceInterpreter=
  flag indicating if the interpreter library should be traced as well (boolean)
autoContinue=
  flag indicating, that the debugger should not stop at the first executable line (boolean)
autoFork=
  flag indicating the automatic fork mode (boolean)
forkChild=
  flag indicating to debug the child after forking (boolean)

#### DebuggerInterfacePython.remoteMoveIP

remoteMoveIP(line)

Public method to move the instruction pointer to a different line.

line
  the new line, where execution should be continued

#### DebuggerInterfacePython.remoteProfile

remoteProfile(fn, argv, wd, erase=False)

Public method to load a new program to collect profiling data.

fn
  the filename to run (string)
argv
  the commandline arguments to pass to the program (string)
wd
  the working directory for the program (string)
erase=
  flag indicating that timing info should be cleared first (boolean)

#### DebuggerInterfacePython.remoteRawInput

remoteRawInput(s)

Public method to send the raw input to the debugged program.

s
  the raw input (string)

#### DebuggerInterfacePython.remoteRun

remoteRun(fn, argv, wd, autoFork=False, forkChild=False)

Public method to load a new program to run.

fn
  the filename to run (string)
argv
  the commandline arguments to pass to the program (string)
wd
  the working directory for the program (string)
autoFork=
  flag indicating the automatic fork mode (boolean)
forkChild=
  flag indicating to debug the child after forking (boolean)

#### DebuggerInterfacePython.remoteSetThread

remoteSetThread(tid)

Public method to request to set the given thread as current thread.

tid
  id of the thread (integer)

#### DebuggerInterfacePython.remoteStatement

remoteStatement(stmt)

Public method to execute a Python statement.

stmt
  the Python statement to execute (string). It should not have a trailing newline.

#### DebuggerInterfacePython.remoteStep

remoteStep()

Public method to single step the debugged program.

#### DebuggerInterfacePython.remoteStepOut

remoteStepOut()

Public method to step out the debugged program.

#### DebuggerInterfacePython.remoteStepOver

remoteStepOver()

Public method to step over the debugged program.

#### DebuggerInterfacePython.remoteStepQuit

remoteStepQuit()

Public method to stop the debugged program.

#### DebuggerInterfacePython.remoteThreadList

remoteThreadList()

Public method to request the list of threads from the client.

#### DebuggerInterfacePython.remoteUTDiscover

remoteUTDiscover(syspath, workdir, discoveryStart)

Public method to perform a test case discovery.

syspath (list of str)
  list of directories to be added to sys.path on the remote side
workdir (str)
  path name of the working directory
discoveryStart (str)
  directory to start auto-discovery at

#### DebuggerInterfacePython.remoteUTPrepare

remoteUTPrepare(fn, tn, tfn, failed, cov, covname, coverase, syspath, workdir, discover, discoveryStart, testCases, debug)

Public method to prepare a new unittest run.

fn (str)
  name of file to load
tn (str)
  name of test to load
tfn (str)
  test function name to load tests from
failed (list of str)
  list of failed test, if only failed test should be run
cov (bool)
  flag indicating collection of coverage data is requested
covname (str)
  name of file to be used to assemble the coverage caches filename
coverase (bool)
  flag indicating erasure of coverage data is requested
syspath (list of str)
  list of directories to be added to sys.path on the remote side
workdir (str)
  path name of the working directory
discover (bool)
  flag indicating to discover the tests automatically
discoveryStart (str)
  directory to start auto-discovery at
testCases (list of str)
  list of test cases to be loaded
debug (bool)
  flag indicating to run unittest with debugging

#### DebuggerInterfacePython.remoteUTRun

remoteUTRun(debug, failfast)

Public method to start a unittest run.

debug (bool)
  flag indicating to run unittest with debugging
failfast (bool)
  flag indicating to stop at the first error

#### DebuggerInterfacePython.remoteUTStop

remoteUTStop()

Public method to stop a unittest run.

#### DebuggerInterfacePython.remoteWatchpoint

remoteWatchpoint(cond, setWatch, temp=False)

Public method to set or clear a watch expression.

cond
  expression of the watch expression (string)
setWatch
  flag indicating setting or resetting a watch expression (boolean)
temp
  flag indicating a temporary watch expression (boolean)

#### DebuggerInterfacePython.remoteWatchpointEnable

remoteWatchpointEnable(cond, enable)

Public method to enable or disable a watch expression.

cond
  expression of the watch expression (string)
enable
  flag indicating enabling or disabling a watch expression (boolean)

#### DebuggerInterfacePython.remoteWatchpointIgnore

remoteWatchpointIgnore(cond, count)

Public method to ignore a watch expression the next couple of occurrences.

cond
  expression of the watch expression (string)
count
  number of occurrences to ignore (int)

#### DebuggerInterfacePython.setCallTraceEnabled

setCallTraceEnabled(on)

Public method to set the call trace state.

on
  flag indicating to enable the call trace function (boolean)

#### DebuggerInterfacePython.shutdown

shutdown()

Public method to cleanly shut down.

It closes our socket and shuts down the debug client. (Needed on Win OS)

#### DebuggerInterfacePython.startRemote

startRemote(port, runInConsole, venvName, originalPathString, workingDir=None)

Public method to start a remote Python interpreter.

port (int)
  port number the debug server is listening on
runInConsole (bool)
  flag indicating to start the debugger in a console window
venvName (str)
  name of the virtual environment to be used
originalPathString (str)
  original PATH environment variable
workingDir (str)
  directory to start the debugger client in

Returns:
  client process object, a flag to indicate a network connection and the name of the interpreter in case of a local execution

Return Type:
  tuple of (QProcess, bool, str)

#### DebuggerInterfacePython.startRemoteForProject

startRemoteForProject(port, runInConsole, venvName, originalPathString, workingDir=None)

Public method to start a remote Python interpreter for a project.

port (int)
  port number the debug server is listening on
runInConsole (bool)
  flag indicating to start the debugger in a console window
venvName (str)
  name of the virtual environment to be used
originalPathString (str)
  original PATH environment variable
workingDir (str)
  directory to start the debugger client in

Returns:
  client process object, a flag to indicate a network connection and the name of the interpreter in case of a local execution

Return Type:
  tuple of (QProcess, bool, str)

Up

## createDebuggerInterfacePython2

createDebuggerInterfacePython2(debugServer, passive)

Module function to create a debugger interface instance.

debugServer (DebugServer)
  reference to the debug server
passive (bool)
  flag indicating passive connection mode

Returns:
  instantiated debugger interface

Return Type:
  DebuggerInterfacePython

Up

## createDebuggerInterfacePython3

createDebuggerInterfacePython3(debugServer, passive)

Module function to create a debugger interface instance.

debugServer (DebugServer)
  reference to the debug server
passive (bool)
  flag indicating passive connection mode

Returns:
  instantiated debugger interface

Return Type:
  DebuggerInterfacePython

Up

## getRegistryData

getRegistryData()

Module function to get characterizing data for the supported debugger interfaces.

Returns:
  list of tuples containing the client type, the client capabilities, the client file type associations and a reference to the creation function

Return Type:
  list of tuple of (str, int, list of str, function)

Up