[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
When writing macros for m4
, most of the time they woould not
work as intended (as is the case with most programming languages).
There is a little support for macro debugging in m4
.
6.1 Displaying macro definitions 6.2 Tracing macro calls 6.3 Controlling debugging output 6.4 Saving debugging output
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
If you want to see what a name expands into, you can use the builtin
dumpdef
:
dumpdef(...) |
which accepts any number of arguments. If called without any arguments, it displays the definitions of all known names, otherwise it displays the definitions of the names given. The output is printed directly on the standard error output.
The expansion of dumpdef
is void.
define(`foo', `Hello world.') => dumpdef(`foo') error-->foo: `Hello world.' => dumpdef(`define') error-->define: <define> => |
The last example shows how builtin macros definitions are displayed.
See section 6.3 Controlling debugging output for information on controlling the details of the display.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
It is possible to trace macro calls and expansions through the builtins
traceon
and traceoff
:
traceon(...) traceoff(...) |
When called without any arguments, traceon
and traceoff
will turn tracing on and off, respectively, for all defined macros.
When called with arguments, only the named macros are affected.
The expansion of traceon
and traceoff
is void.
Whenever a traced macro is called and the arguments have been collected, the call is displayed. If the expansion of the macro call is not void, the expansion can be displayed after the call. The output is printed directly on the standard error output.
define(`foo', `Hello World.') => define(`echo', `$@') => traceon(`foo', `echo') => foo error-->m4trace: -1- foo -> `Hello World.' =>Hello World. echo(gnus, and gnats) error-->m4trace: -1- echo(`gnus', `and gnats') -> ``gnus',`and gnats'' =>gnus,and gnats |
The number between dashes is the depth of the expansion. It is one most of the time, signifying an expansion at the outermost level, but it increases when macro arguments contain unquoted macro calls.
See section 6.3 Controlling debugging output for information on controlling the details of the display.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The `-d' option to m4
controls the amount of details
presented, when using the macros described in the preceding sections.
The flags following the option can be one or more of the following:
t
m4
.
a
traceon
.
e
traceon
.
q
c
x
f
l
p
i
V
If no flags are specified with the `-d' option, the default is `aeq'. The examples in the previous two sections assumed the default flags.
There is a builtin macro debugmode
, which allows on-the-fly control of
the debugging output format:
debugmode(opt flags) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Debug and tracing output can be redirected to files using either the
`-o' option to m4
, or with the builtin macro debugfile
:
debugfile(opt filename) |
debugfile
is called without any arguments, debug and trace output
are sent to the standard error output.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |