Next: Usage Rules Up: Trace Library Previous: Type Definitions

Operations

xTrace

The xTracen macro takes n arguments in addition to the variables tracevar, tracelevel, and formatstring. tracevar is a name associated with the variable 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 ``p'' appended; e.g. udp has traceudpp. In addition to protocol tracing, there are x-kernel trace variables for subsystems: init, processswitch, protocol, processcreation, cksum, event, system, msg, ptbl, and sessn. Most of these are defined in file xkernel/include/xk_debug.h.

Note that the trace facility automatically supplies a newline at the end of the trace message; the supplied format string need not. Also, note that 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);

xTraceP

The xTracePn macros function much the same way as the xTracen macros, except that they take an XObject as their first parameter (instead of a trace variable) and they print the protocol instance name of the XObject before the rest of the trace statement. This turns out to be very useful when reading an x-kernel trace where several protocols were interleaving trace statements. We recommend using the xTracePn macros whenever you have an appropriate XObject in scope, using the xTracen macros only when there is no such XObject available.

xTracePn(XObj, int tracelevel, char * formatstring, args, ... )

xIfTrace, xIfTraceP

If the tracelevel is less than or equal to the value of the tracevar, then execute the statement directly following.

xIfTrace (int tracevar, int tracelevel)

For example:


        int traceudpp;

        xIfTrace(udpp, TR_ERRORS) 
                dump_header();

There is also the analogous operation taking an XObject instead of a trace variable:

xIfTraceP (XObj, int tracelevel)

xAssert

If the expression exp evaluates to FALSE, the x-kernel will print a message and halt.

xAssert (bool exp)

xError

Non-fatal error conditions can print warnings even in nondebugging mode by using the xError call.

xError (char * ErrorString)



Next: Usage Rules Up: Trace Library Previous: Type Definitions


Tue Nov 29 16:28:56 MST 1994