[includes/hd_aprobe5-examples.htm]
Aprobe 5

7. How do I log all of the lines in one routine?

The probe: main.spc
-------------------------

probe thread
{
   probe "main"
   {
      on_line(all) 
      { 
         sp_LogLine; 
      }
   }
}



Main test: main.c
-----------------

#include <stdio.h>

int Items[10];

int sum (int* My_Array)
{
  int i, sum = 0;

  for (i=0; i<10; i++)
  {
     sum += My_Array[i];
  }
  return sum;
}

int main (int argc, char** argv)
{
  int i, total;

  for (i=0; i<10; i++)
  {
     Items[i] = i;
  }
  total = sum (Items);
  printf ("Total of Items = %d\n", total);
  return 0;
}



Compile the main.c program to create main.exe:
----------------------------------------------

gcc -g main.c -o main.exe


Compile the main.spc probe to create main.usm:
----------------------------------------------------

spc -t linux:x86 -x main.exe main.spc


The result:
-----------

Use sptool to run main.exe program with main.usm probe applied to it.

sptool -u main.usm -if main.exe

@:extern:"main" in "main.exe"
+0x001c
 at 03:17:28.972124000
@:extern:"main" in "main.exe"
+0x0029
 at 03:17:28.973743000
@:extern:"main" in "main.exe"
+0x0036
 at 03:17:28.975366000
@:extern:"main" in "main.exe"
+0x0029
 at 03:17:28.976992000
@:extern:"main" in "main.exe"
+0x0036
 at 03:17:28.978621000
@:extern:"main" in "main.exe"
+0x0029
 at 03:17:28.980238000
@:extern:"main" in "main.exe"
+0x0036
 at 03:17:28.981865000
@:extern:"main" in "main.exe"
+0x0029
 at 03:17:28.983486000
@:extern:"main" in "main.exe"
+0x0036
 at 03:17:28.985110000
@:extern:"main" in "main.exe"
+0x0029
 at 03:17:28.986735000
@:extern:"main" in "main.exe"
+0x0036
 at 03:17:28.988357000
@:extern:"main" in "main.exe"
+0x0029
 at 03:17:28.989983000
@:extern:"main" in "main.exe"
+0x0036
 at 03:17:28.991612000
@:extern:"main" in "main.exe"
+0x0029
 at 03:17:28.993230000
@:extern:"main" in "main.exe"
+0x0036
 at 03:17:28.994858000
@:extern:"main" in "main.exe"
+0x0029
 at 03:17:28.996478000
@:extern:"main" in "main.exe"
+0x0036
 at 03:17:28.998103000
@:extern:"main" in "main.exe"
+0x0029
 at 03:17:28.999727000
@:extern:"main" in "main.exe"
+0x0036
 at 03:17:29.001351000
@:extern:"main" in "main.exe"
+0x0029
 at 03:17:29.002974000
@:extern:"main" in "main.exe"
+0x0036
 at 03:17:29.004604000
@:extern:"main" in "main.exe"
+0x003d
 at 03:17:29.006222000
@:extern:"main" in "main.exe"
+0x004d
 at 03:17:29.007850000
Total of Items = 45
@:extern:"main" in "main.exe"
+0x0060
 at 03:17:29.009602000