Home | History | Annotate | Download | only in tests
      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 
     55 testfiles testfile-inlines
     56 
     57 testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005a0 <<\EOF
     58 /tmp/x.cpp:5
     59 EOF
     60 
     61 testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005a1 <<\EOF
     62 /tmp/x.cpp:6
     63 EOF
     64 
     65 testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005b0 <<\EOF
     66 /tmp/x.cpp:10
     67 EOF
     68 
     69 testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005b1 <<\EOF
     70 /tmp/x.cpp:11
     71 EOF
     72 
     73 testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005c0 <<\EOF
     74 /tmp/x.cpp:5
     75 /tmp/x.cpp:15
     76 EOF
     77 
     78 testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005d0 <<\EOF
     79 /tmp/x.cpp:10
     80 /tmp/x.cpp:20
     81 EOF
     82 
     83 testrun_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
     87 EOF
     88 
     89 testrun_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
     93 EOF
     94 
     95 testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005f1 <<\EOF
     96 /tmp/x.cpp:10
     97 /tmp/x.cpp:32
     98 EOF
     99 
    100 testrun_compare ${abs_top_builddir}/src/addr2line -i -e testfile-inlines 0x00000000000005f2 <<\EOF
    101 /tmp/x.cpp:5
    102 /tmp/x.cpp:33
    103 EOF
    104 
    105 # All together now (plus function names).
    106 testrun_compare ${abs_top_builddir}/src/addr2line -f -i -e testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f0 0x00000000000005f1 0x00000000000005f2 <<\EOF
    107 foobar
    108 /tmp/x.cpp:5
    109 foobar
    110 /tmp/x.cpp:6
    111 fubar
    112 /tmp/x.cpp:10
    113 fubar
    114 /tmp/x.cpp:11
    115 foobar inlined at /tmp/x.cpp:15 in _Z3barv
    116 /tmp/x.cpp:5
    117 bar
    118 /tmp/x.cpp:15
    119 fubar inlined at /tmp/x.cpp:20 in _Z3bazv
    120 /tmp/x.cpp:10
    121 baz
    122 /tmp/x.cpp:20
    123 foobar inlined at /tmp/x.cpp:15 in _Z3foov
    124 /tmp/x.cpp:5
    125 bar
    126 /tmp/x.cpp:15
    127 _Z3foov
    128 /tmp/x.cpp:25
    129 fubar inlined at /tmp/x.cpp:20 in _Z3foov
    130 /tmp/x.cpp:10
    131 baz
    132 /tmp/x.cpp:20
    133 _Z3foov
    134 /tmp/x.cpp:26
    135 _Z2fuv
    136 /tmp/x.cpp:31
    137 fubar inlined at /tmp/x.cpp:32 in _Z2fuv
    138 /tmp/x.cpp:10
    139 _Z2fuv
    140 /tmp/x.cpp:32
    141 foobar inlined at /tmp/x.cpp:33 in _Z2fuv
    142 /tmp/x.cpp:5
    143 _Z2fuv
    144 /tmp/x.cpp:33
    145 EOF
    146 
    147 # All together now (plus function names plus addresses).
    148 testrun_compare ${abs_top_builddir}/src/addr2line -a -f -i -e testfile-inlines 0x00000000000005a0 0x00000000000005a1 0x00000000000005b0 0x00000000000005b1 0x00000000000005c0 0x00000000000005d0 0x00000000000005e0 0x00000000000005e1 0x00000000000005f0 0x00000000000005f1 0x00000000000005f2 <<\EOF
    149 0x00000000000005a0
    150 foobar
    151 /tmp/x.cpp:5
    152 0x00000000000005a1
    153 foobar
    154 /tmp/x.cpp:6
    155 0x00000000000005b0
    156 fubar
    157 /tmp/x.cpp:10
    158 0x00000000000005b1
    159 fubar
    160 /tmp/x.cpp:11
    161 0x00000000000005c0
    162 foobar inlined at /tmp/x.cpp:15 in _Z3barv
    163 /tmp/x.cpp:5
    164 bar
    165 /tmp/x.cpp:15
    166 0x00000000000005d0
    167 fubar inlined at /tmp/x.cpp:20 in _Z3bazv
    168 /tmp/x.cpp:10
    169 baz
    170 /tmp/x.cpp:20
    171 0x00000000000005e0
    172 foobar inlined at /tmp/x.cpp:15 in _Z3foov
    173 /tmp/x.cpp:5
    174 bar
    175 /tmp/x.cpp:15
    176 _Z3foov
    177 /tmp/x.cpp:25
    178 0x00000000000005e1
    179 fubar inlined at /tmp/x.cpp:20 in _Z3foov
    180 /tmp/x.cpp:10
    181 baz
    182 /tmp/x.cpp:20
    183 _Z3foov
    184 /tmp/x.cpp:26
    185 0x00000000000005f0
    186 _Z2fuv
    187 /tmp/x.cpp:31
    188 0x00000000000005f1
    189 fubar inlined at /tmp/x.cpp:32 in _Z2fuv
    190 /tmp/x.cpp:10
    191 _Z2fuv
    192 /tmp/x.cpp:32
    193 0x00000000000005f2
    194 foobar inlined at /tmp/x.cpp:33 in _Z2fuv
    195 /tmp/x.cpp:5
    196 _Z2fuv
    197 /tmp/x.cpp:33
    198 EOF
    199 
    200 # All together now (plus function names and addresses and pretty)
    201 testrun_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
    202 0x00000000000005a0: foobar at /tmp/x.cpp:5
    203 0x00000000000005a1: foobar at /tmp/x.cpp:6
    204 0x00000000000005b0: fubar at /tmp/x.cpp:10
    205 0x00000000000005b1: fubar at /tmp/x.cpp:11
    206 0x00000000000005c0: foobar at /tmp/x.cpp:5
    207  (inlined by) bar at /tmp/x.cpp:15
    208 0x00000000000005d0: fubar at /tmp/x.cpp:10
    209  (inlined by) baz at /tmp/x.cpp:20
    210 0x00000000000005e0: foobar at /tmp/x.cpp:5
    211  (inlined by) bar at /tmp/x.cpp:15
    212  (inlined by) _Z3foov at /tmp/x.cpp:25
    213 0x00000000000005e1: fubar at /tmp/x.cpp:10
    214  (inlined by) baz at /tmp/x.cpp:20
    215  (inlined by) _Z3foov at /tmp/x.cpp:26
    216 0x00000000000005f0: _Z2fuv at /tmp/x.cpp:31
    217 0x00000000000005f1: fubar at /tmp/x.cpp:10
    218  (inlined by) _Z2fuv at /tmp/x.cpp:32
    219 0x00000000000005f2: foobar at /tmp/x.cpp:5
    220  (inlined by) _Z2fuv at /tmp/x.cpp:33
    221 EOF
    222 
    223 exit 0
    224