]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/sym-file.exp
Update Copyright year range in all files maintained by GDB.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / sym-file.exp
CommitLineData
ecd75fc8 1# Copyright 2013-2014 Free Software Foundation, Inc.
681f229a
NB
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# Test adding and removing a symbol file dynamically:
17# 1) Run to gdb_add_symbol_file in $srcfile.
18# 2) Set a pending breakpoint at bar in $srcfile3.
19# 3) Load $shlib_name using 'add-symbol-file'.
20# 4) 'info files' must display ${lib_basename}.
21# 5) Continue to bar in $srcfile3.
22# 6) Set a breakpoint at foo in $srcfile3.
23# 7) Continue to foo in $srcfile3.
24# 8) Set a breakpoint at gdb_remove_symbol_file.
25# 9) Continue to gdb_remove_symbol_file in $srcfile.
26# 10) Remove $shlib_name using 'remove-symbol-file'.
27# 11) 'info files' must not display ${lib_basename}, anymore.
28# 12) Check that the breakpoints at foo and bar are pending.
29# 13) Check that the execution can continue without error.
30
31if {![is_elf_target]} {
32 return 0
33}
34
35if [skip_shlib_tests] {
36 return 0
37}
38
39if [is_remote target] {
40 return 0
41}
42
43set target_size TARGET_UNKNOWN
44if {[is_lp64_target]} {
45 set target_size TARGET_LP64
46} elseif {[is_ilp32_target]} {
47 set target_size TARGET_ILP32
48} else {
49 return 0
50}
51
52set main_basename sym-file-main
53set loader_basename sym-file-loader
54set lib_basename sym-file-lib
55
56standard_testfile $main_basename.c $loader_basename.c $lib_basename.c
57
58set libsrc "${srcdir}/${subdir}/${srcfile3}"
59set shlib_name [standard_output_file ${lib_basename}.so]
60set exec_opts [list debug "additional_flags= -I$srcdir/../../include/ -D$target_size\
61 -DSHLIB_NAME\\=\"$shlib_name\""]
62
63if [get_compiler_info] {
64 return -1
65}
66
67if {[gdb_compile_shlib $libsrc $shlib_name {debug}] != ""} {
68 untested ${testfile}
69 return
70}
71
72if {[prepare_for_testing $testfile $binfile "$srcfile $srcfile2" $exec_opts]} {
73 return
74}
75
76# 1) Run to GDB_ADD_SYMBOl_FILE in $srcfile for adding
77# $shlib_name.
78set result [runto gdb_add_symbol_file]
79if {!$result} then {
80 return
81}
82
83# 2) Set a pending breakpoint at bar in $srcfile3.
84set result [gdb_breakpoint bar allow-pending]
85if {!$result} then {
86 return
87}
88
89# 3) Add $shlib_name using 'add-symbol-file'.
90set result [gdb_test "add-symbol-file ${shlib_name} addr" \
91 "Reading symbols from .*${lib_basename}\\.so\\.\\.\\.done\\." \
92 "add-symbol-file .*${lib_basename}\\.so addr" \
93 "add symbol table from file \".*${lib_basename}\\.so\"\
94 at.*\\(y or n\\) " \
95 "y"]
96if {$result != 0} then {
97 return
98}
99
100# 4) 'info files' must display $srcfile3.
101gdb_test "info files" \
102 "^(?=(.*${lib_basename})).*" \
103 "info files must display ${lib_basename}"
104
105# 5) Continue to bar in $srcfile3 to ensure that the breakpoint
106# was bound correctly after adding $shilb_name.
107set lnum_bar [gdb_get_line_number "break at bar" $srcfile3]
108gdb_continue_to_breakpoint bar ".*${lib_basename}\\.c:$lnum_bar.*"
109
110# 6) Set a breakpoint at foo in $srcfile3.
111set result [gdb_breakpoint foo]
112if {!$result} then {
113 return
114}
115
116# 7) Continue to foo in $srcfile3 to ensure that the breakpoint
117# was bound correctly.
118set lnum_foo [gdb_get_line_number "break at foo" $srcfile3]
119gdb_continue_to_breakpoint foo ".*${lib_basename}\\.c:$lnum_foo.*"
120
121# 8) Set a breakpoint at gdb_remove_symbol_file in $srcfile for
122# removing $shlib_name.
123set result [gdb_breakpoint gdb_remove_symbol_file]
124if {!$result} then {
125 return
126}
127
128# 9) Continue to gdb_remove_symbol_file in $srcfile.
129gdb_continue_to_breakpoint gdb_remove_symbol_file
130
131# 10) Remove $shlib_name using 'remove-symbol-file'.
132set result [gdb_test "remove-symbol-file -a addr" \
133 ""\
134 "remove-symbol-file -a addr" \
135 "Remove symbol table from file \".*${lib_basename}\\.so\"\\?\
136.*\\(y or n\\) " \
137 "y"]
138if {$result != 0} then {
139 return
140}
141
142# 11) 'info files' must not display ${lib_basename}, anymore.
143gdb_test "info files" \
144 "^(?!(.*${lib_basename})).*" \
145 "info files must not display ${lib_basename}"
146
147# 12) Check that the breakpoints at foo and bar are pending after removing
148# $shlib_name.
149gdb_test "info breakpoints 2" \
150 ".*PENDING.*" \
151 "check if Breakpoint 2 is pending."
152
153gdb_test "info breakpoints 3" \
154 ".*PENDING.*" \
155 "check if Breakpoint 3 is pending."
156
157# 13) Check that the execution can continue without error.
158gdb_continue_to_end