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