Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Thiago Jung Bauermann <bauerman@br.ibm.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: [rfc] add ppc testcase to test fpscr
Date: Fri, 22 Aug 2008 18:13:00 -0000	[thread overview]
Message-ID: <1219428669.8167.2.camel@localhost.localdomain> (raw)
In-Reply-To: <20080822024659.GA12951@caradoc.them.org>

On Thu, 2008-08-21 at 22:46 -0400, Daniel Jacobowitz wrote:
> I'd have to see more details - the example I gave is used all over the
> testsuite.  e.g. find.exp, restore.exp, setshow.exp.

Shame on me, I changed back to gdb_test and it worked this time. I was
probably struggling with something else and put the blame on the wrong
thing. :-/
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center


2008-08-22  Thiago Jung Bauermann  <bauerman@br.ibm.com>

    Add FPSCR tests.

	* gdb.arch/ppc-fp.exp: New file.
	* gdb.arch/ppc-fp.c: New file.

diff --git a/gdb/testsuite/gdb.arch/ppc-fp.c b/gdb/testsuite/gdb.arch/ppc-fp.c
new file mode 100644
index 0000000..90563f4
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/ppc-fp.c
@@ -0,0 +1,42 @@
+/* Copyright 2008 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/>.  */
+
+#include <stdio.h>
+
+int
+main (int argc, char *argv[])
+{
+  double result;
+
+  asm ("fdiv %0, %1, %1\n"	/* Invalid operation.  */
+       : "=f" (result)
+       : "f" (0.0));
+
+  printf ("result = %f\n", result);
+
+  asm ("mtfsf 0xff, %0\n"  /* Reset FPSCR.  */
+       :
+       : "f" (0.0));
+
+  asm ("fdiv %0, %1, %2\n"	/* Division by zero.  */
+       : "=f" (result)
+       : "f" (1.25), "f" (0.0));
+
+  printf ("result = %f\n", result);
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/ppc-fp.exp b/gdb/testsuite/gdb.arch/ppc-fp.exp
new file mode 100644
index 0000000..1927c45
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/ppc-fp.exp
@@ -0,0 +1,94 @@
+# Copyright (C) 2008 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/>.
+#
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+#
+
+# Tests for Powerpc floating point register setting and fetching
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+if ![istarget "powerpc*"] then {
+    verbose "Skipping powerpc floating point register tests."
+    verbose -log "Skipping powerpc register tests."
+    return
+}
+
+set testfile "ppc-fp"
+set binfile ${objdir}/${subdir}/${testfile}
+set srcfile ${testfile}.c
+
+if [get_compiler_info $binfile] {
+    warning "get_compiler failed"
+    return -1
+}
+
+if ![test_compiler_info gcc*] {
+    # We use GCC's extended asm syntax
+    warning "unknown compiler"
+    return -1
+}
+
+# Try to compile the test case.  If we can't, assume the
+# toolchain does not yet provide DFP support and bail out.
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quiet debug}] != "" } {
+    verbose "Skipping FPSCR tests."
+    return -1
+}
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+gdb_breakpoint [gdb_get_line_number "Invalid operation."]
+gdb_breakpoint [gdb_get_line_number "Division by zero."]
+
+# Run the program, when the prompt comes back it will be for the invalid
+# operation breakpoint.
+gdb_test "run" "" ""
+
+# First, verify if FPSCR is all zeroes.
+gdb_test "print \$fpscr" " = 0\r" "FPSCR is all zeroes"
+
+# Step over invalid operation.
+gdb_test "next" "" ""
+
+# Verify that the following bits are set (See Power ISA for details):
+#
+# 32 - Floating-Point Exception Summary (FX)
+# 34 - Floating-Point Invalid Operation Summary (VX)
+# 42 - Floating-Point Invalid Operation Exception (VXZDZ)
+# 47 - Floating-Point Result Class Descriptor (C)
+# 51 - Floating-Point Unordered or NaN (FU or ?)
+gdb_test "print/t \$fpscr" " = 10100000001000010001000000000000\r" "FPSCR for invalid operation"
+
+gdb_continue_to_breakpoint "go to division by zero"
+
+# Step over division by zero.
+gdb_test "next" "" ""
+
+# Verify that the following bits are set (See Power ISA for details):
+#
+# 32 - Floating-Point Exception Summary (FX)
+# 37 - Floating-Point Zero Divide Exception (ZX)
+# 49 - Floating-Point Greater Than or Positive (FG or >)
+# 51 - Floating-Point Unordered or NaN (FU or ?)
+gdb_test "print/t \$fpscr" " = 10000100000000000101000000000000\r" "FPSCR for division by zero"



  reply	other threads:[~2008-08-22 18:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-21 23:18 Thiago Jung Bauermann
2008-08-21 23:32 ` Daniel Jacobowitz
2008-08-21 23:42   ` Thiago Jung Bauermann
2008-08-22  2:47     ` Daniel Jacobowitz
2008-08-22 18:13       ` Thiago Jung Bauermann [this message]
2008-09-02 21:40         ` Joel Brobecker
2008-09-02 23:35           ` Thiago Jung Bauermann
2008-09-02 23:46             ` Daniel Jacobowitz
2008-09-02 21:55         ` Daniel Jacobowitz
2008-09-03 20:15           ` Thiago Jung Bauermann
2008-09-03 21:01             ` Daniel Jacobowitz
2008-09-04  1:26               ` Thiago Jung Bauermann
2008-09-05  0:12                 ` Joel Brobecker
2008-09-05  3:38                   ` Thiago Jung Bauermann
2008-09-05 14:00                     ` Joel Brobecker
2008-09-05 19:30                       ` Thiago Jung Bauermann

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=1219428669.8167.2.camel@localhost.localdomain \
    --to=bauerman@br.ibm.com \
    --cc=drow@false.org \
    --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