| Index: gdb/testsuite/gdb.base/sym-file.exp
|
| diff --git a/gdb/testsuite/gdb.base/sym-file.exp b/gdb/testsuite/gdb.base/sym-file.exp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6af861b9f90dd81385c97ec3ef55818d8cf1e65b
|
| --- /dev/null
|
| +++ b/gdb/testsuite/gdb.base/sym-file.exp
|
| @@ -0,0 +1,158 @@
|
| +# Copyright 2013 Free Software Foundation, Inc.
|
| +
|
| +# This program is free software; you can redistribute it and/or modify
|
| +# it under the terms of the GNU General Public License as published by
|
| +# the Free Software Foundation; either version 3 of the License, or
|
| +# (at your option) any later version.
|
| +#
|
| +# This program is distributed in the hope that it will be useful,
|
| +# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| +# GNU General Public License for more details.
|
| +#
|
| +# You should have received a copy of the GNU General Public License
|
| +# along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
| +
|
| +# Test adding and removing a symbol file dynamically:
|
| +# 1) Run to gdb_add_symbol_file in $srcfile.
|
| +# 2) Set a pending breakpoint at bar in $srcfile3.
|
| +# 3) Load $shlib_name using 'add-symbol-file'.
|
| +# 4) 'info files' must display ${lib_basename}.
|
| +# 5) Continue to bar in $srcfile3.
|
| +# 6) Set a breakpoint at foo in $srcfile3.
|
| +# 7) Continue to foo in $srcfile3.
|
| +# 8) Set a breakpoint at gdb_remove_symbol_file.
|
| +# 9) Continue to gdb_remove_symbol_file in $srcfile.
|
| +# 10) Remove $shlib_name using 'remove-symbol-file'.
|
| +# 11) 'info files' must not display ${lib_basename}, anymore.
|
| +# 12) Check that the breakpoints at foo and bar are pending.
|
| +# 13) Check that the execution can continue without error.
|
| +
|
| +if {![is_elf_target]} {
|
| + return 0
|
| +}
|
| +
|
| +if [skip_shlib_tests] {
|
| + return 0
|
| +}
|
| +
|
| +if [is_remote target] {
|
| + return 0
|
| +}
|
| +
|
| +set target_size TARGET_UNKNOWN
|
| +if {[is_lp64_target]} {
|
| + set target_size TARGET_LP64
|
| +} elseif {[is_ilp32_target]} {
|
| + set target_size TARGET_ILP32
|
| +} else {
|
| + return 0
|
| +}
|
| +
|
| +set main_basename sym-file-main
|
| +set loader_basename sym-file-loader
|
| +set lib_basename sym-file-lib
|
| +
|
| +standard_testfile $main_basename.c $loader_basename.c $lib_basename.c
|
| +
|
| +set libsrc "${srcdir}/${subdir}/${srcfile3}"
|
| +set shlib_name [standard_output_file ${lib_basename}.so]
|
| +set exec_opts [list debug "additional_flags= -I$srcdir/../../include/ -D$target_size\
|
| + -DSHLIB_NAME\\=\"$shlib_name\""]
|
| +
|
| +if [get_compiler_info] {
|
| + return -1
|
| +}
|
| +
|
| +if {[gdb_compile_shlib $libsrc $shlib_name {debug}] != ""} {
|
| + untested ${testfile}
|
| + return
|
| +}
|
| +
|
| +if {[prepare_for_testing $testfile $binfile "$srcfile $srcfile2" $exec_opts]} {
|
| + return
|
| +}
|
| +
|
| +# 1) Run to GDB_ADD_SYMBOl_FILE in $srcfile for adding
|
| +# $shlib_name.
|
| +set result [runto gdb_add_symbol_file]
|
| +if {!$result} then {
|
| + return
|
| +}
|
| +
|
| +# 2) Set a pending breakpoint at bar in $srcfile3.
|
| +set result [gdb_breakpoint bar allow-pending]
|
| +if {!$result} then {
|
| + return
|
| +}
|
| +
|
| +# 3) Add $shlib_name using 'add-symbol-file'.
|
| +set result [gdb_test "add-symbol-file ${shlib_name} addr" \
|
| + "Reading symbols from .*${lib_basename}\\.so\\.\\.\\.done\\." \
|
| + "add-symbol-file .*${lib_basename}\\.so addr" \
|
| + "add symbol table from file \".*${lib_basename}\\.so\"\
|
| + at.*\\(y or n\\) " \
|
| + "y"]
|
| +if {$result != 0} then {
|
| + return
|
| +}
|
| +
|
| +# 4) 'info files' must display $srcfile3.
|
| +gdb_test "info files" \
|
| + "^(?=(.*${lib_basename})).*" \
|
| + "info files must display ${lib_basename}"
|
| +
|
| +# 5) Continue to bar in $srcfile3 to ensure that the breakpoint
|
| +# was bound correctly after adding $shilb_name.
|
| +set lnum_bar [gdb_get_line_number "break at bar" $srcfile3]
|
| +gdb_continue_to_breakpoint bar ".*${lib_basename}\\.c:$lnum_bar.*"
|
| +
|
| +# 6) Set a breakpoint at foo in $srcfile3.
|
| +set result [gdb_breakpoint foo]
|
| +if {!$result} then {
|
| + return
|
| +}
|
| +
|
| +# 7) Continue to foo in $srcfile3 to ensure that the breakpoint
|
| +# was bound correctly.
|
| +set lnum_foo [gdb_get_line_number "break at foo" $srcfile3]
|
| +gdb_continue_to_breakpoint foo ".*${lib_basename}\\.c:$lnum_foo.*"
|
| +
|
| +# 8) Set a breakpoint at gdb_remove_symbol_file in $srcfile for
|
| +# removing $shlib_name.
|
| +set result [gdb_breakpoint gdb_remove_symbol_file]
|
| +if {!$result} then {
|
| + return
|
| +}
|
| +
|
| +# 9) Continue to gdb_remove_symbol_file in $srcfile.
|
| +gdb_continue_to_breakpoint gdb_remove_symbol_file
|
| +
|
| +# 10) Remove $shlib_name using 'remove-symbol-file'.
|
| +set result [gdb_test "remove-symbol-file -a addr" \
|
| + ""\
|
| + "remove-symbol-file -a addr" \
|
| + "Remove symbol table from file \".*${lib_basename}\\.so\"\\?\
|
| +.*\\(y or n\\) " \
|
| + "y"]
|
| +if {$result != 0} then {
|
| + return
|
| +}
|
| +
|
| +# 11) 'info files' must not display ${lib_basename}, anymore.
|
| +gdb_test "info files" \
|
| + "^(?!(.*${lib_basename})).*" \
|
| + "info files must not display ${lib_basename}"
|
| +
|
| +# 12) Check that the breakpoints at foo and bar are pending after removing
|
| +# $shlib_name.
|
| +gdb_test "info breakpoints 2" \
|
| + ".*PENDING.*" \
|
| + "check if Breakpoint 2 is pending."
|
| +
|
| +gdb_test "info breakpoints 3" \
|
| + ".*PENDING.*" \
|
| + "check if Breakpoint 3 is pending."
|
| +
|
| +# 13) Check that the execution can continue without error.
|
| +gdb_continue_to_end
|
|
|