1// RUN: %clangxx %s -g -fexceptions %extra-clang-opts -o %t
2// RUN: %Test_jit_debuginfo %s %t
3// DEBUGGER: set breakpoint pending on
4// DEBUGGER: break function_test
5// DEBUGGER: break %s:47
6// DEBUGGER: break %s:55
7// DEBUGGER: break %s:60
8// DEBUGGER: break %s:66
9// DEBUGGER: break %s:69
10// DEBUGGER: run
11// DEBUGGER: bt 2
12// CHECK: #0
13// CHECK:  function_test
14// CHECK: #1
15// CHECK:  main
16// DEBUGGER: continue
17// DEBUGGER: print j
18// CHECK: $1 = 0
19// DEBUGGER: step
20// DEBUGGER: print j
21// CHECK: $2 = 1
22// DEBUGGER: continue
23// DEBUGGER: print j
24// CHECK: $3 = -1
25// DEBUGGER: continue
26// DEBUGGER: bt 3
27// CHECK: #0
28// CHECK:  inline_test
29// CHECK: #1
30// CHECK:  function_test
31// CHECK: #2
32// CHECK:  main
33// DEBUGGER: continue
34// DEBUGGER: print j
35// CHECK: $4 = 2
36// DEBUGGER: continue
37// DEBUGGER: print j
38// CHECK: $5 = 0
39// DEBUGGER: continue
40
41__attribute__((noinline)) static int function_test();
42__attribute__((always_inline)) static int inline_test();
43
44int inline_test()
45{
46  int i = 0;
47  i++;
48  return i;
49}
50
51int function_test(int c)
52{
53  int i, j = 0;
54  for (i = 0; i < c; i++) {
55    j++;
56  }
57
58  {
59    int j = -1;
60    j++;
61  }
62
63  j += inline_test();
64
65  if (j > 0) {
66    j = 0;
67  }
68
69  return j;
70}
71
72int main(int argc, char** argv)
73{
74  return function_test(1);
75}
76