1 % Copyright (C) 1992, 1993, 1994, 1999 Aladdin Enterprises. All rights reserved.
3 % This software is provided AS-IS with no warranty, either express or
6 % This software is distributed under license and may not be copied,
7 % modified or distributed except as expressly authorized under the terms
8 % of the license contained in the file LICENSE in this distribution.
10 % For more information about licensing, please refer to
11 % http://www.ghostscript.com/licensing/. For information on
12 % commercial licensing, go to http://www.artifex.com/licensing/ or
13 % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14 % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
16 % $Id: traceop.ps,v 1.4 2002/02/21 21:49:28 giles Exp $
17 % Trace individual operators or procedures.
18 % <opref> is <opname> or <opname> <dict>
19 % (dict defaults to dict where op is currently defined, if writable;
20 % otherwise uses userdict)
21 % <opref> traceop prints vmem usage before;
22 % <opref> <numargs|preproc> prints arguments or runs proc before;
23 % <opref> <numargs|preproc> <numresults|postproc>
24 % also prints results or runs proc after.
25 % If traceflush is true, flush the output after each printout.
28 currentpacking true setpacking
29 .currentglobal true .setglobal
31 % Define the default "before" action
32 /tracebefore { vmstatus 3 traceprint pop pop pop } def
34 % Define the default "after" action
38 dup type /integertype eq {
39 1 sub -1 0 { ( ) print index ==only } for
45 traceflush { flush } if
49 dup type dup /nametype eq exch /dicttype eq or { { tracebefore } } if
50 1 index type dup /nametype eq exch /dicttype eq or { { traceafter } } if
51 /.tpost exch def /.tpre exch def
52 dup type /dicttype ne {
53 dup where not { userdict 1 index {} put userdict } if
56 (Warning: substituting userdict for non-writable dictionary.) =
59 /.tddict exch def /.tdict exch def /.tname exch cvlit def
61 .tname /=only cvx ( ) /print cvx
62 /.tpre load /traceprint cvx /traceend cvx
63 .tdict .tname get /.tdef 1 index cvlit def
65 dup type dup /arraytype eq exch /packedarraytype eq or {
69 /.tpost load /traceprint cvx () /= cvx /traceend cvx
70 .tdef gcheck /.tpre load gcheck and /.tpost load gcheck and .setglobal
72 .tdef type /operatortype eq {
73 .tname exch .makeoperator
76 .tddict exch .tname exch put
79 /tracebind /bind load def % in case someone wants to put it back
80 /bind { } def % disable