|
| 1 | +# Copyright (C) 2012 Free Software Foundation, Inc. |
| 2 | + |
| 3 | +# This program is free software; you can redistribute it and/or modify |
| 4 | +# it under the terms of the GNU General Public License as published by |
| 5 | +# the Free Software Foundation; either version 3 of the License, or |
| 6 | +# (at your option) any later version. |
| 7 | +# |
| 8 | +# This program is distributed in the hope that it will be useful, |
| 9 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | +# GNU General Public License for more details. |
| 12 | +# |
| 13 | +# You should have received a copy of the GNU General Public License |
| 14 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | + |
| 16 | +# Workaround for: |
| 17 | +# invalid IFUNC DW_AT_linkage_name: memmove strstr time |
| 18 | +# http://sourceware.org/bugzilla/show_bug.cgi?id=14166 |
| 19 | + |
| 20 | +if {[skip_shlib_tests]} { |
| 21 | + return 0 |
| 22 | +} |
| 23 | + |
| 24 | +set testfile "gnu-ifunc-strstr-workaround" |
| 25 | +set executable ${testfile} |
| 26 | +set srcfile start.c |
| 27 | +set binfile [standard_output_file ${executable}] |
| 28 | + |
| 29 | +if [prepare_for_testing ${testfile}.exp $executable $srcfile] { |
| 30 | + return -1 |
| 31 | +} |
| 32 | + |
| 33 | +if ![runto_main] { |
| 34 | + return 0 |
| 35 | +} |
| 36 | + |
| 37 | +set test "ptype atoi" |
| 38 | +gdb_test_multiple $test $test { |
| 39 | + -re "type = int \\(const char \\*\\)\r\n$gdb_prompt $" { |
| 40 | + pass $test |
| 41 | + } |
| 42 | + -re "type = int \\(\\)\r\n$gdb_prompt $" { |
| 43 | + untested "$test (no DWARF)" |
| 44 | + return 0 |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +set addr "" |
| 49 | +set test "print strstr" |
| 50 | +gdb_test_multiple $test $test { |
| 51 | + -re " = {<text gnu-indirect-function variable, no debug info>} (0x\[0-9a-f\]+) <strstr>\r\n$gdb_prompt $" { |
| 52 | + set addr $expect_out(1,string) |
| 53 | + pass $test |
| 54 | + } |
| 55 | + -re " = {<text gnu-indirect-function variable, no debug info>} (0x\[0-9a-f\]+) <__strstr>\r\n$gdb_prompt $" { |
| 56 | + set addr $expect_out(1,string) |
| 57 | + pass "$test (GDB workaround)" |
| 58 | + } |
| 59 | + -re " = {<text gnu-indirect-function variable, no debug info>} (0x\[0-9a-f\]+) <__libc_strstr>\r\n$gdb_prompt $" { |
| 60 | + set addr $expect_out(1,string) |
| 61 | + pass "$test (fixed glibc)" |
| 62 | + } |
| 63 | + -re " = {char \\*\\(const char \\*, const char \\*\\)} 0x\[0-9a-f\]+ <strstr>\r\n$gdb_prompt $" { |
| 64 | + untested "$test (gnu-ifunc not in use by glibc)" |
| 65 | + return 0 |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +set test "info sym" |
| 70 | +gdb_test_multiple "info sym $addr" $test { |
| 71 | + -re "strstr in section \\.text of /lib\[^/\]*/libc.so.6\r\n$gdb_prompt $" { |
| 72 | + pass $test |
| 73 | + } |
| 74 | + -re " = {char \\*\\(const char \\*, const char \\*\\)} 0x\[0-9a-f\]+ <strstr>\r\n$gdb_prompt $" { |
| 75 | + # unexpected |
| 76 | + xfail "$test (not in libc.so.6)" |
| 77 | + return 0 |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +set test "info addr strstr" |
| 82 | +gdb_test_multiple $test $test { |
| 83 | + -re "Symbol \"strstr\" is a function at address $addr\\.\r\n$gdb_prompt $" { |
| 84 | + fail "$test (DWARF for strstr)" |
| 85 | + } |
| 86 | + -re "Symbol \"strstr\" is at $addr in a file compiled without debugging\\.\r\n$gdb_prompt $" { |
| 87 | + pass "$test" |
| 88 | + } |
| 89 | +} |
| 90 | + |
| 91 | +set test "print strstr second time" |
| 92 | +gdb_test_multiple "print strstr" $test { |
| 93 | + -re " = {<text gnu-indirect-function variable, no debug info>} $addr <strstr>\r\n$gdb_prompt $" { |
| 94 | + pass $test |
| 95 | + } |
| 96 | + -re " = {<text gnu-indirect-function variable, no debug info>} $addr <__strstr>\r\n$gdb_prompt $" { |
| 97 | + pass "$test (GDB workaround)" |
| 98 | + } |
| 99 | + -re " = {<text gnu-indirect-function variable, no debug info>} $addr <__libc_strstr>\r\n$gdb_prompt $" { |
| 100 | + pass "$test (fixed glibc)" |
| 101 | + } |
| 102 | + -re " = {void \\*\\(void\\)} 0x\[0-9a-f\]+ <strstr>\r\n$gdb_prompt $" { |
| 103 | + fail $test |
| 104 | + } |
| 105 | +} |
| 106 | + |
| 107 | +gdb_test {print strstr("abc","b")} { = 0x[0-9a-f]+ "bc"} |
| 108 | +gdb_test {print strstr("def","e")} { = 0x[0-9a-f]+ "ef"} |
0 commit comments