White-Box Testing       
by Oliver Cole
 

Example 1: 
(a)  

#include "aprobe.h"
probe thread
{
  probe "fstat" in "libc.so"
  {  /* Parameter one is $1, Parameter two is $2, etc */
      on_entry
        log ("St_dev is ", $2-> st_dev);
        log ("Whole st_stat is ", *$2);
  }
}

(b)
  
St_dev  is 0
Whole st_stat is {
  st_dev = 0
  st_pad1 = {
      [0] = 0
      [1] = 0
      [2] = 0
  }
  st_ino = 0
  st_mode = 0
  st_nlink = 0
  st_uid = 0
  st_gid = 0
  st_rdev = 0
  st_pad2 = {
      [0] = -276903488
      [1] = 143764
}


Example 2: 

(a)
#include "aprobe.h"
probe thread
{
   probe "read_q"
   {
   on_entry
     log("Read_q for ", $1, " entered at: ", ap_GetCurrentTime());
   on_line(32)
     log("Read_q at line 32 at: ", ap_GetCurrentTime());
   on_exit
     log("Read_q exited at: ",ap_GetCurrentTime());
 }
}

(b)

Read_q for 8 entered at Tue Oct  5 10:22:25.218414184 1999 
Read_q at line 32 at Tue Oct  5 10:22:25.218427767 1999 
Read_q exited at Tue Oct  5      10:22:25.219538727 1999



Example 3: 

 struc Msg {
 int Length;
 ptr Address);

 void SendMsg(Msg SendThis);
 ...
#include "aprobe.h"
probe thread
{
   probe "SendMsg"
   {
    on_entry
      log($SendThis.Length, ap_GetCurrentTime());
    on_exit
      log(ap_GetCurrentTime());
    }
}


Example 4:

#include "aprobe.h"
Probe thread
{
   probe "DiskRead"
   {
      on_entry ap_StubRoutine; /* DiskRead will not be called */
     on_exit $return = -1;
   }
}


Example 5:

#include "aprobe.h"
probe thread
{
    probe "IPC::ReadfromMsgQueue(Msg)"
    {
     int i, *my_ptr;
     on_entry
        my_ptr = (int*) $Msg; /* save the pointer */
     on_exit
        for (i=0;i<5;i++)
       { *my_ptr = 42;
           my_ptr++; }
     }
 }


Example 6:

#include "aprobe.h"
Probe thread
{
     probe "MyRoutine::DoSomething"
    {
    on_line(32)
       ap_ThrowCppStringException("Application Error");
    }
}


Example 7: 

#include "aprobe.h"
probe thread
{
    probe "compute_factorial"
    {
      on_entry
        if ($n <0) {
            log ("Error: factorial called with", $n);
           ap_LogTraceback(99); 
           exit(-1);} 
     }
}



5


