groff: update vendor branch to v1.20.1
[dragonfly.git] / contrib / groff / tmac / groff_trace.man
CommitLineData
92d0a6a6
JR
1.ig
2groff_trace.7
3
4File position: <groff-source>/tmac/groff_trace.man
5
4d3e9548 6Last update: 05 Jan 2009
92d0a6a6
JR
7
8This file is part of groff, the GNU roff type-setting system.
9
4d3e9548
JL
10Copyright (C) 2002, 2006, 2007, 2008, 2009
11 Free Software Foundation, Inc.
12
13written by Bernd Warken.
92d0a6a6
JR
14
15Permission is granted to copy, distribute and/or modify this document
4d3e9548 16under the terms of the GNU Free Documentation License, Version 1.3 or
92d0a6a6
JR
17any later version published by the Free Software Foundation; with the
18Invariant Sections being this .ig-section and AUTHOR, with no
19Front-Cover Texts, and with no Back-Cover Texts.
20
21A copy of the Free Documentation License is included as a file called
22FDL in the main directory of the groff source package.
23..
24.
92d0a6a6
JR
25.ds Ellipsis .\|.\|.\&\"
26.
4d3e9548 27.TH GROFF_TRACE @MAN7EXT@ "@MDATE@" "Groff Version @VERSION@"
92d0a6a6 28.
4d3e9548
JL
29.SH NAME
30groff_trace \- groff macro package trace.tmac
92d0a6a6
JR
31.
32.\" --------------------------------------------------------------------
4d3e9548 33.SH SYNOPSIS
92d0a6a6
JR
34.\" --------------------------------------------------------------------
35.
4d3e9548
JL
36.SY "groff \-m trace"
37.RI [ options
38.IR \*[Ellipsis] ]
39.RI [ files
40.IR \*[Ellipsis] ]
41.YS
92d0a6a6
JR
42.
43.\" --------------------------------------------------------------------
44.SH DESCRIPTION
45.\" --------------------------------------------------------------------
46.
47The
48.I trace
49macro package of
50.BR groff (@MAN1EXT@)
51can be a valuable tool for debugging documents written in the roff
52formatting language.
53.
4d3e9548 54A call stack trace is protocolled on standard error, this is, a
92d0a6a6
JR
55diagnostic message is emitted on entering and exiting of a macro call.
56.
57This greatly eases to track down an error in some macro.
58.
59.
60.P
61This tracing process is activated by specifying the groff or troff
62command line option
4d3e9548 63.BR \-m\ trace .
92d0a6a6
JR
64This works also with the
65.BR groffer (@MAN1EXT@)
66viewer program.
67.
68A finer control can be obtained by including the macro file within the
69document by the groff macro call
4d3e9548 70.BR .mso\ trace.tmac .
92d0a6a6
JR
71Only macros that are defined after this line are traced.
72.
73.
74.P
4d3e9548
JL
75If command line option
76.B \-r\ trace-full=1
77is given (or if this register is set in the document), number and string
78register assignments together with some other requests are traced also.
79.
80.
81.P
92d0a6a6
JR
82If some other macro package should be traced as well it must be specified
83after
4d3e9548 84.B \-m\ trace
92d0a6a6
JR
85on the command line.
86.
87.
88.P
89The macro file
90.B trace.tmac
91is unusual because it does not contain any macros to be called by a
92user.
93.
94Instead, the existing macro definition and appending facilities are
95modified such that they display diagnostic messages.
96.
97.
98.\" --------------------------------------------------------------------
99.SH EXAMPLES
100.\" --------------------------------------------------------------------
101.
92d0a6a6
JR
102In the following examples, a roff fragment is fed into groff via
103standard input.
104.
105As we are only interested in the diagnostic messages (standard error)
106on the terminal, the normal formatted output (standard output) is
4d3e9548 107redirected to the nirvana device
92d0a6a6
JR
108.IR /dev/null .
109The resulting diagnostic messages are displayed directly below the
110corresponding example.
111.
112.
113.\" --------------------------------------------------------------------
114.SS "Command line option"
4d3e9548 115Example:
92d0a6a6 116.
4d3e9548 117.RS
92d0a6a6 118.P
4d3e9548
JL
119.EX
120\fIsh#\fP echo '.
121> .de test_macro
122> ..
123> .test_macro
124> .test_macro some dummy arguments
125> ' | groff -m trace >/dev/null
126
127*** .de test_macro
128*** de trace enter: .test_macro
129*** trace exit: .test_macro
130*** de trace enter: .test_macro "some" "dummy" "arguments"
131*** trace exit: .test_macro "some" "dummy" "arguments"
132.EE
133.RE
92d0a6a6
JR
134.
135.P
136The entry and the exit of each macro call is displayed on the terminal
137(standard output) \[em] together with the arguments (if any).
138.
139.
140.\" --------------------------------------------------------------------
141.SS "Nested macro calls"
4d3e9548 142Example:
92d0a6a6 143.
4d3e9548 144.RS
92d0a6a6 145.P
4d3e9548
JL
146.EX
147\fIsh#\fP echo '.
148> .de child
149> ..
150> .de parent
151> .child
152> ..
153> .parent
154> ' | groff -m trace >/dev/null
155
156*** .de child
157*** .de parent
158*** de trace enter: .parent
159 *** de trace enter: .child
160 *** trace exit: .child
161*** trace exit: .parent
162.EE
163.RE
92d0a6a6
JR
164.
165.P
166This shows that macro calls can be nested.
167.
168This powerful feature can help to tack down quite complex call stacks.
169.
170.
171.\" --------------------------------------------------------------------
172.SS "Activating with .mso"
4d3e9548 173Example:
92d0a6a6 174.
4d3e9548 175.RS
92d0a6a6 176.P
4d3e9548
JL
177.EX
178\fIsh#\fP echo '.
179> .de before
180> ..
181> .mso trace.tmac
182> .de after
183> ..
184> .before
185> .after
186> .before
187> ' | groff >/dev/null
188
189*** de trace enter: .after
190*** trace exit: .after
191.EE
192.RE
92d0a6a6
JR
193.
194.P
195Here, the tracing is activated within the document, not by a command
196line option.
197.
198As tracing was not active when macro
199.I before
200was defined, no call of this macro is protocolled; on the other hand,
201the macro
202.I after
203is fully protocolled.
204.
205.
206.\" --------------------------------------------------------------------
4d3e9548
JL
207.SH PROBLEMS
208.\" --------------------------------------------------------------------
209.
210Because
211.B trace.tmac
212wraps the
213.B .de
214request (and its cousins), macro arguments are expanded one level more.
215.
216This causes problems if an argument contains four backslashes or more
217to prevent too early expansion of the backslash. For example, this
218macro call
219.
220.IP
221.EX
222\&.foo \e\e\e\en[bar]
223.EE
224.
225.P
226normally passes `\e\en[bar]' to macro `.foo', but with the redefined
227.B .de
228request it passes `\en[bar]' instead.
229.
230.P
231The solution to this problem is to use groff's
232.B \eE
233escape which is an escape character not interpreted in copy mode, for
234example
235.
236.IP
237.EX
238\&.foo \eEn[bar]
239.EE
240.
241.
242.\" --------------------------------------------------------------------
92d0a6a6
JR
243.SH FILES
244.\" --------------------------------------------------------------------
245.
246The
247.I trace
248macros are kept in the file
249.B trace.tmac
250located in the
251.IR "tmac directory" ;
252see
253.BR groff_tmac (@MAN5EXT@)
254for details.
255.
256.
257.\" --------------------------------------------------------------------
258.SH ENVIRONMENT
259.\" --------------------------------------------------------------------
260.
261.TP
4d3e9548 262.B $GROFF_TMAC_PATH
92d0a6a6
JR
263A colon-separated list of additional tmac directories in which to
264search for macro files; see
265.BR groff_tmac (@MAN5EXT@)
266for details.
267.
268.
269.\" --------------------------------------------------------------------
270.SH AUTHOR
271.\" --------------------------------------------------------------------
272.
4d3e9548 273Copyright (C) 2002, 2006, 2007, 2008 Free Software Foundation, Inc.
92d0a6a6
JR
274.
275.P
276This document is distributed under the terms of the FDL (GNU Free
277Documentation License) version 1.1 or later.
278.
279You should have received a copy of the FDL on your system, it is also
280available on-line at the
4d3e9548
JL
281.UR http://\:www.gnu.org/\:copyleft/\:fdl.html
282GNU copyleft site
283.UE .
92d0a6a6
JR
284.
285.P
286This document is part of
287.IR groff ,
288the GNU roff distribution.
289.
4d3e9548 290It was written by Bernd Warken.
92d0a6a6
JR
291.
292.
293.\" --------------------------------------------------------------------
294.SH "SEE ALSO"
295.\" --------------------------------------------------------------------
296.
297.TP
298.BR groff (@MAN1EXT@)
299An overview of the groff system.
300.
92d0a6a6
JR
301.TP
302.BR troff (@MAN1EXT@)
303For details on option
4d3e9548 304.BR \-m .
92d0a6a6
JR
305.
306.TP
307.BR groffer (@MAN1EXT@)
308A viewer program for all kinds of roff documents.
309.
92d0a6a6
JR
310.TP
311.BR groff_tmac (@MAN5EXT@)
312A general description of groff macro packages.
313.
92d0a6a6
JR
314.TP
315.BR groff (@MAN7EXT@)
316A short reference for the groff formatting language.
317.
92d0a6a6
JR
318.P
319A complete reference for all parts of the groff system is found in the
320groff
321.BR info (1)
322file.
323.
92d0a6a6
JR
324.\" Local Variables:
325.\" mode: nroff
326.\" End: