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@"
28 groff_trace \- groff macro package trace.tmac
30 .\" --------------------------------------------------------------------
32 .\" --------------------------------------------------------------------
41 .\" --------------------------------------------------------------------
43 .\" --------------------------------------------------------------------
49 can be a valuable tool for debugging documents written in the roff
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
62 This works also with the
63 .BR groffer (@MAN1EXT@)
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
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
89 is unusual because it does not contain any macros to be called by a
92 Instead, the existing macro definition and appending facilities are
93 modified such that they display diagnostic messages.
96 .\" --------------------------------------------------------------------
98 .\" --------------------------------------------------------------------
100 In the following examples, a roff fragment is fed into groff via
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
107 The resulting diagnostic messages are displayed directly below the
108 corresponding example.
111 .\" --------------------------------------------------------------------
112 .SS "Command line option"
122 > .test_macro some dummy arguments
123 > ' | groff -m trace >/dev/null
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"
152 > ' | groff -m trace >/dev/null
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"
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
196 As tracing was not active when macro
198 was defined, no call of this macro is protocolled; on the other hand,
201 is fully protocolled.
204 .\" --------------------------------------------------------------------
206 .\" --------------------------------------------------------------------
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
220 \&.foo \e\e\e\en[bar]
224 normally passes `\e\en[bar]' to macro `.foo', but with the redefined
226 request it passes `\en[bar]' instead.
229 The solution to this problem is to use groff's
231 escape which is an escape character not interpreted in copy mode, for
240 .\" --------------------------------------------------------------------
242 .\" --------------------------------------------------------------------
246 macros are kept in the file
249 .IR "tmac directory" ;
251 .BR groff_tmac (@MAN5EXT@)
255 .\" --------------------------------------------------------------------
257 .\" --------------------------------------------------------------------
261 A colon-separated list of additional tmac directories in which to
262 search for macro files; see
263 .BR groff_tmac (@MAN5EXT@)
267 .\" --------------------------------------------------------------------
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
284 This document is part of
286 the GNU roff distribution.
288 It was written by Bernd Warken.
291 .\" --------------------------------------------------------------------
293 .\" --------------------------------------------------------------------
296 .BR groff (@MAN1EXT@)
297 An overview of the groff system.
300 .BR troff (@MAN1EXT@)
301 For details on option
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