[Python-checkins] python/dist/src/Python pythonrun.c,2.189,2.190

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Thu, 17 Apr 2003 12:52:33 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv28526/python/Python

Modified Files:
	pythonrun.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: pythonrun.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v
retrieving revision 2.189
retrieving revision 2.190
diff -C2 -d -r2.189 -r2.190
*** pythonrun.c	17 Apr 2003 17:29:22 -0000	2.189
--- pythonrun.c	17 Apr 2003 19:52:29 -0000	2.190
***************
*** 285,291 ****
  	 * up later.
  	 */
! 	if (Py_GETENV("PYTHONDUMPREFS")) {
  		_Py_PrintReferences(stderr);
- 	}
  #endif /* Py_TRACE_REFS */
  
--- 285,290 ----
  	 * up later.
  	 */
! 	if (Py_GETENV("PYTHONDUMPREFS"))
  		_Py_PrintReferences(stderr);
  #endif /* Py_TRACE_REFS */
  
***************
*** 326,329 ****
--- 325,336 ----
  	PyGrammar_RemoveAccelerators(&_PyParser_Grammar);
  
+ #ifdef Py_TRACE_REFS
+ 	/* Display addresses (& refcnts) of all objects still alive.
+ 	 * An address can be used to find the repr of the object, printed
+ 	 * above by _Py_PrintReferences.
+ 	 */
+ 	if (Py_GETENV("PYTHONDUMPREFS"))
+ 		_Py_PrintReferenceAddresses(stderr);
+ #endif /* Py_TRACE_REFS */
  #ifdef PYMALLOC_DEBUG
  	if (Py_GETENV("PYTHONMALLOCSTATS"))