1 #include <stdio.h>
2 
3 inline int inline_ref_1 (int &value) __attribute__((always_inline));
4 inline int inline_ref_2 (int &value) __attribute__((always_inline));
5 
6 int caller_ref_1 (int &value);
7 int caller_ref_2 (int &value);
8 
9 int called_by_inline_ref (int &value);
10 
11 inline void inline_trivial_1 () __attribute__((always_inline));
12 inline void inline_trivial_2 () __attribute__((always_inline));
13 
14 void caller_trivial_1 ();
15 void caller_trivial_2 ();
16 
17 void called_by_inline_trivial ();
18 
19 static int inline_value;
20 
21 int
function_to_call()22 function_to_call ()
23 {
24     return inline_value;
25 }
26 
27 int
caller_ref_1(int & value)28 caller_ref_1 (int &value)
29 {
30     int increment = caller_ref_2(value); // In caller_ref_1.
31     value += increment; // At increment in caller_ref_1.
32     return value;
33 }
34 
35 int
caller_ref_2(int & value)36 caller_ref_2 (int &value)
37 {
38     int increment = inline_ref_1 (value); // In caller_ref_2.
39     value += increment;  // At increment in caller_ref_2.
40     return value;
41 }
42 
43 int
called_by_inline_ref(int & value)44 called_by_inline_ref (int &value)
45 {
46     value += 1; // In called_by_inline_ref.
47     return value;
48 }
49 
50 int
inline_ref_1(int & value)51 inline_ref_1 (int &value)
52 {
53     int increment = inline_ref_2(value); // In inline_ref_1.
54     value += increment; // At increment in inline_ref_1.
55     return value;
56 }
57 
58 int
inline_ref_2(int & value)59 inline_ref_2 (int &value)
60 {
61     int increment = called_by_inline_ref (value);  // In inline_ref_2.
62     value += 1; // At increment in inline_ref_2.
63     return value;
64 }
65 
66 void
caller_trivial_1()67 caller_trivial_1 ()
68 {
69     caller_trivial_2(); // In caller_trivial_1.
70     inline_value += 1;
71 }
72 
73 void
caller_trivial_2()74 caller_trivial_2 ()
75 {
76     inline_trivial_1 (); // In caller_trivial_2.
77     inline_value += 1;  // At increment in caller_trivial_2.
78 }
79 
80 void
called_by_inline_trivial()81 called_by_inline_trivial ()
82 {
83     inline_value += 1; // In called_by_inline_trivial.
84 }
85 
86 void
inline_trivial_1()87 inline_trivial_1 ()
88 {
89     inline_trivial_2(); // In inline_trivial_1.
90     inline_value += 1;  // At increment in inline_trivial_1.
91 }
92 
93 void
inline_trivial_2()94 inline_trivial_2 ()
95 {
96     inline_value += 1; // In inline_trivial_2.
97     called_by_inline_trivial (); // At caller_by_inline_trivial in inline_trivial_2.
98 }
99 
100 int
main(int argc,char ** argv)101 main (int argc, char **argv)
102 {
103 
104     inline_value = 0;    // Stop here and step over to set up stepping over.
105 
106     inline_trivial_1 ();    // At inline_trivial_1 called from main.
107 
108     caller_trivial_1();     // At first call of caller_trivial_1 in main.
109 
110     caller_trivial_1();     // At second call of caller_trivial_1 in main.
111 
112     caller_ref_1 (argc); // At first call of caller_ref_1 in main.
113 
114     caller_ref_1 (argc); // At second call of caller_ref_1 in main.
115 
116     function_to_call (); // Make sure debug info for this function gets generated.
117 
118     return 0;            // About to return from main.
119 }
120