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 .\" --------------------------------------------------------------------
48 .ds Ellipsis .\|.\|.\&\"
50 .\" Global static variables for inter-macro communication
53 .\" --------------------------------------------------------------------
54 .\" setup for the macro definitions below
56 .\" naming: namespace:category_macro.variable_name (experimental)
58 .\" --------------------------------------------------------------------
59 .\" configuration of prompt for `.Shell_cmd'* macros
60 .ds trace:Shell_cmd.prompt_text sh#\" prompt for shell commands
61 .ds trace:Shell_cmd+.prompt_text >\" prompt on continuation lines
62 .ds trace:Shell_cmd_base.prompt_font I\" font for prompts
64 .\" automatically determine setup from the configuration above
65 .als @f trace:Shell_cmd_base.prompt_font\"
66 .als @t trace:Shell_cmd.prompt_text\"
67 .als @t+ trace:Shell_cmd+.prompt_text\"
68 .ds trace:Shell_cmd.prompt \f[\*[@f]]\*[@t]\f[]\" needed
69 .ds trace:Shell_cmd+.prompt \f[\*[@f]]\*[@t+]\f[]\" needed
70 .nr @w \w'\*[trace:Shell_cmd.prompt]'\"
71 .nr @w+ \w'\*[trace:Shell_cmd+.prompt]'\"
73 .\" Full prompt width is maximum of texts plus 1m
74 .nr trace:Shell_cmd_base.prompt_width (\n[@w]>?\n[@w+]+1m)\" needed
83 .\"--------------------------------------------------------------------
84 .\" Ignore all arguments like a comment, even after a .eo call.
87 .c --------------------------------------------------------------------
92 . ds @tmp@ \fB\\$1\f[]\fI\\$2\f[]
94 . Text \\*[@tmp@]\fR\\$*\f[]
98 .c --------------------------------------------------------------------
99 .c .Env_var (<env_var_name> [<punct>])
101 .c Display an environment variable, with optional punctuation.
106 . Text \f[CB]\\$1\f[]\\$2
109 .c --------------------------------------------------------------------
110 .c .Error (<text>...)
112 .c Print error message to terminal and abort.
118 .c --------------------------------------------------------------------
120 . if r@+Example_font \
121 . Error previous .Example was not terminated by a ./Example
122 . nr @+Example_font \\n[.f]
125 .c RS \\n[trace:Shell_cmd_base.prompt_width]u
128 .c --------------------------------------------------------------------
130 . if !r@+Example_font \
131 . Error no previous call to .Example
132 . ft \\n[@+Example_font]
138 .c --------------------------------------------------------------------
140 . if (\\n[.$] <= 0) \
141 . Error \\$0 needs at least one argument.
142 . ds @s .\f[B]\\$1\f[]\"
145 . as @s \~\f[I]\\$*\f[]\"
149 .c --------------------------------------------------------------------
155 .c --------------------------------------------------------------------
156 .c .Shell_cmd (<CR> [<CI>] ...)
158 .c A shell command line; display args alternating in fonts CR and CI.
161 .c .Shell_cmd "groffer --dpi 100 file"
162 .c result: `sh# groffer --dpi 100 file'
163 .c with 'sh#' in font I, the rest in CR
165 .c .Shell_cmd groffer\~--dpi\~100\~file
166 .c result: the same as above
168 .c .Shell_cmd "groffer --dpi=" value " file"
169 .c result: sh# groffer --dpi=value file
170 .c with `groffer --dpi=' and `file' in CR; `value' in CI
172 .c .Shell_cmd groffer\~--dpi= value \~file
173 .c result: the same as the previous example
176 . trace:Shell_cmd_base "\*[trace:Shell_cmd.prompt]" \\$@
178 .c --------------------------------------------------------------------
179 .c .Shell_cmd+ (<CR> [<CI>] ...)
181 .c A continuation line for .Shell_cmd.
184 . trace:Shell_cmd_base "\*[trace:Shell_cmd+.prompt]" \\$@
186 .c --------------------------------------------------------------------
187 .c .Shell_cmd_base (<prompt> [<CR> [<CI>] ...])
189 .c A shell command line; display args alternating in fonts CR and CI.
190 .c Internal, do not use directly.
192 .c Globals: read-only register @.Shell_cmd_width
194 .de trace:Shell_cmd_base
195 . if (\\n[.$] <= 0) \
197 . nr @+font \\n[.f]\"
200 . c gap between prompt and command
201 . nr @+gap \\n[trace:Shell_cmd_base.prompt_width]-\\w'\\*[@prompt]'\"
202 . ds @res \\*[@prompt]\h'\\n[@+gap]u'\"
205 . while (\\n[.$] > 0) \{\
206 . as @res \\f[\\*[@cf]]\\$1\"
228 .c --------------------------------------------------------------------
231 .c Treat the arguments as text, no matter how they look.
234 . if (\\n[.$] == 0) \
238 .c --------------------------------------------------------------------
239 .c .Topic ([<indent>])
241 .c A bulleted paragraph.
252 .c --------------------------------------------------------------------
255 .c Continuation line for .TP header.
262 .c --------------------------------------------------------------------
264 . ds @tmp@ `\f(CR\\$1\f[]'
266 . Text \\*[@tmp@]\\$*
269 .c --------------------------------------------------------------------
271 . ds @tmp@ \f(CB\\$1\f[]
273 . Text \\*[@tmp@]\\$*
276 .c --------------------------------------------------------------------
278 . ds @tmp@ \f(CI\\$1\f[]
280 . Text \\*[@tmp@]\\$*
283 .c --------------------------------------------------------------------
285 . ds @tmp@ \f(CB\\$1\f[]
287 . Text .\\*[@tmp@]\\$*
290 .c --------------------------------------------------------------------
292 . ds @tmp@ \f[CB]\\$1\f[]
294 . Text \[rs]\\*[@tmp@]\\$*
299 .\" --------------------------------------------------------------------
301 .\" --------------------------------------------------------------------
304 .RI [ options\*[Ellipsis] ]
305 .RI [ files\*[Ellipsis] ]
309 Elements in brackets denote optional arguments, and the ellipsis means
310 that there can be any number of arguments of this kind.
313 .\" --------------------------------------------------------------------
315 .\" --------------------------------------------------------------------
320 .BR groff (@MAN1EXT@)
321 can be a valuable tool for debugging documents written in the roff
324 A call stack trace is protocolled on standard error, that means, a
325 diagnostic message is emitted on entering and exiting of a macro call.
327 This greatly eases to track down an error in some macro.
331 This tracing process is activated by specifying the groff or troff
334 This works also with the
335 .BR groffer (@MAN1EXT@)
338 A finer control can be obtained by including the macro file within the
339 document by the groff macro call
340 .BR ".mso\~trace.tmac" .
341 Only macros that are defined after this line are traced.
345 If some other macro package should be traced as well it must be specified
354 is unusual because it does not contain any macros to be called by a
357 Instead, the existing macro definition and appending facilities are
358 modified such that they display diagnostic messages.
361 .\" --------------------------------------------------------------------
363 .\" --------------------------------------------------------------------
366 In the following examples, a roff fragment is fed into groff via
369 As we are only interested in the diagnostic messages (standard error)
370 on the terminal, the normal formatted output (standard output) is
371 redirected into the nirvana device
373 The resulting diagnostic messages are displayed directly below the
374 corresponding example.
377 .\" --------------------------------------------------------------------
378 .SS "Command line option"
382 .Shell_cmd+ ".de test_macro"
384 .Shell_cmd+ ".test_macro"
385 .Shell_cmd+ ".test_macro some dummy arguments"
386 .Shell_cmd+ "' | groff -m trace >/dev/null"
389 *** de trace enter: test_macro
390 *** trace exit: test_macro
391 *** de trace enter: test_macro "some" "dummy" "arguments"
392 *** trace exit: test_macro "some" "dummy" "arguments"
396 The entry and the exit of each macro call is displayed on the terminal
397 (standard output) \[em] together with the arguments (if any).
400 .\" --------------------------------------------------------------------
401 .SS "Nested macro calls"
405 .Shell_cmd+ ".de child"
407 .Shell_cmd+ ".de parent"
410 .Shell_cmd+ ".parent"
411 .Shell_cmd+ "' | groff -m trace >/dev/null"
414 *** de trace enter: parent
415 *** de trace enter: child
416 *** trace exit: child
417 *** trace exit: parent
421 This shows that macro calls can be nested.
423 This powerful feature can help to tack down quite complex call stacks.
426 .\" --------------------------------------------------------------------
427 .SS "Activating with .mso"
430 .Shell_cmd+ ".de before"
432 .Shell_cmd+ ".mso trace.tmac"
433 .Shell_cmd+ ".de after"
438 .Shell_cmd+ "' | groff >/dev/null"
441 *** de trace enter: after
442 *** trace exit: after
446 Here, the tracing is activated within the document, not by a command
449 As tracing was not active when macro
451 was defined, no call of this macro is protocolled; on the other hand,
454 is fully protocolled.
457 .\" --------------------------------------------------------------------
459 .\" --------------------------------------------------------------------
463 macros are kept in the file
466 .IR "tmac directory" ;
468 .BR groff_tmac (@MAN5EXT@)
472 .\" --------------------------------------------------------------------
474 .\" --------------------------------------------------------------------
477 .Env_var $GROFF_TMAC_PATH
478 A colon-separated list of additional tmac directories in which to
479 search for macro files; see
480 .BR groff_tmac (@MAN5EXT@)
484 .\" --------------------------------------------------------------------
486 .\" --------------------------------------------------------------------
488 Copyright (C) 2002 Free Software Foundation, Inc.
491 This document is distributed under the terms of the FDL (GNU Free
492 Documentation License) version 1.1 or later.
494 You should have received a copy of the FDL on your system, it is also
495 available on-line at the
496 .URL http://\:www.gnu.org/\:copyleft/\:fdl.html "GNU copyleft site" .
499 This document is part of
501 the GNU roff distribution.
504 .MTO bwarken@mayn.de "Bernd Warken".
507 .\" --------------------------------------------------------------------
509 .\" --------------------------------------------------------------------
512 .BR groff (@MAN1EXT@)
513 An overview of the groff system.
517 .BR troff (@MAN1EXT@)
518 For details on option
523 .BR groffer (@MAN1EXT@)
524 A viewer program for all kinds of roff documents.
528 .BR groff_tmac (@MAN5EXT@)
529 A general description of groff macro packages.
533 .BR groff (@MAN7EXT@)
534 A short reference for the groff formatting language.
538 A complete reference for all parts of the groff system is found in the