| OLD | NEW |
| 1 # Copyright 2011-2012 Free Software Foundation, Inc. | 1 # Copyright 2011-2013 Free Software Foundation, Inc. |
| 2 | 2 |
| 3 # This program is free software; you can redistribute it and/or modify | 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 | 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 | 5 # the Free Software Foundation; either version 3 of the License, or |
| 6 # (at your option) any later version. | 6 # (at your option) any later version. |
| 7 # | 7 # |
| 8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
| 12 # | 12 # |
| 13 # You should have received a copy of the GNU General Public License | 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/>. | 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | 15 |
| 16 # This file was written by Justin Lebar. (justin.lebar@gmail.com) | 16 # This file was written by Justin Lebar. (justin.lebar@gmail.com) |
| 17 | 17 |
| 18 # | 18 # |
| 19 # Tests skipping shared libraries. | 19 # Tests skipping shared libraries. |
| 20 # | 20 # |
| 21 | 21 |
| 22 # This only works on GNU/Linux. | 22 # This only works on GNU/Linux. |
| 23 if { ![isnative] || [is_remote host] || ![istarget *-linux*] || [skip_shlib_test
s]} { | 23 if { ![isnative] || [is_remote host] || ![istarget *-linux*] || [skip_shlib_test
s]} { |
| 24 continue | 24 continue |
| 25 } | 25 } |
| 26 | 26 |
| 27 set test "skip-solib" | 27 set test "skip-solib" |
| 28 set srcfile_main "${test}-main.c" | 28 set srcfile_main "${test}-main.c" |
| 29 set executable_main ${test}-test | 29 set executable_main ${test}-test |
| 30 set binfile_main ${objdir}/${subdir}/${executable_main} | 30 set binfile_main [standard_output_file ${executable_main}] |
| 31 set srcfile_lib "${test}-lib.c" | 31 set srcfile_lib "${test}-lib.c" |
| 32 set libname "lib${test}" | 32 set libname "lib${test}" |
| 33 set binfile_lib ${objdir}/${subdir}/${libname}.so | 33 set binfile_lib [standard_output_file ${libname}.so] |
| 34 | 34 |
| 35 # | 35 # |
| 36 # Compile our program under test. The main program references a shared library | 36 # Compile our program under test. The main program references a shared library |
| 37 # libskip-solib.so, which contains two functions, square(), which is | 37 # libskip-solib.so, which contains two functions, square(), which is |
| 38 # referenced by the main program, and multiply(), which is not referenced by | 38 # referenced by the main program, and multiply(), which is not referenced by |
| 39 # the main program. | 39 # the main program. |
| 40 # | 40 # |
| 41 | 41 |
| 42 if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list d
ebug additional_flags=-fPIC -Wl,-soname,${libname}.so]] != ""} { | 42 if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list d
ebug additional_flags=-fPIC -Wl,-soname,${libname}.so]] != ""} { |
| 43 return -1 | 43 return -1 |
| 44 } | 44 } |
| 45 | 45 |
| 46 if {[gdb_compile "${srcdir}/${subdir}/${srcfile_main}" "${binfile_main}.o" objec
t debug] != ""} { | 46 if {[gdb_compile "${srcdir}/${subdir}/${srcfile_main}" "${binfile_main}.o" objec
t debug] != ""} { |
| 47 return -1 | 47 return -1 |
| 48 } | 48 } |
| 49 | 49 |
| 50 set testobjdir [standard_output_file {}] |
| 50 if {[gdb_compile "${binfile_main}.o" "${binfile_main}" executable \ | 51 if {[gdb_compile "${binfile_main}.o" "${binfile_main}" executable \ |
| 51 [list debug "additional_flags=-L${objdir}/${subdir} -l${test} \ | 52 [list debug "additional_flags=-L$testobjdir -l${test} \ |
| 52 -Wl,-rpath=${objdir}/${subdir}"]]
!= ""} { | 53 -Wl,-rpath=$testobjdir"]] != ""}
{ |
| 53 return -1 | 54 return -1 |
| 54 } | 55 } |
| 55 | 56 |
| 56 clean_restart ${executable_main} | 57 clean_restart ${executable_main} |
| 57 | 58 |
| 58 # | 59 # |
| 59 # At this point, if we try to skip the file ${srcfile_lib} or the function | 60 # At this point, if we try to skip the file ${srcfile_lib} or the function |
| 60 # multiply(), we should get a prompt asking us if we want to enable the | 61 # multiply(), we should get a prompt asking us if we want to enable the |
| 61 # skip entry pending a shared library load. | 62 # skip entry pending a shared library load. |
| 62 # | 63 # |
| 63 | 64 |
| 64 gdb_test "skip file ${srcfile_lib}" \ | 65 gdb_test "skip file ${srcfile_lib}" \ |
| 65 "File ${srcfile_lib} will be skipped when stepping." \ | 66 "File ${srcfile_lib} will be skipped when stepping." \ |
| 66 "ignoring file in solib" \ | 67 "ignoring file in solib" \ |
| 67 "No source file named ${srcfile_lib}.* | 68 "No source file named ${srcfile_lib}.* |
| 68 Ignore file pending future shared library load.*" \ | 69 Ignore file pending future shared library load.*" \ |
| 69 "y" | 70 "y" |
| 70 | 71 |
| 71 # | 72 # |
| 72 # Does info skip list this entry as pending? | 73 # Checkinfo skip list. |
| 73 # | 74 # |
| 74 gdb_test "info skip" \ | 75 gdb_test "info skip" \ |
| 75 "Num\\s+Type\\s+Enb\\s+Address\\s+What\\s* | 76 "Num\\s+Type\\s+Enb\\s+What\\s* |
| 76 1\\s+file\\s+y\\s+\\s+${srcfile_lib} \\(PENDING\\)\\s*" \ | 77 1\\s+file\\s+y\\s+${srcfile_lib}\\s*" \ |
| 77 "info skip with pending file" | 78 "info skip with pending file" |
| 78 | 79 |
| 79 if ![runto_main] { fail "skip tests suppressed" } | 80 if ![runto_main] { fail "skip tests suppressed" } |
| 80 | 81 |
| 81 # | 82 # |
| 82 # We shouldn't step into square(), since we skipped skip-solib-lib.c. | 83 # We shouldn't step into square(), since we skipped skip-solib-lib.c. |
| 83 # | 84 # |
| 84 gdb_test "step" "" | 85 gdb_test "step" "" |
| 85 gdb_test "bt" "#0\\s+main.*" "step after ignoring solib file." | 86 gdb_test "bt" "#0\\s+main.*" "step after ignoring solib file." |
| 86 | 87 |
| 87 # | 88 # |
| 88 # Our entry should no longer be pending. Note that we unfortunately need to do | |
| 89 # at least one step before the entry will be unmarked as pending. | |
| 90 # | |
| 91 gdb_test "info skip" \ | |
| 92 "Num\\s+Type\\s+Enb\\s+Address\\s+What\\s* | |
| 93 1\\s+file\\s+y\\s+\\s+.*${srcfile_lib}\\s*" \ | |
| 94 "info skip with pending file" | |
| 95 | |
| 96 # | |
| 97 # Now restart gdb and testing ignoring of a function inside a solib. | 89 # Now restart gdb and testing ignoring of a function inside a solib. |
| 98 # | 90 # |
| 99 clean_restart ${executable_main} | 91 clean_restart ${executable_main} |
| 100 | 92 |
| 101 gdb_test "skip function multiply" \ | 93 gdb_test "skip function multiply" \ |
| 102 "Function multiply will be skipped when stepping, pending shared library load.
" \ | 94 "Function multiply will be skipped when stepping\\." \ |
| 103 "ignoring function in solib" \ | 95 "ignoring function in solib" \ |
| 104 "No function found named multiply..* | 96 "No function found named multiply..* |
| 105 Ignore function pending future shared library load.*" \ | 97 Ignore function pending future shared library load.*" \ |
| 106 "y" | 98 "y" |
| 107 | 99 |
| 108 if ![runto_main] { fail "skip tests suppressed" } | 100 if ![runto_main] { fail "skip tests suppressed" } |
| 109 | 101 |
| 110 # | 102 # |
| 111 # Our first step should take us into square. | 103 # Our first step should take us into square. |
| 112 # | 104 # |
| 113 gdb_test "step" "square.*" | 105 gdb_test "step" "square.*" |
| 114 | 106 |
| 115 # | 107 # |
| 116 # Now our entry should no longer be pending. | 108 # Now our entry should no longer be pending. |
| 117 # | 109 # |
| 118 gdb_test "info skip" \ | 110 gdb_test "info skip" \ |
| 119 "Num\\s+Type\\s+Enb\\s+Address\\s+What\\s* | 111 "Num\\s+Type\\s+Enb\\s+What\\s* |
| 120 1\\s+function\\s+y\\s+0x\[0-9a-f\]+\\s+multiply at .*${srcfile_lib}:.*\\s*" \ | 112 1\\s+function\\s+y\\s+multiply\\s*" \ |
| 121 "skip should no longer be pending." | 113 "info skip for function multiply" |
| 122 | 114 |
| 123 # | 115 # |
| 124 # This step shouldn't go into multiply -- we should skip it and go on to the | 116 # This step shouldn't go into multiply -- we should skip it and go on to the |
| 125 # last line of square. | 117 # last line of square. |
| 126 # | 118 # |
| 127 gdb_test "step" "" | 119 gdb_test "step" "" |
| 128 gdb_test "bt" "#0\\s+square.*" | 120 gdb_test "bt" "#0\\s+square.*" |
| OLD | NEW |