next up previous contents index
Next: xTracePxTraceS Up: Operations Previous: Operations

xTrace

   

The xTracen macros take n arguments (where 0 <= n <= 6) in addition to the variables tracevar, tracelevel, and formatstring. tracevar is a name associated with the protocol or subsystem being traced. tracelevel is compared to the value of the trace variable to determine at runtime if the trace statement should be printed. formatstring is a

printf-style formatting statement.

Each protocol has a trace variable based on the protocol name with ``trace'' prepended and ``p'' appended; e.g., udp has trace variable traceudpp. In addition to protocol tracing, there are x-kernel trace variables for subsystems: e.g., init, processswitch, protocol, processcreation, event, msg and ptbl. These are defined in the file xkernel/include/xk_debug.h.

Note that the trace facility automatically supplies a newline at the end of the trace message, therefore the supplied format string need not. Also, the trace facility prepends ``trace'' to the

tracevar argument passed in. Thus, the first argument must be the protocol name with only ``p'' appended; e.g., udpp for udp. Because of this prepending, there should be no whitespace preceding a trace variable name in any tracing statement. Whitespace will cause errors in the macro expansion and result in compilation errors.

xTracen(int tracevar, int tracelevel, char *formatstring, args, ...)

For example:

    int traceudpp;

    xTrace2(udpp, TR_ERRORS, "input port %d output port %d", inp, outp);

will print the trace message if the x-kernel was built in DEBUG mode (see Section 12 and if TR_ERRORS <= traceudpp.



Larry Peterson
Wed Jan 10 10:40:08 MST 1996