xref: /aosp_15_r20/external/elfutils/tests/run-all-dwarf-ranges.sh (revision 7304104da70ce23c86437a01be71edd1a2d7f37e)
1#! /bin/sh
2# Copyright (C) 2018 Red Hat, Inc.
3# This file is part of elfutils.
4#
5# This file 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# elfutils is distributed in the hope that it will be useful, but
11# 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. $srcdir/test-subr.sh
19
20# See run-dwarf-ranges.sh
21# Compiled with:
22# gcc -c -O2 -o testfile-ranges-hello.o -gsplit-dwarf -gdwarf-4 hello.c
23# gcc -c -O2 -o testfile-ranges-world.o -gsplit-dwarf -gdwarf-4 world.c
24# gcc -o testfilesplitranges4 -O2 \
25#        testfile-ranges-hello.o testfile-ranges-world.o
26# eu-strip -f testfilesplitranges4.debug testfilesplitranges4
27
28testfiles testfilesplitranges4.debug
29testfiles testfile-ranges-hello.dwo testfile-ranges-world.dwo
30
31testrun_compare ${abs_builddir}/all-dwarf-ranges testfilesplitranges4.debug <<\EOF
32die: hello.c (11)
33 4004e0..4004ff
34 4003e0..4003f7
35
36die: no_say (2e)
37 4004f0..4004ff
38
39die: main (2e)
40 4003e0..4003f7
41
42die: subject (1d)
43 4003e3..4003ef
44
45die: subject (2e)
46 4004e0..4004f0
47
48die: world.c (11)
49 400500..400567
50
51die: no_main (2e)
52 400550..400567
53
54die: no_subject (1d)
55 400553..40055f
56
57die: say (2e)
58 400500..400540
59
60die: happy (1d)
61 40051c..400526
62 400530..400534
63 400535..40053f
64
65die: sad (1d)
66 40051c..400526
67 400535..40053f
68
69die: no_subject (2e)
70 400540..400550
71
72EOF
73
74# Same with -gdwarf-5
75# gcc -c -O2 -o testfile-ranges-hello5.o -gsplit-dwarf -gdwarf-5 hello.c
76# gcc -c -O2 -o testfile-ranges-world5.o -gsplit-dwarf -gdwarf-5 world.c
77# gcc -o testfilesplitranges5 -O2 testfile-ranges-hello5.o testfile-ranges-world5.o
78# eu-strip -f testfilesplitranges5.debug testfilesplitranges5
79
80testfiles testfilesplitranges5.debug
81testfiles testfile-ranges-hello5.dwo testfile-ranges-world5.dwo
82
83testrun_compare ${abs_builddir}/all-dwarf-ranges testfilesplitranges5.debug <<\EOF
84die: hello.c (11)
85 401150..40117a
86 401050..401067
87
88die: no_say (2e)
89 401160..40117a
90
91die: main (2e)
92 401050..401067
93
94die: subject (1d)
95 401053..40105f
96
97die: subject (2e)
98 401150..401160
99
100die: world.c (11)
101 401180..4011e7
102
103die: no_main (2e)
104 4011d0..4011e7
105
106die: no_subject (1d)
107 4011d3..4011df
108
109die: say (2e)
110 401180..4011c0
111
112die: happy (1d)
113 40119b..40119b
114 40119c..4011a6
115 4011b0..4011b4
116 4011b5..4011bf
117
118die: sad (1d)
119 40119b..40119b
120 40119c..4011a6
121 4011b4..4011b4
122 4011b5..4011bf
123
124die: no_subject (2e)
125 4011c0..4011d0
126
127EOF
128
129# See testfile-dwp.source.
130testfiles testfile-dwp-5 testfile-dwp-5.dwp
131testfiles testfile-dwp-4 testfile-dwp-4.dwp
132
133testrun_compare ${abs_builddir}/all-dwarf-ranges testfile-dwp-5 << EOF
134die: foo.cc (11)
135 401190..401200
136
137die: foo (2e)
138 4011c0..401200
139
140die: x_x (1d)
141 4011cb..4011eb
142 4011f8..401200
143
144die: <unknown> (b)
145 4011cb..4011eb
146 4011f8..401200
147
148die: x_x (2e)
149 401190..4011bd
150
151die: <unknown> (b)
152 401190..401190
153 401192..4011bb
154
155die: bar.cc (11)
156 401200..40121b
157
158die: bar (2e)
159 401200..40121b
160
161die: main.cc (11)
162 401020..4010a0
163
164die: main (2e)
165 401020..4010a0
166
167die: fibonacci (1d)
168 401030..401032
169 401036..401060
170 401099..4010a0
171
172die: fibonacci (1d)
173 40103a..401060
174 401099..4010a0
175
176die: <unknown> (b)
177 40103a..401060
178 401099..4010a0
179
180die: <unknown> (b)
181 40103a..401044
182 401050..401060
183
184die: <unknown> (b)
185 401050..401053
186 401056..401059
187
188EOF
189
190testrun_compare ${abs_builddir}/all-dwarf-ranges testfile-dwp-4 << EOF
191die: foo.cc (11)
192 401190..401200
193
194die: foo (2e)
195 4011c0..401200
196
197die: x_x (1d)
198 4011cb..4011eb
199 4011f8..401200
200
201die: <unknown> (b)
202 4011cb..4011eb
203 4011f8..401200
204
205die: x_x (2e)
206 401190..4011bd
207
208die: bar.cc (11)
209 401200..40121b
210
211die: bar (2e)
212 401200..40121b
213
214die: main.cc (11)
215 401020..4010a0
216
217die: main (2e)
218 401020..4010a0
219
220die: fibonacci (1d)
221 401030..401032
222 401036..401060
223 401099..4010a0
224
225die: fibonacci (1d)
226 40103a..401060
227 401099..4010a0
228
229die: <unknown> (b)
230 40103a..401060
231 401099..4010a0
232
233die: <unknown> (b)
234 40103a..401044
235 401050..401060
236
237die: <unknown> (b)
238 401050..401053
239 401056..401059
240
241EOF
242
243exit 0
244