aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorDavid Taylor <dtaylor@emc.com>2016-04-12 15:02:57 -0400
committerDavid Taylor <david.taylor@emc.com>2016-06-24 21:02:36 -0400
commit6b8505468e64c2be8d0eea1f2b8db86fa3897600 (patch)
tree81de3154cfc05d9811239c11ef05cbb3a6fec06d /gdb/testsuite
parente0204c4d4ceb9be0b0ccf8f92ab683aab54f67cd (diff)
downloadgdb-6b8505468e64c2be8d0eea1f2b8db86fa3897600.zip
gdb-6b8505468e64c2be8d0eea1f2b8db86fa3897600.tar.gz
gdb-6b8505468e64c2be8d0eea1f2b8db86fa3897600.tar.bz2
Support structure offsets that are 512K or larger.
GDB computes structure byte offsets using a 32 bit integer. And, first it computes the offset in bits and then converts to bytes. The result is that any offset that if 512K bytes or larger overflows. This patch changes GDB to use LONGEST for such calculations. PR gdb/17520 Structure offset wrong when 1/4 GB or greater. * c-lang.h: Change all parameters, variables, and struct or union members used as struct or union fie3ld offsets from int to LONGEST. * c-valprint.c: Likewise. * cp-abi.c: Likewise. * cp-abi.h: Likewise. * cp-valprint.c: Likewise. * d-valprint.c: Likewise. * dwarf2loc.c: Likewise. * eval.c: Likewise. * extension-priv.h: Likewise. * extension.c: Likewise. * extension.h: Likewise. * findvar.c: Likewise. * gdbtypes.h: Likewise. * gnu-v2-abi.c: Likewise. * gnu-v3-abi.c: Likewise. * go-valprint.c: Likewise. * guile/guile-internal.h: Likewise. * guile/scm-pretty-print.c: Likewise. * jv-valprint.c Likewise. * opencl-lang.c: Likewise. * p-lang.h: Likewise. * python/py-prettyprint.c: Likewise. * python/python-internal.h: Likewise. * spu-tdep.c: Likewise. * typeprint.c: Likewise. * valarith.c: Likewise. * valops.c: Likewise. * valprint.c: Likewise. * valprint.h: Likewise. * value.c: Likewise. * value.h: Likewise. * p-valprint.c: Likewise. * c-typeprint.c (c_type_print_base): When printing offset, use plongest, not %d. * gdbtypes.c (recursive_dump_type): Ditto.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/offsets.c28
-rw-r--r--gdb/testsuite/gdb.base/offsets.exp45
3 files changed, 78 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 8b5274d..8679965 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-06-24 David Taylor <dtaylor@emc.com>
+
+ * gdb.base/offsets.exp: New file.
+ * gdb.base/offsets.c: New file.
+
2016-06-23 Tom Tromey <tom@tromey.com>
PR gdb/16483:
diff --git a/gdb/testsuite/gdb.base/offsets.c b/gdb/testsuite/gdb.base/offsets.c
new file mode 100644
index 0000000..2a1edeb
--- /dev/null
+++ b/gdb/testsuite/gdb.base/offsets.c
@@ -0,0 +1,28 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2014 - 2016 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/>. */
+
+struct big_struct
+{
+ char first[0x10000000 + 16];
+ long second;
+} big_struct;
+
+int
+main (int argc, char *argv[])
+{
+ return (0);
+}
diff --git a/gdb/testsuite/gdb.base/offsets.exp b/gdb/testsuite/gdb.base/offsets.exp
new file mode 100644
index 0000000..b65fac7
--- /dev/null
+++ b/gdb/testsuite/gdb.base/offsets.exp
@@ -0,0 +1,45 @@
+# Test big offsets
+
+# Copyright (c) 2014- 2016 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/>.
+
+standard_testfile offsets.c
+
+if { [prepare_for_testing "failed to prepare for testing large offsets" \
+ ${testfile} ${srcfile}] } {
+ untested offsets.exp
+ return -1
+}
+
+set test "print &big_struct test"
+gdb_test_multiple "print &big_struct" "$test" {
+ -re "\\$\[0-9\]* = .* (0x\[0-9a-fA-F\]*) .*\[\r\n\]*$gdb_prompt $" {
+ set addr1 $expect_out(1,string)
+ pass "$test ($addr1)"
+ }
+}
+
+set test "print &big_struct.second test"
+gdb_test_multiple "print &big_struct.second" "$test" {
+ -re "\\$\[0-9\]* = .* (0x\[0-9a-fA-F\]*) .*\[\r\n\]*$gdb_prompt $" {
+ set addr2 $expect_out(1,string)
+
+ if {[expr $addr2 - $addr1] == [expr 0x10000000 + 16]} {
+ pass "big offsets"
+ } else {
+ fail "big offsets"
+ }
+ }
+}