Formatting.
[s-roff.git] / tmac / trace.tmac
blob07e541c994d30868bc17f2a25e1b5b303e36b69b
1 .\" trace.tmac
2 .\"
3 .\" Load this before a macro package that you want to trace.
4 .\"
5 .\"
6 .\" Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002, 2003, 2004, 2006,
7 .\"               2007, 2008
8 .\"   Free Software Foundation, Inc.
9 .\"      Written by James Clark (jjc@jclark.com)
10 .\"
11 .\" This file is part of groff.
12 .\"
13 .\" groff is free software; you can redistribute it and/or modify it under
14 .\" the terms of the GNU General Public License as published by the Free
15 .\" Software Foundation; either version 2, or (at your option) any later
16 .\" version.
17 .\"
18 .\" groff is distributed in the hope that it will be useful, but WITHOUT ANY
19 .\" WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 .\" FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21 .\" for more details.
22 .\"
23 .\" You should have received a copy of the GNU General Public License along
24 .\" with groff; see the file COPYING.  If not, write to the Free Software
25 .\" Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
26 .\"
29 .\" Regarding the usage of `.do': All lines of macros which should
30 .\" work in compatibility mode must be protected if they contain
31 .\" GNU troff extensions and are defined with `.de'.  Example: `.ds',
32 .\" but not `.ds1', since the latter can't be called in compatibility
33 .\" mode.
36 .do if d !!!sp \
37 .  nx
39 .nr _C \n(.C
40 .cp 0
42 .ds !!!sp " \"
44 .de !!c
47 .eo
49 .rn nr !!nr
51 .de nr
52 .  do ecs
53 .  ec
54 .  do !!nr \$*
55 .  do tm1 "\*[!!!sp]*** .nr \$* (-> \n[\$1])
56 .  do ecr
59 .rn ds !!ds
60 .rn ds1 !!ds1
61 .rn as !!as
62 .rn as1 !!as1
64 .de ds
65 .  do ecs
66 .  ec
67 .  do tm1 "\*[!!!sp]*** .ds \$^
68 .  do !!ds \$^\"
69 .  do ecr
72 .de1 ds1
73 .  ecs
74 .  ec
75 .  tm1 "\*[!!!sp]*** .ds1 \$^
76 .  !!ds1 \$^\"
77 .  ecr
80 .de as
81 .  do ecs
82 .  ec
83 .  do tm1 "\*[!!!sp]*** .as \$^
84 .  do !!as \$^\"
85 .  do ecr
88 .de1 as1
89 .  ecs
90 .  ec
91 .  tm1 "\*[!!!sp]*** .as1 \$^
92 .  !!as1 \$^\"
93 .  ecr
96 .rn substring !!substring
98 .de1 substring
99 .  ecs
100 .  ec
101 .  !!substring \$*
102 .  tm1 "\*[!!!sp]*** .substring \$* (-> `\*[\$1]')
103 .  ecr
106 .rn als !!als
108 .de1 als
109 .  ecs
110 .  ec
111 .  !!als \$1 \$2
112 .  if d !!\$2 \
113 .    !!als !!\$1 !!\$2
114 .  tm1 "\*[!!!sp]*** .als \$1 \$2
115 .  ecr
118 .!!c Now the central tracing macros.  The redefined `de' macros
119 .!!c create wrapper macros `foo' which emit tracing messages
120 .!!c before and after the call to the traced macro `!!foo'.
121 .!!c
122 .!!c Note that we define `!!foo' in advance so that an alias to
123 .!!c `!!!!foo' is possible.  The latter occurs if `foo' is
124 .!!c called as \\[foo].
125 .!!c
126 .!!c The call to `dei' must be the last instruction in the macro
127 .!!c (since it continues the definition of the macro to trace).
129 .rn de !!de
130 .rn de1 !!de1
132 .!!de de
133 .  do ecs
134 .  ec
135 .  do !!de \$1
136 .    do ie \\n[.br] \
137 .      !!ds !!!br .\"
138 .    el \
139 .      do !!ds !!!br '\"
140 .    ie "\$1"\\$0" \
141 .      do tm1 "\\*[!!!sp]*** de trace enter: \\*[!!!br]\\$0 \\$@
142 .    el \
143 .      do tm1 "\\*[!!!sp]*** de trace enter \$1: \\*[!!!br]\\$0 \\$@
144 .    do !!as !!!sp " \"
145 .    do ie \\n[.br] \
146 .      do !!\\$0 \\$@
147 .    el \
148 '      do !!\\$0 \\$@
149 .    do !!substring !!!sp 1
150 .    do ie \\n[.br] \
151 .      !!ds !!!br .\"
152 .    el \
153 .      do !!ds !!!br '\"
154 .    ie "\$1"\\$0" \
155 .      do tm1 "\\*[!!!sp]*** trace exit: \\*[!!!br]\\$0 \\$@
156 .    el \
157 .      do tm1 "\\*[!!!sp]*** trace exit \$1: \\*[!!!br]\\$0 \\$@
160 .  do !!ds !!d1 !!\$1
161 .  do !!ds !!d2 \$2
163 .  do !!de !!\$1
165 .  do !!als !!!!\$1 !!\$1
167 .  do ecr
168 .  do dei !!d1 !!d2
171 .!!de1 de1
172 .  ecs
173 .  ec
174 .  !!de1 \$1
175 .    ie \\n[.br] \
176 .      !!ds !!!br .\"
177 .    el \
178 .      !!ds !!!br '\"
179 .    ie "\$1"\\$0" \
180 .      tm1 "\\*[!!!sp]*** de1 trace enter: \\*[!!!br]\\$0 \\$@
181 .    el \
182 .      tm1 "\\*[!!!sp]*** de1 trace enter \$1: \\*[!!!br]\\$0 \\$@
183 .    !!as !!!sp " \"
184 .    ie \\n[.br] \
185 .      !!\\$0 \\$@
186 .    el \
187 '      !!\\$0 \\$@
188 .    !!substring !!!sp 1
189 .    ie \\n[.br] \
190 .      !!ds !!!br .\"
191 .    el \
192 .      !!ds !!!br '\"
193 .    ie "\$1"\\$0" \
194 .      tm1 "\\*[!!!sp]*** trace exit: \\*[!!!br]\\$0 \\$@
195 .    el \
196 .      tm1 "\\*[!!!sp]*** trace exit \$1: \\*[!!!br]\\$0 \\$@
199 .  !!ds !!d1 !!\$1
200 .  !!ds !!d2 \$2
202 .  !!de1 !!\$1
204 .  !!als !!!!\$1 !!\$1
206 .  ecr
207 .  dei1 !!d1 !!d2
210 .rn am !!am
211 .rn am1 !!am1
213 .!!de am
214 .  do ecs
215 .  ec
216 .  do !!de \$1
217 .    do ie \\n[.br] \
218 .      !!ds !!!br .\"
219 .    el \
220 .      do !!ds !!!br '\"
221 .    ie "\$1"\\$0" \
222 .      do tm1 "\\*[!!!sp]*** am trace enter: \\*[!!!br]\\$0 \\$@
223 .    el \
224 .      do tm1 "\\*[!!!sp]*** am trace enter \$1: \\*[!!!br]\\$0 \\$@
225 .    do !!as !!!sp " \"
226 .    do ie \\n[.br] \
227 .      do !!\\$0 \\$@
228 .    el \
229 '      do !!\\$0 \\$@
230 .    do !!substring !!!sp 1
231 .    do ie \\n[.br] \
232 .      !!ds !!!br .\"
233 .    el \
234 .      do !!ds !!!br '\"
235 .    ie "\$1"\\$0" \
236 .      do tm1 "\\*[!!!sp]*** trace exit: \\*[!!!br]\\$0 \\$@
237 .    el \
238 .      do tm1 "\\*[!!!sp]*** trace exit \$1: \\*[!!!br]\\$0 \\$@
241 .  do !!ds !!a1 !!\$1
242 .  do !!ds !!a2 \$2
244 .  do !!de !!\$1
246 .  do !!als !!!!\$1 !!\$1
248 .  do ecr
249 .  do ami !!a1 !!a2
252 .!!de1 am1
253 .  ecs
254 .  ec
255 .  !!de1 \$1
256 .    ie \\n[.br] \
257 .      !!ds !!!br .\"
258 .    el \
259 .      !!ds !!!br '\"
260 .    ie "\$1"\\$0" \
261 .      tm1 "\\*[!!!sp]*** am1 trace enter: \\*[!!!br]\\$0 \\$@
262 .    el \
263 .      tm1 "\\*[!!!sp]*** am1 trace enter \$1: \\*[!!!br]\\$0 \\$@
264 .    !!as !!!sp " \"
265 .    ie \\n[.br] \
266 .      !!\\$0 \\$@
267 .    el \
268 '      !!\\$0 \\$@
269 .    !!substring !!!sp 1
270 .    ie \\n[.br] \
271 .      !!ds !!!br .\"
272 .    el \
273 .      !!ds !!!br '\"
274 .    ie "\$1"\\$0" \
275 .      tm1 "\\*[!!!sp]*** trace exit: \\*[!!!br]\\$0 \\$@
276 .    el \
277 .      tm1 "\\*[!!!sp]*** trace exit \$1: \\*[!!!br]\\$0 \\$@
280 .  !!ds !!a1 !!\$1
281 .  !!ds !!a2 \$2
283 .  !!de1 !!\$1
285 .  !!als !!!!\$1 !!\$1
287 .  ecr
288 .  ami1 !!a1 !!a2
291 .rn return !!return
293 .!!de1 return
294 .  tm1 "\*[!!!sp]*** return
295 .  !!return twice
298 .rn so !!so
300 .!!de so
301 .  do ecs
302 .  ec
303 .  do tm1 "\*[!!!sp]*** .so \$* {
304 .  do !!as !!!sp " \"
305 .  do ecr
306 .  do !!so \$*
307 .  do ecs
308 .  ec
309 .  do !!substring !!!sp 1
310 .  do tm1 "\*[!!!sp]*** }
311 .  do ecr
314 .!!c We must use `.de' for the redefinition of .mso to avoid
315 .!!c side effects; for example, it might be called with
316 .!!c `.do mso ...'.
318 .rn mso !!mso
320 .!!de mso
321 .  do ecs
322 .  ec
323 .  do tm1 "\*[!!!sp]*** .mso \$* {
324 .  do !!as !!!sp " \"
325 .  do ecr
326 .  do !!mso \$*
327 .  do ecs
328 .  ec
329 .  do !!substring !!!sp 1
330 .  do tm1 "\*[!!!sp]*** }
331 .  do ecr
335 .rn rn !!rn
337 .!!de rn
338 .  do ecs
339 .  ec
340 .  dp !!rn \$1 \$2
341 .  do if d !!\$1 \
342 .    !!rn !!\$1 !!\$2
343 .  do tm1 "\*[!!!sp]*** .rn \$1 \$2
344 .  do ecr
349 .cp \n(_C
351 .\" EOF