This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

alternate static marker approach


We have been thinking about alternative static marker approaches. Perhaps the @cast support might provide an alternative to the clever, or baroque depending on one's perspective, macros used to set up the markers. The dtrace .d input file types are self contained so if a .d file was converted to a .h file and made available in a place like /usr/share then it would be easy for @cast to make use of it.

For the purpose of the example the dup syscall has been hijacked as a means of setting the probe. So given this little example:
* tstsyscall.h *
// this would be created from package.d
struct astruct
{
int a;
int b;
};
* tstsyscall.c *
#define _GNU_SOURCE
#include <sys/syscall.h>
#include "tstsyscall.h"
int
main(int argc, char *argv[])
{
int ret;
int a1 = 1;
int a2 = 2;
int a3 = 3;
int a4 = 4;
struct astruct astruct = {5, 6};
// STAP_PROBE(test,probe_one,a1,a2,a3,a4,&astruct) would map to:
ret = syscall (__NR_dup, -12345, a1, a2, a3, a4, &astruct);
}


So a probe like:
stap -c ./tstsyscall.x -e 'probe process("tstsyscall.x").mark("test") {
printf("a2=%d a3=%d a4=%d a5=%d astruct.a=%d astruct.b=%d\n",
a1, a2, a3, a4, astruct.a, astruct.b)'

could map to something like:

stap -c ./tstsyscall.x -e '
probe syscall.dup {
arg2=int_arg(2);arg3=int_arg(3);arg4=int_arg(4);arg5=int_arg(5);
arg6a=@cast(ulong_arg(6),"astruct","</work/.../tstsyscall.h>")->a;
arg6b=@cast(ulong_arg(6),"astruct","</work/.../tstsyscall.h>")->b;
printf("a1=%d a2=%d a3=%d a4=%d astruct.a=%d astruct.b=%d\n",name, arg1,arg2,arg3,arg4,arg5,arg6a,arg6b)}'


which yields:

a1=1 a2=2 a3=3 a4=4 astruct.a=5 astruct.b=6

For example here is an excerpt from tclDTrace.d
typedef struct Tcl_Obj Tcl_Obj;
provider tcl {
probe proc__entry(char* name, int objc, Tcl_Obj **objv);
...
}
struct Tcl_Obj {
   int refCount;
   char *bytes;
   int length;
   ...
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]