1#! /bin/sh
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
147exit 0
148