[includes/hd_aprobe5-examples.htm]
Aprobe 5

6. How do I log the data in a class when in a probe for a member function?

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

probe thread
{
   probe extern:"example::example(void)"
   {  
      on_exit
      {
         log ("this->data_1 = ", $this->data_1);
         log ("example::data_2 = ", $example::data_2);

         log parameter("\"this\" (parameter) = ", $this, ", *\"this\" (parameter) = ", *$this);
      }
   }
}


Main test: main.cpp
-------------------

class example
{
  public:
    int        data_1;
    static int data_2;
    example() { data_1=17; }
};

int example::data_2 = 27;

int my_member_function( example P )
{
   int copy_of_1 = P.data_1;
   int copy_of_2 = P.data_2;
   return copy_of_1 + copy_of_2;
}

int main ()
{
   example Value;
   
   Value.data_2 = 37;
   return my_member_function( Value );
}


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

gcc -g main.cpp -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

this->data_1 = 17
example::data_2 = 27
"this" (parameter) = BFFFE4D4, *"this" (parameter) = {
  data_1 = 17
}