2007-12-02 10:37:29 -04:00
|
|
|
:mod:`bdb` --- Debugger framework
|
|
|
|
=================================
|
|
|
|
|
|
|
|
.. module:: bdb
|
|
|
|
:synopsis: Debugger framework.
|
|
|
|
|
|
|
|
The :mod:`bdb` module handles basic debugger functions, like setting breakpoints
|
|
|
|
or managing execution via the debugger.
|
|
|
|
|
|
|
|
The following exception is defined:
|
|
|
|
|
|
|
|
.. exception:: BdbQuit
|
|
|
|
|
|
|
|
Exception raised by the :class:`Bdb` class for quitting the debugger.
|
|
|
|
|
|
|
|
|
|
|
|
The :mod:`bdb` module also defines two classes:
|
|
|
|
|
|
|
|
.. class:: Breakpoint(self, file, line[, temporary=0[, cond=None [, funcname=None]]])
|
|
|
|
|
|
|
|
This class implements temporary breakpoints, ignore counts, disabling and
|
|
|
|
(re-)enabling, and conditionals.
|
|
|
|
|
|
|
|
Breakpoints are indexed by number through a list called :attr:`bpbynumber`
|
|
|
|
and by ``(file, line)`` pairs through :attr:`bplist`. The former points to a
|
|
|
|
single instance of class :class:`Breakpoint`. The latter points to a list of
|
|
|
|
such instances since there may be more than one breakpoint per line.
|
|
|
|
|
|
|
|
When creating a breakpoint, its associated filename should be in canonical
|
|
|
|
form. If a *funcname* is defined, a breakpoint hit will be counted when the
|
|
|
|
first line of that function is executed. A conditional breakpoint always
|
|
|
|
counts a hit.
|
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
:class:`Breakpoint` instances have the following methods:
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: deleteMe()
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Delete the breakpoint from the list associated to a file/line. If it is
|
|
|
|
the last breakpoint in that position, it also deletes the entry for the
|
|
|
|
file/line.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: enable()
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Mark the breakpoint as enabled.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: disable()
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Mark the breakpoint as disabled.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
|
|
|
|
.. method:: pprint([out])
|
|
|
|
|
|
|
|
Print all the information about the breakpoint:
|
|
|
|
|
|
|
|
* The breakpoint number.
|
|
|
|
* If it is temporary or not.
|
|
|
|
* Its file,line position.
|
|
|
|
* The condition that causes a break.
|
|
|
|
* If it must be ignored the next N times.
|
|
|
|
* The breakpoint hit count.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
|
|
|
|
|
|
|
.. class:: Bdb()
|
|
|
|
|
|
|
|
The :class:`Bdb` acts as a generic Python debugger base class.
|
|
|
|
|
|
|
|
This class takes care of the details of the trace facility; a derived class
|
|
|
|
should implement user interaction. The standard debugger class
|
|
|
|
(:class:`pdb.Pdb`) is an example.
|
|
|
|
|
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
The following methods of :class:`Bdb` normally don't need to be overridden.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: canonic(filename)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Auxiliary method for getting a filename in a canonical form, that is, as a
|
|
|
|
case-normalized (on case-insensitive filesystems) absolute path, stripped
|
|
|
|
of surrounding angle brackets.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: reset()
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Set the :attr:`botframe`, :attr:`stopframe`, :attr:`returnframe` and
|
|
|
|
:attr:`quitting` attributes with values ready to start debugging.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: trace_dispatch(frame, event, arg)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
This function is installed as the trace function of debugged frames. Its
|
|
|
|
return value is the new trace function (in most cases, that is, itself).
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
The default implementation decides how to dispatch a frame, depending on
|
|
|
|
the type of event (passed as a string) that is about to be executed.
|
|
|
|
*event* can be one of the following:
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
* ``"line"``: A new line of code is going to be executed.
|
|
|
|
* ``"call"``: A function is about to be called, or another code block
|
|
|
|
entered.
|
|
|
|
* ``"return"``: A function or other code block is about to return.
|
|
|
|
* ``"exception"``: An exception has occurred.
|
|
|
|
* ``"c_call"``: A C function is about to be called.
|
|
|
|
* ``"c_return"``: A C function has returned.
|
|
|
|
* ``"c_exception"``: A C function has thrown an exception.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
For the Python events, specialized functions (see below) are called. For
|
|
|
|
the C events, no action is taken.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
The *arg* parameter depends on the previous event.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67245 | benjamin.peterson | 2008-11-17 23:05:19 +0100 (Mon, 17 Nov 2008) | 1 line
improve __hash__ docs
........
r67277 | skip.montanaro | 2008-11-19 04:35:41 +0100 (Wed, 19 Nov 2008) | 1 line
patch from issue 1108
........
r67289 | brett.cannon | 2008-11-19 21:29:39 +0100 (Wed, 19 Nov 2008) | 2 lines
Ignore .pyc and .pyo files.
........
r67295 | benjamin.peterson | 2008-11-20 05:05:12 +0100 (Thu, 20 Nov 2008) | 1 line
move useful sys.settrace information to the function's documentation from the debugger
........
r67301 | benjamin.peterson | 2008-11-20 22:25:31 +0100 (Thu, 20 Nov 2008) | 1 line
fix indentation and a sphinx warning
........
r67302 | benjamin.peterson | 2008-11-20 22:44:23 +0100 (Thu, 20 Nov 2008) | 1 line
oops! didn't mean to disable that test
........
r67303 | benjamin.peterson | 2008-11-20 23:06:22 +0100 (Thu, 20 Nov 2008) | 1 line
backport r67300
........
r67307 | amaury.forgeotdarc | 2008-11-21 00:34:31 +0100 (Fri, 21 Nov 2008) | 9 lines
Fixed issue #4233.
Changed semantic of _fileio.FileIO's close() method on file objects with closefd=False.
The file descriptor is still kept open but the file object behaves like a closed file.
The FileIO object also got a new readonly attribute closefd.
Approved by Barry
Backport of r67106 from the py3k branch
........
r67330 | georg.brandl | 2008-11-22 09:34:14 +0100 (Sat, 22 Nov 2008) | 2 lines
#4364: fix attribute name on ctypes object.
........
r67332 | georg.brandl | 2008-11-22 09:45:33 +0100 (Sat, 22 Nov 2008) | 2 lines
Fix typo.
........
r67336 | georg.brandl | 2008-11-22 11:08:50 +0100 (Sat, 22 Nov 2008) | 2 lines
Fix error about "-*-" being mandatory in coding cookies.
........
r67355 | georg.brandl | 2008-11-23 20:17:25 +0100 (Sun, 23 Nov 2008) | 2 lines
#4392: fix parameter name.
........
r67359 | georg.brandl | 2008-11-23 22:57:30 +0100 (Sun, 23 Nov 2008) | 2 lines
#4399: fix typo.
........
r67362 | gregory.p.smith | 2008-11-24 01:41:43 +0100 (Mon, 24 Nov 2008) | 2 lines
Document PY_SSIZE_T_CLEAN for PyArg_ParseTuple.
........
r67364 | benjamin.peterson | 2008-11-24 02:16:29 +0100 (Mon, 24 Nov 2008) | 2 lines
replace reference to debugger-hooks
........
r67367 | georg.brandl | 2008-11-24 17:16:07 +0100 (Mon, 24 Nov 2008) | 2 lines
Fix typo.
........
r67368 | georg.brandl | 2008-11-24 20:56:47 +0100 (Mon, 24 Nov 2008) | 2 lines
#4404: make clear what "path" is.
........
r67370 | jeremy.hylton | 2008-11-24 23:00:29 +0100 (Mon, 24 Nov 2008) | 8 lines
Add unittests that verify documented behavior of public methods in Transport
class.
These methods can be overridden. The tests verify that the overridden
methods are called, and that changes to the connection have a visible
effect on the request.
........
2008-12-05 04:51:30 -04:00
|
|
|
See the documentation for :func:`sys.settrace` for more information on the
|
|
|
|
trace function. For more information on code and frame objects, refer to
|
|
|
|
:ref:`types`.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: dispatch_line(frame)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
If the debugger should stop on the current line, invoke the
|
|
|
|
:meth:`user_line` method (which should be overridden in subclasses).
|
|
|
|
Raise a :exc:`BdbQuit` exception if the :attr:`Bdb.quitting` flag is set
|
|
|
|
(which can be set from :meth:`user_line`). Return a reference to the
|
|
|
|
:meth:`trace_dispatch` method for further tracing in that scope.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: dispatch_call(frame, arg)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
If the debugger should stop on this function call, invoke the
|
|
|
|
:meth:`user_call` method (which should be overridden in subclasses).
|
|
|
|
Raise a :exc:`BdbQuit` exception if the :attr:`Bdb.quitting` flag is set
|
|
|
|
(which can be set from :meth:`user_call`). Return a reference to the
|
|
|
|
:meth:`trace_dispatch` method for further tracing in that scope.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: dispatch_return(frame, arg)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
If the debugger should stop on this function return, invoke the
|
|
|
|
:meth:`user_return` method (which should be overridden in subclasses).
|
|
|
|
Raise a :exc:`BdbQuit` exception if the :attr:`Bdb.quitting` flag is set
|
|
|
|
(which can be set from :meth:`user_return`). Return a reference to the
|
|
|
|
:meth:`trace_dispatch` method for further tracing in that scope.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: dispatch_exception(frame, arg)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
If the debugger should stop at this exception, invokes the
|
|
|
|
:meth:`user_exception` method (which should be overridden in subclasses).
|
|
|
|
Raise a :exc:`BdbQuit` exception if the :attr:`Bdb.quitting` flag is set
|
|
|
|
(which can be set from :meth:`user_exception`). Return a reference to the
|
|
|
|
:meth:`trace_dispatch` method for further tracing in that scope.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Normally derived classes don't override the following methods, but they may
|
|
|
|
if they want to redefine the definition of stopping and breakpoints.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: stop_here(frame)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
This method checks if the *frame* is somewhere below :attr:`botframe` in
|
|
|
|
the call stack. :attr:`botframe` is the frame in which debugging started.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: break_here(frame)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
This method checks if there is a breakpoint in the filename and line
|
|
|
|
belonging to *frame* or, at least, in the current function. If the
|
|
|
|
breakpoint is a temporary one, this method deletes it.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: break_anywhere(frame)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
This method checks if there is a breakpoint in the filename of the current
|
|
|
|
frame.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Derived classes should override these methods to gain control over debugger
|
|
|
|
operation.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: user_call(frame, argument_list)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
This method is called from :meth:`dispatch_call` when there is the
|
|
|
|
possibility that a break might be necessary anywhere inside the called
|
|
|
|
function.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: user_line(frame)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
This method is called from :meth:`dispatch_line` when either
|
|
|
|
:meth:`stop_here` or :meth:`break_here` yields True.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: user_return(frame, return_value)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
This method is called from :meth:`dispatch_return` when :meth:`stop_here`
|
|
|
|
yields True.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: user_exception(frame, exc_info)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
This method is called from :meth:`dispatch_exception` when
|
|
|
|
:meth:`stop_here` yields True.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: do_clear(arg)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Handle how a breakpoint must be removed when it is a temporary one.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
This method must be implemented by derived classes.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Derived classes and clients can call the following methods to affect the
|
|
|
|
stepping state.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: set_step()
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Stop after one line of code.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: set_next(frame)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Stop on the next line in or below the given frame.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: set_return(frame)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Stop when returning from the given frame.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-05-11 11:13:25 -03:00
|
|
|
.. method:: set_until(frame)
|
|
|
|
|
|
|
|
Stop when the line with the line no greater than the current one is
|
|
|
|
reached or when returning from current frame
|
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: set_trace([frame])
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Start debugging from *frame*. If *frame* is not specified, debugging
|
|
|
|
starts from caller's frame.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: set_continue()
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Stop only at breakpoints or when finished. If there are no breakpoints,
|
|
|
|
set the system trace function to None.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: set_quit()
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Set the :attr:`quitting` attribute to True. This raises :exc:`BdbQuit` in
|
|
|
|
the next call to one of the :meth:`dispatch_\*` methods.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Derived classes and clients can call the following methods to manipulate
|
|
|
|
breakpoints. These methods return a string containing an error message if
|
|
|
|
something went wrong, or ``None`` if all is well.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: set_break(filename, lineno[, temporary=0[, cond[, funcname]]])
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Set a new breakpoint. If the *lineno* line doesn't exist for the
|
|
|
|
*filename* passed as argument, return an error message. The *filename*
|
|
|
|
should be in canonical form, as described in the :meth:`canonic` method.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: clear_break(filename, lineno)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Delete the breakpoints in *filename* and *lineno*. If none were set, an
|
|
|
|
error message is returned.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: clear_bpbynumber(arg)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Delete the breakpoint which has the index *arg* in the
|
|
|
|
:attr:`Breakpoint.bpbynumber`. If *arg* is not numeric or out of range,
|
|
|
|
return an error message.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: clear_all_file_breaks(filename)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Delete all breakpoints in *filename*. If none were set, an error message
|
|
|
|
is returned.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: clear_all_breaks()
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Delete all existing breakpoints.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: get_break(filename, lineno)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Check if there is a breakpoint for *lineno* of *filename*.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: get_breaks(filename, lineno)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Return all breakpoints for *lineno* in *filename*, or an empty list if
|
|
|
|
none are set.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: get_file_breaks(filename)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Return all breakpoints in *filename*, or an empty list if none are set.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: get_all_breaks()
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Return all breakpoints that are set.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Derived classes and clients can call the following methods to get a data
|
|
|
|
structure representing a stack trace.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: get_stack(f, t)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Get a list of records for a frame and all higher (calling) and lower
|
|
|
|
frames, and the size of the higher part.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: format_stack_entry(frame_lineno, [lprefix=': '])
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Return a string with information about a stack entry, identified by a
|
|
|
|
``(frame, lineno)`` tuple:
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
* The canonical form of the filename which contains the frame.
|
|
|
|
* The function name, or ``"<lambda>"``.
|
|
|
|
* The input arguments.
|
|
|
|
* The return value.
|
|
|
|
* The line of code (if it exists).
|
2007-12-02 10:37:29 -04:00
|
|
|
|
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
The following two methods can be called by clients to use a debugger to debug
|
|
|
|
a :term:`statement`, given as a string.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: run(cmd, [globals, [locals]])
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Debug a statement executed via the :keyword:`exec` statement. *globals*
|
|
|
|
defaults to :attr:`__main__.__dict__`, *locals* defaults to *globals*.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: runeval(expr, [globals, [locals]])
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Debug an expression executed via the :func:`eval` function. *globals* and
|
|
|
|
*locals* have the same meaning as in :meth:`run`.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: runctx(cmd, globals, locals)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
For backwards compatibility. Calls the :meth:`run` method.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
.. method:: runcall(func, *args, **kwds)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2008-04-24 22:29:10 -03:00
|
|
|
Debug a single function call, and return its result.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
|
|
|
|
|
|
|
Finally, the module defines the following functions:
|
|
|
|
|
|
|
|
.. function:: checkfuncname(b, frame)
|
|
|
|
|
|
|
|
Check whether we should break here, depending on the way the breakpoint *b*
|
|
|
|
was set.
|
|
|
|
|
|
|
|
If it was set via line number, it checks if ``b.line`` is the same as the one
|
|
|
|
in the frame also passed as argument. If the breakpoint was set via function
|
|
|
|
name, we have to check we are in the right frame (the right function) and if
|
|
|
|
we are in its first executable line.
|
|
|
|
|
|
|
|
.. function:: effective(file, line, frame)
|
|
|
|
|
|
|
|
Determine if there is an effective (active) breakpoint at this line of code.
|
|
|
|
Return breakpoint number or 0 if none.
|
|
|
|
|
|
|
|
Called only if we know there is a breakpoint at this location. Returns the
|
|
|
|
breakpoint that was triggered and a flag that indicates if it is ok to delete
|
|
|
|
a temporary breakpoint.
|
|
|
|
|
|
|
|
.. function:: set_trace()
|
|
|
|
|
|
|
|
Starts debugging with a :class:`Bdb` instance from caller's frame.
|