Home ⌂Doc Index ◂Up ▴

eric6.DebugClients.Python.DebugBase

Module implementing the debug base class which based originally on bdb.

Global Attributes

gRecursionLimit

Classes

DebugBase Class implementing base class of the debugger.

Functions

printerr Module function used for debugging the debug client.
setRecursionLimit Module function to set the recursion limit.


DebugBase

Class implementing base class of the debugger.

Provides methods for the 'owning' client to call to step etc.

Derived from

object

Class Attributes

_fnCache
filesToSkip
lib
pathsToSkip
pollTimerEnabled

Class Methods

None

Methods

DebugBase Constructor
__checkBreakInFrame Private method to check if the function / method has a line number which is a breakpoint.
__do_clearBreak Private method called to clear a temporary breakpoint.
__do_clearWatch Private method called to clear a temporary watch expression.
__eventPollTimer Private method to set a flag every 0.5 s to check for new messages.
__extractExceptionName Private method to extract the exception name given the exception type object.
__extractSystemExitMessage Private method to get the SystemExit code and message.
__extract_stack Private member to return a list of stack frames.
__sendCallTrace Private method to send a call/return trace.
__skipFrame Private method to filter out debugger files.
_set_stopinfo Protected method to update the frame pointers.
bootstrap Public method to bootstrap a thread.
break_here Public method reimplemented from bdb.py to fix the filename from the frame.
fix_frame_filename Public method used to fixup the filename for a given frame.
getCurrentFrame Public method to return the current frame.
getFrameLocals Public method to return the locals dictionary of the current frame or a frame below.
getStack Public method to get the stack.
go Public method to resume the thread.
move_instruction_pointer Public methode to move the instruction pointer to another line.
profile Public method used to trace some stuff independent of the debugger trace function.
profileWithRecursion Public method used to trace some stuff independent of the debugger trace function.
run Public method to start a given command under debugger control.
setRecursionDepth Public method to determine the current recursion depth.
set_continue Public method to stop only on next breakpoint.
set_next Public method to stop on the next line in or below the given frame.
set_quit Public method to quit.
set_return Public method to stop when returning from the given frame.
set_step Public method to stop after one line of code.
set_trace Public method to start debugging from 'frame'.
step Public method to perform a step operation in this thread.
stepOut Public method to perform a step out of the current call.
stop_here Public method reimplemented to filter out debugger files.
storeFrameLocals Public method to store the locals into the frame, so an access to frame.f_locals returns the last data.
tracePythonLibs Public method to update the settings to trace into Python libraries.
trace_dispatch Public method reimplemented from bdb.py to do some special things.
user_exception Public method reimplemented to report an exception to the debug server.
user_line Public method reimplemented to handle the program about to execute a particular line.

Static Methods

None

DebugBase (Constructor)

DebugBase(dbgClient)

Constructor

dbgClient
the owning client

DebugBase.__checkBreakInFrame

__checkBreakInFrame(frame)

Private method to check if the function / method has a line number which is a breakpoint.

frame (frame object)
the frame object
Returns:
Flag indicating a function / method with breakpoint
Return Type:
bool

DebugBase.__do_clearBreak

__do_clearBreak(filename, lineno)

Private method called to clear a temporary breakpoint.

filename (str)
name of the file the bp belongs to
lineno (int)
linenumber of the bp

DebugBase.__do_clearWatch

__do_clearWatch(cond)

Private method called to clear a temporary watch expression.

cond (str)
expression of the watch expression to be cleared

DebugBase.__eventPollTimer

__eventPollTimer()

Private method to set a flag every 0.5 s to check for new messages.

DebugBase.__extractExceptionName

__extractExceptionName(exctype)

Private method to extract the exception name given the exception type object.

exctype
type of the exception
Returns:
exception name (string)

DebugBase.__extractSystemExitMessage

__extractSystemExitMessage(excinfo)

Private method to get the SystemExit code and message.

excinfo (tuple(Exception, excval object, traceback frame object))
details about the SystemExit exception
Returns:
SystemExit code and message
Return Type:
int, str

DebugBase.__extract_stack

__extract_stack(exctb)

Private member to return a list of stack frames.

exctb
exception traceback
Returns:
list of stack frames

DebugBase.__sendCallTrace

__sendCallTrace(event, fromFrame, toFrame)

Private method to send a call/return trace.

event (str)
trace event
fromFrame (frame object)
originating frame
toFrame (frame object)
destination frame

DebugBase.__skipFrame

__skipFrame(frame)

Private method to filter out debugger files.

Tracing is turned off for files that are part of the debugger that are called from the application being debugged.

frame (frame object)
the frame object
Returns:
flag indicating whether the debugger should skip this frame
Return Type:
bool

DebugBase._set_stopinfo

_set_stopinfo(stopframe, returnframe)

Protected method to update the frame pointers.

stopframe (frame object)
the frame object where to stop
returnframe (frame object)
the frame object where to stop on a function return

DebugBase.bootstrap

bootstrap(target, args, kwargs)

Public method to bootstrap a thread.

It wraps the call to the user function to enable tracing before hand.

target (function pointer)
function which is called in the new created thread
args (tuple)
arguments to pass to target
kwargs (dict)
keyword arguments to pass to target

DebugBase.break_here

break_here(frame)

Public method reimplemented from bdb.py to fix the filename from the frame.

See fix_frame_filename for more info.

frame (frame object)
the frame object
Returns:
flag indicating the break status
Return Type:
bool

DebugBase.fix_frame_filename

fix_frame_filename(frame)

Public method used to fixup the filename for a given frame.

The logic employed here is that if a module was loaded from a .pyc file, then the correct .py to operate with should be in the same path as the .pyc. The reason this logic is needed is that when a .pyc file is generated, the filename embedded and thus what is readable in the code object of the frame object is the fully qualified filepath when the pyc is generated. If files are moved from machine to machine this can break debugging as the .pyc will refer to the .py on the original machine. Another case might be sharing code over a network... This logic deals with that.

frame (frame object)
the frame object
Returns:
fixed up file name
Return Type:
str

DebugBase.getCurrentFrame

getCurrentFrame()

Public method to return the current frame.

Returns:
the current frame
Return Type:
frame object

DebugBase.getFrameLocals

getFrameLocals(frmnr=0)

Public method to return the locals dictionary of the current frame or a frame below.

frmnr=
distance of frame to get locals dictionary of. 0 is the current frame (int)
Returns:
locals dictionary of the frame

DebugBase.getStack

getStack(frame=None, applyTrace=False)

Public method to get the stack.

frame= (frame object or list)
frame object to inspect
applyTrace= (bool)
flag to assign trace function to fr.f_trace
Returns:
list of lists with file name (string), line number (integer) and function name (string)

DebugBase.go

go(special)

Public method to resume the thread.

It resumes the thread stopping only at breakpoints or exceptions.

special
flag indicating a special continue operation

DebugBase.move_instruction_pointer

move_instruction_pointer(lineno)

Public methode to move the instruction pointer to another line.

lineno (int)
new line number

DebugBase.profile

profile(frame, event, arg)

Public method used to trace some stuff independent of the debugger trace function.

frame (frame object)
current stack frame
event (str)
trace event
arg (depends on the previous event parameter)
arguments

DebugBase.profileWithRecursion

profileWithRecursion(frame, event, arg)

Public method used to trace some stuff independent of the debugger trace function.

frame (frame object)
current stack frame
event (str)
trace event
arg (depends on the previous event parameter)
arguments
Raises RuntimeError:
raised to indicate too many recursions

DebugBase.run

run(cmd, globalsDict=None, localsDict=None, debug=True)

Public method to start a given command under debugger control.

cmd (str or CodeType)
command / code to execute under debugger control
globalsDict= (dict)
dictionary of global variables for cmd
localsDict= (dict)
dictionary of local variables for cmd
debug= (bool)
flag if command should run under debugger control

DebugBase.setRecursionDepth

setRecursionDepth(frame)

Public method to determine the current recursion depth.

frame
The current stack frame.

DebugBase.set_continue

set_continue(special)

Public method to stop only on next breakpoint.

special (bool)
flag indicating a special continue operation

DebugBase.set_next

set_next(frame)

Public method to stop on the next line in or below the given frame.

frame (frame object)
the frame object

DebugBase.set_quit

set_quit()

Public method to quit.

Disables the trace functions and resets all frame pointer.

DebugBase.set_return

set_return(frame)

Public method to stop when returning from the given frame.

frame (frame object)
the frame object

DebugBase.set_step

set_step()

Public method to stop after one line of code.

DebugBase.set_trace

set_trace(frame=None)

Public method to start debugging from 'frame'.

If frame is not specified, debugging starts from caller's frame. Because of jump optimizations it's not possible to use sys.breakpoint() as last instruction in a function or method.

frame= (frame object)
frame to start debugging from

DebugBase.step

step(traceMode)

Public method to perform a step operation in this thread.

traceMode
If it is True, then the step is a step into, otherwise it is a step over.

DebugBase.stepOut

stepOut()

Public method to perform a step out of the current call.

DebugBase.stop_here

stop_here(frame)

Public method reimplemented to filter out debugger files.

Tracing is turned off for files that are part of the debugger that are called from the application being debugged.

frame (frame object)
the frame object
Returns:
flag indicating whether the debugger should stop here
Return Type:
bool

DebugBase.storeFrameLocals

storeFrameLocals(frmnr=0)

Public method to store the locals into the frame, so an access to frame.f_locals returns the last data.

frmnr=
distance of frame to store locals dictionary to. 0 is the current frame (int)

DebugBase.tracePythonLibs

tracePythonLibs(enable)

Public method to update the settings to trace into Python libraries.

enable (bool)
flag to debug into Python libraries

DebugBase.trace_dispatch

trace_dispatch(frame, event, arg)

Public method reimplemented from bdb.py to do some special things.

This specialty is to check the connection to the debug server for new events (i.e. new breakpoints) while we are going through the code.

frame (frame object)
The current stack frame
event (str)
The trace event
arg (depends on the previous event parameter)
The arguments
Returns:
local trace function
Return Type:
trace function or None
Raises SystemExit:

DebugBase.user_exception

user_exception(excinfo, unhandled=False)

Public method reimplemented to report an exception to the debug server.

excinfo (tuple(Exception, excval object, traceback frame object))
details about the exception
unhandled= (bool)
flag indicating an uncaught exception

DebugBase.user_line

user_line(frame)

Public method reimplemented to handle the program about to execute a particular line.

frame
the frame object
Up


printerr

printerr(s)

Module function used for debugging the debug client.

s
data to be printed
Up


setRecursionLimit

setRecursionLimit(limit)

Module function to set the recursion limit.

limit
recursion limit (integer)
Up



Home ⌂Doc Index ◂Up ▴