Debian Codegraph @

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

raw
1 static inline int
2 m(char *name, int i, long j)
3 {
4 // Random syntactical block to be inlined.
5 // Mimics what STAP_PROBE macro does a bit.
6 do {
7 // Dummy (volatile) counter to trick gcc into thinking we are actually
8 // using the label. If not it will partially optimize the label away,
9 // but still emits a somewhat bogus DW_AT_low_pc for it...
10 volatile int c = 0;
11 volatile __typeof__(name) p_name = name;
12 volatile __typeof__(i) p_i = i;
13 volatile __typeof__(j) p_j = j;
14 // empty asm to force locals into regs.
15 inlined_label: asm volatile ("" : "=g"(c) : "g"(p_name), "g"(p_i), "g"(p_j));
16 if (c != 0) goto inlined_label;
17 } while (0);
18 return i + 32;
19 }
20
21 static inline int
22 call(int pi, long pj)
23 {
24 volatile int ic = pi - 42;
25 volatile long jc = pj + 42;
26 return m("call", ic, jc);
27 }
28
29 static inline int
30 call2(int pi2, long pj2)
31 {
32 volatile int ic2 = pi2 + 64;
33 volatile long jc2 = pj2 - 64;
34 return m("call2", ic2, jc2);
35 }
36
37 int
38 main (int argc, char **argv)
39 {
40 volatile int i = 64;
41 volatile long j = 42;
42 call(i, j);
43 call2(i, j);
44 m("main", i, j);
45 return 0;
46 }