]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.dwarf2/pieces.c
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / pieces.c
CommitLineData
8acc9f48 1/* Copyright (C) 2010-2013 Free Software Foundation, Inc.
afd74c5f
TT
2
3 This file is part of GDB.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* The original program corresponding to pieces.S.
19 This came from https://bugzilla.redhat.com/show_bug.cgi?id=589467
20 Note that it is not ever compiled, pieces.S is used instead.
21 However, it is used to extract breakpoint line numbers. */
22
23struct A { int i; int j; };
d3b1e874 24struct B { int i : 12; int j : 12; int : 4; };
cb826367 25struct C { int i; int j; int q; };
afd74c5f
TT
26
27__attribute__((noinline)) void
28bar (int x)
29{
30 asm volatile ("" : : "r" (x) : "memory");
31}
32
33__attribute__((noinline)) int
34f1 (int k)
35{
36 struct A a = { 4, k + 6 };
37 asm ("" : "+r" (a.i));
38 a.j++;
39 bar (a.i); /* { dg-final { gdb-test 20 "a.i" "4" } } */
40 bar (a.j); /* { dg-final { gdb-test 20 "a.j" "14" } } */
41 return a.i + a.j; /* f1 breakpoint */
42}
43
44__attribute__((noinline)) int
45f2 (int k)
46{
47 int a[2] = { 4, k + 6 };
48 asm ("" : "+r" (a[0]));
49 a[1]++;
50 bar (a[0]); /* { dg-final { gdb-test 31 "a\[0\]" "4" } } */
51 bar (a[1]); /* { dg-final { gdb-test 31 "a\[1\]" "14" } } */
52 return a[0] + a[1]; /* f2 breakpoint */
53}
54
55__attribute__((noinline)) int
56f3 (int k)
57{
58 struct B a = { 4, k + 6 };
59 asm ("" : "+r" (a.i));
60 a.j++;
61 bar (a.i); /* { dg-final { gdb-test 42 "a.i" "4" } } */
62 bar (a.j); /* { dg-final { gdb-test 42 "a.j" "14" } } */
63 return a.i + a.j; /* f3 breakpoint */
64}
65
66__attribute__((noinline)) int
67f4 (int k)
68{
69 int a[2] = { k, k };
70 asm ("" : "+r" (a[0]));
71 a[1]++;
72 bar (a[0]);
73 bar (a[1]);
74 return a[0] + a[1]; /* f4 breakpoint */
75}
76
77__attribute__((noinline)) int
78f5 (int k)
79{
80 struct A a = { k, k };
81 asm ("" : "+r" (a.i));
82 a.j++;
83 bar (a.i);
84 bar (a.j);
85 return a.i + a.j; /* f5 breakpoint */
86}
87
cb826367
TT
88__attribute__((noinline)) int
89f6 (int k)
90{
91 int z = 23;
d3b1e874 92 struct C a = { k, k, z };
cb826367
TT
93 asm ("" : "+r" (a.i));
94 a.j++;
95 bar (a.i);
96 bar (a.j);
97 return a.i + a.j; /* f6 breakpoint */
98}
99
afd74c5f
TT
100int
101main (void)
102{
103 int k;
104 asm ("" : "=r" (k) : "0" (7));
105 f1 (k);
106 f2 (k);
107 f3 (k);
108 f4 (k);
109 f5 (k);
cb826367 110 f6 (k);
afd74c5f
TT
111 return 0;
112}