1GROFF_TRACE(7)         Miscellaneous Information Manual         GROFF_TRACE(7)
2
3
4

NAME

6       groff_trace - groff macro package trace.tmac
7

SYNOPSIS

9       groff -m trace [options ...] [files ...]
10

DESCRIPTION

12       The  trace  macro package of groff(1) can be a valuable tool for debug‐
13       ging documents written in the roff formatting language.  A  call  stack
14       trace  is  protocolled on standard error, this is, a diagnostic message
15       is emitted on entering and exiting of a macro call.  This greatly eases
16       to track down an error in some macro.
17
18       This tracing process is activated by specifying the groff or troff com‐
19       mand line option -m trace.  This works also with the groffer(1)  viewer
20       program.   A  finer control can be obtained by including the macro file
21       within the document by the  groff  macro  call  .mso trace.tmac.   Only
22       macros that are defined after this line are traced.
23
24       If command line option -r trace-full=1 is given (or if this register is
25       set in the document), number and string register  assignments  together
26       with some other requests are traced also.
27
28       If  some other macro package should be traced as well it must be speci‐
29       fied after -m trace on the command line.
30
31       The macro file trace.tmac is unusual because it does  not  contain  any
32       macros  to be called by a user.  Instead, the existing macro definition
33       and appending facilities are modified such that they display diagnostic
34       messages.
35

EXAMPLES

37       In  the following examples, a roff fragment is fed into groff via stan‐
38       dard input.  As we are  only  interested  in  the  diagnostic  messages
39       (standard error) on the terminal, the normal formatted output (standard
40       output) is redirected to the nirvana device /dev/null.   The  resulting
41       diagnostic  messages  are  displayed  directly  below the corresponding
42       example.
43
44   Command line option
45       Example:
46
47              sh# echo '.
48              > .de test_macro
49              > ..
50              > .test_macro
51              > .test_macro some dummy arguments
52              > ' | groff -m trace >/dev/null
53
54              *** .de test_macro
55              *** de trace enter: .test_macro
56              *** trace exit: .test_macro
57              *** de trace enter: .test_macro "some" "dummy" "arguments"
58              *** trace exit: .test_macro "some" "dummy" "arguments"
59
60       The entry and the exit of each macro call is displayed on the  terminal
61       (standard output) — together with the arguments (if any).
62
63   Nested macro calls
64       Example:
65
66              sh# echo '.
67              > .de child
68              > ..
69              > .de parent
70              > .child
71              > ..
72              > .parent
73              > ' | groff -m trace >/dev/null
74
75              *** .de child
76              *** .de parent
77              *** de trace enter: .parent
78               *** de trace enter: .child
79               *** trace exit: .child
80              *** trace exit: .parent
81
82       This  shows  that macro calls can be nested.  This powerful feature can
83       help to tack down quite complex call stacks.
84
85   Activating with .mso
86       Example:
87
88              sh# echo '.
89              > .de before
90              > ..
91              > .mso trace.tmac
92              > .de after
93              > ..
94              > .before
95              > .after
96              > .before
97              >  ' | groff >/dev/null
98
99              *** de trace enter: .after
100              *** trace exit: .after
101
102       Here, the tracing is activated within the document, not  by  a  command
103       line  option.  As tracing was not active when macro before was defined,
104       no call of this macro is protocolled; on  the  other  hand,  the  macro
105       after is fully protocolled.
106

PROBLEMS

108       Because trace.tmac wraps the .de request (and its cousins), macro argu‐
109       ments are expanded one level more.  This causes problems if an argument
110       contains four backslashes or more to prevent too early expansion of the
111       backslash.  For example, this macro call
112
113              .foo \\\\n[bar]
114
115       normally passes `\\n[bar]' to macro `.foo', but with the redefined  .de
116       request it passes `\n[bar]' instead.
117
118       The  solution  to  this problem is to use groff's \E escape which is an
119       escape character not interpreted in copy mode, for example
120
121              .foo \En[bar]
122

FILES

124       The trace macros are kept in the file trace.tmac located  in  the  tmac
125       directory; see groff_tmac(5) for details.
126

ENVIRONMENT

128       $GROFF_TMAC_PATH
129              A  colon-separated  list of additional tmac directories in which
130              to search for macro files; see groff_tmac(5) for details.
131

AUTHOR

133       Copyright (C) 2002, 2006, 2007, 2008 Free Software Foundation, Inc.
134
135       This document is distributed under the terms of the FDL (GNU Free Docu‐
136       mentation  License)  version  1.1 or later.  You should have received a
137       copy of the FDL on your system, it is also available on-line at the GNU
138       copyleft site ⟨http://www.gnu.org/copyleft/fdl.html⟩.
139
140       This  document  is  part  of  groff, the GNU roff distribution.  It was
141       written by Bernd Warken.
142

SEE ALSO

144       groff(1)
145              An overview of the groff system.
146
147       troff(1)
148              For details on option -m.
149
150       groffer(1)
151              A viewer program for all kinds of roff documents.
152
153       groff_tmac(5)
154              A general description of groff macro packages.
155
156       groff(7)
157              A short reference for the groff formatting language.
158
159       A complete reference for all parts of the groff system is found in  the
160       groff info(1) file.
161
162
163
164Groff Version 1.20.1            9 January 2009                  GROFF_TRACE(7)
Impressum