static user probes

Stan Cox scox@redhat.com
Tue Oct 14 21:40:00 GMT 2008


Maneesh Soni wrote:

> Which is stap-probes.c file and why is this required?

That is just an editing problem.  It isn't required

> Is this .d file written by the user or generated automatically?
> what is the use of it?

It is written by the user and describes the argument signature for the 
probes.

> Do you mean, stap-probes-tstlable.c? Could you also share the .py?

Sure.  Here is an stap example which will now hit a probe and print 
arguments and also the python script.

***** cat tstlabel.c *****  test program
#include <stdlib.h>
#include "stap-probes.h"

foo ()
{
   STAP_PROBE(tstlabel,label1);
}

bar (int i)
{
   STAP_PROBE(tstlabel,label2,i);
}

baz (int i, char* s)
{
   STAP_PROBE(tstlabel,label3,i,s);
}

main ()
{
   foo();
   bar(2);
   baz(3,"abc");
}

***** cat stap-probes.h ***** marker include file
#define STAP_PROBE(provider,probe,...)        \
   _stap_probe_ ## probe (__VA_ARGS__);

***** cat tstlabel.d ***** used to create stap-probes-tstlabel.c
provider tstlabel {
    probe label1();
    probe label2(int);
    probe label3(int, char*);
};


***** cat stap-probes-tstlabel.c ***** currently, a generated file
_stap_probe_label1 ()
{
    return 1;
}

_stap_probe_label2 (int a)
{
    return 1;
}

_stap_probe_label3 (int a, char* b)
{
    return 1;
}

***** cat 19180.stp ***** script to test above
probe process.mark("label1")
{
    printf("label3\n")
}

probe process.mark("label2")
{
    printf("label3 arg1=%d\n", $a)
}
probe process.mark("label3")
{
    printf("label3 arg1=%d arg2=%#x\n", $a, $b)
}


stap -c /home/scox/stap/1918/tstlabel.x 19180.stp
label1
label2 arg1=2
label3 arg1=3 arg2=0x4005e8

-------------- next part --------------
A non-text attachment was scrubbed...
Name: stap-probes.py
Type: text/x-python
Size: 2903 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/systemtap/attachments/20081014/1e62539a/attachment.py>


More information about the Systemtap mailing list