Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: [RFA 3/2(+)] Test size of x86/x86_64 segment registers
Date: Wed, 02 May 2012 00:01:00 -0000	[thread overview]
Message-ID: <1335916870-5161-1-git-send-email-brobecker@adacore.com> (raw)
In-Reply-To: <1335913461-1628-1-git-send-email-brobecker@adacore.com>

(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


  parent reply	other threads:[~2012-05-02  0:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-01 23:04 Invalid segment resister value on x86_64-windows Joel Brobecker
2012-05-01 23:04 ` [RFA/commit 1/2] Regenerate the features/i386 target description .c files Joel Brobecker
2012-05-02  6:34   ` Sergio Durigan Junior
2012-05-01 23:05 ` [RFA 2/2] [x86/x86_64] Segment registers are 16 bits long (not 32bits) Joel Brobecker
2012-05-02  0:01 ` Joel Brobecker [this message]
2012-05-02 10:10 ` Invalid segment resister value on x86_64-windows Mark Kettenis
2012-05-02 17:57   ` Joel Brobecker
2012-05-02 20:45     ` Mark Kettenis
2012-05-02 21:26       ` Joel Brobecker
2012-05-02 21:27         ` Joel Brobecker
2012-05-02 21:50           ` Mark Kettenis
2012-05-02 21:58           ` [WINDOWS/RFC] " Joel Brobecker
2012-05-02 22:10             ` Christopher Faylor
2012-05-02 22:16               ` Christopher Faylor
2012-05-04 18:38               ` checked in: " Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1335916870-5161-1-git-send-email-brobecker@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox