2 .TH GROFF_TRACE @MAN7EXT@ "@MDATE@" "Groff Version @VERSION@"
4 groff_trace \- groff macro package trace.tmac
6 .\" The .SH was moved to this place to make `apropos' happy.
9 .\" --------------------------------------------------------------------
11 .\" --------------------------------------------------------------------
16 File position: <groff-source>/tmac/groff_trace.man
18 Last update: 14 July 2002
20 This file is part of groff, the GNU roff type-setting system.
22 Copyright (C) 2002 Free Software Foundation, Inc.
23 written by Bernd Warken <bwarken@mayn.de>
25 Permission is granted to copy, distribute and/or modify this document
26 under the terms of the GNU Free Documentation License, Version 1.1 or
27 any later version published by the Free Software Foundation; with the
28 Invariant Sections being this .ig-section and AUTHOR, with no
29 Front-Cover Texts, and with no Back-Cover Texts.
31 A copy of the Free Documentation License is included as a file called
32 FDL in the main directory of the groff source package.
35 .\" --------------------------------------------------------------------
37 .\" --------------------------------------------------------------------
39 .do nr groff_trace_C \n[.C]
51 .ds Ellipsis .\|.\|.\&\"
53 .\" Global static variables for inter-macro communication
56 .\" --------------------------------------------------------------------
57 .\" setup for the macro definitions below
59 .\" naming: namespace:category_macro.variable_name (experimental)
61 .\" --------------------------------------------------------------------
62 .\" configuration of prompt for `.Shell_cmd'* macros
63 .ds trace:Shell_cmd.prompt_text sh#\" prompt for shell commands
64 .ds trace:Shell_cmd+.prompt_text >\" prompt on continuation lines
65 .ds trace:Shell_cmd_base.prompt_font I\" font for prompts
67 .\" automatically determine setup from the configuration above
68 .als @f trace:Shell_cmd_base.prompt_font\"
69 .als @t trace:Shell_cmd.prompt_text\"
70 .als @t+ trace:Shell_cmd+.prompt_text\"
71 .ds trace:Shell_cmd.prompt \f[\*[@f]]\*[@t]\f[]\" needed
72 .ds trace:Shell_cmd+.prompt \f[\*[@f]]\*[@t+]\f[]\" needed
73 .nr @w \w'\*[trace:Shell_cmd.prompt]'\"
74 .nr @w+ \w'\*[trace:Shell_cmd+.prompt]'\"
76 .\" Full prompt width is maximum of texts plus 1m
77 .nr trace:Shell_cmd_base.prompt_width (\n[@w]>?\n[@w+]+1m)\" needed
86 .\"--------------------------------------------------------------------
87 .\" Ignore all arguments like a comment, even after a .eo call.
90 .c --------------------------------------------------------------------
95 . ds @tmp@ \fB\\$1\f[]\fI\\$2\f[]
97 . Text \\*[@tmp@]\fR\\$*\f[]
101 .c --------------------------------------------------------------------
102 .c .Env_var (<env_var_name> [<punct>])
104 .c Display an environment variable, with optional punctuation.
109 . Text \f[CB]\\$1\f[]\\$2
112 .c --------------------------------------------------------------------
113 .c .Error (<text>...)
115 .c Print error message to terminal and abort.
121 .c --------------------------------------------------------------------
123 . if r@+Example_font \
124 . Error previous .Example was not terminated by a ./Example
125 . nr @+Example_font \\n[.f]
128 .c RS \\n[trace:Shell_cmd_base.prompt_width]u
131 .c --------------------------------------------------------------------
133 . if !r@+Example_font \
134 . Error no previous call to .Example
135 . ft \\n[@+Example_font]
141 .c --------------------------------------------------------------------
143 . if (\\n[.$] <= 0) \
144 . Error \\$0 needs at least one argument.
145 . ds @s .\f[B]\\$1\f[]\"
148 . as @s \~\f[I]\\$*\f[]\"
152 .c --------------------------------------------------------------------
158 .c --------------------------------------------------------------------
159 .c .Shell_cmd (<CR> [<CI>] ...)
161 .c A shell command line; display args alternating in fonts CR and CI.
164 .c .Shell_cmd "groffer --dpi 100 file"
165 .c result: `sh# groffer --dpi 100 file'
166 .c with 'sh#' in font I, the rest in CR
168 .c .Shell_cmd groffer\~--dpi\~100\~file
169 .c result: the same as above
171 .c .Shell_cmd "groffer --dpi=" value " file"
172 .c result: sh# groffer --dpi=value file
173 .c with `groffer --dpi=' and `file' in CR; `value' in CI
175 .c .Shell_cmd groffer\~--dpi= value \~file
176 .c result: the same as the previous example
179 . trace:Shell_cmd_base "\*[trace:Shell_cmd.prompt]" \\$@
181 .c --------------------------------------------------------------------
182 .c .Shell_cmd+ (<CR> [<CI>] ...)
184 .c A continuation line for .Shell_cmd.
187 . trace:Shell_cmd_base "\*[trace:Shell_cmd+.prompt]" \\$@
189 .c --------------------------------------------------------------------
190 .c .Shell_cmd_base (<prompt> [<CR> [<CI>] ...])
192 .c A shell command line; display args alternating in fonts CR and CI.
193 .c Internal, do not use directly.
195 .c Globals: read-only register @.Shell_cmd_width
197 .de trace:Shell_cmd_base
198 . if (\\n[.$] <= 0) \
200 . nr @+font \\n[.f]\"
203 . c gap between prompt and command
204 . nr @+gap \\n[trace:Shell_cmd_base.prompt_width]-\\w'\\*[@prompt]'\"
205 . ds @res \\*[@prompt]\h'\\n[@+gap]u'\"
208 . while (\\n[.$] > 0) \{\
209 . as @res \\f[\\*[@cf]]\\$1\"
231 .c --------------------------------------------------------------------
234 .c Treat the arguments as text, no matter how they look.
237 . if (\\n[.$] == 0) \
241 .c --------------------------------------------------------------------
242 .c .Topic ([<indent>])
244 .c A bulleted paragraph.
255 .c --------------------------------------------------------------------
258 .c Continuation line for .TP header.
265 .c --------------------------------------------------------------------
267 . ds @tmp@ `\f(CR\\$1\f[]'
269 . Text \\*[@tmp@]\\$*
272 .c --------------------------------------------------------------------
274 . ds @tmp@ \f(CB\\$1\f[]
276 . Text \\*[@tmp@]\\$*
279 .c --------------------------------------------------------------------
281 . ds @tmp@ \f(CI\\$1\f[]
283 . Text \\*[@tmp@]\\$*
286 .c --------------------------------------------------------------------
288 . ds @tmp@ \f(CB\\$1\f[]
290 . Text .\\*[@tmp@]\\$*
293 .c --------------------------------------------------------------------
295 . ds @tmp@ \f[CB]\\$1\f[]
297 . Text \[rs]\\*[@tmp@]\\$*
302 .\" --------------------------------------------------------------------
304 .\" --------------------------------------------------------------------
307 .RI [ options\*[Ellipsis] ]
308 .RI [ files\*[Ellipsis] ]
312 Elements in brackets denote optional arguments, and the ellipsis means
313 that there can be any number of arguments of this kind.
316 .\" --------------------------------------------------------------------
318 .\" --------------------------------------------------------------------
323 .BR groff (@MAN1EXT@)
324 can be a valuable tool for debugging documents written in the roff
327 A call stack trace is protocolled on standard error, that means, a
328 diagnostic message is emitted on entering and exiting of a macro call.
330 This greatly eases to track down an error in some macro.
334 This tracing process is activated by specifying the groff or troff
337 This works also with the
338 .BR groffer (@MAN1EXT@)
341 A finer control can be obtained by including the macro file within the
342 document by the groff macro call
343 .BR ".mso\~trace.tmac" .
344 Only macros that are defined after this line are traced.
348 If some other macro package should be traced as well it must be specified
357 is unusual because it does not contain any macros to be called by a
360 Instead, the existing macro definition and appending facilities are
361 modified such that they display diagnostic messages.
364 .\" --------------------------------------------------------------------
366 .\" --------------------------------------------------------------------
369 In the following examples, a roff fragment is fed into groff via
372 As we are only interested in the diagnostic messages (standard error)
373 on the terminal, the normal formatted output (standard output) is
374 redirected into the nirvana device
376 The resulting diagnostic messages are displayed directly below the
377 corresponding example.
380 .\" --------------------------------------------------------------------
381 .SS "Command line option"
385 .Shell_cmd+ ".de test_macro"
387 .Shell_cmd+ ".test_macro"
388 .Shell_cmd+ ".test_macro some dummy arguments"
389 .Shell_cmd+ "' | groff -m trace >/dev/null"
392 *** de trace enter: test_macro
393 *** trace exit: test_macro
394 *** de trace enter: test_macro "some" "dummy" "arguments"
395 *** trace exit: test_macro "some" "dummy" "arguments"
399 The entry and the exit of each macro call is displayed on the terminal
400 (standard output) \[em] together with the arguments (if any).
403 .\" --------------------------------------------------------------------
404 .SS "Nested macro calls"
408 .Shell_cmd+ ".de child"
410 .Shell_cmd+ ".de parent"
413 .Shell_cmd+ ".parent"
414 .Shell_cmd+ "' | groff -m trace >/dev/null"
417 *** de trace enter: parent
418 *** de trace enter: child
419 *** trace exit: child
420 *** trace exit: parent
424 This shows that macro calls can be nested.
426 This powerful feature can help to tack down quite complex call stacks.
429 .\" --------------------------------------------------------------------
430 .SS "Activating with .mso"
433 .Shell_cmd+ ".de before"
435 .Shell_cmd+ ".mso trace.tmac"
436 .Shell_cmd+ ".de after"
441 .Shell_cmd+ "' | groff >/dev/null"
444 *** de trace enter: after
445 *** trace exit: after
449 Here, the tracing is activated within the document, not by a command
452 As tracing was not active when macro
454 was defined, no call of this macro is protocolled; on the other hand,
457 is fully protocolled.
460 .\" --------------------------------------------------------------------
462 .\" --------------------------------------------------------------------
466 macros are kept in the file
469 .IR "tmac directory" ;
471 .BR groff_tmac (@MAN5EXT@)
475 .\" --------------------------------------------------------------------
477 .\" --------------------------------------------------------------------
480 .Env_var $GROFF_TMAC_PATH
481 A colon-separated list of additional tmac directories in which to
482 search for macro files; see
483 .BR groff_tmac (@MAN5EXT@)
487 .\" --------------------------------------------------------------------
489 .\" --------------------------------------------------------------------
491 Copyright (C) 2002 Free Software Foundation, Inc.
494 This document is distributed under the terms of the FDL (GNU Free
495 Documentation License) version 1.1 or later.
497 You should have received a copy of the FDL on your system, it is also
498 available on-line at the
499 .URL http://\:www.gnu.org/\:copyleft/\:fdl.html "GNU copyleft site" .
502 This document is part of
504 the GNU roff distribution.
507 .MTO bwarken@mayn.de "Bernd Warken".
510 .\" --------------------------------------------------------------------
512 .\" --------------------------------------------------------------------
515 .BR groff (@MAN1EXT@)
516 An overview of the groff system.
520 .BR troff (@MAN1EXT@)
521 For details on option
526 .BR groffer (@MAN1EXT@)
527 A viewer program for all kinds of roff documents.
531 .BR groff_tmac (@MAN5EXT@)
532 A general description of groff macro packages.
536 .BR groff (@MAN7EXT@)
537 A short reference for the groff formatting language.
541 A complete reference for all parts of the groff system is found in the
546 .cp \n[groff_trace_C]