next up previous contents index
Next: Usage Rules Up: Trace Library Previous: Type Definitions

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.

xTraceP, xTraceS

  

The xTracePn and xTraceSn macros function much the same way as the xTracen macros, except that they take a Protl or Sessn as their first parameter (instead of a trace variable) and they print the protocol instance name 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 and xTraceSn macros whenever you have an appropriate Protl Sessn in scope, using the xTracen macros only when there is no such Protl or Sessn available.

xTracePn(Protl protocol, int tracelevel, char *formatstring, args, ...) xTraceSn(Sessn session, int tracelevel, char *formatstring, args, ...)

xIfTrace, xIfTraceP, xIfTraceS

 

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();

xIfTraceP and xIfTraceS are the analogous operations, taking a Protl or Sessn instead of a trace variable.

xIfTraceP(Protl protocol, int tracelevel) xIfTraceS(Sessn session, int tracelevel)



next up previous contents index
Next: Usage Rules Up: Trace Library Previous: Type Definitions



Larry Peterson
Tue Jul 1 14:50:34 MST 1997