Previous: , Up: FWEB macros   [Contents][Index]


7.2.4 Debugging with macros

If an FWEB macro expands to more than one output line, debugging can be a bit confusing if the debugger (e.g., gdb) displays lines in the web source file instead of the output file (as it normally does for C and C++). While single-stepping through the code, the debugger will incorrectly step the screen display for each output line even if the macro call occupies just one line in the source file. To localize the debugger’s confusion, insert a ‘@#line’ command after the macro call. For example,

@c
@ Example of a macro that expands to several output lines.
@m UPDATE(i, delta_i)
     i += delta_i;
     store(i)@;
@a
main()
{
UPDATE(j, 5);
@#line
// More code.  The debugger will be in sync from here on.
}

An alternative for highly confusing situations is to use the ‘-#’ option (see -#).

Another potentially confusing situation occurs when ‘@%’ is used to comment out a line. FWEB deals with the line-number problem that arises here automatically; see -T#.