2007-12-02 10:37:29 -04:00
|
|
|
:mod:`bdb` --- Debugger framework
|
|
|
|
=================================
|
|
|
|
|
|
|
|
.. module:: bdb
|
|
|
|
:synopsis: Debugger framework.
|
|
|
|
|
2011-08-18 21:14:03 -03:00
|
|
|
**Source code:** :source:`Lib/bdb.py`
|
|
|
|
|
|
|
|
--------------
|
|
|
|
|
2007-12-02 10:37:29 -04:00
|
|
|
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:
|
|
|
|
|
2013-12-23 12:19:34 -04:00
|
|
|
.. class:: Breakpoint(self, file, line, temporary=0, cond=None, funcname=None)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2009-10-05 18:25:03 -03:00
|
|
|
.. class:: Bdb(skip=None)
|
2007-12-02 10:37:29 -04:00
|
|
|
|
2009-10-05 18:25:03 -03:00
|
|
|
The :class:`Bdb` class acts as a generic Python debugger base class.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2009-10-05 18:25:03 -03:00
|
|
|
The *skip* argument, if given, must be an iterable of glob-style
|
|
|
|
module name patterns. The debugger will not step into frames that
|
|
|
|
originate in a module that matches one of these patterns. Whether a
|
|
|
|
frame is considered to originate in a certain module is determined
|
|
|
|
by the ``__name__`` in the frame globals.
|
|
|
|
|
|
|
|
.. versionadded:: 2.7
|
|
|
|
The *skip* argument.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
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.
|
Merged revisions 82798,82805,83659,83977,84015,84018,84141,84264,84326-84327,84480,84482,84484,84530-84531,84553,84619,84915-84916 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r82798 | georg.brandl | 2010-07-11 11:23:11 +0200 (So, 11 Jul 2010) | 1 line
#6774: explain shutdown() behavior varying with platform.
........
r82805 | georg.brandl | 2010-07-11 11:42:10 +0200 (So, 11 Jul 2010) | 1 line
#7935: cross-reference to ast.literal_eval() from eval() docs.
........
r83659 | georg.brandl | 2010-08-03 14:06:29 +0200 (Di, 03 Aug 2010) | 1 line
Terminology fix: exceptions are raised, except in generator.throw().
........
r83977 | georg.brandl | 2010-08-13 17:10:49 +0200 (Fr, 13 Aug 2010) | 1 line
Fix copy-paste error.
........
r84015 | georg.brandl | 2010-08-14 17:44:34 +0200 (Sa, 14 Aug 2010) | 1 line
Add some maintainers.
........
r84018 | georg.brandl | 2010-08-14 17:48:49 +0200 (Sa, 14 Aug 2010) | 1 line
Typo fix.
........
r84141 | georg.brandl | 2010-08-17 16:11:59 +0200 (Di, 17 Aug 2010) | 1 line
Markup nits.
........
r84264 | georg.brandl | 2010-08-22 22:23:38 +0200 (So, 22 Aug 2010) | 1 line
#9649: fix default value description.
........
r84326 | georg.brandl | 2010-08-26 16:30:15 +0200 (Do, 26 Aug 2010) | 1 line
#9689: add links from overview to in-depth class API descriptions.
........
r84327 | georg.brandl | 2010-08-26 16:30:56 +0200 (Do, 26 Aug 2010) | 1 line
#9681: typo.
........
r84480 | georg.brandl | 2010-09-04 00:33:27 +0200 (Sa, 04 Sep 2010) | 1 line
More inclusive title.
........
r84482 | georg.brandl | 2010-09-04 00:40:02 +0200 (Sa, 04 Sep 2010) | 1 line
#9760: clarify what context expression is.
........
r84484 | georg.brandl | 2010-09-04 00:49:27 +0200 (Sa, 04 Sep 2010) | 1 line
Fix missing word.
........
r84530 | georg.brandl | 2010-09-05 19:07:12 +0200 (So, 05 Sep 2010) | 1 line
#9747: fix copy-paste error in getresgid() doc.
........
r84531 | georg.brandl | 2010-09-05 19:09:18 +0200 (So, 05 Sep 2010) | 1 line
#9776: fix some spacing.
........
r84553 | georg.brandl | 2010-09-06 08:49:07 +0200 (Mo, 06 Sep 2010) | 1 line
#9780: both { and } are not valid fill characters.
........
r84619 | georg.brandl | 2010-09-08 12:43:45 +0200 (Mi, 08 Sep 2010) | 1 line
Add Lukasz.
........
r84915 | georg.brandl | 2010-09-20 08:27:02 +0200 (Mo, 20 Sep 2010) | 1 line
Fix typo.
........
r84916 | georg.brandl | 2010-09-20 08:29:01 +0200 (Mo, 20 Sep 2010) | 1 line
Mention % as string formatting.
........
2010-10-06 06:28:45 -03:00
|
|
|
* ``"c_exception"``: A C function has raised 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
|
|
|
|
2008-11-23 21:16:29 -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
|
2013-11-29 06:16:53 -04:00
|
|
|
: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`
|
2013-11-29 06:16:53 -04:00
|
|
|
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
|
2013-11-29 06:16:53 -04:00
|
|
|
: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
|
|
|
|
2013-11-29 06:16:53 -04:00
|
|
|
Set the :attr:`quitting` attribute to ``True``. This raises :exc:`BdbQuit` in
|
2008-04-24 22:29:10 -03:00
|
|
|
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
|
|
|
|
2012-05-22 05:27:40 -03:00
|
|
|
.. method:: set_break(filename, lineno, temporary=0, cond=None, funcname=None)
|
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.
|
2009-01-03 16:55:06 -04:00
|
|
|
|
2007-12-02 10:37:29 -04:00
|
|
|
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.
|
2010-11-26 14:26:04 -04:00
|
|
|
Return a tuple of the breakpoint and a boolean that indicates if it is ok
|
|
|
|
to delete a temporary breakpoint. Return ``(None, None)`` if there is no
|
|
|
|
matching breakpoint.
|
2007-12-02 10:37:29 -04:00
|
|
|
|
|
|
|
.. function:: set_trace()
|
|
|
|
|
2010-11-26 14:26:04 -04:00
|
|
|
Start debugging with a :class:`Bdb` instance from caller's frame.
|