aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2007-02-26 20:04:38 +0000
committerDaniel Jacobowitz <drow@false.org>2007-02-26 20:04:38 +0000
commit2711e4564f4ab411bdf2cedff3fb92abadd630b8 (patch)
tree53e997b7e4ecb939ec38343c531c5a7aab8aaf7c /gdb/testsuite
parentbaef701fc2712c0e7119fc5e7996b15af154e88b (diff)
downloadgdb-2711e4564f4ab411bdf2cedff3fb92abadd630b8.zip
gdb-2711e4564f4ab411bdf2cedff3fb92abadd630b8.tar.gz
gdb-2711e4564f4ab411bdf2cedff3fb92abadd630b8.tar.bz2
* symfile.c (place_section): Check SEC_ALLOC. Do not check VMA.
(default_symfile_offsets): Check VMA here. Update section VMAs. * gdb.cp/cp-relocate.cc, gdb.cp/cp-relocate.exp: New.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.cp/cp-relocate.cc29
-rw-r--r--gdb/testsuite/gdb.cp/cp-relocate.exp137
3 files changed, 170 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 656d0c8..8049665 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2007-02-26 Daniel Jacobowitz <dan@codesourcery.com>
+ * gdb.cp/cp-relocate.cc, gdb.cp/cp-relocate.exp: New.
+
+2007-02-26 Daniel Jacobowitz <dan@codesourcery.com>
+
* gdb.arch/iwmmxt-regs.c, gdb.arch/iwmmxt-regs.exp: Update
register capitalization.
diff --git a/gdb/testsuite/gdb.cp/cp-relocate.cc b/gdb/testsuite/gdb.cp/cp-relocate.cc
new file mode 100644
index 0000000..e129d73
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/cp-relocate.cc
@@ -0,0 +1,29 @@
+/* This test file is part of GDB, the GNU debugger.
+
+ Copyright 2007
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+template<int X> int func(int)
+{
+ return X;
+}
+
+int caller()
+{
+ return func<1>(1) + func<2>(2);
+}
diff --git a/gdb/testsuite/gdb.cp/cp-relocate.exp b/gdb/testsuite/gdb.cp/cp-relocate.exp
new file mode 100644
index 0000000..1fd1c0f
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/cp-relocate.exp
@@ -0,0 +1,137 @@
+# Copyright 2007 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+# Test loading symbols from unrelocated C++ object files.
+
+set testfile cp-relocate
+set srcfile ${testfile}.cc
+set binfile ${objdir}/${subdir}/${testfile}.o
+
+if { [skip_cplus_tests] } { continue }
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {c++ debug}] != "" } {
+ untested cp-relocate.exp
+ return -1
+}
+
+proc get_func_address { func } {
+ global gdb_prompt hex
+
+ set rfunc [string_to_regexp $func]
+ gdb_test_multiple "print '${func}'" "get address of ${func}" {
+ -re "\\\$\[0-9\]+ = \\{.*\\} (0|($hex) <${rfunc}>)\[\r\n\]+${gdb_prompt} $" {
+ # $1 = {int ()} 0x24 <function_bar>
+ # But if the function is at zero, the name may be omitted.
+ pass "get address of ${func}"
+ if { $expect_out(1,string) == "0" } {
+ return "0x0"
+ } else {
+ return $expect_out(2,string)
+ }
+ }
+ }
+ return ""
+}
+
+# Load the file as an executable; GDB should assign non-overlapping
+# section offsets.
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_file_cmd ${binfile}
+
+# Find the interesting functions. We go to a little effort to find
+# the right function names here, to work around PR c++/40.
+set func1_name ""
+set func2_name ""
+gdb_test_multiple "info functions func<.>" "info functions" {
+ -re "\r\nint (\[^\r\]*func<1>\[^\r]*);" {
+ set func1_name $expect_out(1,string)
+ exp_continue
+ }
+ -re "\r\nint (\[^\r\]*func<2>\[^\r]*);" {
+ set func2_name $expect_out(1,string)
+ exp_continue
+ }
+ -re "$gdb_prompt $" {
+ if { ${func1_name} != "" && ${func2_name} != "" } {
+ pass "info functions"
+ } else {
+ fail "info functions"
+ return -1
+ }
+ }
+}
+
+# Check that all the functions have different addresses.
+set func1_addr [get_func_address "$func1_name"]
+set func2_addr [get_func_address "$func2_name"]
+set caller_addr [get_func_address "caller"]
+
+if { "${func1_addr}" == "${func2_addr}"
+ || "${func1_addr}" == "${func2_addr}"
+ || "${func2_addr}" == "${caller_addr}" } {
+ fail "C++ functions have different addresses"
+} else {
+ pass "C++ functions have different addresses"
+}
+
+# Figure out the names of the sections containing the template
+# functions.
+set func1_sec ""
+set func2_sec ""
+gdb_test_multiple "info file" "info file" {
+ -re "($hex) - ($hex) is (\[^\r\]*)\r" {
+ if { $expect_out(1,string) <= $func1_addr
+ && $expect_out(2,string) > $func1_addr } {
+ set func1_sec $expect_out(3,string)
+ } elseif { $expect_out(1,string) <= $func2_addr
+ && $expect_out(2,string) > $func2_addr } {
+ set func2_sec $expect_out(3,string)
+ }
+ exp_continue
+ }
+ -re "$gdb_prompt $" {
+ if { ${func1_sec} != "" && ${func2_sec} != "" } {
+ pass "info file"
+ } else {
+ fail "info file"
+ return -1
+ }
+ }
+}
+
+if { $func1_sec == $func2_sec } {
+ untested "cp-relocate.exp - template functions in same sections"
+ return -1
+}
+
+# Now start a clean GDB, for add-symbol-file tests.
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+gdb_test "add-symbol-file ${binfile} 0 -s ${func1_sec} 0x40000 -s ${func2_sec} 0x80000" \
+ "Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
+ "add-symbol-file ${binfile}" \
+ "add symbol table from file \".*${testfile}\\.o\" at.*\\(y or n\\) " \
+ "y"
+
+# Make sure the function addresses were updated.
+gdb_test "break *'$func1_name'" \
+ "Breakpoint $decimal at 0x4....: file .*"
+gdb_test "break *'$func2_name'" \
+ "Breakpoint $decimal at 0x8....: file .*"