[gs-cvs] rev 8342 - in trunk/gs: doc src
leonardo at ghostscript.com
leonardo at ghostscript.com
Thu Nov 1 09:20:02 PDT 2007
Author: leonardo
Date: 2007-11-01 09:20:01 -0700 (Thu, 01 Nov 2007)
New Revision: 8342
Modified:
trunk/gs/doc/Use.htm
trunk/gs/src/iinit.c
trunk/gs/src/iinit.h
trunk/gs/src/int.mak
trunk/gs/src/interp.c
Log:
PS interpreter : Trace the executed operators' names.
DETAILS :
This change is syntactically equivalent for a default build.
For obtaining the new functionality Ghostscript must be compiled
with a new predefined macro DEBUG_TRACE_PS_OPERATORS.
The new debug switch '!' prints names of operators executed while the interpretation.
Note : Inline operators (which are expanded inside interp.c) are not printed.
EXPECTED DIFFERENCES :
None.
Modified: trunk/gs/doc/Use.htm
===================================================================
--- trunk/gs/doc/Use.htm 2007-11-01 15:56:22 UTC (rev 8341)
+++ trunk/gs/doc/Use.htm 2007-11-01 16:20:01 UTC (rev 8342)
@@ -2980,6 +2980,8 @@
<dt> <b><tt>"</tt></b><dd>contexts, every operation
<dt><b><tt>^</tt></b><dd>reference counting
<dt><b><tt>_</tt></b><dd>high-level output
+<dt><b><tt>!</tt></b><dd>Postscript operator names (this option is available only
+when Ghostscript is compiled with a predefined macro DEBUG_TRACE_PS_OPERATORS)
<dt><b><tt>|</tt></b><dd>(reserved for experimental code)
</dl>
Modified: trunk/gs/src/iinit.c
===================================================================
--- trunk/gs/src/iinit.c 2007-11-01 15:56:22 UTC (rev 8341)
+++ trunk/gs/src/iinit.c 2007-11-01 16:20:01 UTC (rev 8342)
@@ -512,3 +512,27 @@
return 0;
}
+
+#ifdef DEBUG_TRACE_PS_OPERATORS
+static const char *unknown_op_name = "unknown_op";
+
+const char *
+op_get_name_string(op_proc_t opproc)
+{
+ const op_def *const *tptr;
+ int code;
+
+ /* Enter each operator into the appropriate dictionary. */
+
+ for (tptr = op_defs_all; *tptr != 0; tptr++) {
+ const op_def *def;
+
+ for (def = *tptr; def->oname != 0; def++)
+ if (!op_def_is_begin_dict(def)) {
+ if (def->proc == opproc)
+ return def->oname;
+ }
+ }
+ return unknown_op_name;
+}
+#endif
Modified: trunk/gs/src/iinit.h
===================================================================
--- trunk/gs/src/iinit.h 2007-11-01 15:56:22 UTC (rev 8341)
+++ trunk/gs/src/iinit.h 2007-11-01 16:20:01 UTC (rev 8342)
@@ -24,6 +24,9 @@
int obj_init(i_ctx_t **, gs_dual_memory_t *);
int zop_init(i_ctx_t *);
int op_init(i_ctx_t *);
+#ifdef DEBUG_TRACE_PS_OPERATORS
+const char *op_get_name_string(op_proc_t opproc);
+#endif
/*
* Test whether there are any Level 2 operators in the executable.
Modified: trunk/gs/src/int.mak
===================================================================
--- trunk/gs/src/int.mak 2007-11-01 15:56:22 UTC (rev 8341)
+++ trunk/gs/src/int.mak 2007-11-01 16:20:01 UTC (rev 8342)
@@ -2055,7 +2055,7 @@
$(dstack_h) $(ierrors_h) $(estack_h) $(files_h)\
$(ialloc_h) $(iconf_h) $(idebug_h) $(idict_h) $(idisp_h) $(iinit_h)\
$(iname_h) $(interp_h) $(iplugin_h) $(isave_h) $(iscan_h) $(ivmspace_h)\
- $(main_h) $(oper_h) $(ostack_h)\
+ $(iinit_h) $(main_h) $(oper_h) $(ostack_h)\
$(sfilter_h) $(store_h) $(stream_h) $(strimpl_h)
$(PSCC) $(PSO_)imain.$(OBJ) $(C_) $(PSSRC)imain.c
Modified: trunk/gs/src/interp.c
===================================================================
--- trunk/gs/src/interp.c 2007-11-01 15:56:22 UTC (rev 8341)
+++ trunk/gs/src/interp.c 2007-11-01 16:20:01 UTC (rev 8342)
@@ -41,6 +41,7 @@
#include "itoken.h"
#include "iutil.h" /* for array_get */
#include "ivmspace.h"
+#include "iinit.h"
#include "dstack.h"
#include "files.h" /* for file_check_read */
#include "oper.h"
@@ -102,9 +103,13 @@
static int
call_operator(op_proc_t op_proc, i_ctx_t *i_ctx_p)
{
- int code = op_proc(i_ctx_p);
+ int code;
- return code;
+# ifdef DEBUG_TRACE_PS_OPERATORS
+ if_debug1('!', "[!]operator %s\n", op_get_name_string(op_proc));
+# endif
+ code = op_proc(i_ctx_p);
+ return code; /* A good place for a conditional breakpoint. */
}
#else
# define call_operator(proc, p) ((*(proc))(p))
More information about the gs-cvs
mailing list