You copied the Doc URL to your clipboard.

Creating custom performance counters

In addition to the hardware-specific and Linux performance counters that you can configure using the Counter Configuration dialog box, the gator daemon and driver provide hooks that enable you to customize the counters collected during a capture.

Streamline derives its default set of counters from the performance monitoring unit, linux hooks, and memory-mapped peripherals. You can add your own counters to this list if there is a hardware metric that you want to track which Streamline does not provide by default.

The gator_events_mmaped.c example file

In the gator-driver.tar.gz archive distributed with your copy of Streamline is a gator source file called gator_events_mmaped.c. The events contained in this file are not included in the events.xml file and do not appear in the list of available counters in the Counter Configuration dialog box. This file was provided as an example of how to add custom counters.

Note

You can locate all of the files provided by DS-5 by selecting Help → ARM Extras... from the main menu.

To familiarize yourself with the process of adding your own counters, incorporate the simulated examples from gator_events_mmaped.c into gator.

To do so, follow these steps:

  1. Open the gator_events_mmaped.c sample file in the editor of your choice.

  2. Copy the xml from the comments section of gator_events_mmaped.c.

  3. Open events.xml, located in the .../gator directory.

  4. Add the copied xml from the comments section of gator_events_mmaped.c to events.xml, just after the closing tag of the Linux category.

  5. Remove any * comment markers from the copied xml.

  6. Save events.xml.

  7. Copy events.xml to your target.

  8. Enter ./gatord & on the command line of your target to restart gatord.

  9. Open the Counter Configuration dialog in Streamline. Note that a new category, mmaped, appears with the Sine, Triangle, and PWM simulated counters.

  10. Add Sine to list of counters.

  11. Run a capture session.

If successful, the waveform generated by the simulated Sine counter appears in the charts section of the Timeline view.

Figure 51. The custom Sine counter in the Timeline view

The custom Sine counter in the Timeline view

Creating your own counters

To create your own counters, mimic the methods used in the gator_events_mmaped.c or any of the other gator_events_x files included with the gator source.

Make sure to do the following to ensure that gatord interacts with your custom source:

  1. Create an empty gator_events_your_custom.c file or duplicate gator_events_mmaped.c.

  2. Update the makefile to build the new gator_events_your_custom.c file.

  3. Add the preprocessor directive #include "gator.h" if you do not use gator_events_mmaped.c as a template.

  4. Include the gator_events_init macro.

  5. Implement the following functions in your new source file: gator_events_your_custom_init , gator_events_your_custom_interface, gator_events_your_custom_create_files, gator_events_your_custom_start, gator_events_your_custom_read, and gator_events_your_custom_stop.

  6. All of your new counters must be added to the events.xml file.

gator_events functions

Here is a brief description of each of the gator event functions:

gator_events_your_custom_init

gator calls this function startup.

gator_events_your_custom_interface

Tells gator what triggers calls to your custom events file.

gator_events_your_custom_create_files

Adds custom directories and enabled, event, and key files to /dev/gator/events

gator_events_your_custom_start

gator calls this at the start or execution.

gator_events_your_custom_read

gator calls this function at every sample.

gator_events_your_custom_stop

gator calls this at the termination of a capture session.

Adding your events to the events.xml file

Use the following attributes in the counter elements in your events.xml file:

type

The identifier of the counter resource.

event

Architecture specific or implementation-specific event number, in decimal, determined from either the architecture specification document or the Technical Reference Manual of the processor.

title

The title of the chart that Streamline displays. Counters with matching titles stack in the charts.

name

The name that Streamline displays.

per_cpu

Defines whether or not Streamline collects data on a per cpu basis. Set this value to yes and Streamline collects data from each cpu separately for this counter.

L2C-310 memory-mapped peripherals

To get L2C-310 memory-mapped peripherals working with Streamline, do the following:

  1. Open the gator_events_l2c-310.c file located in the archive in .../gator/driver-src

  2. Find the init function in gator_events_l2c-310.c

  3. Add the following #if statement to the existing #if statements in the init function:

    #if defined(Your_Architecture)
    
    	gator_events_l2c310_probe(L2C_310_Address);
    
    #endif
    

    Note

    Replace Your_Architecture with the name of your architecture and L2C_310_Address with the physical address of your L2C-310 in hexadecimal.

  4. Rebuild the gator driver.

  5. Connect to your target.

Was this page helpful? Yes No