op_prg_odb_pktrace_active()
Abstract
Determines if the specified packet is affected by tracing commands issued under ODB, the Simulation Debugger.
Syntax
op_prg_odb_pktrace_active (pkptr)
| Argument | Type | Description |
|---|---|---|
pkptr |
Packet* |
pointer to the packet-of-interest. [A pointer to a packet can be obtained from many KPs, including op_pk_create(), op_pk_create_fmt(), op_pk_copy(), op_pk_get(), op_subq_pk_access(), and op_subq_pk_remove().] |
Return Type
Boolean
Boolean value indicating whether the specified packet is being traced. This value is OPC_TRUE if the specified packet is being traced, OPC_FALSE otherwise.
Example
/* obtain a packet from the higher layer input stream */
pkptr = op_pk_get (HIGH_LAYER_INSTRM);
/* determine if the packet is being traced */
if (op_prg_odb_pktrace_active (pkptr) == OPC_TRUE)
{
/* tracing is active: print packet info. */
printf ("---------- Packet %04d ----------\n", op_pk_id (pkptr));
printf ("* Received by object #%d\n", op_id_self ());
op_pk_nfd_get (pkptr, "message_class", &mclass);
printf ("* Message class %s\n", Msg_Class_Table [mclass]);
printf ("---------------------------------\n");
}
/* insert the packet into the processing queue */
op_subq_pk_insert (0, pkptr, OPC_QPOS_TAIL);
Details
Traces are a special status of simulations that when activated, permit specific diagnostic information to be printed and related actions to occur. Simulation traces are supported within the ODB simulation debugger (see “Simulation Debugger (ODB)“ on page 39 for information on using ODB). Various types of traces can be activated within ODB, including full, module-oriented, packet-oriented, and labeled traces. Packet-oriented traces are activated via the ODB commands pktrace and pttrace. This KP detects active packet traces, provided that the passed packet exactly matches the packet ID or tree ID passed to the corresponding ODB command.
In addition to specific packet traces, this KP will return OPC_TRUE if a full trace is in effect, as defined by the ODB command fulltrace.
This KP returns OPC_FALSE when used with an optimized simulation kernel.
Purpose
Provides a mechanism for performing special actions if a packet trace has been defined in ODB. The actions usually include diagnostic print statements generated by op_prg_odb_print_major(), op_prg_odb_print_minor(), or printf(). However, the actions can include any KPs, including manipulating the affected packet as shown in the Example section to the left.
Errors
- Program Abort: Segmentation violation (due to an invalid packet pointer or malformed packet).
Reference
- Use the KPs op_prg_odb_print_major() and op_prg_odb_print_minor() to print diagnostic statements
- Use the KP op_pk_print() to print the contents of the packet
- Use the KP op_prg_odb_ltrace_active() to determine if a specific labeled trace is active
- Use the KP op_prg_odb_trace_active() to determine if a full or surrounding module trace is active