Index: Misc/gdbinit =================================================================== --- Misc/gdbinit (révision 65930) +++ Misc/gdbinit (copie de travail) @@ -12,18 +12,30 @@ # $1 = void # (gdb) +# 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,36 +46,15 @@ set $_names = co->co_varnames set $_name = PyString_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 end -# A rewrite of the Python interpreter's line number calculator in GDB's -# command language define lineno - set $__continue = 1 - set $__co = f->f_code - set $__lasti = f->f_lasti - set $__sz = ((PyStringObject *)$__co->co_lnotab)->ob_size/2 - set $__p = (unsigned char *)((PyStringObject *)$__co->co_lnotab)->ob_sval - set $__li = $__co->co_firstlineno - set $__ad = 0 - while ($__sz-1 >= 0 && $__continue) - set $__sz = $__sz - 1 - set $__ad = $__ad + *$__p - set $__p = $__p + 1 - if ($__ad > $__lasti) - set $__continue = 0 - end - set $__li = $__li + *$__p - set $__p = $__p + 1 - end - printf "%d", $__li + printf "%d", PyCode_Addr2Line(co, f->f_lasti) end # print the current frame - verbose