diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2010-10-17 18:49:46 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2010-10-17 18:49:46 (GMT) |
commit | 1468429ea6ee5523d02f5199751dc94c6b3f930c (patch) | |
tree | bdc76ed6551b04b326b0f7345dec4177113d017b /Misc/gdbinit | |
parent | ded5acf34ae0185a4b19ed213eec4c2cdfda7060 (diff) | |
download | cpython-1468429ea6ee5523d02f5199751dc94c6b3f930c.zip cpython-1468429ea6ee5523d02f5199751dc94c6b3f930c.tar.gz cpython-1468429ea6ee5523d02f5199751dc94c6b3f930c.tar.bz2 |
Merged revisions 85646 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r85646 | gregory.p.smith | 2010-10-17 11:38:04 -0700 (Sun, 17 Oct 2010) | 6 lines
* Applys part of the patch from http://bugs.python.org/issue3631 to add
a py_decref macro, fixup the pyo macro and reuse it and avoid a memory
leak introduced by the pylocals macro.
* Adds a note about gdb 7 python debugging support with links for
more info on that.
........
Diffstat (limited to 'Misc/gdbinit')
-rw-r--r-- | Misc/gdbinit | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/Misc/gdbinit b/Misc/gdbinit index 33de784..e3482a4 100644 --- a/Misc/gdbinit +++ b/Misc/gdbinit @@ -1,5 +1,3 @@ -# -*- ksh -*- -# # If you use the GNU debugger gdb to debug the Python C runtime, you # might find some of the following commands useful. Copy this to your # ~/.gdbinit file and it'll get loaded into gdb automatically when you @@ -11,19 +9,36 @@ # address : 84a7a2c # $1 = void # (gdb) +# +# NOTE: If you have gdb 7 or later, it supports debugging of Python directly +# with embedded macros that you may find superior to what is in here. +# See https://fedoraproject.org/wiki/Features/EasierPythonDebugging +# and http://bugs.python.org/issue8032 for more gdb 7 python information. + +# gdb version of Py_DECREF(obj) macro +define py_decref + set $__obj = $arg0 + set $__obj->ob_refcnt -= 1 + if ($__obj->ob_refcnt == 0) + set $__obj = _Py_Dealloc($__obj) + end +end # Prints a representation of the object to stderr, along with the # number of reference counts it current has and the hex address the # object is allocated at. The argument must be a PyObject* define pyo -print _PyObject_Dump($arg0) + # side effect of calling _PyObject_Dump is to dump the object's + # info - assigning just prevents gdb from printing the + # NULL return value + set $_unused_void = _PyObject_Dump($arg0) end # Prints a representation of the object to stderr, along with the # number of reference counts it current has and the hex address the # object is allocated at. The argument must be a PyGC_Head* define pyg -print _PyGC_Dump($arg0) + print _PyGC_Dump($arg0) end # print the local variables of the current frame @@ -34,10 +49,8 @@ define pylocals set $_names = co->co_varnames set $_name = _PyUnicode_AsString(PyTuple_GetItem($_names, $_i)) printf "%s:\n", $_name - # side effect of calling _PyObject_Dump is to dump the object's - # info - assigning just prevents gdb from printing the - # NULL return value - set $_val = _PyObject_Dump(f->f_localsplus[$_i]) + py_decref $_name + pyo f->f_localsplus[$_i] end set $_i = $_i + 1 end |