Step 2 : ARM 4.0 C Hello World example

Description

Now we will instrument the printf() line. ARM 4.0 requires to register application and transaction meta data before a transaction can be measured.

  1. First of all we need to include the standard arm4.h header file.
  2. Before we can register the application meta data we need an
    arm_id_t app_id;
    for API handshaking where the ARM agent stores the ID for our application type
  3. Now we can register our application meta data with the arm_register_application() call. We pass the following parameters:
    1. our application name
    2. ARM_ID_NONE - since the agent generates an ID for us.
    3. ARM_FLAG_NONE - there are no flags defined for this API call.
    4. ARM_BUF4_NONE - it is a simple example, so no optional data is passed.
    5. pointer to our app_id variable where the agent stores the generated ID for our application type.

Code

01: #include <stdio.h>
02: #include "arm4.h"
03: 
04: int main(int argc, char *argv[])
05: {   
06:    arm_id_t app_id;
07:    arm_register_application("HelloWorldApp", ARM_ID_NONE,
08:                              ARM_FLAG_NONE, ARM_BUF4_NONE,
09:                              &app_id);
10:    printf("Hello world!\n");
11:    return 0;
12: }