[Python-checkins] CVS: python/dist/src/Objects object.c,2.114,2.115
Barry Warsaw
bwarsaw@users.sourceforge.net
Tue, 23 Jan 2001 08:24:38 -0800
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv6032
Modified Files:
object.c
Log Message:
A few miscellaneous helpers.
PyObject_Dump(): New function that is useful when debugging Python's C
runtime. In something like gdb it can be a pain to get some useful
information out of PyObject*'s. This function prints the str() of the
object to stderr, along with the object's refcount and hex address.
PyGC_Dump(): Similar to PyObject_Dump() but knows how to cast from the
garbage collector prefix back to the PyObject* structure.
[See Misc/gdbinit for some useful gdb hooks]
none_dealloc(): Rather than SEGV if we accidentally decref None out of
existance, we assign None's and NotImplemented's destructor slot to
this function, which just calls abort().
Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.114
retrieving revision 2.115
diff -C2 -r2.114 -r2.115
*** object.c 2001/01/22 19:28:09 2.114
--- object.c 2001/01/23 16:24:35 2.115
***************
*** 221,224 ****
--- 221,237 ----
}
+ /* For debugging convenience. See Misc/gdbinit for some useful gdb hooks */
+ void PyObject_Dump(PyObject* op)
+ {
+ (void)PyObject_Print(op, stderr, 0);
+ fprintf(stderr, "\nrefcounts: %d\n", op->ob_refcnt);
+ fprintf(stderr, "address : %x\n", op);
+ }
+ void PyGC_Dump(PyGC_Head* op)
+ {
+ PyObject_Dump(PyObject_FROM_GC(op));
+ }
+
+
PyObject *
PyObject_Repr(PyObject *v)
***************
*** 1214,1217 ****
--- 1227,1241 ----
}
+ /* ARGUSED */
+ static void
+ none_dealloc(PyObject* ignore)
+ {
+ /* This should never get called, but we also don't want to SEGV if
+ * we accidently decref None out of existance.
+ */
+ abort();
+ }
+
+
static PyTypeObject PyNothing_Type = {
PyObject_HEAD_INIT(&PyType_Type)
***************
*** 1220,1224 ****
0,
0,
! 0, /*tp_dealloc*/ /*never called*/
0, /*tp_print*/
0, /*tp_getattr*/
--- 1244,1248 ----
0,
0,
! (destructor)none_dealloc, /*tp_dealloc*/ /*never called*/
0, /*tp_print*/
0, /*tp_getattr*/
***************
*** 1251,1255 ****
0,
0,
! 0, /*tp_dealloc*/ /*never called*/
0, /*tp_print*/
0, /*tp_getattr*/
--- 1275,1279 ----
0,
0,
! (destructor)none_dealloc, /*tp_dealloc*/ /*never called*/
0, /*tp_print*/
0, /*tp_getattr*/