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