[Python-checkins] python/dist/src/Python ceval.c,2.357,2.358 sysmodule.c,2.116,2.117

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Wed, 09 Apr 2003 12:06:54 -0700


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

Modified Files:
	ceval.c sysmodule.c 
Log Message:
- New function sys.call_tracing() allows pdb to debug code
  recursively.
- pdb has a new command, "debug", which lets you step through
  arbitrary code from the debugger's (pdb) prompt.


Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.357
retrieving revision 2.358
diff -C2 -d -r2.357 -r2.358
*** ceval.c	16 Mar 2003 20:14:44 -0000	2.357
--- ceval.c	9 Apr 2003 19:06:17 -0000	2.358
***************
*** 3025,3028 ****
--- 3025,3046 ----
  }
  
+ PyObject *
+ _PyEval_CallTracing(PyObject *func, PyObject *args)
+ {
+ 	PyFrameObject *frame = PyEval_GetFrame();
+ 	PyThreadState *tstate = frame->f_tstate;
+ 	int save_tracing = tstate->tracing;
+ 	int save_use_tracing = tstate->use_tracing;
+ 	PyObject *result;
+ 
+ 	tstate->tracing = 0;
+ 	tstate->use_tracing = ((tstate->c_tracefunc != NULL)
+ 			       || (tstate->c_profilefunc != NULL));
+ 	result = PyObject_Call(func, args, NULL);
+ 	tstate->tracing = save_tracing;
+ 	tstate->use_tracing = save_use_tracing;
+ 	return result;
+ }
+ 
  static int
  maybe_call_line_trace(Py_tracefunc func, PyObject *obj, 

Index: sysmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v
retrieving revision 2.116
retrieving revision 2.117
diff -C2 -d -r2.116 -r2.117
*** sysmodule.c	5 Mar 2003 15:13:47 -0000	2.116
--- sysmodule.c	9 Apr 2003 19:06:19 -0000	2.117
***************
*** 18,21 ****
--- 18,22 ----
  #include "compile.h"
  #include "frameobject.h"
+ #include "eval.h"
  
  #include "osdefs.h"
***************
*** 610,613 ****
--- 611,631 ----
  }
  
+ PyDoc_STRVAR(call_tracing_doc,
+ "call_tracing(func, args) -> object\n\
+ \n\
+ Call func(*args), while tracing is enabled.  The tracing state is\n\
+ saved, and restored afterwards.  This is intended to be called from\n\
+ a debugger from a checkpoint, to recursively debug some other code."
+ );
+ 
+ static PyObject *
+ sys_call_tracing(PyObject *self, PyObject *args)
+ {
+ 	PyObject *func, *funcargs;
+ 	if (!PyArg_ParseTuple(args, "OO:call_tracing", &func, &funcargs))
+ 		return NULL;
+ 	return _PyEval_CallTracing(func, funcargs);
+ }
+ 
  PyDoc_STRVAR(callstats_doc,
  "callstats() -> tuple of integers\n\
***************
*** 701,704 ****
--- 719,723 ----
  	 setrecursionlimit_doc},
  	{"settrace",	sys_settrace, METH_O, settrace_doc},
+ 	{"call_tracing", sys_call_tracing, METH_VARARGS, call_tracing_doc},
  	{NULL,		NULL}		/* sentinel */
  };