[Python-checkins] python/dist/src/Objects object.c,2.207,2.208
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Thu, 17 Apr 2003 12:52:32 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv28526/python/Objects
Modified Files:
object.c
Log Message:
_Py_PrintReferences(): Changed to print object address at start of each
new line.
New pvt API function _Py_PrintReferenceAddresses(): Prints only the
addresses and refcnts of the live objects. This is always safe to call,
because it has no dependence on Python's C API.
Py_Finalize(): If envar PYTHONDUMPREFS is set, call (the new)
_Py_PrintReferenceAddresses() right before dumping final pymalloc stats.
We can't print the reprs of the objects here because too much of the
interpreter has been shut down. You need to correlate the addresses
displayed here with the object reprs printed by the earlier
PYTHONDUMPREFS call to _Py_PrintReferences().
Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.207
retrieving revision 2.208
diff -C2 -d -r2.207 -r2.208
*** object.c 15 Apr 2003 15:10:51 -0000 2.207
--- object.c 17 Apr 2003 19:52:28 -0000 2.208
***************
*** 2023,2026 ****
--- 2023,2029 ----
}
+ /* Print all live objects. Because PyObject_Print is called, the
+ * interpreter must be in a healthy state.
+ */
void
_Py_PrintReferences(FILE *fp)
***************
*** 2029,2037 ****
fprintf(fp, "Remaining objects:\n");
for (op = refchain._ob_next; op != &refchain; op = op->_ob_next) {
! fprintf(fp, "[%d] ", op->ob_refcnt);
if (PyObject_Print(op, fp, 0) != 0)
PyErr_Clear();
putc('\n', fp);
}
}
--- 2032,2052 ----
fprintf(fp, "Remaining objects:\n");
for (op = refchain._ob_next; op != &refchain; op = op->_ob_next) {
! fprintf(fp, "%p [%d] ", op, op->ob_refcnt);
if (PyObject_Print(op, fp, 0) != 0)
PyErr_Clear();
putc('\n', fp);
}
+ }
+
+ /* Print the addresses of all live objects. Unlike _Py_PrintReferences, this
+ * doesn't make any calls to the Python C API, so is always safe to call.
+ */
+ void
+ _Py_PrintReferenceAddresses(FILE *fp)
+ {
+ PyObject *op;
+ fprintf(fp, "Remaining object addresses:\n");
+ for (op = refchain._ob_next; op != &refchain; op = op->_ob_next)
+ fprintf(fp, "%p [%d]\n", op, op->ob_refcnt);
}