Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/process_by_pid.stp

raw
1 global probed
2
3 probe begin {
4 probed["function"] = 0;
5 probed["statement"] = 0;
6 probed["plt"] = 0;
7 probed["provider"] = 0;
8 probed["mark"] = 0;
9 printf("systemtap starting probe\n");
10 }
11
12 probe process($1).function("*") {
13 assert($1 == pid(), "failed in process(PID).function(\"*\")")
14 probed["function"] ++;
15 }
16
17 probe process($1).function("main").label("marker_here") ? {
18 assert($1 == pid(), "failed in process(PID).function(main).label(marker_here)")
19 // gcc may not provide enough information to for stap to see this point, hence
20 // why it's optional. since it's optional, don't keep track of whether it's
21 // been seen.
22 }
23
24 probe process($1).statement("*") {
25 assert($1 == pid(), "failed in process(PID).statement\"*\")")
26 probed["statement"]++;
27 }
28
29 probe process($1).plt {
30 assert($1 == pid(), "failed in process(PID).plt")
31 probed["plt"] ++;
32 }
33
34 probe process($1).provider("*").mark("*") {
35 assert($1 == pid(), "failed in process(PID).provider(\"*\").mark(\"*\")")
36 probed["provider"] ++;
37 }
38
39 probe process($1).mark("*") {
40 assert($1 == pid(), "failed in process(PID).mark(\"*\")")
41 probed["mark"] ++;
42 }
43
44 probe end {
45 printf("systemtap ending probe\n");
46 if (probed["function"] > 0 && probed["plt"] > 0 && probed["mark"] > 0
47 && probed["statement"] > 0 && probed["provider"] > 0)
48 printf("pass\n");
49 else
50 {
51 printf("fail: did not hit all probe points successfully.\n");
52 // print out some information to find out as to where the test failed
53 printf("Hit: function:%d, plt:%d, mark:%d, statement:%d, provider:%d",
54 probed["function"], probed["plt"], probed["mark"], probed["statement"],
55 probed["provider"]);
56 }
57 }