Aprobe 5

4. How do I log the value of a string parameter?

The probe: hello.spc

probe thread
   probe "Emit_Greeting"
         log ("Enter Emit_Greeting, msg = ", sp_StringValue($1));
         // $1 refers to a function's first parameter.

Main test: hello.c

#include <stdio.h>

int Emit_Greeting (char* msg) 
   printf ("%s\n", msg);

int main (int argc, char** argv)
  Emit_Greeting ("Hello world.");
  return 0;

Compile the hello.c program to create hello.exe:

gcc -g hello.c -o hello.exe

Compile the hello.spc probe to create hello.usm:

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

The result:

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

sptool -u hello.usm -if hello.exe

Enter Emit_Greeting, msg = Hello world.
Hello world.