Writing Trace Data to Buffers Tutorial

Explains how to use the kernel trace tool API to write trace data to buffers.

Purpose

The kernel trace tool API can write kernel side trace data to user side buffers for use by applications such as the command line kernel trace tool.

Intended audience

This document is intended for application developers writing a trace tool using the kernel trace tool component.

Required background

The trace filters defined in EUser. The kernel trace tool component in general.

Introduction

Writing trace data to buffers is a short task which is performed in combination with related tasks as explained in Kernel Trace Tool Tutorial.

Using Kernel Trace Tool to Write Trace Data to Buffers

The following tasks will be covered in this tutorial:

  • Writing trace data to buffers.

Basic procedure

The high level steps to writing trace data to buffers are shown here:

  1. Read the data chunk by chunk until it is exhausted.

  2. When each chunk is read, mark it as read.

Using the API

These are the function calls required to

  1. Set up a loop which terminates when the data is exhausted.

  2. Within the loop call the GetData() function of the RBTrace object.

  3. The data is now in a buffer, the data argument of GetData(), and available for further processing.

  4. Still within the loop call the DataUsed() function of the RBTrace object. You must do this for each call to GetData() to remove used data from the buffer.


         RBTrace trace;
   ...
            while((size=trace.GetData(data))!=0)
                {
                ProcessTheTraceData(data,size);
                trace.DataUsed();
                }