Copyright (C) 2000-2012 |
Whole document tree
How to debug macros and input
When writing macros for Displaying macro definitions
If you want to see what a name expands into, you can use the builtin
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 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 Controlling debugging output for information on controlling the details of the display. Tracing macro calls
It is possible to trace macro calls and expansions through the builtins
traceon(...) traceoff(...)
When called without any arguments,
The expansion of 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 Controlling debugging output for information on controlling the details of the display. Controlling debugging output
The `-d' option to The flags following the option can be one or more of the following:
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(opt flags) The argument flags should be a subset of the letters listed above. As special cases, if the argument starts with a `+', the flags are added to the current debug flags, and if it starts with a `-', they are removed. If no argument is present, the debugging flags are set to zero (as if no `-d' was given), and with an empty argument the flags are reset to the default. Saving debugging output
Debug and tracing output can be redirected to files using either the
`-o' option to debugfile(opt filename)
will send all further debug and trace output to filename. If
filename is empty, debug and trace output are discarded and if
Go to the first, previous, next, last section, table of contents. |