op_prg_odb_ltrace_active()
Abstract
Determines if the specified labeled trace has been activated by an ODB command.
Syntax
op_prg_odb_ltrace_active (label)
| Argument | Type | Description |
|---|---|---|
label |
const char* |
label string to be associated with the trace. This string is compared with the labels of active labeled traces. These types of traces are activated via the ODB commands ltrace or mltrace. Labels can include any ASCII characters, including whitespace characters. |
Return Type
Boolean
Boolean value indicating whether the specified labeled trace is active.This value is OPC_TRUE if the specified trace is active, OPC_FALSE otherwise.
Example
/* check to see if a queue dump trace is enabled */
if (op_prg_odb_ltrace_active ("queue_dump") == OPC_TRUE)
{
/* a trace is enabled, so scan through the queue’s contents */
queue_size = op_subq_stat (0, OPC_QSTAT_PKSIZE);
for (pos = 0; pos < queue_size; pos++)
{
/* obtain each packet from the subqueue */
pkptr = op_subq_pk_access (0, i);
/* extract each packet’s source and destination addresses */
op_pk_nfd_get (pkptr, "src_addr", &src_addr);
op_pk_nfd_get (pkptr, "dst_addr", &dst_addr);
/* print out the information */
printf ("packet [%d]: src_addr [%d] / dst_addr [%d]\n", pos,
src_addr, dst_addr);
}
}
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. Labeled traces are activated via the ODB commands ltrace (for labeled traces which are global) or mltrace (for labeled traces which apply only to a specific module). This KP detects labeled traces activated via either command, provided that the label string passed to the KP exactly matches the label string passed to the ODB command. Labeled traces which are restricted to a specific module will only be detected if this KP is being invoked by the process executing in that module. In addition to specific labeled 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 labeled 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 statistic writing, packet manipulation, etc.
Errors
- Program Abort: Segmentation violation. (due to an invalid label pointer, or a malformed label string)
Reference
- Use the KPs op_prg_odb_print_major() and op_prg_odb_print_minor() to print diagnostic statements
- Use the KP op_prg_odb_pktrace_active() to determine if a specific packet trace is active
- Use the KP op_prg_odb_trace_active() to determine if a full or surrounding module trace is active