OLD | NEW |
(Empty) | |
| 1 # Copyright 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 set executable print-file-var-main |
| 17 |
| 18 set lib1 "print-file-var-lib1" |
| 19 set lib2 "print-file-var-lib2" |
| 20 |
| 21 set libobj1 "${objdir}/${subdir}/${lib1}.so" |
| 22 set libobj2 "${objdir}/${subdir}/${lib2}.so" |
| 23 |
| 24 set lib_opts { debug additional_flags=-fPIC } |
| 25 |
| 26 if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib1}.c \ |
| 27 ${libobj1} \ |
| 28 ${lib_opts} ] != "" } { |
| 29 return -1 |
| 30 } |
| 31 if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib2}.c \ |
| 32 ${libobj2} \ |
| 33 ${lib_opts} ] != "" } { |
| 34 return -1 |
| 35 } |
| 36 if { [gdb_compile "${srcdir}/${subdir}/${executable}.c" \ |
| 37 "${objdir}/${subdir}/${executable}" \ |
| 38 executable \ |
| 39 [list debug shlib=${libobj1} shlib=${libobj2}]] |
| 40 != ""} { |
| 41 return -1 |
| 42 } |
| 43 |
| 44 clean_restart $executable |
| 45 gdb_load_shlibs $libobj1 $libobj2 |
| 46 |
| 47 if ![runto_main] { |
| 48 untested "could not run to main" |
| 49 return -1 |
| 50 } |
| 51 |
| 52 # Try printing "this_version_num" qualified with the name of the file |
| 53 # where the variables are defined. There are two global variables |
| 54 # with that name, and some systems such as GNU/Linux merge them |
| 55 # into one single entity, while some other systems such as Windows |
| 56 # keep them separate. In the first situation, we have to verify |
| 57 # that GDB does not randomly select the wrong instance, even when |
| 58 # a specific filename is used to qualified the lookup. And in the |
| 59 # second case, we have to verify that GDB does select the instance |
| 60 # defined in the given filename. |
| 61 # |
| 62 # To avoid adding target-specific code in this testcase, the program |
| 63 # sets two local variable named 'v1' and 'v2' with the value of |
| 64 # our global variables. This allows us to compare the value that |
| 65 # GDB returns for each query against the actual value seen by |
| 66 # the program itself. |
| 67 |
| 68 # Get past the initialization of variables 'v1' and 'v2'. |
| 69 |
| 70 set bp_location \ |
| 71 [gdb_get_line_number "STOP" "${executable}.c"] |
| 72 gdb_test "break $executable.c:$bp_location" \ |
| 73 "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \ |
| 74 "breapoint past v1 & v2 initialization" |
| 75 |
| 76 gdb_test "continue" \ |
| 77 "Breakpoint \[0-9\]+, main \\(\\) at.*" \ |
| 78 "continue to STOP marker" |
| 79 |
| 80 # Now check the value of this_version_id in both print-file-var-lib1.c |
| 81 # and print-file-var-lib2.c. |
| 82 |
| 83 gdb_test "print 'print-file-var-lib1.c'::this_version_id == v1" \ |
| 84 " = 1" |
| 85 |
| 86 gdb_test "print 'print-file-var-lib2.c'::this_version_id == v2" \ |
| 87 " = 1" |
OLD | NEW |