Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
'''
|
|
|
|
From gdb 7 onwards, gdb's build can be configured --with-python, allowing gdb
|
|
|
|
to be extended with Python code e.g. for library-specific data visualizations,
|
|
|
|
such as for the C++ STL types. Documentation on this API can be seen at:
|
|
|
|
http://sourceware.org/gdb/current/onlinedocs/gdb/Python-API.html
|
|
|
|
|
|
|
|
|
|
|
|
This python module deals with the case when the process being debugged (the
|
|
|
|
"inferior process" in gdb parlance) is itself python, or more specifically,
|
|
|
|
linked against libpython. In this situation, almost every item of data is a
|
|
|
|
(PyObject*), and having the debugger merely print their addresses is not very
|
|
|
|
enlightening.
|
|
|
|
|
|
|
|
This module embeds knowledge about the implementation details of libpython so
|
|
|
|
that we can emit useful visualizations e.g. a string, a list, a dict, a frame
|
|
|
|
giving file/line information and the state of local variables
|
|
|
|
|
|
|
|
In particular, given a gdb.Value corresponding to a PyObject* in the inferior
|
|
|
|
process, we can generate a "proxy value" within the gdb process. For example,
|
|
|
|
given a PyObject* in the inferior process that is in fact a PyListObject*
|
2010-04-21 13:53:05 +00:00
|
|
|
holding three PyObject* that turn out to be PyBytesObject* instances, we can
|
2010-04-21 22:38:42 +00:00
|
|
|
generate a proxy value within the gdb process that is a list of bytes
|
|
|
|
instances:
|
|
|
|
[b"foo", b"bar", b"baz"]
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
Doing so can be expensive for complicated graphs of objects, and could take
|
|
|
|
some time, so we also have a "write_repr" method that writes a representation
|
|
|
|
of the data to a file-like object. This allows us to stop the traversal by
|
|
|
|
having the file-like object raise an exception if it gets too much data.
|
|
|
|
|
|
|
|
With both "proxyval" and "write_repr" we keep track of the set of all addresses
|
|
|
|
visited so far in the traversal, to avoid infinite recursion due to cycles in
|
|
|
|
the graph of object references.
|
|
|
|
|
|
|
|
We try to defer gdb.lookup_type() invocations for python types until as late as
|
|
|
|
possible: for a dynamically linked python binary, when the process starts in
|
|
|
|
the debugger, the libpython.so hasn't been dynamically loaded yet, so none of
|
|
|
|
the type names are known to the debugger
|
|
|
|
|
|
|
|
The module also extends gdb with some python-specific commands.
|
|
|
|
'''
|
2013-11-23 17:40:36 +01:00
|
|
|
|
|
|
|
# NOTE: some gdbs are linked with Python 3, so this file should be dual-syntax
|
|
|
|
# compatible (2.6+ and 3.0+). See #19308.
|
|
|
|
|
2016-09-08 13:47:41 -07:00
|
|
|
from __future__ import print_function
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
import gdb
|
2013-11-23 17:40:36 +01:00
|
|
|
import os
|
2010-05-19 23:04:56 +00:00
|
|
|
import locale
|
2010-07-14 08:54:40 +00:00
|
|
|
import sys
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
2013-11-23 17:40:36 +01:00
|
|
|
if sys.version_info[0] >= 3:
|
|
|
|
unichr = chr
|
|
|
|
xrange = range
|
|
|
|
long = int
|
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
# Look up the gdb.Type for some standard types:
|
2016-04-20 18:07:21 +02:00
|
|
|
# Those need to be refreshed as types (pointer sizes) may change when
|
|
|
|
# gdb loads different executables
|
|
|
|
|
|
|
|
def _type_char_ptr():
|
|
|
|
return gdb.lookup_type('char').pointer() # char*
|
|
|
|
|
|
|
|
|
|
|
|
def _type_unsigned_char_ptr():
|
|
|
|
return gdb.lookup_type('unsigned char').pointer() # unsigned char*
|
|
|
|
|
|
|
|
|
|
|
|
def _type_unsigned_short_ptr():
|
|
|
|
return gdb.lookup_type('unsigned short').pointer()
|
|
|
|
|
|
|
|
|
|
|
|
def _type_unsigned_int_ptr():
|
|
|
|
return gdb.lookup_type('unsigned int').pointer()
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
2016-04-20 18:07:21 +02:00
|
|
|
|
|
|
|
def _sizeof_void_p():
|
2016-04-20 18:26:12 +02:00
|
|
|
return gdb.lookup_type('void').pointer().sizeof
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
|
2016-04-20 18:26:12 +02:00
|
|
|
# value computed later, see PyUnicodeObjectPtr.proxy()
|
|
|
|
_is_pep393 = None
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
2016-04-20 18:26:12 +02:00
|
|
|
Py_TPFLAGS_HEAPTYPE = (1 << 9)
|
2013-11-23 17:40:36 +01:00
|
|
|
Py_TPFLAGS_LONG_SUBCLASS = (1 << 24)
|
|
|
|
Py_TPFLAGS_LIST_SUBCLASS = (1 << 25)
|
|
|
|
Py_TPFLAGS_TUPLE_SUBCLASS = (1 << 26)
|
|
|
|
Py_TPFLAGS_BYTES_SUBCLASS = (1 << 27)
|
|
|
|
Py_TPFLAGS_UNICODE_SUBCLASS = (1 << 28)
|
|
|
|
Py_TPFLAGS_DICT_SUBCLASS = (1 << 29)
|
|
|
|
Py_TPFLAGS_BASE_EXC_SUBCLASS = (1 << 30)
|
|
|
|
Py_TPFLAGS_TYPE_SUBCLASS = (1 << 31)
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
MAX_OUTPUT_LEN=1024
|
|
|
|
|
2010-04-21 22:38:42 +00:00
|
|
|
hexdigits = "0123456789abcdef"
|
|
|
|
|
2010-05-19 23:04:56 +00:00
|
|
|
ENCODING = locale.getpreferredencoding()
|
2010-04-21 22:38:42 +00:00
|
|
|
|
2020-03-20 08:23:26 +01:00
|
|
|
FRAME_INFO_OPTIMIZED_OUT = '(frame information optimized out)'
|
|
|
|
UNABLE_READ_INFO_PYTHON_FRAME = 'Unable to read information on python frame'
|
2017-08-21 16:40:29 -07:00
|
|
|
EVALFRAME = '_PyEval_EvalFrameDefault'
|
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
class NullPyObjectPtr(RuntimeError):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def safety_limit(val):
|
2015-11-02 03:37:02 +00:00
|
|
|
# Given an integer value from the process being debugged, limit it to some
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
# safety threshold so that arbitrary breakage within said process doesn't
|
|
|
|
# break the gdb process too much (e.g. sizes of iterations, sizes of lists)
|
|
|
|
return min(val, 1000)
|
|
|
|
|
|
|
|
|
|
|
|
def safe_range(val):
|
|
|
|
# As per range, but don't trust the value too much: cap it to a safety
|
|
|
|
# threshold in case the data was corrupted
|
2013-11-23 17:40:36 +01:00
|
|
|
return xrange(safety_limit(int(val)))
|
|
|
|
|
|
|
|
if sys.version_info[0] >= 3:
|
|
|
|
def write_unicode(file, text):
|
|
|
|
file.write(text)
|
|
|
|
else:
|
|
|
|
def write_unicode(file, text):
|
|
|
|
# Write a byte or unicode string to file. Unicode strings are encoded to
|
|
|
|
# ENCODING encoding with 'backslashreplace' error handler to avoid
|
|
|
|
# UnicodeEncodeError.
|
|
|
|
if isinstance(text, unicode):
|
|
|
|
text = text.encode(ENCODING, 'backslashreplace')
|
|
|
|
file.write(text)
|
|
|
|
|
|
|
|
try:
|
|
|
|
os_fsencode = os.fsencode
|
2013-11-23 18:20:42 +01:00
|
|
|
except AttributeError:
|
2013-11-23 17:40:36 +01:00
|
|
|
def os_fsencode(filename):
|
|
|
|
if not isinstance(filename, unicode):
|
|
|
|
return filename
|
|
|
|
encoding = sys.getfilesystemencoding()
|
|
|
|
if encoding == 'mbcs':
|
|
|
|
# mbcs doesn't support surrogateescape
|
|
|
|
return filename.encode(encoding)
|
|
|
|
encoded = []
|
|
|
|
for char in filename:
|
|
|
|
# surrogateescape error handler
|
|
|
|
if 0xDC80 <= ord(char) <= 0xDCFF:
|
|
|
|
byte = chr(ord(char) - 0xDC00)
|
|
|
|
else:
|
|
|
|
byte = char.encode(encoding)
|
|
|
|
encoded.append(byte)
|
|
|
|
return ''.join(encoded)
|
2010-10-17 19:35:30 +00:00
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
class StringTruncated(RuntimeError):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class TruncatedStringIO(object):
|
2013-08-29 11:35:43 +03:00
|
|
|
'''Similar to io.StringIO, but can truncate the output by raising a
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
StringTruncated exception'''
|
|
|
|
def __init__(self, maxlen=None):
|
|
|
|
self._val = ''
|
|
|
|
self.maxlen = maxlen
|
|
|
|
|
|
|
|
def write(self, data):
|
|
|
|
if self.maxlen:
|
|
|
|
if len(data) + len(self._val) > self.maxlen:
|
|
|
|
# Truncation:
|
|
|
|
self._val += data[0:self.maxlen - len(self._val)]
|
|
|
|
raise StringTruncated()
|
|
|
|
|
|
|
|
self._val += data
|
|
|
|
|
|
|
|
def getvalue(self):
|
|
|
|
return self._val
|
|
|
|
|
|
|
|
class PyObjectPtr(object):
|
|
|
|
"""
|
2015-11-02 03:37:02 +00:00
|
|
|
Class wrapping a gdb.Value that's either a (PyObject*) within the
|
2010-04-21 13:53:05 +00:00
|
|
|
inferior process, or some subclass pointer e.g. (PyBytesObject*)
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
There will be a subclass for every refined PyObject type that we care
|
|
|
|
about.
|
|
|
|
|
|
|
|
Note that at every stage the underlying pointer could be NULL, point
|
|
|
|
to corrupt data, etc; this is the debugger, after all.
|
|
|
|
"""
|
|
|
|
_typename = 'PyObject'
|
|
|
|
|
|
|
|
def __init__(self, gdbval, cast_to=None):
|
|
|
|
if cast_to:
|
|
|
|
self._gdbval = gdbval.cast(cast_to)
|
|
|
|
else:
|
|
|
|
self._gdbval = gdbval
|
|
|
|
|
|
|
|
def field(self, name):
|
|
|
|
'''
|
|
|
|
Get the gdb.Value for the given field within the PyObject, coping with
|
|
|
|
some python 2 versus python 3 differences.
|
|
|
|
|
|
|
|
Various libpython types are defined using the "PyObject_HEAD" and
|
|
|
|
"PyObject_VAR_HEAD" macros.
|
|
|
|
|
|
|
|
In Python 2, this these are defined so that "ob_type" and (for a var
|
|
|
|
object) "ob_size" are fields of the type in question.
|
|
|
|
|
|
|
|
In Python 3, this is defined as an embedded PyVarObject type thus:
|
|
|
|
PyVarObject ob_base;
|
|
|
|
so that the "ob_size" field is located insize the "ob_base" field, and
|
|
|
|
the "ob_type" is most easily accessed by casting back to a (PyObject*).
|
|
|
|
'''
|
|
|
|
if self.is_null():
|
|
|
|
raise NullPyObjectPtr(self)
|
|
|
|
|
|
|
|
if name == 'ob_type':
|
|
|
|
pyo_ptr = self._gdbval.cast(PyObjectPtr.get_gdb_type())
|
|
|
|
return pyo_ptr.dereference()[name]
|
|
|
|
|
|
|
|
if name == 'ob_size':
|
2010-04-21 22:38:42 +00:00
|
|
|
pyo_ptr = self._gdbval.cast(PyVarObjectPtr.get_gdb_type())
|
|
|
|
return pyo_ptr.dereference()[name]
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
# General case: look it up inside the object:
|
|
|
|
return self._gdbval.dereference()[name]
|
|
|
|
|
|
|
|
def pyop_field(self, name):
|
|
|
|
'''
|
|
|
|
Get a PyObjectPtr for the given PyObject* field within this PyObject,
|
|
|
|
coping with some python 2 versus python 3 differences.
|
|
|
|
'''
|
|
|
|
return PyObjectPtr.from_pyobject_ptr(self.field(name))
|
|
|
|
|
|
|
|
def write_field_repr(self, name, out, visited):
|
|
|
|
'''
|
|
|
|
Extract the PyObject* field named "name", and write its representation
|
|
|
|
to file-like object "out"
|
|
|
|
'''
|
|
|
|
field_obj = self.pyop_field(name)
|
|
|
|
field_obj.write_repr(out, visited)
|
|
|
|
|
|
|
|
def get_truncated_repr(self, maxlen):
|
|
|
|
'''
|
|
|
|
Get a repr-like string for the data, but truncate it at "maxlen" bytes
|
|
|
|
(ending the object graph traversal as soon as you do)
|
|
|
|
'''
|
|
|
|
out = TruncatedStringIO(maxlen)
|
|
|
|
try:
|
|
|
|
self.write_repr(out, set())
|
|
|
|
except StringTruncated:
|
|
|
|
# Truncation occurred:
|
|
|
|
return out.getvalue() + '...(truncated)'
|
|
|
|
|
|
|
|
# No truncation occurred:
|
|
|
|
return out.getvalue()
|
|
|
|
|
|
|
|
def type(self):
|
|
|
|
return PyTypeObjectPtr(self.field('ob_type'))
|
|
|
|
|
|
|
|
def is_null(self):
|
|
|
|
return 0 == long(self._gdbval)
|
|
|
|
|
|
|
|
def is_optimized_out(self):
|
|
|
|
'''
|
|
|
|
Is the value of the underlying PyObject* visible to the debugger?
|
|
|
|
|
|
|
|
This can vary with the precise version of the compiler used to build
|
|
|
|
Python, and the precise version of gdb.
|
|
|
|
|
|
|
|
See e.g. https://bugzilla.redhat.com/show_bug.cgi?id=556975 with
|
|
|
|
PyEval_EvalFrameEx's "f"
|
|
|
|
'''
|
|
|
|
return self._gdbval.is_optimized_out
|
|
|
|
|
|
|
|
def safe_tp_name(self):
|
|
|
|
try:
|
2018-06-14 22:34:52 +02:00
|
|
|
ob_type = self.type()
|
|
|
|
tp_name = ob_type.field('tp_name')
|
|
|
|
return tp_name.string()
|
|
|
|
# NullPyObjectPtr: NULL tp_name?
|
|
|
|
# RuntimeError: Can't even read the object at all?
|
|
|
|
# UnicodeDecodeError: Failed to decode tp_name bytestring
|
|
|
|
except (NullPyObjectPtr, RuntimeError, UnicodeDecodeError):
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return 'unknown'
|
|
|
|
|
|
|
|
def proxyval(self, visited):
|
|
|
|
'''
|
|
|
|
Scrape a value from the inferior process, and try to represent it
|
|
|
|
within the gdb process, whilst (hopefully) avoiding crashes when
|
|
|
|
the remote data is corrupt.
|
|
|
|
|
|
|
|
Derived classes will override this.
|
|
|
|
|
|
|
|
For example, a PyIntObject* with ob_ival 42 in the inferior process
|
|
|
|
should result in an int(42) in this process.
|
|
|
|
|
|
|
|
visited: a set of all gdb.Value pyobject pointers already visited
|
|
|
|
whilst generating this value (to guard against infinite recursion when
|
|
|
|
visiting object graphs with loops). Analogous to Py_ReprEnter and
|
|
|
|
Py_ReprLeave
|
|
|
|
'''
|
|
|
|
|
|
|
|
class FakeRepr(object):
|
|
|
|
"""
|
|
|
|
Class representing a non-descript PyObject* value in the inferior
|
|
|
|
process for when we don't have a custom scraper, intended to have
|
|
|
|
a sane repr().
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, tp_name, address):
|
|
|
|
self.tp_name = tp_name
|
|
|
|
self.address = address
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
# For the NULL pointer, we have no way of knowing a type, so
|
|
|
|
# special-case it as per
|
|
|
|
# http://bugs.python.org/issue8032#msg100882
|
|
|
|
if self.address == 0:
|
|
|
|
return '0x0'
|
|
|
|
return '<%s at remote 0x%x>' % (self.tp_name, self.address)
|
|
|
|
|
|
|
|
return FakeRepr(self.safe_tp_name(),
|
|
|
|
long(self._gdbval))
|
|
|
|
|
|
|
|
def write_repr(self, out, visited):
|
|
|
|
'''
|
|
|
|
Write a string representation of the value scraped from the inferior
|
|
|
|
process to "out", a file-like object.
|
|
|
|
'''
|
|
|
|
# Default implementation: generate a proxy value and write its repr
|
|
|
|
# However, this could involve a lot of work for complicated objects,
|
|
|
|
# so for derived classes we specialize this
|
|
|
|
return out.write(repr(self.proxyval(visited)))
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def subclass_from_type(cls, t):
|
|
|
|
'''
|
|
|
|
Given a PyTypeObjectPtr instance wrapping a gdb.Value that's a
|
|
|
|
(PyTypeObject*), determine the corresponding subclass of PyObjectPtr
|
|
|
|
to use
|
|
|
|
|
|
|
|
Ideally, we would look up the symbols for the global types, but that
|
|
|
|
isn't working yet:
|
|
|
|
(gdb) python print gdb.lookup_symbol('PyList_Type')[0].value
|
|
|
|
Traceback (most recent call last):
|
|
|
|
File "<string>", line 1, in <module>
|
|
|
|
NotImplementedError: Symbol type not yet supported in Python scripts.
|
|
|
|
Error while executing Python code.
|
|
|
|
|
|
|
|
For now, we use tp_flags, after doing some string comparisons on the
|
|
|
|
tp_name for some special-cases that don't seem to be visible through
|
|
|
|
flags
|
|
|
|
'''
|
|
|
|
try:
|
|
|
|
tp_name = t.field('tp_name').string()
|
|
|
|
tp_flags = int(t.field('tp_flags'))
|
2018-06-14 22:34:52 +02:00
|
|
|
# RuntimeError: NULL pointers
|
|
|
|
# UnicodeDecodeError: string() fails to decode the bytestring
|
|
|
|
except (RuntimeError, UnicodeDecodeError):
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
# Handle any kind of error e.g. NULL ptrs by simply using the base
|
|
|
|
# class
|
|
|
|
return cls
|
|
|
|
|
2013-11-23 17:40:36 +01:00
|
|
|
#print('tp_flags = 0x%08x' % tp_flags)
|
|
|
|
#print('tp_name = %r' % tp_name)
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
name_map = {'bool': PyBoolObjectPtr,
|
|
|
|
'classobj': PyClassObjectPtr,
|
|
|
|
'NoneType': PyNoneStructPtr,
|
|
|
|
'frame': PyFrameObjectPtr,
|
|
|
|
'set' : PySetObjectPtr,
|
|
|
|
'frozenset' : PySetObjectPtr,
|
|
|
|
'builtin_function_or_method' : PyCFunctionObjectPtr,
|
2017-02-01 16:29:54 +01:00
|
|
|
'method-wrapper': wrapperobject,
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
}
|
|
|
|
if tp_name in name_map:
|
|
|
|
return name_map[tp_name]
|
|
|
|
|
|
|
|
if tp_flags & Py_TPFLAGS_HEAPTYPE:
|
|
|
|
return HeapTypeObjectPtr
|
|
|
|
|
|
|
|
if tp_flags & Py_TPFLAGS_LONG_SUBCLASS:
|
|
|
|
return PyLongObjectPtr
|
|
|
|
if tp_flags & Py_TPFLAGS_LIST_SUBCLASS:
|
|
|
|
return PyListObjectPtr
|
|
|
|
if tp_flags & Py_TPFLAGS_TUPLE_SUBCLASS:
|
|
|
|
return PyTupleObjectPtr
|
2010-04-21 22:38:42 +00:00
|
|
|
if tp_flags & Py_TPFLAGS_BYTES_SUBCLASS:
|
2010-04-21 13:53:05 +00:00
|
|
|
return PyBytesObjectPtr
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
if tp_flags & Py_TPFLAGS_UNICODE_SUBCLASS:
|
|
|
|
return PyUnicodeObjectPtr
|
|
|
|
if tp_flags & Py_TPFLAGS_DICT_SUBCLASS:
|
|
|
|
return PyDictObjectPtr
|
|
|
|
if tp_flags & Py_TPFLAGS_BASE_EXC_SUBCLASS:
|
|
|
|
return PyBaseExceptionObjectPtr
|
|
|
|
#if tp_flags & Py_TPFLAGS_TYPE_SUBCLASS:
|
|
|
|
# return PyTypeObjectPtr
|
|
|
|
|
|
|
|
# Use the base class:
|
|
|
|
return cls
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def from_pyobject_ptr(cls, gdbval):
|
|
|
|
'''
|
|
|
|
Try to locate the appropriate derived class dynamically, and cast
|
|
|
|
the pointer accordingly.
|
|
|
|
'''
|
|
|
|
try:
|
|
|
|
p = PyObjectPtr(gdbval)
|
|
|
|
cls = cls.subclass_from_type(p.type())
|
|
|
|
return cls(gdbval, cast_to=cls.get_gdb_type())
|
|
|
|
except RuntimeError:
|
|
|
|
# Handle any kind of error e.g. NULL ptrs by simply using the base
|
|
|
|
# class
|
|
|
|
pass
|
|
|
|
return cls(gdbval)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def get_gdb_type(cls):
|
|
|
|
return gdb.lookup_type(cls._typename).pointer()
|
|
|
|
|
|
|
|
def as_address(self):
|
|
|
|
return long(self._gdbval)
|
|
|
|
|
2010-04-21 22:38:42 +00:00
|
|
|
class PyVarObjectPtr(PyObjectPtr):
|
|
|
|
_typename = 'PyVarObject'
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
class ProxyAlreadyVisited(object):
|
|
|
|
'''
|
|
|
|
Placeholder proxy to use when protecting against infinite recursion due to
|
|
|
|
loops in the object graph.
|
|
|
|
|
|
|
|
Analogous to the values emitted by the users of Py_ReprEnter and Py_ReprLeave
|
|
|
|
'''
|
|
|
|
def __init__(self, rep):
|
|
|
|
self._rep = rep
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return self._rep
|
|
|
|
|
|
|
|
|
|
|
|
def _write_instance_repr(out, visited, name, pyop_attrdict, address):
|
2011-12-12 18:54:29 +01:00
|
|
|
'''Shared code for use by all classes:
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
write a representation to file-like object "out"'''
|
|
|
|
out.write('<')
|
|
|
|
out.write(name)
|
|
|
|
|
|
|
|
# Write dictionary of instance attributes:
|
|
|
|
if isinstance(pyop_attrdict, PyDictObjectPtr):
|
|
|
|
out.write('(')
|
|
|
|
first = True
|
|
|
|
for pyop_arg, pyop_val in pyop_attrdict.iteritems():
|
|
|
|
if not first:
|
|
|
|
out.write(', ')
|
|
|
|
first = False
|
|
|
|
out.write(pyop_arg.proxyval(visited))
|
|
|
|
out.write('=')
|
|
|
|
pyop_val.write_repr(out, visited)
|
|
|
|
out.write(')')
|
|
|
|
out.write(' at remote 0x%x>' % address)
|
|
|
|
|
|
|
|
|
|
|
|
class InstanceProxy(object):
|
|
|
|
|
|
|
|
def __init__(self, cl_name, attrdict, address):
|
|
|
|
self.cl_name = cl_name
|
|
|
|
self.attrdict = attrdict
|
|
|
|
self.address = address
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
if isinstance(self.attrdict, dict):
|
|
|
|
kwargs = ', '.join(["%s=%r" % (arg, val)
|
2020-12-24 18:16:04 +01:00
|
|
|
for arg, val in self.attrdict.items()])
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return '<%s(%s) at remote 0x%x>' % (self.cl_name,
|
|
|
|
kwargs, self.address)
|
|
|
|
else:
|
|
|
|
return '<%s at remote 0x%x>' % (self.cl_name,
|
|
|
|
self.address)
|
|
|
|
|
|
|
|
def _PyObject_VAR_SIZE(typeobj, nitems):
|
2011-12-19 13:42:24 +01:00
|
|
|
if _PyObject_VAR_SIZE._type_size_t is None:
|
|
|
|
_PyObject_VAR_SIZE._type_size_t = gdb.lookup_type('size_t')
|
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return ( ( typeobj.field('tp_basicsize') +
|
|
|
|
nitems * typeobj.field('tp_itemsize') +
|
2016-04-20 18:07:21 +02:00
|
|
|
(_sizeof_void_p() - 1)
|
|
|
|
) & ~(_sizeof_void_p() - 1)
|
2011-12-19 13:42:24 +01:00
|
|
|
).cast(_PyObject_VAR_SIZE._type_size_t)
|
|
|
|
_PyObject_VAR_SIZE._type_size_t = None
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
class HeapTypeObjectPtr(PyObjectPtr):
|
|
|
|
_typename = 'PyObject'
|
|
|
|
|
|
|
|
def get_attr_dict(self):
|
|
|
|
'''
|
|
|
|
Get the PyDictObject ptr representing the attribute dictionary
|
|
|
|
(or None if there's a problem)
|
|
|
|
'''
|
|
|
|
try:
|
|
|
|
typeobj = self.type()
|
|
|
|
dictoffset = int_from_int(typeobj.field('tp_dictoffset'))
|
|
|
|
if dictoffset != 0:
|
|
|
|
if dictoffset < 0:
|
|
|
|
type_PyVarObject_ptr = gdb.lookup_type('PyVarObject').pointer()
|
|
|
|
tsize = int_from_int(self._gdbval.cast(type_PyVarObject_ptr)['ob_size'])
|
|
|
|
if tsize < 0:
|
|
|
|
tsize = -tsize
|
|
|
|
size = _PyObject_VAR_SIZE(typeobj, tsize)
|
|
|
|
dictoffset += size
|
|
|
|
assert dictoffset > 0
|
2016-04-20 18:07:21 +02:00
|
|
|
assert dictoffset % _sizeof_void_p() == 0
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
2016-04-20 18:07:21 +02:00
|
|
|
dictptr = self._gdbval.cast(_type_char_ptr()) + dictoffset
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
PyObjectPtrPtr = PyObjectPtr.get_gdb_type().pointer()
|
|
|
|
dictptr = dictptr.cast(PyObjectPtrPtr)
|
|
|
|
return PyObjectPtr.from_pyobject_ptr(dictptr.dereference())
|
|
|
|
except RuntimeError:
|
|
|
|
# Corrupt data somewhere; fail safe
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Not found, or some kind of error:
|
|
|
|
return None
|
|
|
|
|
|
|
|
def proxyval(self, visited):
|
|
|
|
'''
|
2011-12-12 18:54:29 +01:00
|
|
|
Support for classes.
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
Currently we just locate the dictionary using a transliteration to
|
|
|
|
python of _PyObject_GetDictPtr, ignoring descriptors
|
|
|
|
'''
|
|
|
|
# Guard against infinite loops:
|
|
|
|
if self.as_address() in visited:
|
|
|
|
return ProxyAlreadyVisited('<...>')
|
|
|
|
visited.add(self.as_address())
|
|
|
|
|
|
|
|
pyop_attr_dict = self.get_attr_dict()
|
|
|
|
if pyop_attr_dict:
|
|
|
|
attr_dict = pyop_attr_dict.proxyval(visited)
|
|
|
|
else:
|
|
|
|
attr_dict = {}
|
|
|
|
tp_name = self.safe_tp_name()
|
|
|
|
|
2011-12-12 18:54:29 +01:00
|
|
|
# Class:
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return InstanceProxy(tp_name, attr_dict, long(self._gdbval))
|
|
|
|
|
|
|
|
def write_repr(self, out, visited):
|
|
|
|
# Guard against infinite loops:
|
|
|
|
if self.as_address() in visited:
|
|
|
|
out.write('<...>')
|
|
|
|
return
|
|
|
|
visited.add(self.as_address())
|
|
|
|
|
|
|
|
pyop_attrdict = self.get_attr_dict()
|
|
|
|
_write_instance_repr(out, visited,
|
|
|
|
self.safe_tp_name(), pyop_attrdict, self.as_address())
|
|
|
|
|
|
|
|
class ProxyException(Exception):
|
|
|
|
def __init__(self, tp_name, args):
|
|
|
|
self.tp_name = tp_name
|
|
|
|
self.args = args
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return '%s%r' % (self.tp_name, self.args)
|
|
|
|
|
|
|
|
class PyBaseExceptionObjectPtr(PyObjectPtr):
|
|
|
|
"""
|
|
|
|
Class wrapping a gdb.Value that's a PyBaseExceptionObject* i.e. an exception
|
|
|
|
within the process being debugged.
|
|
|
|
"""
|
|
|
|
_typename = 'PyBaseExceptionObject'
|
|
|
|
|
|
|
|
def proxyval(self, visited):
|
|
|
|
# Guard against infinite loops:
|
|
|
|
if self.as_address() in visited:
|
|
|
|
return ProxyAlreadyVisited('(...)')
|
|
|
|
visited.add(self.as_address())
|
|
|
|
arg_proxy = self.pyop_field('args').proxyval(visited)
|
|
|
|
return ProxyException(self.safe_tp_name(),
|
|
|
|
arg_proxy)
|
|
|
|
|
|
|
|
def write_repr(self, out, visited):
|
|
|
|
# Guard against infinite loops:
|
|
|
|
if self.as_address() in visited:
|
|
|
|
out.write('(...)')
|
|
|
|
return
|
|
|
|
visited.add(self.as_address())
|
|
|
|
|
|
|
|
out.write(self.safe_tp_name())
|
|
|
|
self.write_field_repr('args', out, visited)
|
|
|
|
|
|
|
|
class PyClassObjectPtr(PyObjectPtr):
|
|
|
|
"""
|
|
|
|
Class wrapping a gdb.Value that's a PyClassObject* i.e. a <classobj>
|
|
|
|
instance within the process being debugged.
|
|
|
|
"""
|
|
|
|
_typename = 'PyClassObject'
|
|
|
|
|
|
|
|
|
|
|
|
class BuiltInFunctionProxy(object):
|
|
|
|
def __init__(self, ml_name):
|
|
|
|
self.ml_name = ml_name
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return "<built-in function %s>" % self.ml_name
|
|
|
|
|
|
|
|
class BuiltInMethodProxy(object):
|
|
|
|
def __init__(self, ml_name, pyop_m_self):
|
|
|
|
self.ml_name = ml_name
|
|
|
|
self.pyop_m_self = pyop_m_self
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return ('<built-in method %s of %s object at remote 0x%x>'
|
|
|
|
% (self.ml_name,
|
|
|
|
self.pyop_m_self.safe_tp_name(),
|
|
|
|
self.pyop_m_self.as_address())
|
|
|
|
)
|
|
|
|
|
|
|
|
class PyCFunctionObjectPtr(PyObjectPtr):
|
|
|
|
"""
|
|
|
|
Class wrapping a gdb.Value that's a PyCFunctionObject*
|
|
|
|
(see Include/methodobject.h and Objects/methodobject.c)
|
|
|
|
"""
|
|
|
|
_typename = 'PyCFunctionObject'
|
|
|
|
|
|
|
|
def proxyval(self, visited):
|
|
|
|
m_ml = self.field('m_ml') # m_ml is a (PyMethodDef*)
|
2018-06-14 22:34:52 +02:00
|
|
|
try:
|
|
|
|
ml_name = m_ml['ml_name'].string()
|
|
|
|
except UnicodeDecodeError:
|
|
|
|
ml_name = '<ml_name:UnicodeDecodeError>'
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
pyop_m_self = self.pyop_field('m_self')
|
|
|
|
if pyop_m_self.is_null():
|
|
|
|
return BuiltInFunctionProxy(ml_name)
|
|
|
|
else:
|
|
|
|
return BuiltInMethodProxy(ml_name, pyop_m_self)
|
|
|
|
|
|
|
|
|
|
|
|
class PyCodeObjectPtr(PyObjectPtr):
|
|
|
|
"""
|
|
|
|
Class wrapping a gdb.Value that's a PyCodeObject* i.e. a <code> instance
|
|
|
|
within the process being debugged.
|
|
|
|
"""
|
|
|
|
_typename = 'PyCodeObject'
|
|
|
|
|
|
|
|
def addr2line(self, addrq):
|
|
|
|
'''
|
|
|
|
Get the line number for a given bytecode offset
|
|
|
|
|
|
|
|
Analogous to PyCode_Addr2Line; translated from pseudocode in
|
|
|
|
Objects/lnotab_notes.txt
|
|
|
|
'''
|
2020-11-12 09:43:29 +00:00
|
|
|
co_linetable = self.pyop_field('co_linetable').proxyval(set())
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
# Initialize lineno to co_firstlineno as per PyCode_Addr2Line
|
|
|
|
# not 0, as lnotab_notes.txt has it:
|
|
|
|
lineno = int_from_int(self.field('co_firstlineno'))
|
|
|
|
|
2020-11-12 09:43:29 +00:00
|
|
|
if addrq < 0:
|
|
|
|
return lineno
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
addr = 0
|
2020-11-12 09:43:29 +00:00
|
|
|
for addr_incr, line_incr in zip(co_linetable[::2], co_linetable[1::2]):
|
|
|
|
if addr_incr == 255:
|
|
|
|
break
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
addr += ord(addr_incr)
|
2020-11-12 09:43:29 +00:00
|
|
|
line_delta = ord(line_incr)
|
|
|
|
if line_delta == 128:
|
|
|
|
line_delta = 0
|
|
|
|
elif line_delta > 128:
|
|
|
|
line_delta -= 256
|
|
|
|
lineno += line_delta
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
if addr > addrq:
|
|
|
|
return lineno
|
2020-11-12 09:43:29 +00:00
|
|
|
assert False, "Unreachable"
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
class PyDictObjectPtr(PyObjectPtr):
|
|
|
|
"""
|
|
|
|
Class wrapping a gdb.Value that's a PyDictObject* i.e. a dict instance
|
|
|
|
within the process being debugged.
|
|
|
|
"""
|
|
|
|
_typename = 'PyDictObject'
|
|
|
|
|
|
|
|
def iteritems(self):
|
|
|
|
'''
|
|
|
|
Yields a sequence of (PyObjectPtr key, PyObjectPtr value) pairs,
|
2013-08-26 01:32:56 +03:00
|
|
|
analogous to dict.iteritems()
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
'''
|
2012-04-23 11:24:50 -04:00
|
|
|
keys = self.field('ma_keys')
|
|
|
|
values = self.field('ma_values')
|
2016-11-22 19:40:58 +09:00
|
|
|
entries, nentries = self._get_entries(keys)
|
|
|
|
for i in safe_range(nentries):
|
|
|
|
ep = entries[i]
|
2012-04-23 11:24:50 -04:00
|
|
|
if long(values):
|
|
|
|
pyop_value = PyObjectPtr.from_pyobject_ptr(values[i])
|
|
|
|
else:
|
|
|
|
pyop_value = PyObjectPtr.from_pyobject_ptr(ep['me_value'])
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
if not pyop_value.is_null():
|
|
|
|
pyop_key = PyObjectPtr.from_pyobject_ptr(ep['me_key'])
|
|
|
|
yield (pyop_key, pyop_value)
|
|
|
|
|
|
|
|
def proxyval(self, visited):
|
|
|
|
# Guard against infinite loops:
|
|
|
|
if self.as_address() in visited:
|
|
|
|
return ProxyAlreadyVisited('{...}')
|
|
|
|
visited.add(self.as_address())
|
|
|
|
|
|
|
|
result = {}
|
|
|
|
for pyop_key, pyop_value in self.iteritems():
|
|
|
|
proxy_key = pyop_key.proxyval(visited)
|
|
|
|
proxy_value = pyop_value.proxyval(visited)
|
|
|
|
result[proxy_key] = proxy_value
|
|
|
|
return result
|
|
|
|
|
|
|
|
def write_repr(self, out, visited):
|
|
|
|
# Guard against infinite loops:
|
|
|
|
if self.as_address() in visited:
|
|
|
|
out.write('{...}')
|
|
|
|
return
|
|
|
|
visited.add(self.as_address())
|
|
|
|
|
|
|
|
out.write('{')
|
|
|
|
first = True
|
|
|
|
for pyop_key, pyop_value in self.iteritems():
|
|
|
|
if not first:
|
|
|
|
out.write(', ')
|
|
|
|
first = False
|
|
|
|
pyop_key.write_repr(out, visited)
|
|
|
|
out.write(': ')
|
|
|
|
pyop_value.write_repr(out, visited)
|
|
|
|
out.write('}')
|
|
|
|
|
2016-11-22 19:40:58 +09:00
|
|
|
def _get_entries(self, keys):
|
2016-11-22 13:09:39 +01:00
|
|
|
dk_nentries = int(keys['dk_nentries'])
|
2021-05-28 09:54:10 +01:00
|
|
|
dk_size = 1<<int(keys['dk_log2_size'])
|
2016-11-22 19:40:58 +09:00
|
|
|
try:
|
|
|
|
# <= Python 3.5
|
|
|
|
return keys['dk_entries'], dk_size
|
2017-03-01 13:16:23 -05:00
|
|
|
except RuntimeError:
|
2016-11-22 19:40:58 +09:00
|
|
|
# >= Python 3.6
|
|
|
|
pass
|
|
|
|
|
|
|
|
if dk_size <= 0xFF:
|
|
|
|
offset = dk_size
|
|
|
|
elif dk_size <= 0xFFFF:
|
|
|
|
offset = 2 * dk_size
|
|
|
|
elif dk_size <= 0xFFFFFFFF:
|
|
|
|
offset = 4 * dk_size
|
|
|
|
else:
|
|
|
|
offset = 8 * dk_size
|
|
|
|
|
2018-04-20 11:32:08 -07:00
|
|
|
ent_addr = keys['dk_indices'].address
|
2016-11-22 13:09:39 +01:00
|
|
|
ent_addr = ent_addr.cast(_type_unsigned_char_ptr()) + offset
|
2016-11-22 19:40:58 +09:00
|
|
|
ent_ptr_t = gdb.lookup_type('PyDictKeyEntry').pointer()
|
2016-11-22 13:09:39 +01:00
|
|
|
ent_addr = ent_addr.cast(ent_ptr_t)
|
|
|
|
|
|
|
|
return ent_addr, dk_nentries
|
2016-11-22 19:40:58 +09:00
|
|
|
|
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
class PyListObjectPtr(PyObjectPtr):
|
|
|
|
_typename = 'PyListObject'
|
|
|
|
|
|
|
|
def __getitem__(self, i):
|
|
|
|
# Get the gdb.Value for the (PyObject*) with the given index:
|
|
|
|
field_ob_item = self.field('ob_item')
|
|
|
|
return field_ob_item[i]
|
|
|
|
|
|
|
|
def proxyval(self, visited):
|
|
|
|
# Guard against infinite loops:
|
|
|
|
if self.as_address() in visited:
|
|
|
|
return ProxyAlreadyVisited('[...]')
|
|
|
|
visited.add(self.as_address())
|
|
|
|
|
|
|
|
result = [PyObjectPtr.from_pyobject_ptr(self[i]).proxyval(visited)
|
|
|
|
for i in safe_range(int_from_int(self.field('ob_size')))]
|
|
|
|
return result
|
|
|
|
|
|
|
|
def write_repr(self, out, visited):
|
|
|
|
# Guard against infinite loops:
|
|
|
|
if self.as_address() in visited:
|
|
|
|
out.write('[...]')
|
|
|
|
return
|
|
|
|
visited.add(self.as_address())
|
|
|
|
|
|
|
|
out.write('[')
|
|
|
|
for i in safe_range(int_from_int(self.field('ob_size'))):
|
|
|
|
if i > 0:
|
|
|
|
out.write(', ')
|
|
|
|
element = PyObjectPtr.from_pyobject_ptr(self[i])
|
|
|
|
element.write_repr(out, visited)
|
|
|
|
out.write(']')
|
|
|
|
|
|
|
|
class PyLongObjectPtr(PyObjectPtr):
|
|
|
|
_typename = 'PyLongObject'
|
|
|
|
|
|
|
|
def proxyval(self, visited):
|
|
|
|
'''
|
|
|
|
Python's Include/longobjrep.h has this declaration:
|
|
|
|
struct _longobject {
|
|
|
|
PyObject_VAR_HEAD
|
|
|
|
digit ob_digit[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
with this description:
|
|
|
|
The absolute value of a number is equal to
|
|
|
|
SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i)
|
|
|
|
Negative numbers are represented with ob_size < 0;
|
|
|
|
zero is represented by ob_size == 0.
|
|
|
|
|
|
|
|
where SHIFT can be either:
|
|
|
|
#define PyLong_SHIFT 30
|
|
|
|
#define PyLong_SHIFT 15
|
|
|
|
'''
|
|
|
|
ob_size = long(self.field('ob_size'))
|
|
|
|
if ob_size == 0:
|
2013-11-23 17:40:36 +01:00
|
|
|
return 0
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
ob_digit = self.field('ob_digit')
|
|
|
|
|
|
|
|
if gdb.lookup_type('digit').sizeof == 2:
|
2013-11-23 17:40:36 +01:00
|
|
|
SHIFT = 15
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
else:
|
2013-11-23 17:40:36 +01:00
|
|
|
SHIFT = 30
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
digits = [long(ob_digit[i]) * 2**(SHIFT*i)
|
|
|
|
for i in safe_range(abs(ob_size))]
|
|
|
|
result = sum(digits)
|
|
|
|
if ob_size < 0:
|
|
|
|
result = -result
|
|
|
|
return result
|
|
|
|
|
2010-04-21 22:38:42 +00:00
|
|
|
def write_repr(self, out, visited):
|
|
|
|
# Write this out as a Python 3 int literal, i.e. without the "L" suffix
|
|
|
|
proxy = self.proxyval(visited)
|
|
|
|
out.write("%s" % proxy)
|
|
|
|
|
|
|
|
|
|
|
|
class PyBoolObjectPtr(PyLongObjectPtr):
|
|
|
|
"""
|
|
|
|
Class wrapping a gdb.Value that's a PyBoolObject* i.e. one of the two
|
|
|
|
<bool> instances (Py_True/Py_False) within the process being debugged.
|
|
|
|
"""
|
|
|
|
def proxyval(self, visited):
|
|
|
|
if PyLongObjectPtr.proxyval(self, visited):
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
class PyNoneStructPtr(PyObjectPtr):
|
|
|
|
"""
|
|
|
|
Class wrapping a gdb.Value that's a PyObject* pointing to the
|
|
|
|
singleton (we hope) _Py_NoneStruct with ob_type PyNone_Type
|
|
|
|
"""
|
|
|
|
_typename = 'PyObject'
|
|
|
|
|
|
|
|
def proxyval(self, visited):
|
|
|
|
return None
|
|
|
|
|
2021-05-21 10:57:35 +01:00
|
|
|
FRAME_SPECIALS_GLOBAL_OFFSET = 0
|
|
|
|
FRAME_SPECIALS_BUILTINS_OFFSET = 1
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
class PyFrameObjectPtr(PyObjectPtr):
|
|
|
|
_typename = 'PyFrameObject'
|
|
|
|
|
2011-12-19 13:42:24 +01:00
|
|
|
def __init__(self, gdbval, cast_to=None):
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
PyObjectPtr.__init__(self, gdbval, cast_to)
|
|
|
|
|
|
|
|
if not self.is_optimized_out():
|
|
|
|
self.co = PyCodeObjectPtr.from_pyobject_ptr(self.field('f_code'))
|
|
|
|
self.co_name = self.co.pyop_field('co_name')
|
|
|
|
self.co_filename = self.co.pyop_field('co_filename')
|
|
|
|
|
|
|
|
self.f_lineno = int_from_int(self.field('f_lineno'))
|
|
|
|
self.f_lasti = int_from_int(self.field('f_lasti'))
|
|
|
|
self.co_nlocals = int_from_int(self.co.field('co_nlocals'))
|
bpo-43693: Add new internal code objects fields: co_fastlocalnames and co_fastlocalkinds. (gh-26388)
A number of places in the code base (notably ceval.c and frameobject.c) rely on mapping variable names to indices in the frame "locals plus" array (AKA fast locals), and thus opargs. Currently the compiler indirectly encodes that information on the code object as the tuples co_varnames, co_cellvars, and co_freevars. At runtime the dependent code must calculate the proper mapping from those, which isn't ideal and impacts performance-sensitive sections. This is something we can easily address in the compiler instead.
This change addresses the situation by replacing internal use of co_varnames, etc. with a single combined tuple of names in locals-plus order, along with a minimal array mapping each to its kind (local vs. cell vs. free). These two new PyCodeObject fields, co_fastlocalnames and co_fastllocalkinds, are not exposed to Python code for now, but co_varnames, etc. are still available with the same values as before (though computed lazily).
Aside from the (mild) performance impact, there are a number of other benefits:
* there's now a clear, direct relationship between locals-plus and variables
* code that relies on the locals-plus-to-name mapping is simpler
* marshaled code objects are smaller and serialize/de-serialize faster
Also note that we can take this approach further by expanding the possible values in co_fastlocalkinds to include specific argument types (e.g. positional-only, kwargs). Doing so would allow further speed-ups in _PyEval_MakeFrameVector(), which is where args get unpacked into the locals-plus array. It would also allow us to shrink marshaled code objects even further.
https://bugs.python.org/issue43693
2021-06-03 10:28:27 -06:00
|
|
|
pnames = self.co.field('co_localsplusnames')
|
|
|
|
self.co_localsplusnames = PyTupleObjectPtr.from_pyobject_ptr(pnames)
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
def iter_locals(self):
|
|
|
|
'''
|
|
|
|
Yield a sequence of (name,value) pairs of PyObjectPtr instances, for
|
|
|
|
the local variables of this frame
|
|
|
|
'''
|
|
|
|
if self.is_optimized_out():
|
|
|
|
return
|
|
|
|
|
2021-05-21 10:57:35 +01:00
|
|
|
f_localsplus = self.field('f_localsptr')
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
for i in safe_range(self.co_nlocals):
|
|
|
|
pyop_value = PyObjectPtr.from_pyobject_ptr(f_localsplus[i])
|
bpo-43693: Add new internal code objects fields: co_fastlocalnames and co_fastlocalkinds. (gh-26388)
A number of places in the code base (notably ceval.c and frameobject.c) rely on mapping variable names to indices in the frame "locals plus" array (AKA fast locals), and thus opargs. Currently the compiler indirectly encodes that information on the code object as the tuples co_varnames, co_cellvars, and co_freevars. At runtime the dependent code must calculate the proper mapping from those, which isn't ideal and impacts performance-sensitive sections. This is something we can easily address in the compiler instead.
This change addresses the situation by replacing internal use of co_varnames, etc. with a single combined tuple of names in locals-plus order, along with a minimal array mapping each to its kind (local vs. cell vs. free). These two new PyCodeObject fields, co_fastlocalnames and co_fastllocalkinds, are not exposed to Python code for now, but co_varnames, etc. are still available with the same values as before (though computed lazily).
Aside from the (mild) performance impact, there are a number of other benefits:
* there's now a clear, direct relationship between locals-plus and variables
* code that relies on the locals-plus-to-name mapping is simpler
* marshaled code objects are smaller and serialize/de-serialize faster
Also note that we can take this approach further by expanding the possible values in co_fastlocalkinds to include specific argument types (e.g. positional-only, kwargs). Doing so would allow further speed-ups in _PyEval_MakeFrameVector(), which is where args get unpacked into the locals-plus array. It would also allow us to shrink marshaled code objects even further.
https://bugs.python.org/issue43693
2021-06-03 10:28:27 -06:00
|
|
|
if pyop_value.is_null():
|
|
|
|
continue
|
|
|
|
pyop_name = PyObjectPtr.from_pyobject_ptr(self.co_localsplusnames[i])
|
|
|
|
yield (pyop_name, pyop_value)
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
2021-05-21 10:57:35 +01:00
|
|
|
def _f_globals(self):
|
|
|
|
f_localsplus = self.field('f_localsptr')
|
|
|
|
nlocalsplus = int_from_int(self.co.field('co_nlocalsplus'))
|
|
|
|
index = nlocalsplus + FRAME_SPECIALS_GLOBAL_OFFSET
|
|
|
|
return PyObjectPtr.from_pyobject_ptr(f_localsplus[index])
|
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
def iter_globals(self):
|
|
|
|
'''
|
|
|
|
Yield a sequence of (name,value) pairs of PyObjectPtr instances, for
|
|
|
|
the global variables of this frame
|
|
|
|
'''
|
|
|
|
if self.is_optimized_out():
|
2011-12-19 13:42:24 +01:00
|
|
|
return ()
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
2021-05-21 10:57:35 +01:00
|
|
|
pyop_globals = self._f_globals()
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return pyop_globals.iteritems()
|
|
|
|
|
2021-05-21 10:57:35 +01:00
|
|
|
def _f_builtins(self):
|
|
|
|
f_localsplus = self.field('f_localsptr')
|
|
|
|
nlocalsplus = int_from_int(self.co.field('co_nlocalsplus'))
|
|
|
|
index = nlocalsplus + FRAME_SPECIALS_BUILTINS_OFFSET
|
|
|
|
return PyObjectPtr.from_pyobject_ptr(f_localsplus[index])
|
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
def iter_builtins(self):
|
|
|
|
'''
|
|
|
|
Yield a sequence of (name,value) pairs of PyObjectPtr instances, for
|
|
|
|
the builtin variables
|
|
|
|
'''
|
|
|
|
if self.is_optimized_out():
|
2011-12-19 13:42:24 +01:00
|
|
|
return ()
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
2021-05-21 10:57:35 +01:00
|
|
|
pyop_builtins = self._f_builtins()
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return pyop_builtins.iteritems()
|
|
|
|
|
|
|
|
def get_var_by_name(self, name):
|
|
|
|
'''
|
|
|
|
Look for the named local variable, returning a (PyObjectPtr, scope) pair
|
|
|
|
where scope is a string 'local', 'global', 'builtin'
|
|
|
|
|
|
|
|
If not found, return (None, None)
|
|
|
|
'''
|
|
|
|
for pyop_name, pyop_value in self.iter_locals():
|
|
|
|
if name == pyop_name.proxyval(set()):
|
|
|
|
return pyop_value, 'local'
|
|
|
|
for pyop_name, pyop_value in self.iter_globals():
|
|
|
|
if name == pyop_name.proxyval(set()):
|
|
|
|
return pyop_value, 'global'
|
|
|
|
for pyop_name, pyop_value in self.iter_builtins():
|
|
|
|
if name == pyop_name.proxyval(set()):
|
|
|
|
return pyop_value, 'builtin'
|
|
|
|
return None, None
|
|
|
|
|
|
|
|
def filename(self):
|
|
|
|
'''Get the path of the current Python source file, as a string'''
|
|
|
|
if self.is_optimized_out():
|
2020-03-20 08:23:26 +01:00
|
|
|
return FRAME_INFO_OPTIMIZED_OUT
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return self.co_filename.proxyval(set())
|
|
|
|
|
|
|
|
def current_line_num(self):
|
|
|
|
'''Get current line number as an integer (1-based)
|
|
|
|
|
|
|
|
Translated from PyFrame_GetLineNumber and PyCode_Addr2Line
|
|
|
|
|
|
|
|
See Objects/lnotab_notes.txt
|
|
|
|
'''
|
|
|
|
if self.is_optimized_out():
|
|
|
|
return None
|
|
|
|
f_trace = self.field('f_trace')
|
|
|
|
if long(f_trace) != 0:
|
|
|
|
# we have a non-NULL f_trace:
|
|
|
|
return self.f_lineno
|
2018-10-15 23:19:57 +02:00
|
|
|
|
|
|
|
try:
|
2021-04-01 16:00:31 +01:00
|
|
|
return self.co.addr2line(self.f_lasti*2)
|
2018-10-15 23:19:57 +02:00
|
|
|
except Exception:
|
|
|
|
# bpo-34989: addr2line() is a complex function, it can fail in many
|
|
|
|
# ways. For example, it fails with a TypeError on "FakeRepr" if
|
|
|
|
# gdb fails to load debug symbols. Use a catch-all "except
|
|
|
|
# Exception" to make the whole function safe. The caller has to
|
|
|
|
# handle None anyway for optimized Python.
|
|
|
|
return None
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
def current_line(self):
|
|
|
|
'''Get the text of the current source line as a string, with a trailing
|
|
|
|
newline character'''
|
|
|
|
if self.is_optimized_out():
|
2020-03-20 08:23:26 +01:00
|
|
|
return FRAME_INFO_OPTIMIZED_OUT
|
2018-10-15 23:19:57 +02:00
|
|
|
|
|
|
|
lineno = self.current_line_num()
|
|
|
|
if lineno is None:
|
|
|
|
return '(failed to get frame line number)'
|
|
|
|
|
2010-10-17 19:35:30 +00:00
|
|
|
filename = self.filename()
|
2011-07-01 12:57:44 +02:00
|
|
|
try:
|
2018-10-15 23:19:57 +02:00
|
|
|
with open(os_fsencode(filename), 'r') as fp:
|
|
|
|
lines = fp.readlines()
|
2011-07-01 12:57:44 +02:00
|
|
|
except IOError:
|
|
|
|
return None
|
2018-10-15 23:19:57 +02:00
|
|
|
|
|
|
|
try:
|
|
|
|
# Convert from 1-based current_line_num to 0-based list offset
|
|
|
|
return lines[lineno - 1]
|
|
|
|
except IndexError:
|
|
|
|
return None
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
def write_repr(self, out, visited):
|
|
|
|
if self.is_optimized_out():
|
2020-03-20 08:23:26 +01:00
|
|
|
out.write(FRAME_INFO_OPTIMIZED_OUT)
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return
|
2018-10-15 23:19:57 +02:00
|
|
|
lineno = self.current_line_num()
|
|
|
|
lineno = str(lineno) if lineno is not None else "?"
|
|
|
|
out.write('Frame 0x%x, for file %s, line %s, in %s ('
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
% (self.as_address(),
|
2010-04-21 22:38:42 +00:00
|
|
|
self.co_filename.proxyval(visited),
|
2018-10-15 23:19:57 +02:00
|
|
|
lineno,
|
2010-04-21 22:38:42 +00:00
|
|
|
self.co_name.proxyval(visited)))
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
first = True
|
|
|
|
for pyop_name, pyop_value in self.iter_locals():
|
|
|
|
if not first:
|
|
|
|
out.write(', ')
|
|
|
|
first = False
|
|
|
|
|
|
|
|
out.write(pyop_name.proxyval(visited))
|
|
|
|
out.write('=')
|
|
|
|
pyop_value.write_repr(out, visited)
|
|
|
|
|
|
|
|
out.write(')')
|
|
|
|
|
2011-05-13 17:40:15 +02:00
|
|
|
def print_traceback(self):
|
|
|
|
if self.is_optimized_out():
|
2020-03-20 08:23:26 +01:00
|
|
|
sys.stdout.write(' %s\n' % FRAME_INFO_OPTIMIZED_OUT)
|
2011-12-19 13:42:24 +01:00
|
|
|
return
|
2011-05-13 17:40:15 +02:00
|
|
|
visited = set()
|
2018-10-15 23:19:57 +02:00
|
|
|
lineno = self.current_line_num()
|
|
|
|
lineno = str(lineno) if lineno is not None else "?"
|
|
|
|
sys.stdout.write(' File "%s", line %s, in %s\n'
|
2011-05-13 17:40:15 +02:00
|
|
|
% (self.co_filename.proxyval(visited),
|
2018-10-15 23:19:57 +02:00
|
|
|
lineno,
|
2011-05-13 17:40:15 +02:00
|
|
|
self.co_name.proxyval(visited)))
|
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
class PySetObjectPtr(PyObjectPtr):
|
|
|
|
_typename = 'PySetObject'
|
|
|
|
|
2013-08-24 21:07:07 +02:00
|
|
|
@classmethod
|
|
|
|
def _dummy_key(self):
|
|
|
|
return gdb.lookup_global_symbol('_PySet_Dummy').value()
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
dummy_ptr = self._dummy_key()
|
|
|
|
table = self.field('table')
|
|
|
|
for i in safe_range(self.field('mask') + 1):
|
|
|
|
setentry = table[i]
|
|
|
|
key = setentry['key']
|
|
|
|
if key != 0 and key != dummy_ptr:
|
|
|
|
yield PyObjectPtr.from_pyobject_ptr(key)
|
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
def proxyval(self, visited):
|
|
|
|
# Guard against infinite loops:
|
|
|
|
if self.as_address() in visited:
|
|
|
|
return ProxyAlreadyVisited('%s(...)' % self.safe_tp_name())
|
|
|
|
visited.add(self.as_address())
|
|
|
|
|
2013-08-24 21:07:07 +02:00
|
|
|
members = (key.proxyval(visited) for key in self)
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
if self.safe_tp_name() == 'frozenset':
|
|
|
|
return frozenset(members)
|
|
|
|
else:
|
|
|
|
return set(members)
|
|
|
|
|
|
|
|
def write_repr(self, out, visited):
|
2010-04-21 22:38:42 +00:00
|
|
|
# Emulate Python 3's set_repr
|
|
|
|
tp_name = self.safe_tp_name()
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
# Guard against infinite loops:
|
|
|
|
if self.as_address() in visited:
|
|
|
|
out.write('(...)')
|
|
|
|
return
|
|
|
|
visited.add(self.as_address())
|
|
|
|
|
2010-04-21 22:38:42 +00:00
|
|
|
# Python 3's set_repr special-cases the empty set:
|
|
|
|
if not self.field('used'):
|
|
|
|
out.write(tp_name)
|
|
|
|
out.write('()')
|
|
|
|
return
|
|
|
|
|
|
|
|
# Python 3 uses {} for set literals:
|
|
|
|
if tp_name != 'set':
|
|
|
|
out.write(tp_name)
|
|
|
|
out.write('(')
|
|
|
|
|
|
|
|
out.write('{')
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
first = True
|
2013-08-24 21:07:07 +02:00
|
|
|
for key in self:
|
|
|
|
if not first:
|
|
|
|
out.write(', ')
|
|
|
|
first = False
|
|
|
|
key.write_repr(out, visited)
|
2010-04-21 22:38:42 +00:00
|
|
|
out.write('}')
|
|
|
|
|
|
|
|
if tp_name != 'set':
|
|
|
|
out.write(')')
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
|
2010-04-21 13:53:05 +00:00
|
|
|
class PyBytesObjectPtr(PyObjectPtr):
|
|
|
|
_typename = 'PyBytesObject'
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
field_ob_size = self.field('ob_size')
|
|
|
|
field_ob_sval = self.field('ob_sval')
|
2016-04-20 18:07:21 +02:00
|
|
|
char_ptr = field_ob_sval.address.cast(_type_unsigned_char_ptr())
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return ''.join([chr(char_ptr[i]) for i in safe_range(field_ob_size)])
|
|
|
|
|
|
|
|
def proxyval(self, visited):
|
|
|
|
return str(self)
|
|
|
|
|
2010-04-21 22:38:42 +00:00
|
|
|
def write_repr(self, out, visited):
|
|
|
|
# Write this out as a Python 3 bytes literal, i.e. with a "b" prefix
|
|
|
|
|
|
|
|
# Get a PyStringObject* within the Python 2 gdb process:
|
|
|
|
proxy = self.proxyval(visited)
|
|
|
|
|
|
|
|
# Transliteration of Python 3's Objects/bytesobject.c:PyBytes_Repr
|
|
|
|
# to Python 2 code:
|
|
|
|
quote = "'"
|
|
|
|
if "'" in proxy and not '"' in proxy:
|
|
|
|
quote = '"'
|
|
|
|
out.write('b')
|
|
|
|
out.write(quote)
|
|
|
|
for byte in proxy:
|
|
|
|
if byte == quote or byte == '\\':
|
|
|
|
out.write('\\')
|
|
|
|
out.write(byte)
|
|
|
|
elif byte == '\t':
|
|
|
|
out.write('\\t')
|
|
|
|
elif byte == '\n':
|
|
|
|
out.write('\\n')
|
|
|
|
elif byte == '\r':
|
|
|
|
out.write('\\r')
|
|
|
|
elif byte < ' ' or ord(byte) >= 0x7f:
|
|
|
|
out.write('\\x')
|
|
|
|
out.write(hexdigits[(ord(byte) & 0xf0) >> 4])
|
|
|
|
out.write(hexdigits[ord(byte) & 0xf])
|
|
|
|
else:
|
|
|
|
out.write(byte)
|
|
|
|
out.write(quote)
|
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
class PyTupleObjectPtr(PyObjectPtr):
|
|
|
|
_typename = 'PyTupleObject'
|
|
|
|
|
|
|
|
def __getitem__(self, i):
|
|
|
|
# Get the gdb.Value for the (PyObject*) with the given index:
|
|
|
|
field_ob_item = self.field('ob_item')
|
|
|
|
return field_ob_item[i]
|
|
|
|
|
|
|
|
def proxyval(self, visited):
|
|
|
|
# Guard against infinite loops:
|
|
|
|
if self.as_address() in visited:
|
|
|
|
return ProxyAlreadyVisited('(...)')
|
|
|
|
visited.add(self.as_address())
|
|
|
|
|
2017-05-18 07:35:54 -07:00
|
|
|
result = tuple(PyObjectPtr.from_pyobject_ptr(self[i]).proxyval(visited)
|
|
|
|
for i in safe_range(int_from_int(self.field('ob_size'))))
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return result
|
|
|
|
|
|
|
|
def write_repr(self, out, visited):
|
|
|
|
# Guard against infinite loops:
|
|
|
|
if self.as_address() in visited:
|
|
|
|
out.write('(...)')
|
|
|
|
return
|
|
|
|
visited.add(self.as_address())
|
|
|
|
|
|
|
|
out.write('(')
|
|
|
|
for i in safe_range(int_from_int(self.field('ob_size'))):
|
|
|
|
if i > 0:
|
|
|
|
out.write(', ')
|
|
|
|
element = PyObjectPtr.from_pyobject_ptr(self[i])
|
|
|
|
element.write_repr(out, visited)
|
|
|
|
if self.field('ob_size') == 1:
|
|
|
|
out.write(',)')
|
|
|
|
else:
|
|
|
|
out.write(')')
|
|
|
|
|
|
|
|
class PyTypeObjectPtr(PyObjectPtr):
|
|
|
|
_typename = 'PyTypeObject'
|
|
|
|
|
|
|
|
|
2010-04-21 22:38:42 +00:00
|
|
|
def _unichr_is_printable(char):
|
|
|
|
# Logic adapted from Python 3's Tools/unicode/makeunicodedata.py
|
|
|
|
if char == u" ":
|
|
|
|
return True
|
|
|
|
import unicodedata
|
2010-09-08 20:57:48 +00:00
|
|
|
return unicodedata.category(char) not in ("C", "Z")
|
|
|
|
|
|
|
|
if sys.maxunicode >= 0x10000:
|
|
|
|
_unichr = unichr
|
|
|
|
else:
|
|
|
|
# Needed for proper surrogate support if sizeof(Py_UNICODE) is 2 in gdb
|
|
|
|
def _unichr(x):
|
|
|
|
if x < 0x10000:
|
|
|
|
return unichr(x)
|
|
|
|
x -= 0x10000
|
|
|
|
ch1 = 0xD800 | (x >> 10)
|
|
|
|
ch2 = 0xDC00 | (x & 0x3FF)
|
|
|
|
return unichr(ch1) + unichr(ch2)
|
2010-04-21 22:38:42 +00:00
|
|
|
|
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
class PyUnicodeObjectPtr(PyObjectPtr):
|
|
|
|
_typename = 'PyUnicodeObject'
|
|
|
|
|
2010-04-21 22:38:42 +00:00
|
|
|
def char_width(self):
|
|
|
|
_type_Py_UNICODE = gdb.lookup_type('Py_UNICODE')
|
|
|
|
return _type_Py_UNICODE.sizeof
|
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
def proxyval(self, visited):
|
2011-12-08 00:08:22 +01:00
|
|
|
global _is_pep393
|
|
|
|
if _is_pep393 is None:
|
2019-03-11 20:21:25 -07:00
|
|
|
fields = gdb.lookup_type('PyUnicodeObject').fields()
|
2011-12-08 00:08:22 +01:00
|
|
|
_is_pep393 = 'data' in [f.name for f in fields]
|
2011-09-28 07:41:54 +02:00
|
|
|
if _is_pep393:
|
|
|
|
# Python 3.3 and newer
|
|
|
|
may_have_surrogates = False
|
2011-09-28 08:35:25 +02:00
|
|
|
compact = self.field('_base')
|
|
|
|
ascii = compact['_base']
|
|
|
|
state = ascii['state']
|
2011-10-03 13:53:37 +02:00
|
|
|
is_compact_ascii = (int(state['ascii']) and int(state['compact']))
|
2011-09-28 08:35:25 +02:00
|
|
|
if not int(state['ready']):
|
2011-09-28 07:41:54 +02:00
|
|
|
# string is not ready
|
2011-11-04 22:34:01 +01:00
|
|
|
field_length = long(compact['wstr_length'])
|
2011-09-28 07:41:54 +02:00
|
|
|
may_have_surrogates = True
|
2011-09-28 08:35:25 +02:00
|
|
|
field_str = ascii['wstr']
|
|
|
|
else:
|
2011-11-04 22:34:01 +01:00
|
|
|
field_length = long(ascii['length'])
|
2011-10-03 13:53:37 +02:00
|
|
|
if is_compact_ascii:
|
2011-09-28 08:35:25 +02:00
|
|
|
field_str = ascii.address + 1
|
|
|
|
elif int(state['compact']):
|
|
|
|
field_str = compact.address + 1
|
|
|
|
else:
|
|
|
|
field_str = self.field('data')['any']
|
|
|
|
repr_kind = int(state['kind'])
|
|
|
|
if repr_kind == 1:
|
2016-04-20 18:07:21 +02:00
|
|
|
field_str = field_str.cast(_type_unsigned_char_ptr())
|
2011-09-28 08:35:25 +02:00
|
|
|
elif repr_kind == 2:
|
2016-04-20 18:07:21 +02:00
|
|
|
field_str = field_str.cast(_type_unsigned_short_ptr())
|
2011-10-08 19:33:24 +02:00
|
|
|
elif repr_kind == 4:
|
2016-04-20 18:07:21 +02:00
|
|
|
field_str = field_str.cast(_type_unsigned_int_ptr())
|
2011-09-28 07:41:54 +02:00
|
|
|
else:
|
|
|
|
# Python 3.2 and earlier
|
2011-09-28 08:35:25 +02:00
|
|
|
field_length = long(self.field('length'))
|
2011-09-28 07:41:54 +02:00
|
|
|
field_str = self.field('str')
|
|
|
|
may_have_surrogates = self.char_width() == 2
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
# Gather a list of ints from the Py_UNICODE array; these are either
|
2011-09-28 07:41:54 +02:00
|
|
|
# UCS-1, UCS-2 or UCS-4 code points:
|
|
|
|
if not may_have_surrogates:
|
2010-09-08 20:57:48 +00:00
|
|
|
Py_UNICODEs = [int(field_str[i]) for i in safe_range(field_length)]
|
|
|
|
else:
|
|
|
|
# A more elaborate routine if sizeof(Py_UNICODE) is 2 in the
|
|
|
|
# inferior process: we must join surrogate pairs.
|
|
|
|
Py_UNICODEs = []
|
|
|
|
i = 0
|
2010-09-08 21:07:40 +00:00
|
|
|
limit = safety_limit(field_length)
|
|
|
|
while i < limit:
|
2010-09-08 20:57:48 +00:00
|
|
|
ucs = int(field_str[i])
|
|
|
|
i += 1
|
|
|
|
if ucs < 0xD800 or ucs >= 0xDC00 or i == field_length:
|
|
|
|
Py_UNICODEs.append(ucs)
|
|
|
|
continue
|
|
|
|
# This could be a surrogate pair.
|
|
|
|
ucs2 = int(field_str[i])
|
|
|
|
if ucs2 < 0xDC00 or ucs2 > 0xDFFF:
|
|
|
|
continue
|
|
|
|
code = (ucs & 0x03FF) << 10
|
|
|
|
code |= ucs2 & 0x03FF
|
|
|
|
code += 0x00010000
|
|
|
|
Py_UNICODEs.append(code)
|
|
|
|
i += 1
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
# Convert the int code points to unicode characters, and generate a
|
2010-09-08 20:57:48 +00:00
|
|
|
# local unicode instance.
|
|
|
|
# This splits surrogate pairs if sizeof(Py_UNICODE) is 2 here (in gdb).
|
2013-04-11 21:37:45 +02:00
|
|
|
result = u''.join([
|
|
|
|
(_unichr(ucs) if ucs <= 0x10ffff else '\ufffd')
|
|
|
|
for ucs in Py_UNICODEs])
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return result
|
|
|
|
|
2010-04-21 22:38:42 +00:00
|
|
|
def write_repr(self, out, visited):
|
|
|
|
# Write this out as a Python 3 str literal, i.e. without a "u" prefix
|
|
|
|
|
|
|
|
# Get a PyUnicodeObject* within the Python 2 gdb process:
|
|
|
|
proxy = self.proxyval(visited)
|
|
|
|
|
|
|
|
# Transliteration of Python 3's Object/unicodeobject.c:unicode_repr
|
|
|
|
# to Python 2:
|
|
|
|
if "'" in proxy and '"' not in proxy:
|
|
|
|
quote = '"'
|
|
|
|
else:
|
|
|
|
quote = "'"
|
|
|
|
out.write(quote)
|
|
|
|
|
|
|
|
i = 0
|
|
|
|
while i < len(proxy):
|
|
|
|
ch = proxy[i]
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
# Escape quotes and backslashes
|
|
|
|
if ch == quote or ch == '\\':
|
|
|
|
out.write('\\')
|
|
|
|
out.write(ch)
|
|
|
|
|
|
|
|
# Map special whitespace to '\t', \n', '\r'
|
|
|
|
elif ch == '\t':
|
|
|
|
out.write('\\t')
|
|
|
|
elif ch == '\n':
|
|
|
|
out.write('\\n')
|
|
|
|
elif ch == '\r':
|
|
|
|
out.write('\\r')
|
|
|
|
|
|
|
|
# Map non-printable US ASCII to '\xhh' */
|
|
|
|
elif ch < ' ' or ch == 0x7F:
|
|
|
|
out.write('\\x')
|
|
|
|
out.write(hexdigits[(ord(ch) >> 4) & 0x000F])
|
|
|
|
out.write(hexdigits[ord(ch) & 0x000F])
|
|
|
|
|
|
|
|
# Copy ASCII characters as-is
|
|
|
|
elif ord(ch) < 0x7F:
|
|
|
|
out.write(ch)
|
|
|
|
|
|
|
|
# Non-ASCII characters
|
|
|
|
else:
|
2010-05-19 23:04:56 +00:00
|
|
|
ucs = ch
|
2010-09-08 20:57:48 +00:00
|
|
|
ch2 = None
|
2010-09-08 21:57:37 +00:00
|
|
|
if sys.maxunicode < 0x10000:
|
2010-09-08 20:57:48 +00:00
|
|
|
# If sizeof(Py_UNICODE) is 2 here (in gdb), join
|
|
|
|
# surrogate pairs before calling _unichr_is_printable.
|
2010-05-19 23:04:56 +00:00
|
|
|
if (i < len(proxy)
|
|
|
|
and 0xD800 <= ord(ch) < 0xDC00 \
|
|
|
|
and 0xDC00 <= ord(proxy[i]) <= 0xDFFF):
|
2010-04-21 22:38:42 +00:00
|
|
|
ch2 = proxy[i]
|
2010-09-08 20:57:48 +00:00
|
|
|
ucs = ch + ch2
|
2010-05-19 23:04:56 +00:00
|
|
|
i += 1
|
|
|
|
|
2010-09-08 21:57:37 +00:00
|
|
|
# Unfortuately, Python 2's unicode type doesn't seem
|
|
|
|
# to expose the "isprintable" method
|
2010-05-19 23:04:56 +00:00
|
|
|
printable = _unichr_is_printable(ucs)
|
|
|
|
if printable:
|
|
|
|
try:
|
|
|
|
ucs.encode(ENCODING)
|
|
|
|
except UnicodeEncodeError:
|
|
|
|
printable = False
|
2010-04-21 22:38:42 +00:00
|
|
|
|
|
|
|
# Map Unicode whitespace and control characters
|
|
|
|
# (categories Z* and C* except ASCII space)
|
2010-05-19 23:04:56 +00:00
|
|
|
if not printable:
|
2010-09-08 21:57:37 +00:00
|
|
|
if ch2 is not None:
|
|
|
|
# Match Python 3's representation of non-printable
|
|
|
|
# wide characters.
|
|
|
|
code = (ord(ch) & 0x03FF) << 10
|
|
|
|
code |= ord(ch2) & 0x03FF
|
|
|
|
code += 0x00010000
|
|
|
|
else:
|
|
|
|
code = ord(ucs)
|
2010-04-21 22:38:42 +00:00
|
|
|
|
|
|
|
# Map 8-bit characters to '\\xhh'
|
2010-05-19 23:04:56 +00:00
|
|
|
if code <= 0xff:
|
2010-04-21 22:38:42 +00:00
|
|
|
out.write('\\x')
|
2010-05-19 23:04:56 +00:00
|
|
|
out.write(hexdigits[(code >> 4) & 0x000F])
|
|
|
|
out.write(hexdigits[code & 0x000F])
|
2010-04-21 22:38:42 +00:00
|
|
|
# Map 21-bit characters to '\U00xxxxxx'
|
2010-05-19 23:04:56 +00:00
|
|
|
elif code >= 0x10000:
|
2010-04-21 22:38:42 +00:00
|
|
|
out.write('\\U')
|
2010-05-19 23:04:56 +00:00
|
|
|
out.write(hexdigits[(code >> 28) & 0x0000000F])
|
|
|
|
out.write(hexdigits[(code >> 24) & 0x0000000F])
|
|
|
|
out.write(hexdigits[(code >> 20) & 0x0000000F])
|
|
|
|
out.write(hexdigits[(code >> 16) & 0x0000000F])
|
|
|
|
out.write(hexdigits[(code >> 12) & 0x0000000F])
|
|
|
|
out.write(hexdigits[(code >> 8) & 0x0000000F])
|
|
|
|
out.write(hexdigits[(code >> 4) & 0x0000000F])
|
|
|
|
out.write(hexdigits[code & 0x0000000F])
|
2010-04-21 22:38:42 +00:00
|
|
|
# Map 16-bit characters to '\uxxxx'
|
|
|
|
else:
|
|
|
|
out.write('\\u')
|
2010-05-19 23:04:56 +00:00
|
|
|
out.write(hexdigits[(code >> 12) & 0x000F])
|
|
|
|
out.write(hexdigits[(code >> 8) & 0x000F])
|
|
|
|
out.write(hexdigits[(code >> 4) & 0x000F])
|
|
|
|
out.write(hexdigits[code & 0x000F])
|
2010-04-21 22:38:42 +00:00
|
|
|
else:
|
|
|
|
# Copy characters as-is
|
|
|
|
out.write(ch)
|
2010-09-08 20:57:48 +00:00
|
|
|
if ch2 is not None:
|
2010-05-19 23:04:56 +00:00
|
|
|
out.write(ch2)
|
2010-04-21 22:38:42 +00:00
|
|
|
|
|
|
|
out.write(quote)
|
|
|
|
|
|
|
|
|
2017-02-01 16:29:54 +01:00
|
|
|
class wrapperobject(PyObjectPtr):
|
|
|
|
_typename = 'wrapperobject'
|
|
|
|
|
|
|
|
def safe_name(self):
|
|
|
|
try:
|
|
|
|
name = self.field('descr')['d_base']['name'].string()
|
|
|
|
return repr(name)
|
2018-06-14 22:34:52 +02:00
|
|
|
except (NullPyObjectPtr, RuntimeError, UnicodeDecodeError):
|
2017-02-01 16:29:54 +01:00
|
|
|
return '<unknown name>'
|
|
|
|
|
|
|
|
def safe_tp_name(self):
|
|
|
|
try:
|
|
|
|
return self.field('self')['ob_type']['tp_name'].string()
|
2018-06-14 22:34:52 +02:00
|
|
|
except (NullPyObjectPtr, RuntimeError, UnicodeDecodeError):
|
2017-02-01 16:29:54 +01:00
|
|
|
return '<unknown tp_name>'
|
|
|
|
|
|
|
|
def safe_self_addresss(self):
|
|
|
|
try:
|
|
|
|
address = long(self.field('self'))
|
|
|
|
return '%#x' % address
|
|
|
|
except (NullPyObjectPtr, RuntimeError):
|
|
|
|
return '<failed to get self address>'
|
|
|
|
|
|
|
|
def proxyval(self, visited):
|
|
|
|
name = self.safe_name()
|
|
|
|
tp_name = self.safe_tp_name()
|
|
|
|
self_address = self.safe_self_addresss()
|
|
|
|
return ("<method-wrapper %s of %s object at %s>"
|
|
|
|
% (name, tp_name, self_address))
|
|
|
|
|
|
|
|
def write_repr(self, out, visited):
|
|
|
|
proxy = self.proxyval(visited)
|
|
|
|
out.write(proxy)
|
2010-04-21 22:38:42 +00:00
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
def int_from_int(gdbval):
|
2019-09-24 05:34:12 +02:00
|
|
|
return int(gdbval)
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
def stringify(val):
|
|
|
|
# TODO: repr() puts everything on one line; pformat can be nicer, but
|
|
|
|
# can lead to v.long results; this function isolates the choice
|
|
|
|
if True:
|
|
|
|
return repr(val)
|
|
|
|
else:
|
|
|
|
from pprint import pformat
|
|
|
|
return pformat(val)
|
|
|
|
|
|
|
|
|
|
|
|
class PyObjectPtrPrinter:
|
|
|
|
"Prints a (PyObject*)"
|
|
|
|
|
|
|
|
def __init__ (self, gdbval):
|
|
|
|
self.gdbval = gdbval
|
|
|
|
|
|
|
|
def to_string (self):
|
|
|
|
pyop = PyObjectPtr.from_pyobject_ptr(self.gdbval)
|
|
|
|
if True:
|
|
|
|
return pyop.get_truncated_repr(MAX_OUTPUT_LEN)
|
|
|
|
else:
|
|
|
|
# Generate full proxy value then stringify it.
|
|
|
|
# Doing so could be expensive
|
|
|
|
proxyval = pyop.proxyval(set())
|
|
|
|
return stringify(proxyval)
|
|
|
|
|
|
|
|
def pretty_printer_lookup(gdbval):
|
|
|
|
type = gdbval.type.unqualified()
|
2017-02-01 16:29:54 +01:00
|
|
|
if type.code != gdb.TYPE_CODE_PTR:
|
|
|
|
return None
|
|
|
|
|
|
|
|
type = type.target().unqualified()
|
|
|
|
t = str(type)
|
|
|
|
if t in ("PyObject", "PyFrameObject", "PyUnicodeObject", "wrapperobject"):
|
|
|
|
return PyObjectPtrPrinter(gdbval)
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
During development, I've been manually invoking the code in this way:
|
|
|
|
(gdb) python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
sys.path.append('/home/david/coding/python-gdb')
|
|
|
|
import libpython
|
|
|
|
end
|
|
|
|
|
|
|
|
then reloading it after each edit like this:
|
|
|
|
(gdb) python reload(libpython)
|
|
|
|
|
|
|
|
The following code should ensure that the prettyprinter is registered
|
|
|
|
if the code is autoloaded by gdb when visiting libpython.so, provided
|
|
|
|
that this python file is installed to the same path as the library (or its
|
|
|
|
.debug file) plus a "-gdb.py" suffix, e.g:
|
|
|
|
/usr/lib/libpython2.6.so.1.0-gdb.py
|
|
|
|
/usr/lib/debug/usr/lib/libpython2.6.so.1.0.debug-gdb.py
|
|
|
|
"""
|
|
|
|
def register (obj):
|
2012-10-09 11:16:03 -04:00
|
|
|
if obj is None:
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
obj = gdb
|
|
|
|
|
|
|
|
# Wire up the pretty-printer
|
|
|
|
obj.pretty_printers.append(pretty_printer_lookup)
|
|
|
|
|
|
|
|
register (gdb.current_objfile ())
|
|
|
|
|
|
|
|
|
2010-04-21 06:05:58 +00:00
|
|
|
|
|
|
|
# Unfortunately, the exact API exposed by the gdb module varies somewhat
|
|
|
|
# from build to build
|
|
|
|
# See http://bugs.python.org/issue8279?#msg102276
|
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
class Frame(object):
|
|
|
|
'''
|
|
|
|
Wrapper for gdb.Frame, adding various methods
|
|
|
|
'''
|
|
|
|
def __init__(self, gdbframe):
|
|
|
|
self._gdbframe = gdbframe
|
|
|
|
|
|
|
|
def older(self):
|
|
|
|
older = self._gdbframe.older()
|
|
|
|
if older:
|
|
|
|
return Frame(older)
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
|
|
|
def newer(self):
|
|
|
|
newer = self._gdbframe.newer()
|
|
|
|
if newer:
|
|
|
|
return Frame(newer)
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
|
|
|
def select(self):
|
2010-04-21 06:05:58 +00:00
|
|
|
'''If supported, select this frame and return True; return False if unsupported
|
|
|
|
|
|
|
|
Not all builds have a gdb.Frame.select method; seems to be present on Fedora 12
|
|
|
|
onwards, but absent on Ubuntu buildbot'''
|
|
|
|
if not hasattr(self._gdbframe, 'select'):
|
|
|
|
print ('Unable to select frame: '
|
|
|
|
'this build of gdb does not expose a gdb.Frame.select method')
|
|
|
|
return False
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
self._gdbframe.select()
|
2010-04-21 06:05:58 +00:00
|
|
|
return True
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
def get_index(self):
|
|
|
|
'''Calculate index of frame, starting at 0 for the newest frame within
|
|
|
|
this thread'''
|
|
|
|
index = 0
|
|
|
|
# Go down until you reach the newest frame:
|
|
|
|
iter_frame = self
|
|
|
|
while iter_frame.newer():
|
|
|
|
index += 1
|
|
|
|
iter_frame = iter_frame.newer()
|
|
|
|
return index
|
|
|
|
|
2012-06-27 14:15:34 -04:00
|
|
|
# We divide frames into:
|
|
|
|
# - "python frames":
|
|
|
|
# - "bytecode frames" i.e. PyEval_EvalFrameEx
|
|
|
|
# - "other python frames": things that are of interest from a python
|
|
|
|
# POV, but aren't bytecode (e.g. GC, GIL)
|
|
|
|
# - everything else
|
|
|
|
|
|
|
|
def is_python_frame(self):
|
2017-08-21 16:40:29 -07:00
|
|
|
'''Is this a _PyEval_EvalFrameDefault frame, or some other important
|
2012-06-27 14:15:34 -04:00
|
|
|
frame? (see is_other_python_frame for what "important" means in this
|
|
|
|
context)'''
|
2017-08-21 16:40:29 -07:00
|
|
|
if self.is_evalframe():
|
2012-06-27 14:15:34 -04:00
|
|
|
return True
|
|
|
|
if self.is_other_python_frame():
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2017-08-21 16:40:29 -07:00
|
|
|
def is_evalframe(self):
|
|
|
|
'''Is this a _PyEval_EvalFrameDefault frame?'''
|
|
|
|
if self._gdbframe.name() == EVALFRAME:
|
2010-04-20 22:32:07 +00:00
|
|
|
'''
|
|
|
|
I believe we also need to filter on the inline
|
|
|
|
struct frame_id.inline_depth, only regarding frames with
|
|
|
|
an inline depth of 0 as actually being this function
|
|
|
|
|
|
|
|
So we reject those with type gdb.INLINE_FRAME
|
|
|
|
'''
|
|
|
|
if self._gdbframe.type() == gdb.NORMAL_FRAME:
|
2017-08-21 16:40:29 -07:00
|
|
|
# We have a _PyEval_EvalFrameDefault frame:
|
2010-04-20 22:32:07 +00:00
|
|
|
return True
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
return False
|
|
|
|
|
2012-06-27 14:15:34 -04:00
|
|
|
def is_other_python_frame(self):
|
|
|
|
'''Is this frame worth displaying in python backtraces?
|
|
|
|
Examples:
|
|
|
|
- waiting on the GIL
|
|
|
|
- garbage-collecting
|
|
|
|
- within a CFunction
|
|
|
|
If it is, return a descriptive string
|
|
|
|
For other frames, return False
|
|
|
|
'''
|
|
|
|
if self.is_waiting_for_gil():
|
|
|
|
return 'Waiting for the GIL'
|
2016-11-22 22:53:18 +01:00
|
|
|
|
|
|
|
if self.is_gc_collect():
|
2012-06-27 14:15:34 -04:00
|
|
|
return 'Garbage-collecting'
|
2016-11-22 22:53:18 +01:00
|
|
|
|
|
|
|
# Detect invocations of PyCFunction instances:
|
2017-01-18 17:20:01 +01:00
|
|
|
frame = self._gdbframe
|
|
|
|
caller = frame.name()
|
2016-11-22 22:53:18 +01:00
|
|
|
if not caller:
|
|
|
|
return False
|
|
|
|
|
2019-07-05 14:48:24 +02:00
|
|
|
if (caller.startswith('cfunction_vectorcall_') or
|
2019-09-11 13:01:01 +02:00
|
|
|
caller == 'cfunction_call'):
|
2017-02-03 07:43:03 +09:00
|
|
|
arg_name = 'func'
|
2016-11-22 22:53:18 +01:00
|
|
|
# Within that frame:
|
|
|
|
# "func" is the local containing the PyObject* of the
|
|
|
|
# PyCFunctionObject instance
|
|
|
|
# "f" is the same value, but cast to (PyCFunctionObject*)
|
|
|
|
# "self" is the (PyObject*) of the 'self'
|
|
|
|
try:
|
|
|
|
# Use the prettyprinter for the func:
|
2017-01-18 17:20:01 +01:00
|
|
|
func = frame.read_var(arg_name)
|
2016-11-22 22:53:18 +01:00
|
|
|
return str(func)
|
2018-06-14 16:28:07 +02:00
|
|
|
except ValueError:
|
|
|
|
return ('PyCFunction invocation (unable to read %s: '
|
|
|
|
'missing debuginfos?)' % arg_name)
|
2016-11-22 22:53:18 +01:00
|
|
|
except RuntimeError:
|
2017-01-18 17:20:01 +01:00
|
|
|
return 'PyCFunction invocation (unable to read %s)' % arg_name
|
2012-06-27 14:15:34 -04:00
|
|
|
|
2017-02-01 16:29:54 +01:00
|
|
|
if caller == 'wrapper_call':
|
2018-06-14 16:28:07 +02:00
|
|
|
arg_name = 'wp'
|
2017-02-01 16:29:54 +01:00
|
|
|
try:
|
2018-06-14 16:28:07 +02:00
|
|
|
func = frame.read_var(arg_name)
|
2017-02-01 16:29:54 +01:00
|
|
|
return str(func)
|
2018-06-14 16:28:07 +02:00
|
|
|
except ValueError:
|
|
|
|
return ('<wrapper_call invocation (unable to read %s: '
|
|
|
|
'missing debuginfos?)>' % arg_name)
|
2017-02-01 16:29:54 +01:00
|
|
|
except RuntimeError:
|
2018-06-14 16:28:07 +02:00
|
|
|
return '<wrapper_call invocation (unable to read %s)>' % arg_name
|
2017-02-01 16:29:54 +01:00
|
|
|
|
2012-06-27 14:15:34 -04:00
|
|
|
# This frame isn't worth reporting:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def is_waiting_for_gil(self):
|
|
|
|
'''Is this frame waiting on the GIL?'''
|
|
|
|
# This assumes the _POSIX_THREADS version of Python/ceval_gil.h:
|
|
|
|
name = self._gdbframe.name()
|
|
|
|
if name:
|
2020-03-09 19:35:26 +01:00
|
|
|
return (name == 'take_gil')
|
2012-06-27 14:15:34 -04:00
|
|
|
|
|
|
|
def is_gc_collect(self):
|
2020-10-30 21:09:48 +01:00
|
|
|
'''Is this frame gc_collect_main() within the garbage-collector?'''
|
|
|
|
return self._gdbframe.name() in ('collect', 'gc_collect_main')
|
2012-06-27 14:15:34 -04:00
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
def get_pyop(self):
|
|
|
|
try:
|
|
|
|
f = self._gdbframe.read_var('f')
|
2011-12-19 13:42:24 +01:00
|
|
|
frame = PyFrameObjectPtr.from_pyobject_ptr(f)
|
|
|
|
if not frame.is_optimized_out():
|
|
|
|
return frame
|
|
|
|
# gdb is unable to get the "f" argument of PyEval_EvalFrameEx()
|
|
|
|
# because it was "optimized out". Try to get "f" from the frame
|
|
|
|
# of the caller, PyEval_EvalCodeEx().
|
|
|
|
orig_frame = frame
|
|
|
|
caller = self._gdbframe.older()
|
|
|
|
if caller:
|
|
|
|
f = caller.read_var('f')
|
|
|
|
frame = PyFrameObjectPtr.from_pyobject_ptr(f)
|
|
|
|
if not frame.is_optimized_out():
|
|
|
|
return frame
|
|
|
|
return orig_frame
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
except ValueError:
|
|
|
|
return None
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def get_selected_frame(cls):
|
|
|
|
_gdbframe = gdb.selected_frame()
|
|
|
|
if _gdbframe:
|
|
|
|
return Frame(_gdbframe)
|
|
|
|
return None
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def get_selected_python_frame(cls):
|
2012-06-27 14:15:34 -04:00
|
|
|
'''Try to obtain the Frame for the python-related code in the selected
|
|
|
|
frame, or None'''
|
2016-12-16 10:00:39 +01:00
|
|
|
try:
|
|
|
|
frame = cls.get_selected_frame()
|
|
|
|
except gdb.error:
|
|
|
|
# No frame: Python didn't start yet
|
|
|
|
return None
|
2012-06-27 14:15:34 -04:00
|
|
|
|
|
|
|
while frame:
|
|
|
|
if frame.is_python_frame():
|
|
|
|
return frame
|
|
|
|
frame = frame.older()
|
|
|
|
|
|
|
|
# Not found:
|
|
|
|
return None
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def get_selected_bytecode_frame(cls):
|
|
|
|
'''Try to obtain the Frame for the python bytecode interpreter in the
|
|
|
|
selected GDB frame, or None'''
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
frame = cls.get_selected_frame()
|
|
|
|
|
|
|
|
while frame:
|
2017-08-21 16:40:29 -07:00
|
|
|
if frame.is_evalframe():
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return frame
|
|
|
|
frame = frame.older()
|
|
|
|
|
|
|
|
# Not found:
|
|
|
|
return None
|
|
|
|
|
|
|
|
def print_summary(self):
|
2017-08-21 16:40:29 -07:00
|
|
|
if self.is_evalframe():
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
pyop = self.get_pyop()
|
|
|
|
if pyop:
|
2010-08-17 22:49:25 +00:00
|
|
|
line = pyop.get_truncated_repr(MAX_OUTPUT_LEN)
|
|
|
|
write_unicode(sys.stdout, '#%i %s\n' % (self.get_index(), line))
|
2011-12-19 13:42:24 +01:00
|
|
|
if not pyop.is_optimized_out():
|
|
|
|
line = pyop.current_line()
|
|
|
|
if line is not None:
|
|
|
|
sys.stdout.write(' %s\n' % line.strip())
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
else:
|
|
|
|
sys.stdout.write('#%i (unable to read python frame information)\n' % self.get_index())
|
|
|
|
else:
|
2012-06-27 14:15:34 -04:00
|
|
|
info = self.is_other_python_frame()
|
|
|
|
if info:
|
|
|
|
sys.stdout.write('#%i %s\n' % (self.get_index(), info))
|
|
|
|
else:
|
|
|
|
sys.stdout.write('#%i\n' % self.get_index())
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
2011-05-13 17:40:15 +02:00
|
|
|
def print_traceback(self):
|
2017-08-21 16:40:29 -07:00
|
|
|
if self.is_evalframe():
|
2011-05-13 17:40:15 +02:00
|
|
|
pyop = self.get_pyop()
|
|
|
|
if pyop:
|
|
|
|
pyop.print_traceback()
|
2011-12-19 13:42:24 +01:00
|
|
|
if not pyop.is_optimized_out():
|
|
|
|
line = pyop.current_line()
|
|
|
|
if line is not None:
|
|
|
|
sys.stdout.write(' %s\n' % line.strip())
|
2011-05-13 17:40:15 +02:00
|
|
|
else:
|
|
|
|
sys.stdout.write(' (unable to read python frame information)\n')
|
|
|
|
else:
|
2012-06-27 14:15:34 -04:00
|
|
|
info = self.is_other_python_frame()
|
|
|
|
if info:
|
|
|
|
sys.stdout.write(' %s\n' % info)
|
|
|
|
else:
|
|
|
|
sys.stdout.write(' (not a python frame)\n')
|
2011-05-13 17:40:15 +02:00
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
class PyList(gdb.Command):
|
|
|
|
'''List the current Python source code, if any
|
|
|
|
|
|
|
|
Use
|
|
|
|
py-list START
|
|
|
|
to list at a different line number within the python source.
|
|
|
|
|
|
|
|
Use
|
|
|
|
py-list START, END
|
|
|
|
to list a specific range of lines within the python source.
|
|
|
|
'''
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
gdb.Command.__init__ (self,
|
|
|
|
"py-list",
|
|
|
|
gdb.COMMAND_FILES,
|
|
|
|
gdb.COMPLETE_NONE)
|
|
|
|
|
|
|
|
|
|
|
|
def invoke(self, args, from_tty):
|
|
|
|
import re
|
|
|
|
|
|
|
|
start = None
|
|
|
|
end = None
|
|
|
|
|
|
|
|
m = re.match(r'\s*(\d+)\s*', args)
|
|
|
|
if m:
|
|
|
|
start = int(m.group(0))
|
|
|
|
end = start + 10
|
|
|
|
|
|
|
|
m = re.match(r'\s*(\d+)\s*,\s*(\d+)\s*', args)
|
|
|
|
if m:
|
|
|
|
start, end = map(int, m.groups())
|
|
|
|
|
2012-06-27 14:15:34 -04:00
|
|
|
# py-list requires an actual PyEval_EvalFrameEx frame:
|
|
|
|
frame = Frame.get_selected_bytecode_frame()
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
if not frame:
|
2013-11-23 17:40:36 +01:00
|
|
|
print('Unable to locate gdb frame for python bytecode interpreter')
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
pyop = frame.get_pyop()
|
2011-12-19 13:42:24 +01:00
|
|
|
if not pyop or pyop.is_optimized_out():
|
2020-03-20 08:23:26 +01:00
|
|
|
print(UNABLE_READ_INFO_PYTHON_FRAME)
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
filename = pyop.filename()
|
|
|
|
lineno = pyop.current_line_num()
|
2018-10-15 23:19:57 +02:00
|
|
|
if lineno is None:
|
|
|
|
print('Unable to read python frame line number')
|
|
|
|
return
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
if start is None:
|
|
|
|
start = lineno - 5
|
|
|
|
end = lineno + 5
|
|
|
|
|
|
|
|
if start<1:
|
|
|
|
start = 1
|
|
|
|
|
2011-07-01 12:57:44 +02:00
|
|
|
try:
|
|
|
|
f = open(os_fsencode(filename), 'r')
|
|
|
|
except IOError as err:
|
|
|
|
sys.stdout.write('Unable to open %s: %s\n'
|
|
|
|
% (filename, err))
|
|
|
|
return
|
|
|
|
with f:
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
all_lines = f.readlines()
|
|
|
|
# start and end are 1-based, all_lines is 0-based;
|
|
|
|
# so [start-1:end] as a python slice gives us [start, end] as a
|
|
|
|
# closed interval
|
|
|
|
for i, line in enumerate(all_lines[start-1:end]):
|
|
|
|
linestr = str(i+start)
|
|
|
|
# Highlight current line:
|
|
|
|
if i + start == lineno:
|
|
|
|
linestr = '>' + linestr
|
|
|
|
sys.stdout.write('%4s %s' % (linestr, line))
|
|
|
|
|
|
|
|
|
|
|
|
# ...and register the command:
|
|
|
|
PyList()
|
|
|
|
|
|
|
|
def move_in_stack(move_up):
|
|
|
|
'''Move up or down the stack (for the py-up/py-down command)'''
|
|
|
|
frame = Frame.get_selected_python_frame()
|
2016-12-16 10:00:39 +01:00
|
|
|
if not frame:
|
|
|
|
print('Unable to locate python frame')
|
|
|
|
return
|
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
while frame:
|
|
|
|
if move_up:
|
|
|
|
iter_frame = frame.older()
|
|
|
|
else:
|
|
|
|
iter_frame = frame.newer()
|
|
|
|
|
|
|
|
if not iter_frame:
|
|
|
|
break
|
|
|
|
|
2012-06-27 14:15:34 -04:00
|
|
|
if iter_frame.is_python_frame():
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
# Result:
|
2010-04-21 06:05:58 +00:00
|
|
|
if iter_frame.select():
|
|
|
|
iter_frame.print_summary()
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
frame = iter_frame
|
|
|
|
|
|
|
|
if move_up:
|
2013-11-23 17:40:36 +01:00
|
|
|
print('Unable to find an older python frame')
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
else:
|
2013-11-23 17:40:36 +01:00
|
|
|
print('Unable to find a newer python frame')
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
class PyUp(gdb.Command):
|
|
|
|
'Select and print the python stack frame that called this one (if any)'
|
|
|
|
def __init__(self):
|
|
|
|
gdb.Command.__init__ (self,
|
|
|
|
"py-up",
|
|
|
|
gdb.COMMAND_STACK,
|
|
|
|
gdb.COMPLETE_NONE)
|
|
|
|
|
|
|
|
|
|
|
|
def invoke(self, args, from_tty):
|
|
|
|
move_in_stack(move_up=True)
|
|
|
|
|
|
|
|
class PyDown(gdb.Command):
|
|
|
|
'Select and print the python stack frame called by this one (if any)'
|
|
|
|
def __init__(self):
|
|
|
|
gdb.Command.__init__ (self,
|
|
|
|
"py-down",
|
|
|
|
gdb.COMMAND_STACK,
|
|
|
|
gdb.COMPLETE_NONE)
|
|
|
|
|
|
|
|
|
|
|
|
def invoke(self, args, from_tty):
|
|
|
|
move_in_stack(move_up=False)
|
|
|
|
|
2010-04-20 22:32:07 +00:00
|
|
|
# Not all builds of gdb have gdb.Frame.select
|
|
|
|
if hasattr(gdb.Frame, 'select'):
|
|
|
|
PyUp()
|
|
|
|
PyDown()
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
2011-05-13 17:40:15 +02:00
|
|
|
class PyBacktraceFull(gdb.Command):
|
|
|
|
'Display the current python frame and all the frames within its call stack (if any)'
|
|
|
|
def __init__(self):
|
|
|
|
gdb.Command.__init__ (self,
|
|
|
|
"py-bt-full",
|
|
|
|
gdb.COMMAND_STACK,
|
|
|
|
gdb.COMPLETE_NONE)
|
|
|
|
|
|
|
|
|
|
|
|
def invoke(self, args, from_tty):
|
|
|
|
frame = Frame.get_selected_python_frame()
|
2016-12-16 10:00:39 +01:00
|
|
|
if not frame:
|
|
|
|
print('Unable to locate python frame')
|
|
|
|
return
|
|
|
|
|
2011-05-13 17:40:15 +02:00
|
|
|
while frame:
|
2012-06-27 14:15:34 -04:00
|
|
|
if frame.is_python_frame():
|
2011-05-13 17:40:15 +02:00
|
|
|
frame.print_summary()
|
|
|
|
frame = frame.older()
|
|
|
|
|
|
|
|
PyBacktraceFull()
|
|
|
|
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
class PyBacktrace(gdb.Command):
|
|
|
|
'Display the current python frame and all the frames within its call stack (if any)'
|
|
|
|
def __init__(self):
|
|
|
|
gdb.Command.__init__ (self,
|
|
|
|
"py-bt",
|
|
|
|
gdb.COMMAND_STACK,
|
|
|
|
gdb.COMPLETE_NONE)
|
|
|
|
|
|
|
|
|
|
|
|
def invoke(self, args, from_tty):
|
|
|
|
frame = Frame.get_selected_python_frame()
|
2016-12-16 10:00:39 +01:00
|
|
|
if not frame:
|
|
|
|
print('Unable to locate python frame')
|
|
|
|
return
|
|
|
|
|
|
|
|
sys.stdout.write('Traceback (most recent call first):\n')
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
while frame:
|
2012-06-27 14:15:34 -04:00
|
|
|
if frame.is_python_frame():
|
2011-05-13 17:40:15 +02:00
|
|
|
frame.print_traceback()
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
frame = frame.older()
|
|
|
|
|
|
|
|
PyBacktrace()
|
|
|
|
|
|
|
|
class PyPrint(gdb.Command):
|
|
|
|
'Look up the given python variable name, and print it'
|
|
|
|
def __init__(self):
|
|
|
|
gdb.Command.__init__ (self,
|
|
|
|
"py-print",
|
|
|
|
gdb.COMMAND_DATA,
|
|
|
|
gdb.COMPLETE_NONE)
|
|
|
|
|
|
|
|
|
|
|
|
def invoke(self, args, from_tty):
|
|
|
|
name = str(args)
|
|
|
|
|
|
|
|
frame = Frame.get_selected_python_frame()
|
|
|
|
if not frame:
|
2013-11-23 17:40:36 +01:00
|
|
|
print('Unable to locate python frame')
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
pyop_frame = frame.get_pyop()
|
|
|
|
if not pyop_frame:
|
2020-03-20 08:23:26 +01:00
|
|
|
print(UNABLE_READ_INFO_PYTHON_FRAME)
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
pyop_var, scope = pyop_frame.get_var_by_name(name)
|
|
|
|
|
|
|
|
if pyop_var:
|
2013-11-23 17:40:36 +01:00
|
|
|
print('%s %r = %s'
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
% (scope,
|
|
|
|
name,
|
|
|
|
pyop_var.get_truncated_repr(MAX_OUTPUT_LEN)))
|
|
|
|
else:
|
2013-11-23 17:40:36 +01:00
|
|
|
print('%r not found' % name)
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
|
|
|
|
PyPrint()
|
|
|
|
|
|
|
|
class PyLocals(gdb.Command):
|
|
|
|
'Look up the given python variable name, and print it'
|
|
|
|
def __init__(self):
|
|
|
|
gdb.Command.__init__ (self,
|
|
|
|
"py-locals",
|
|
|
|
gdb.COMMAND_DATA,
|
|
|
|
gdb.COMPLETE_NONE)
|
|
|
|
|
|
|
|
|
|
|
|
def invoke(self, args, from_tty):
|
|
|
|
name = str(args)
|
|
|
|
|
|
|
|
frame = Frame.get_selected_python_frame()
|
|
|
|
if not frame:
|
2013-11-23 17:40:36 +01:00
|
|
|
print('Unable to locate python frame')
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
pyop_frame = frame.get_pyop()
|
|
|
|
if not pyop_frame:
|
2020-03-20 08:23:26 +01:00
|
|
|
print(UNABLE_READ_INFO_PYTHON_FRAME)
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
for pyop_name, pyop_value in pyop_frame.iter_locals():
|
2013-11-23 17:40:36 +01:00
|
|
|
print('%s = %s'
|
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
Issue #8032: For gdb7, a python-gdb.py file is added to the build,
allowing to use advanced gdb features when debugging Python.
........
r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
as a regular test by regrtest.py, and fails.
........
r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
Don't install python-gdb.py as an executable.
........
r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
Issue 8287: try to fix the gdb-python install errors on Solaris
and FreeBSD. Patch by Dave Malcolm.
........
r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
Ensure that the gdb hooks can be installed when
srcdir != builddir.
Without this patch it is no longer possible to
build python when you don't run configure from
the root of the source tree.
........
r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
Issue 8316: make test_gdb robust in the face of differing terminal
widths. Patch by Dave Malcolm.
........
r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
Issue #8337: Disable the remaining test also for now.
........
2010-04-11 21:49:28 +00:00
|
|
|
% (pyop_name.proxyval(set()),
|
|
|
|
pyop_value.get_truncated_repr(MAX_OUTPUT_LEN)))
|
|
|
|
|
|
|
|
PyLocals()
|