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

source code of lldb/test/API/functionalities/inline-stepping/calling.cpp