This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA 3/2(+)] Test size of x86/x86_64 segment registers


(forgot to write a testcase)

Rather than verifying the value of the segment registers, which I think
would be tricky, one way to regression-test the problem is to verify
that the size of the segment registers is 2 bytes, rather than 4.

gdb/testsuite/ChangeLog:

        * gdb.arch/i386-segregs.c, gdb.arch/i386-segregs.exp: New files.

Tested on x86_64-linux.

---
 gdb/testsuite/gdb.arch/i386-segregs.c   |   22 +++++++++++++++++
 gdb/testsuite/gdb.arch/i386-segregs.exp |   39 +++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 0 deletions(-)
 create mode 100644 gdb/testsuite/gdb.arch/i386-segregs.c
 create mode 100644 gdb/testsuite/gdb.arch/i386-segregs.exp

diff --git a/gdb/testsuite/gdb.arch/i386-segregs.c b/gdb/testsuite/gdb.arch/i386-segregs.c
new file mode 100644
index 0000000..6fdc6f8
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/i386-segregs.c
@@ -0,0 +1,22 @@
+/* Copyright 2012 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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/>.  */
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/i386-segregs.exp b/gdb/testsuite/gdb.arch/i386-segregs.exp
new file mode 100644
index 0000000..58d1b13
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/i386-segregs.exp
@@ -0,0 +1,39 @@
+# Copyright 2012 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/>.
+
+# This testcase is going to verify the handling of the x86/x86_64
+# segment registers.  Skip this test if the target CPU does not match.
+if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } then {
+    return 0
+}
+
+set testfile "i386-segregs"
+set srcfile ${testfile}.c
+
+if [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug $additional_flags}] {
+    untested "failed to compile ${testfile}"
+    return -1
+}
+
+if ![runto_main] then {
+    untested "could not run to main"
+    return -1
+}
+
+# Print the size of all segment registers.  It should always be 2.
+foreach reg_name {"cs" "ss" "ds" "es" "fs" "gs"} {
+    gdb_test "print sizeof \$$reg_name" "= 2"
+}
+
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]