This chapter leads you through some tutorials to help you learn how to use TraceEvent() to control event tracing.

These tutorials all follow the same general procedure:

  1. Compile the specified C program into a file of the same name, without the .c extension.
  2. Run the specified tracelogger command. Because we're running tracelogger in daemon mode, it doesn't start logging events until our program tells it to. This means that you don't have to rush to start your C program; the tracing waits for you.

    The default number of buffers is 32, which produces a rather large file, so we'll use the -n option to limit the number of buffers to a reasonable number. Feel free to use the default, but expect a large file.

  3. In a separate terminal window, run the compiled C program. Some examples use options.
  4. Watch the first terminal window; a few seconds after you start your C program, tracelogger will finish running.
  5. If you run the program, it generates its own sample result file. The "tracebuffer" files are binary files that can be interpreted only with the libtraceparser library, which the traceprinter utility uses.

    If you don't want to run the program, take a look at our traceprinter output. (Note that different versions and systems will create slightly different results.)

Note: You may include these samples in your code as long as you comply with the license agreement.