1#!/usr/local/bin/bash
2# Copyright (C) 2013 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# // g++ x.cpp -g -fPIC -olibx.so -shared -O3 -fvisibility=hidden
21#
22# void foobar()
23# {
24#   __asm__ ( "nop" ::: );
25# }
26#
27# void fubar()
28# {
29#   __asm__ ( "nop" ::: );
30# }
31#
32# void bar()
33# {
34#   foobar();
35# }
36#
37# void baz()
38# {
39#   fubar();
40# }
41#
42# void foo()
43# {
44#   bar();
45#   baz();
46# }
47#
48# void fu()
49# {
50#   __asm__ ( "nop" ::: );
51#   fubar();
52#   foobar();
53# }
54
55testfiles testfile-inlines
56
57testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005a0 <<\EOF
58/tmp/x.cpp:5
59EOF
60
61testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005a1 <<\EOF
62/tmp/x.cpp:6
63EOF
64
65testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005b0 <<\EOF
66/tmp/x.cpp:10
67EOF
68
69testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005b1 <<\EOF
70/tmp/x.cpp:11
71EOF
72
73testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005c0 <<\EOF
74/tmp/x.cpp:5
75/tmp/x.cpp:15
76EOF
77
78testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005d0 <<\EOF
79/tmp/x.cpp:10
80/tmp/x.cpp:20
81EOF
82
83testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005e0 <<\EOF
84/tmp/x.cpp:5
85/tmp/x.cpp:15
86/tmp/x.cpp:25
87EOF
88
89testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005e1 <<\EOF
90/tmp/x.cpp:10
91/tmp/x.cpp:20
92/tmp/x.cpp:26
93EOF
94
95testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005f1 <<\EOF
96/tmp/x.cpp:10
97/tmp/x.cpp:32
98EOF
99
100testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005f2 <<\EOF
101/tmp/x.cpp:5
102/tmp/x.cpp:33
103EOF
104
105# All together now (plus function names).
106testrun_compare ${abs_top_builddir}/src/addr2line -f -i -e testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f0 0x00000000000005f1 0x00000000000005f2 <<\EOF
107foobar
108/tmp/x.cpp:5
109foobar
110/tmp/x.cpp:6
111fubar
112/tmp/x.cpp:10
113fubar
114/tmp/x.cpp:11
115foobar inlined at /tmp/x.cpp:15 in _Z3barv
116/tmp/x.cpp:5
117bar
118/tmp/x.cpp:15
119fubar inlined at /tmp/x.cpp:20 in _Z3bazv
120/tmp/x.cpp:10
121baz
122/tmp/x.cpp:20
123foobar inlined at /tmp/x.cpp:15 in _Z3foov
124/tmp/x.cpp:5
125bar
126/tmp/x.cpp:15
127_Z3foov
128/tmp/x.cpp:25
129fubar inlined at /tmp/x.cpp:20 in _Z3foov
130/tmp/x.cpp:10
131baz
132/tmp/x.cpp:20
133_Z3foov
134/tmp/x.cpp:26
135_Z2fuv
136/tmp/x.cpp:31
137fubar inlined at /tmp/x.cpp:32 in _Z2fuv
138/tmp/x.cpp:10
139_Z2fuv
140/tmp/x.cpp:32
141foobar inlined at /tmp/x.cpp:33 in _Z2fuv
142/tmp/x.cpp:5
143_Z2fuv
144/tmp/x.cpp:33
145EOF
146
147# All together now (plus function names plus addresses).
148testrun_compare ${abs_top_builddir}/src/addr2line -a -f -i -e testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f0 0x00000000000005f1 0x00000000000005f2 <<\EOF
1490x00000000000005a0
150foobar
151/tmp/x.cpp:5
1520x00000000000005a1
153foobar
154/tmp/x.cpp:6
1550x00000000000005b0
156fubar
157/tmp/x.cpp:10
1580x00000000000005b1
159fubar
160/tmp/x.cpp:11
1610x00000000000005c0
162foobar inlined at /tmp/x.cpp:15 in _Z3barv
163/tmp/x.cpp:5
164bar
165/tmp/x.cpp:15
1660x00000000000005d0
167fubar inlined at /tmp/x.cpp:20 in _Z3bazv
168/tmp/x.cpp:10
169baz
170/tmp/x.cpp:20
1710x00000000000005e0
172foobar inlined at /tmp/x.cpp:15 in _Z3foov
173/tmp/x.cpp:5
174bar
175/tmp/x.cpp:15
176_Z3foov
177/tmp/x.cpp:25
1780x00000000000005e1
179fubar inlined at /tmp/x.cpp:20 in _Z3foov
180/tmp/x.cpp:10
181baz
182/tmp/x.cpp:20
183_Z3foov
184/tmp/x.cpp:26
1850x00000000000005f0
186_Z2fuv
187/tmp/x.cpp:31
1880x00000000000005f1
189fubar inlined at /tmp/x.cpp:32 in _Z2fuv
190/tmp/x.cpp:10
191_Z2fuv
192/tmp/x.cpp:32
1930x00000000000005f2
194foobar inlined at /tmp/x.cpp:33 in _Z2fuv
195/tmp/x.cpp:5
196_Z2fuv
197/tmp/x.cpp:33
198EOF
199
200# All together now (plus function names and addresses and pretty)
201testrun_compare ${abs_top_builddir}/src/addr2line --pretty-print -a -f -i -e testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f0 0x00000000000005f1 0x00000000000005f2 <<\EOF
2020x00000000000005a0: foobar at /tmp/x.cpp:5
2030x00000000000005a1: foobar at /tmp/x.cpp:6
2040x00000000000005b0: fubar at /tmp/x.cpp:10
2050x00000000000005b1: fubar at /tmp/x.cpp:11
2060x00000000000005c0: foobar at /tmp/x.cpp:5
207 (inlined by) bar at /tmp/x.cpp:15
2080x00000000000005d0: fubar at /tmp/x.cpp:10
209 (inlined by) baz at /tmp/x.cpp:20
2100x00000000000005e0: foobar at /tmp/x.cpp:5
211 (inlined by) bar at /tmp/x.cpp:15
212 (inlined by) _Z3foov at /tmp/x.cpp:25
2130x00000000000005e1: fubar at /tmp/x.cpp:10
214 (inlined by) baz at /tmp/x.cpp:20
215 (inlined by) _Z3foov at /tmp/x.cpp:26
2160x00000000000005f0: _Z2fuv at /tmp/x.cpp:31
2170x00000000000005f1: fubar at /tmp/x.cpp:10
218 (inlined by) _Z2fuv at /tmp/x.cpp:32
2190x00000000000005f2: foobar at /tmp/x.cpp:5
220 (inlined by) _Z2fuv at /tmp/x.cpp:33
221EOF
222
223exit 0
224