Debian Codegraph @

upstream/fedora-rawhide/man7/groff_trace.7

raw
1 .TH groff_trace 7 "2026-03-03" "groff 1.24.0"
2 .SH Name
3 groff_trace \- macros for debugging GNU
4 .I roff
5 documents
6 .
7 .
8 .\" ====================================================================
9 .\" Legal Terms
10 .\" ====================================================================
11 .\"
12 .\" Copyright 2002-2022 Free Software Foundation, Inc.
13 .\"
14 .\" This file is part of groff, the GNU roff typesetting system.
15 .\"
16 .\" Permission is granted to copy, distribute and/or modify this
17 .\" document under the terms of the GNU Free Documentation License,
18 .\" Version 1.3 or any later version published by the Free Software
19 .\" Foundation; with no Invariant Sections, with no Front-Cover Texts,
20 .\" and with no Back-Cover Texts.
21 .\"
22 .\" A copy of the Free Documentation License is included as a file
23 .\" called FDL in the main directory of the groff source package.
24 .
25 .
26 .\" Save and disable compatibility mode (for, e.g., Solaris 10/11).
27 .do nr *groff_groff_trace_7_man_C \n[.cp]
28 .cp 0
29 .
30 .\" Define fallback for groff 1.23's MR macro if the system lacks it.
31 .nr do-fallback 0
32 .if !\n(.f .nr do-fallback 1 \" mandoc
33 .if \n(.g .if !d MR .nr do-fallback 1 \" older groff
34 .if !\n(.g .nr do-fallback 1 \" non-groff *roff
35 .if \n[do-fallback] \{\
36 . de MR
37 . ie \\n(.$=1 \
38 . I \%\\$1
39 . el \
40 . IR \%\\$1 (\\$2)\\$3
41 . .
42 .\}
43 .rr do-fallback
44 .
45 .
46 .\" ====================================================================
47 .SH Synopsis
48 .\" ====================================================================
49 .
50 .SY "groff \-m trace"
51 .RI [ option\~ .\|.\|.\&]
52 .RI [ file\~ .\|.\|.]
53 .YS
54 .
55 .
56 .\" ====================================================================
57 .SH Description
58 .\" ====================================================================
59 .
60 .I trace
61 is a macro package for the
62 .MR groff 7
63 document formatting system,
64 designed as an aid for debugging documents written in its language.
65 .
66 It issues a message to the standard error stream upon entry to and exit
67 from each macro call.
68 .
69 This can ease the process of isolating errors in macro definitions.
70 .
71 .
72 .P
73 Activate the package by specifying the command-line option
74 .RB \[lq] \-m\~trace \[rq]
75 to the formatter program
76 (often
77 .MR groff 1 ).
78 .
79 You can achieve finer control by including the macro file within the
80 document;
81 invoke the
82 .B mso
83 request,
84 as in
85 .RB \[lq] .mso\~trace.tmac \[rq].
86 .
87 Only macros that are defined after this invocation are traced.
88 .
89 If the
90 .B trace\-full
91 register is set to a true value,
92 as with the command-line option
93 .RB \[lq] \-r\~trace\-full=1 \[rq],
94 register and string assignments,
95 along with some other requests,
96 are traced also.
97 .
98 If another macro package should be traced as well,
99 specify it after
100 .RB \[lq] \-m\~trace \[rq]
101 on the command line.
102 .
103 .
104 .P
105 The macro file
106 .I trace.tmac
107 is unusual because it does not contain any macros to be called by a
108 user.
109 .
110 Instead,
111 .IR groff 's
112 macro definition and alteration facilities are wrapped such that they
113 display diagnostic messages.
114 .
115 .
116 .\" ====================================================================
117 .SS Limitations
118 .\" ====================================================================
119 .
120 Because
121 .I trace.tmac
122 wraps the
123 .B de
124 request
125 (and its cousins),
126 macro arguments are expanded one level more.
127 .
128 This causes problems if an argument uses four or more backslashes to
129 delay interpretation of an escape sequence.
130 .
131 For example,
132 the macro call
133 .
134 .RS
135 .EX
136 \&.foo \[rs]\[rs]\[rs]\[rs]n[bar]
137 .EE
138 .RE
139 .
140 normally passes \[lq]\[rs]\[rs]n[bar]\[rq] to macro \[lq]foo\[rq],
141 but with
142 .B de
143 redefined,
144 it passes \[lq]\[rs]n[bar]\[rq] instead.
145 .
146 .
147 .P
148 The solution to this problem is to use
149 .IR groff 's
150 .B \[rs]E
151 escape sequence,
152 an escape character that is not interpreted in copy mode.
153 .
154 .RS
155 .EX
156 \&.foo \[rs]En[bar]
157 .EE
158 .RE
159 .
160 .
161 .br
162 .ne 3v
163 .\" ====================================================================
164 .SH Files
165 .\" ====================================================================
166 .
167 .TP
168 .I /usr/\:\%share/\:\%groff/\:\%1.24.0/\:\%tmac/\:trace\:.tmac
169 implements the package.
170 .
171 .
172 .\" ====================================================================
173 .SH Examples
174 .\" ====================================================================
175 .
176 We will illustrate
177 .I trace.tmac
178 using the shell's \[lq]here document\[rq] feature to supply
179 .I groff
180 with a document
181 on the standard input stream.
182 .
183 Since we are interested only in diagnostic messages appearing on the
184 standard error stream,
185 we discard the formatted output by redirecting the standard output
186 stream to
187 .IR /dev/null .
188 .
189 .
190 .\" ====================================================================
191 .SS "Observing nested macro calls"
192 .\" ====================================================================
193 .
194 Macro calls can be nested,
195 even with themselves.
196 .
197 Tracing recurses along with them;
198 this feature can help to detangle complex call stacks.
199 .
200 .
201 .RS
202 .P
203 .EX
204 .RB $\~ "cat <<EOF | groff \-m trace > /dev/null
205 .B .de countdown
206 .B . nop \[rs]\[rs]$1
207 .B . nr count (\[rs]\[rs]$1 - 1)
208 .B . if \[rs]\[rs]n[count] .countdown \[rs]\[rs]n[count]
209 .B ..
210 .B .countdown 3
211 .B blastoff
212 .B EOF
213 \~*** .de countdown
214 \~*** de trace enter: .countdown "3"
215 \~\~*** de trace enter: .countdown "2"
216 \~\~\~*** de trace enter: .countdown "1"
217 \~\~\~*** trace exit: .countdown "1"
218 \~\~*** trace exit: .countdown "2"
219 \~*** trace exit: .countdown "3"
220 .EE
221 .RE
222 .
223 .
224 .\" ====================================================================
225 .SS "Tracing with the mso request"
226 .\" ====================================================================
227 .
228 Now let us activate tracing within the document,
229 not with a command-line option.
230 .
231 We might do so when employing a macro package like
232 .I ms
233 or
234 .IR mom ,
235 to avoid distraction by traces of macros we didn't write.
236 .
237 .
238 .RS
239 .P
240 .EX
241 .RB $\~ "cat <<EOF | groff -ms > /dev/null"
242 .B .LP
243 .B This is my introductory paragraph.
244 .B .mso trace.tmac
245 .B .de Mymac
246 .B ..
247 .B .Mymac
248 .B .PP
249 .B Let us review the existing literature.
250 .B EOF
251 \~*** .de Mymac
252 \~*** de trace enter: .Mymac
253 \~*** trace exit: .Mymac
254 .EE
255 .RE
256 .
257 .
258 .P
259 As tracing was not yet active when the macros \[lq]LP\[rq] and
260 \[lq]PP\[rq] were defined
261 (by
262 .IR s.tmac ),
263 their calls were not traced;
264 contrast with the macro \[lq]Mymac\[rq].
265 .
266 .
267 .\" ====================================================================
268 .SH Authors
269 .\" ====================================================================
270 .
271 .I trace.tmac
272 was written by James Clark.
273 .
274 This document was written by
275 .MT groff\-bernd\:.warken\-72@\:web\:.de
276 Bernd Warken
277 .ME
278 and
279 .MT g.branden\:.robinson@\:gmail\:.com
280 G.\& Branden Robinson
281 .ME .
282 .
283 .
284 .\" ====================================================================
285 .SH "See also"
286 .\" ====================================================================
287 .
288 .IR "Groff: The GNU Implementation of troff" ,
289 by Trent A.\& Fisher and Werner Lemberg,
290 is the primary
291 .I groff
292 manual.
293 .
294 You can browse it interactively with \[lq]info groff\[rq].
295 .
296 .
297 .TP
298 .MR groff 1
299 gives an overview of the
300 .I groff
301 document formatting system.
302 .
303 .
304 .TP
305 .MR \%troff 1
306 supplies details of the
307 .B \-m
308 command-line option.
309 .
310 .
311 .TP
312 .MR groff_tmac 5
313 offers a survey of
314 .I groff
315 macro packages.
316 .
317 .
318 .TP
319 .MR groff 7
320 is a reference manual for the
321 .I groff
322 language.
323 .
324 .
325 .\" Restore compatibility mode (for, e.g., Solaris 10/11).
326 .cp \n[*groff_groff_trace_7_man_C]
327 .do rr *groff_groff_trace_7_man_C
328 .
329 .
330 .\" Local Variables:
331 .\" fill-column: 72
332 .\" mode: nroff
333 .\" End:
334 .\" vim: set filetype=groff textwidth=72: