1 #! /bin/sh 2 # Copyright (C) 2015, 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 testfiles debug-ranges-no-lowpc.o 21 22 testrun_compare ${abs_builddir}/dwarf-ranges debug-ranges-no-lowpc.o 0xb <<\EOF 23 1..2 (base 0) 24 3..4 (base 0) 25 EOF 26 27 # - hello.c 28 # int say (const char *prefix); 29 # 30 # char * 31 # subject (char *word, int count) 32 # { 33 # return count > 0 ? word : (word + count); 34 # } 35 # 36 # int 37 # main (int argc, char **argv) 38 # { 39 # return say (subject (argv[0], argc)); 40 # } 41 # 42 # int 43 # no_say (const char *prefix) 44 # { 45 # const char *world = subject ("World", 42); 46 # return prefix ? say (prefix) : say (world); 47 # } 48 # 49 # - world.c 50 # char * subject (char *word, int count); 51 # int no_say (const char *prefix); 52 # 53 # static int 54 # sad (char c) 55 # { 56 # return c > 0 ? c : c + 1; 57 # } 58 # 59 # static int 60 # happy (const char *w) 61 # { 62 # return sad (w[1]); 63 # } 64 # 65 # int 66 # say (const char *prefix) 67 # { 68 # const char *world = subject ("World", 42);; 69 # return prefix ? sad (prefix[0]) : happy (world); 70 # } 71 # 72 # char * 73 # no_subject (char *word, int count) 74 # { 75 # return count > 0 ? word : (word + count); 76 # } 77 # 78 # int 79 # no_main (int argc, char **argv) 80 # { 81 # return no_say (no_subject (argv[0], argc)); 82 # } 83 # 84 # - gcc -c -O2 -gdwarf-4 hello.c 85 # - gcc -c -O2 -gdwarf-4 world.c 86 # - gcc -o testfileranges4 -O2 -gdwarf-4 hello.o world.o 87 # - eu-strip -f testfileranges4.debug testfileranges4 88 89 testfiles testfileranges4.debug 90 testrun_compare ${abs_builddir}/dwarf-ranges testfileranges4.debug 0xb <<\EOF 91 400500..40053a (base 0) 92 400400..400415 (base 0) 93 EOF 94 95 testrun_compare ${abs_builddir}/dwarf-ranges testfileranges4.debug 0xcd <<\EOF 96 400400..400402 (base 0) 97 400405..40040d (base 0) 98 EOF 99 100 testrun_compare ${abs_builddir}/dwarf-ranges testfileranges4.debug 0x374 <<\EOF 101 4005a0..4005a2 (base 400540) 102 4005a5..4005ad (base 400540) 103 EOF 104 105 # Like above, but with -gdwarf-5. 106 testfiles testfileranges5.debug 107 testrun_compare ${abs_builddir}/dwarf-ranges testfileranges5.debug 0xc <<\EOF 108 401150..40117a (base 0) 109 401050..401067 (base 0) 110 EOF 111 112 testrun_compare ${abs_builddir}/dwarf-ranges testfileranges5.debug 0x2ce <<\EOF 113 40119b..40119b (base 401180) 114 40119c..4011a6 (base 401180) 115 4011b0..4011b4 (base 401180) 116 4011b5..4011bf (base 401180) 117 EOF 118 119 testrun_compare ${abs_builddir}/dwarf-ranges testfileranges5.debug 0x2ef <<\EOF 120 40119b..40119b (base 401180) 121 40119c..4011a6 (base 401180) 122 4011b4..4011b4 (base 401180) 123 4011b5..4011bf (base 401180) 124 EOF 125 126 exit 0 127