The following example adds an event trace entry to the system trace buffer. For this example, the trace entry will contain the contents of two internal program variables.

#define INCL_DOSPROCESS

#include <stdio.h>                     /* C library for standard I/O        */
#include <stdlib.h>                    /* C library of standard routines    */
#include <string.h>                    /* C library for string operations   */
#include <os2.h>                       /* OS/2 Dos api calls                */
#include <trace.h>                     /* Trace public API data structures  */

#define HKWD_TEST                      43
#define hkwd_test_entry                0001

struct {
  ULONG  var1;
  USHORT var2;
} trace_data;

TCEREQUEST trace_create_entry_packet;

VOID main(VOID)
{
  APIRET rc = NO_ERROR;

  /**************************************************************************/
  /* Set up the TraceCreateEntry parameter packet                           */
  /**************************************************************************/
  trace_create_entry_packet.packet_size            = sizeof(TCEREQUEST);
  trace_create_entry_packet.packet_revision_number = WPOS_RELEASE_1;
  trace_create_entry_packet.major_event_code       = HKWD_TEST;
  trace_create_entry_packet.minor_event_code       = hkwd_test_entry;
  trace_create_entry_packet.event_data_length      = sizeof(trace_data);
  trace_create_entry_packet.event_data             = (PVOID)&trace_data;

  /**************************************************************************/
  /* Place tracepoint data in the tracepoint data buffer                    */
  /**************************************************************************/
  trace_data.var1 = UINT_MAX;
  trace_data.var2 = 1;

  rc = TraceCreateEntry(&trace_create_entry_packet);
  if (rc != NO_ERROR) {
    printf("TraceCreateEntry RC(%d)\n", rc);
  }
}


[Back: TraceCreateEntry - Remarks]
[Next: TraceCreateEntry - Topics]