Merge branch 'topic/sync-to-go-2'
[s-roff.git] / man / tmac-trace.7.in
blobd21d12a4358878fa64909e7b29415fcb82ab6938
1 .ig
2 @L_ROFF@_trace.7
4 Copyright (c) 2014 - 2017 Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>.
6 Copyright (C) 2002, 2006 - 2008 Free Software Foundation, Inc.
7 written by Bernd Warken.
9 Permission is granted to copy, distribute and/or modify this document
10 under the terms of the GNU Free Documentation License, Version 1.1 or
11 any later version published by the Free Software Foundation; with the
12 Invariant Sections being this .ig-section and AUTHOR, with no
13 Front-Cover Texts, and with no Back-Cover Texts.
15 You should have received a copy of the Free Documentation License
16 as part of the file COPYING; also located in the main directory of the
17 source package of this program.
20 .do nr __compat \n[.C]
21 .cp 0
22 .ds Ellipsis .\|.\|.\&\"
25 .TH @U_ROFF@_TRACE @MAN7EXT@ "@MDATE@" "@T_ROFF@ v@VERSION@"
27 .\"
28 .SH NAME
29 @L_ROFF@_trace \- @T_ROFF@ macro package trace.tmac
31 .\"
32 .SH SYNOPSIS
34 .SY "@L_ROFF@ \-m trace"
35 .RI [ options
36 .IR \*[Ellipsis] ]
37 .RI [ files
38 .IR \*[Ellipsis] ]
39 .YS
41 .\"
42 .SH DESCRIPTION
44 The
45 .I trace
46 macro package can be a valuable tool for debugging documents written
47 in the roff formatting language.
48 A call stack trace is protocolled on standard error, this is, a
49 diagnostic message is emitted on entering and exiting of a macro call.
50 This greatly eases to track down an error in some macro.
53 This tracing process is activated by specifying the groff or troff
54 command line option
55 .BR \-m\ trace .
56 A finer control can be obtained by including the macro file within the
57 document via
58 .BR .mso\ trace.tmac .
59 Only macros that are defined after this line are traced.
62 If command line option
63 .B \-r\ trace-full=1
64 is given (or if this register is set in the document), number and string
65 register assignments together with some other requests are traced also.
68 If some other macro package should be traced as well it must be specified
69 after
70 .B \-m\ trace
71 on the command line.
74 The macro file
75 .B trace.tmac
76 is unusual because it does not contain any macros to be called by a
77 user.
78 Instead, the existing macro definition and appending facilities are
79 modified such that they display diagnostic messages.
81 .\"
82 .SH EXAMPLES
84 In the following examples, a roff fragment is fed into @L_ROFF@ via
85 standard input.
86 As we are only interested in the diagnostic messages (standard error)
87 on the terminal, the normal formatted output (standard output) is
88 redirected to the nirvana device
89 .IR /dev/null .
90 The resulting diagnostic messages are displayed directly below the
91 corresponding example.
93 .\"
94 .SS "Command line option"
96 Example:
98 .RS
101 \fIsh#\fP echo '.
102 > .de test_macro
103 > ..
104 > .test_macro
105 > .test_macro some dummy arguments
106 > ' | @L_ROFF@ -m trace >/dev/null
108 *** .de test_macro
109 *** de trace enter: .test_macro
110 *** trace exit: .test_macro
111 *** de trace enter: .test_macro "some" "dummy" "arguments"
112 *** trace exit: .test_macro "some" "dummy" "arguments"
117 The entry and the exit of each macro call is displayed on the terminal
118 (standard output) \[em] together with the arguments (if any).
121 .SS "Nested macro calls"
123 Example:
128 \fIsh#\fP echo '.
129 > .de child
130 > ..
131 > .de parent
132 > .child
133 > ..
134 > .parent
135 > ' | @L_ROFF@ -m trace >/dev/null
137 *** .de child
138 *** .de parent
139 *** de trace enter: .parent
140  *** de trace enter: .child
141  *** trace exit: .child
142 *** trace exit: .parent
147 This shows that macro calls can be nested.
148 This powerful feature can help to tack down quite complex call stacks.
151 .SS "Activating with .mso"
153 Example:
158 \fIsh#\fP echo '.
159 > .de before
160 > ..
161 > .mso trace.tmac
162 > .de after
163 > ..
164 > .before
165 > .after
166 > .before
167 >  ' | @L_ROFF@ >/dev/null
169 *** de trace enter: .after
170 *** trace exit: .after
175 Here, the tracing is activated within the document, not by a command
176 line option.
177 As tracing was not active when macro
178 .I before
179 was defined, no call of this macro is protocolled; on the other hand,
180 the macro
181 .I after
182 is fully protocolled.
185 .SH PROBLEMS
187 Because
188 .B trace.tmac
189 wraps the
190 .B .de
191 request (and its cousins), macro arguments are expanded one level more.
192 This causes problems if an argument contains four backslashes or more
193 to prevent too early expansion of the backslash.  For example, this
194 macro call
198 \&.foo \e\e\e\en[bar]
202 normally passes `\e\en[bar]' to macro `.foo', but with the redefined
203 .B .de
204 request it passes `\en[bar]' instead.
207 The solution to this problem is to use @L_ROFF@'s
208 .B \eE
209 escape which is an escape character not interpreted in copy mode, for
210 example
214 \&.foo \eEn[bar]
218 .SH FILES
221 .I trace
222 macros are kept in the file
223 .B trace.tmac
224 located in the
225 .IR "tmac directory" ;
227 .BR @L_ROFF@-tmac (@MAN5EXT@)
228 for details.
231 .SH ENVIRONMENT
234 .B $@U_ROFF@_TMAC_PATH
235 A colon-separated list of additional tmac directories in which to
236 search for macro files; see
237 .BR @L_ROFF@-tmac (@MAN5EXT@)
238 for details.
241 .SH AUTHOR
243 Copyright (c) 2014 - 2017 Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>.
245 Copyright (C) 2002, 2006 - 2008 Free Software Foundation, Inc.
247 This document was written by Bernd Warken.
249 This document is distributed under the terms of the FDL (GNU Free
250 Documentation License) version 1.1 or later.
252 You should have received a copy of the FDL on your system, it is also
253 available on-line at the
254 .UR http://\:www.gnu.org/\:copyleft/\:fdl.html
255 GNU copyleft site
256 .UE .
259 .SH "SEE ALSO"
262 .BR @L_ROFF@ (@MAN1EXT@)
263 An overview of the @T_ROFF@ system.
266 .BR @L_TROFF@ (@MAN1EXT@)
267 For details on option
268 .BR \-m .
271 .BR @L_ROFF@-tmac (@MAN5EXT@)
272 A general description of @T_ROFF@ macro packages.
275 .BR @L_ROFF@ (@MAN7EXT@)
276 A short reference for the @T_ROFF@ formatting language.
278 .cp \n[__compat]
279 .rr __compat
281 .\" s-ts-mode