Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/implicitptr.c

raw
1 #include <sys/sdt.h>
2
3 #define MARK(name) STAP_PROBE(implicitptr, name)
4
5 int z;
6 int **j2;
7 int ***k2;
8 int ****l2;
9
10 static int
11 foo (int i)
12 {
13 int *j = &i;
14 int **k = &j;
15 int ***l = &k;
16 j2 = &j; k2 = &k; l2 = &l;
17 l1: MARK (foo_l1);
18 z++; /* side effect helps the probe placement hit right */
19 i++;
20 return i;
21 }
22
23 struct S
24 {
25 int *x, y;
26 };
27
28 int u[6];
29
30 static inline int
31 add (struct S *a, struct S *b, int c)
32 {
33 *a->x += *b->x;
34 a->y += b->y;
35 l1: MARK (add_l1);
36 u[c + 0]++;
37 a = (struct S *) 0;
38 u[c + 1]++;
39 a = b;
40 l2: MARK (add_l2);
41 u[c + 2]++;
42 return *a->x + *b->x + a->y + b->y;
43 }
44
45 static int
46 bar (int i)
47 {
48 int j = i;
49 int k;
50 struct S p[2] = { { &i, i * 2 }, { &j, j * 2 } };
51 l1: MARK (bar_l1);
52 k = add (&p[0], &p[1], 0);
53 l2: MARK (bar_l2);
54 p[0].x = &j;
55 p[1].x = &i;
56 k += add (&p[0], &p[1], 3);
57 l3: MARK (bar_l3);
58 return i + j + k;
59 }
60
61 int x = 22;
62
63 int
64 main (void)
65 {
66 x = foo (x);
67 x = bar (x);
68 return 0;
69 }