manpagez: man pages & more
info m4
Home | html | info | man

File: m4.info,  Node: Dumpdef,  Next: Trace,  Up: Debugging

7.1 Displaying macro definitions
================================

If you want to see what a name expands into, you can use the builtin
‘dumpdef’:

 -- Builtin: dumpdef([NAMES...])
     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
     to the current debug file (usually standard error), and is sorted
     by name.  If an unknown name is encountered, a warning is printed.

     The expansion of ‘dumpdef’ is void.

     $ m4 -d
     define(`foo', `Hello world.')
     ⇒
     dumpdef(`foo')
     error→foo: `Hello world.'
     ⇒
     dumpdef(`define')
     error→define: 
     ⇒

   The last example shows how builtin macros definitions are displayed.
The definition that is dumped corresponds to what would occur if the
macro were to be called at that point, even if other definitions are
still live due to redefining a macro during argument collection.

     $ m4 -d
     pushdef(`f', ``$0'1')pushdef(`f', ``$0'2')
     ⇒
     f(popdef(`f')dumpdef(`f'))
     error→f: ``$0'1'
     ⇒f2
     f(popdef(`f')dumpdef(`f'))
     error→m4:stdin:3: undefined macro `f'
     ⇒f1

   *Note Debug Levels::, for information on controlling the details of
the display.

© manpagez.com 2000-2025
Individual documents may contain additional copyright information.