* tmac/www.tmac (TS, TE, EQ, EN): Don't use .als for setting up
[s-roff.git] / tmac / groff_trace.man
blob49632c6d6d5436f7afa10f6ce2c23d9fdcd606c7
1 .ig
2 groff_trace.7
4 File position: <groff-source>/tmac/groff_trace.man
6 Last update: 01 Oct 2008
8 This file is part of groff, the GNU roff type-setting system.
10 Copyright (C) 2002, 2006, 2007, 2008 Free Software Foundation, Inc.
11 written by Bernd Warken.
13 Permission is granted to copy, distribute and/or modify this document
14 under the terms of the GNU Free Documentation License, Version 1.1 or
15 any later version published by the Free Software Foundation; with the
16 Invariant Sections being this .ig-section and AUTHOR, with no
17 Front-Cover Texts, and with no Back-Cover Texts.
19 A copy of the Free Documentation License is included as a file called
20 FDL in the main directory of the groff source package.
23 .ds Ellipsis .\|.\|.\&\"
25 .TH GROFF_TRACE @MAN7EXT@ "@MDATE@" "Groff Version @VERSION@"
27 .SH NAME
28 groff_trace \- groff macro package trace.tmac
30 .\" --------------------------------------------------------------------
31 .SH SYNOPSIS
32 .\" --------------------------------------------------------------------
34 .SY "groff \-m trace"
35 .RI [ options
36 .IR \*[Ellipsis] ]
37 .RI [ files
38 .IR \*[Ellipsis] ]
39 .YS
41 .\" --------------------------------------------------------------------
42 .SH DESCRIPTION
43 .\" --------------------------------------------------------------------
45 The
46 .I trace
47 macro package of
48 .BR groff (@MAN1EXT@)
49 can be a valuable tool for debugging documents written in the roff
50 formatting language.
52 A call stack trace is protocolled on standard error, this is, a
53 diagnostic message is emitted on entering and exiting of a macro call.
55 This greatly eases to track down an error in some macro.
59 This tracing process is activated by specifying the groff or troff
60 command line option
61 .BR \-m\ trace .
62 This works also with the
63 .BR groffer (@MAN1EXT@)
64 viewer program.
66 A finer control can be obtained by including the macro file within the
67 document by the groff macro call
68 .BR .mso\ trace.tmac .
69 Only macros that are defined after this line are traced.
73 If command line option
74 .B \-r\ trace-full=1
75 is given (or if this register is set in the document), number and string
76 register assignments together with some other requests are traced also.
80 If some other macro package should be traced as well it must be specified
81 after
82 .B \-m\ trace
83 on the command line.
87 The macro file
88 .B trace.tmac
89 is unusual because it does not contain any macros to be called by a
90 user.
92 Instead, the existing macro definition and appending facilities are
93 modified such that they display diagnostic messages.
96 .\" --------------------------------------------------------------------
97 .SH EXAMPLES
98 .\" --------------------------------------------------------------------
100 In the following examples, a roff fragment is fed into groff via
101 standard input.
103 As we are only interested in the diagnostic messages (standard error)
104 on the terminal, the normal formatted output (standard output) is
105 redirected to the nirvana device
106 .IR /dev/null .
107 The resulting diagnostic messages are displayed directly below the
108 corresponding example.
111 .\" --------------------------------------------------------------------
112 .SS "Command line option"
113 Example:
118 \fIsh#\fP echo '.
119 > .de test_macro
120 > ..
121 > .test_macro
122 > .test_macro some dummy arguments
123 > ' | groff -m trace >/dev/null
125 *** .de test_macro
126 *** de trace enter: .test_macro
127 *** trace exit: .test_macro
128 *** de trace enter: .test_macro "some" "dummy" "arguments"
129 *** trace exit: .test_macro "some" "dummy" "arguments"
134 The entry and the exit of each macro call is displayed on the terminal
135 (standard output) \[em] together with the arguments (if any).
138 .\" --------------------------------------------------------------------
139 .SS "Nested macro calls"
140 Example:
145 \fIsh#\fP echo '.
146 > .de child
147 > ..
148 > .de parent
149 > .child
150 > ..
151 > .parent
152 > ' | groff -m trace >/dev/null
154 *** .de child
155 *** .de parent
156 *** de trace enter: .parent
157  *** de trace enter: .child
158  *** trace exit: .child
159 *** trace exit: .parent
164 This shows that macro calls can be nested.
166 This powerful feature can help to tack down quite complex call stacks.
169 .\" --------------------------------------------------------------------
170 .SS "Activating with .mso"
171 Example:
176 \fIsh#\fP echo '.
177 > .de before
178 > ..
179 > .mso trace.tmac
180 > .de after
181 > ..
182 > .before
183 > .after
184 > .before
185 >  ' | groff >/dev/null
187 *** de trace enter: .after
188 *** trace exit: .after
193 Here, the tracing is activated within the document, not by a command
194 line option.
196 As tracing was not active when macro
197 .I before
198 was defined, no call of this macro is protocolled; on the other hand,
199 the macro
200 .I after
201 is fully protocolled.
204 .\" --------------------------------------------------------------------
205 .SH PROBLEMS
206 .\" --------------------------------------------------------------------
208 Because
209 .B trace.tmac
210 wraps the
211 .B .de
212 request (and its cousins), macro arguments are expanded one level more.
214 This causes problems if an argument contains four backslashes or more
215 to prevent too early expansion of the backslash.  For example, this
216 macro call
220 \&.foo \e\e\e\en[bar]
224 normally passes `\e\en[bar]' to macro `.foo', but with the redefined
225 .B .de
226 request it passes `\en[bar]' instead.
229 The solution to this problem is to use groff's
230 .B \eE
231 escape which is an escape character not interpreted in copy mode, for
232 example
236 \&.foo \eEn[bar]
240 .\" --------------------------------------------------------------------
241 .SH FILES
242 .\" --------------------------------------------------------------------
245 .I trace
246 macros are kept in the file
247 .B trace.tmac
248 located in the
249 .IR "tmac directory" ;
251 .BR groff_tmac (@MAN5EXT@)
252 for details.
255 .\" --------------------------------------------------------------------
256 .SH ENVIRONMENT
257 .\" --------------------------------------------------------------------
260 .B $GROFF_TMAC_PATH
261 A colon-separated list of additional tmac directories in which to
262 search for macro files; see
263 .BR groff_tmac (@MAN5EXT@)
264 for details.
267 .\" --------------------------------------------------------------------
268 .SH AUTHOR
269 .\" --------------------------------------------------------------------
271 Copyright (C) 2002, 2006, 2007, 2008 Free Software Foundation, Inc.
274 This document is distributed under the terms of the FDL (GNU Free
275 Documentation License) version 1.1 or later.
277 You should have received a copy of the FDL on your system, it is also
278 available on-line at the
279 .UR http://\:www.gnu.org/\:copyleft/\:fdl.html
280 GNU copyleft site
281 .UE .
284 This document is part of
285 .IR groff ,
286 the GNU roff distribution.
288 It was written by Bernd Warken.
291 .\" --------------------------------------------------------------------
292 .SH "SEE ALSO"
293 .\" --------------------------------------------------------------------
296 .BR groff (@MAN1EXT@)
297 An overview of the groff system.
300 .BR troff (@MAN1EXT@)
301 For details on option
302 .BR \-m .
305 .BR groffer (@MAN1EXT@)
306 A viewer program for all kinds of roff documents.
309 .BR groff_tmac (@MAN5EXT@)
310 A general description of groff macro packages.
313 .BR groff (@MAN7EXT@)
314 A short reference for the groff formatting language.
317 A complete reference for all parts of the groff system is found in the
318 groff
319 .BR info (1)
320 file.
322 .\" Local Variables:
323 .\" mode: nroff
324 .\" End: