OC Systems

Home | Contact | Advanced Search 

Technology

How can I log a string passed to a library function like strdup() where there's no debug information ?

In the absence of debug information all parameters would be assumed to be of type 'int' and only positional ($1, $2, etc.) references will be allowed.

If you know the type of such parameter you could cast it to the right type. The strdup() function doesn't have debug information, but you could still compile and use the following apc file:

probe thread
{
   probe extern:"strdup()" in "libc.so"
   {
      on_entry
         log("strdup(", ap_StringValue($1), ")");
   }
}


Note that ap_StringValue is a macro which among other things casts the argument to a string.

For a complete list of subprograms that you can probe in shared libraries do:

apinfo -sa <your_executable_here>

It is best not to mix apc code that relies on debug information with the apc code that should compile without it. This way when you compile the apc code that doesn't require debug info you may omit the -x option altogether, and you would not have any warnings from the apc compiler.

Aprobe Technology Overview

Schedule a web demo

Contact us