C++ applications probe manager

C++ Probe Manager supports probing of C++ applications in a way identical to C probe managers. Support for "uft" style entry/exit probes on any C++ function, including member, overloaded, operator, and template functions in the core executable. A function entry/exit probe in C++ must use the @@uftxlc++ probe manager.

All tuples in the @@uftxlc++ style probe specifications have the same usage and format as for the @@uft style probe strings, with the exception of the function name. Because C++ allows a single function name to be overloaded, the function name specified in the probe string may have to include the function's argument types to uniquely identify the function being probed.

For example:

@@uftxlc++:12345:*:"foobar(int, char *)":entry
@@uftxlc++:/usr/test:*:"foobar(int, char *)":entry
Note: The return type is missing from the above probe string because it does not take part in the name mangling algorithm for regular functions. In case of a template function, the user must specify an explicit template instantiation to probe on and must also specify the return type of the template instantiation:
@@uftxlc++:12345:*:void foobar<int>(int, char *):entry
Note: The probe strings must use quotes around the function name as specified in above two examples and the probevue command will signal an error if the quotes are missing. The quotes are not only because of the colon ":" but also because of the comma ",".The comma operator is used for separating multiple probes on the same line and without the quotes it takes precedence. This results in very strange error messages for the user.

When probing a class member function or a function defined in a namespace, the fully qualified function name must be used in the probe string. To avoid any ambiguity between the single colon (:) tuple separator in probe strings and the double colon (::) scope resolution operator in a fully qualified C++ name, the entire function name tuple in the probe string must be quoted.

@@uftxlc++:12345:*:"Foo::bar(int)":entry
Limitations:
  1. Access to data fields that are inherited from a virtual base class is not supported.
  2. Template classes are not supported and must not be included in the C++ header.
  3. Pointers to members are not supported.
  4. To probe a class with the class definition, an object of the class is instantiated in the header file either as a global object or in a dummy function.

Example:

Below is c++ application

#include  "header.cc"
main()
{
int             i = 10;
incr_num(i);
float           a = 3.14;
incr_num(a);
char            ch = 'A';
incr_num(ch);
double          d = 1.11;
incr_num(d);
}

Content of the "header.cc"

# cat header.cc
#include <iostream.h>
template <class T>
T incr_num( T a)
{
return (++a);
}
int dummy()
{
int  i=10,j=20;
incr_num(i);
float a=3.14;
incr_num(a);
char  ch ='A',dh='Z';
incr_num(ch);
double d=1.1,e=1.11;
incr_num(d);
return  0;
}

Content of the Vue script vue_cpp.e

##C++
#include "header.cc"
##Vue
@@uftxlc++:$__CPID:*:"incr_num<int>(int)":entry
{
printf("Hello1_%d\n",__arg1 );
}
@@uftxlc++:$__CPID:*:"incr_num <  float   > (float)" :entry
{
printf("Hello2_%f\n",__arg1 );
}
@@uftxlc++:$__CPID:*:"incr_num <  char    > ( char )":entry
{
printf("Hello3_%c\n",__arg1 );
}
@@uftxlc++:$__CPID:*:"incr_num <  double    > ( double )":entry
{
printf("Hello4_%lf\n",__arg1 );
exit();
}

Execution :

/usr/vacpp/bin/xlC  app.c++
#  probevue  -X ./a.out  vue_cpp.e
Hello1_10
Hello2_3.140000
Hello3_A
Hello4_1.110000
The function prototype in the fourth tuple can be specified as an Extended Regular Expression (ERE). The ERE should be enclosed between ‘”/’ and ‘/”’ like "/<ERE>/". When function prototype is specified as an ERE, all the functions matching the specified regular expression in the specified module will be probed.
/* Probe entry of all the C++ functions in the executable a.out */
@@uftxlc++:$__CPID:a.out:”/.*/”:entry
/* Probe exit of all the C++ functions with ‘foo’ word in it */
@@uftxlc++:$__CPID:*:”/foo/”:exit

In the entry probes, where a function name is specified as a regular expression, individual arguments cannot be accessed. However, probevue function print_args() can be used to print the function name and its arguments. The argument values is printed based on the argument type information available in the traceback table of the function.

In the exit probes, where a function name is specified as a regular expression, return value cannot be accessed.