Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfc] add ppc testcase to test fpscr
@ 2008-08-21 23:18 Thiago Jung Bauermann
  2008-08-21 23:32 ` Daniel Jacobowitz
  0 siblings, 1 reply; 16+ messages in thread
From: Thiago Jung Bauermann @ 2008-08-21 23:18 UTC (permalink / raw)
  To: gdb-patches ml

Hi,

I've been playing with GDB code related to powerpc's fpscr, and noticed
that there's nothing testing it in the testsuite. This patch adds basic
sanity checking of that register.

Also, this adds the function gdb_send_cmd to lib/gdb.exp. More than once
I've wanted to send a commad to GDB and wait to get the prompt back
(because send_gdb is too fast and can create racy testcases). This
function scratches that itch.

What do you think? OK to commit?
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center

:ADDPATCH testsuite:

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

    	* gdb.arch/ppc-fp.exp: New file.
    	* gdb.arch/ppc-fp.c: New file.
    	* lib/gdb.exp (gdb_send_cmd): New function.

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..38e033c
--- /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_send_cmd "run"
+
+# First, verify if FPSCR is all zeroes.
+gdb_test "print \$fpscr" " = 0\r" "FPSCR is all zeroes"
+
+# Step over invalid operation.
+gdb_send_cmd "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_send_cmd "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"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 3761d7a..268feab 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1922,6 +1922,30 @@ proc send_gdb { string } {
     return [remote_send host "$string"];
 }
 
+# gdb_send_cmd COMMAND
+#
+# Sends a command to GDB and waits for the prompt to come back.
+# It doesn't register a PASS if it succeeds, but it will register
+# a FAIL if waiting for the prompt times out.
+#
+# COMMAND: is the GDB command to be run.
+#
+# Returns whatever gdb_test_multiple returns, which is:
+#    1 if the test failed, according to a built-in failure pattern
+#    0 if only user-supplied patterns matched
+#   -1 if there was an internal error.
+#
+proc gdb_send_cmd { command } {
+  global gdb_prompt
+
+  return [gdb_test_multiple "$command" "" {
+    -re "\[\r\n]+$gdb_prompt $" {}
+    timeout { 
+	fail "$command (timeout)"
+    }
+  }]
+}
+
 #
 #
 



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-08-21 23:18 [rfc] add ppc testcase to test fpscr Thiago Jung Bauermann
@ 2008-08-21 23:32 ` Daniel Jacobowitz
  2008-08-21 23:42   ` Thiago Jung Bauermann
  0 siblings, 1 reply; 16+ messages in thread
From: Daniel Jacobowitz @ 2008-08-21 23:32 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: gdb-patches ml

On Thu, Aug 21, 2008 at 08:16:51PM -0300, Thiago Jung Bauermann wrote:
> Hi,
> 
> I've been playing with GDB code related to powerpc's fpscr, and noticed
> that there's nothing testing it in the testsuite. This patch adds basic
> sanity checking of that register.
> 
> Also, this adds the function gdb_send_cmd to lib/gdb.exp. More than once
> I've wanted to send a commad to GDB and wait to get the prompt back
> (because send_gdb is too fast and can create racy testcases). This
> function scratches that itch.

Isn't this just the same as gdb_test "command" "" "" ?

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-08-21 23:32 ` Daniel Jacobowitz
@ 2008-08-21 23:42   ` Thiago Jung Bauermann
  2008-08-22  2:47     ` Daniel Jacobowitz
  0 siblings, 1 reply; 16+ messages in thread
From: Thiago Jung Bauermann @ 2008-08-21 23:42 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches ml

On Thu, 2008-08-21 at 19:31 -0400, Daniel Jacobowitz wrote:
> > Also, this adds the function gdb_send_cmd to lib/gdb.exp. More than once
> > I've wanted to send a commad to GDB and wait to get the prompt back
> > (because send_gdb is too fast and can create racy testcases). This
> > function scratches that itch.
> 
> Isn't this just the same as gdb_test "command" "" "" ?

Tried that, didn't work. Your command would check for:

-re "\[\r\n\]*()\[\r\n\]+$gdb_prompt $"

Which apparently is not good...

I admit I didn't look that much into it.

-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-08-21 23:42   ` Thiago Jung Bauermann
@ 2008-08-22  2:47     ` Daniel Jacobowitz
  2008-08-22 18:13       ` Thiago Jung Bauermann
  0 siblings, 1 reply; 16+ messages in thread
From: Daniel Jacobowitz @ 2008-08-22  2:47 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: gdb-patches ml

On Thu, Aug 21, 2008 at 08:41:21PM -0300, Thiago Jung Bauermann wrote:
> On Thu, 2008-08-21 at 19:31 -0400, Daniel Jacobowitz wrote:
> > > Also, this adds the function gdb_send_cmd to lib/gdb.exp. More than once
> > > I've wanted to send a commad to GDB and wait to get the prompt back
> > > (because send_gdb is too fast and can create racy testcases). This
> > > function scratches that itch.
> > 
> > Isn't this just the same as gdb_test "command" "" "" ?
> 
> Tried that, didn't work. Your command would check for:
> 
> -re "\[\r\n\]*()\[\r\n\]+$gdb_prompt $"
> 
> Which apparently is not good...
> 
> I admit I didn't look that much into it.

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.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-08-22  2:47     ` Daniel Jacobowitz
@ 2008-08-22 18:13       ` Thiago Jung Bauermann
  2008-09-02 21:40         ` Joel Brobecker
  2008-09-02 21:55         ` Daniel Jacobowitz
  0 siblings, 2 replies; 16+ messages in thread
From: Thiago Jung Bauermann @ 2008-08-22 18:13 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches ml

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"



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-08-22 18:13       ` Thiago Jung Bauermann
@ 2008-09-02 21:40         ` Joel Brobecker
  2008-09-02 23:35           ` Thiago Jung Bauermann
  2008-09-02 21:55         ` Daniel Jacobowitz
  1 sibling, 1 reply; 16+ messages in thread
From: Joel Brobecker @ 2008-09-02 21:40 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: gdb-patches ml

> 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.

I didn't see anyone actually review the patch so I took a look.
Looks OK to me, but I'm really wonderng why you added a '\r' at
the end of the expected output in our gdb_test calls. For instance:

> +gdb_test "print \$fpscr" " = 0\r" "FPSCR is all zeroes"

Usually, I just do:

    gdb_test "print \$fpscr" " = 0" "FPSCR is all zeroes"

Is there something specific that you are trying to do with the '\r'?

> +#include <stdio.h>

Is the use of stdio necessary in this case. If you can do without,
then this would allow us to run this testcase in the bareboard case
(powerpc-elf). Not strictly necessary, but nice to have...

-- 
Joel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-08-22 18:13       ` Thiago Jung Bauermann
  2008-09-02 21:40         ` Joel Brobecker
@ 2008-09-02 21:55         ` Daniel Jacobowitz
  2008-09-03 20:15           ` Thiago Jung Bauermann
  1 sibling, 1 reply; 16+ messages in thread
From: Daniel Jacobowitz @ 2008-09-02 21:55 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: gdb-patches ml

On Fri, Aug 22, 2008 at 03:11:09PM -0300, Thiago Jung Bauermann wrote:
> +# Run the program, when the prompt comes back it will be for the invalid
> +# operation breakpoint.
> +gdb_test "run" "" ""

This is similar to what Joel said about testing bare metal targets -
using "run" will break gdbserver testing.  Pick almost any test and you
can see how this is usually handled, e.g. by gdb_run_cmd or "runto
main".

> +# First, verify if FPSCR is all zeroes.
> +gdb_test "print \$fpscr" " = 0\r" "FPSCR is all zeroes"

Oh, also there's PowerPC targets without hardware floating
point... and GDB is sometimes smart enough nowadays to not display
dummy FP registers.  So having fpscr not exist is legitimate.
There's also the E500, which does not have a classic FPU.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-09-02 21:40         ` Joel Brobecker
@ 2008-09-02 23:35           ` Thiago Jung Bauermann
  2008-09-02 23:46             ` Daniel Jacobowitz
  0 siblings, 1 reply; 16+ messages in thread
From: Thiago Jung Bauermann @ 2008-09-02 23:35 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches ml

El mar, 02-09-2008 a las 23:39 +0200, Joel Brobecker escribió:
> I didn't see anyone actually review the patch so I took a look.

Thanks!

> Looks OK to me, but I'm really wonderng why you added a '\r' at
> the end of the expected output in our gdb_test calls.

That was the closest I could think of to an EOL marker. Using '$' is not
an option, I believe.

>  For instance:
> 
> > +gdb_test "print \$fpscr" " = 0\r" "FPSCR is all zeroes"
> 
> Usually, I just do:
> 
>     gdb_test "print \$fpscr" " = 0" "FPSCR is all zeroes"
> 
> Is there something specific that you are trying to do with the '\r'?

In the instance you show I agree it's not very useful, but here:

> > +gdb_test "print/t \$fpscr" " = 10100000001000010001000000000000\r" "FPSCR for invalid operation"

I want to be sure I am testing the lower 32-bits of the FPSCR. For the
moment, this is meaningless since the FPSCR is assumed to always be 32
bits wide in GDB (also, the " = " in the beginning of the pattern
doesn't help). But the FPSCR is actually 64 bits wide starting with
Power ISA 2.05 (only Power6 at the moment). That's what I'm playing with
which prompted me to write this testcase, actually.

> > +#include <stdio.h>
> 
> Is the use of stdio necessary in this case. If you can do without,
> then this would allow us to run this testcase in the bareboard case
> (powerpc-elf). Not strictly necessary, but nice to have...

I added the printf calls just to make sure GCC doesn't make the 'result'
variable vanish. Maybe that's not necessary, since the asm blocks
mention result as an output variable? Or maybe GCC would also nuke the
asm blocks instead, seeing that they serve no useful purpose if 'result'
is also not used? I don't know.
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-09-02 23:35           ` Thiago Jung Bauermann
@ 2008-09-02 23:46             ` Daniel Jacobowitz
  0 siblings, 0 replies; 16+ messages in thread
From: Daniel Jacobowitz @ 2008-09-02 23:46 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: Joel Brobecker, gdb-patches ml

On Tue, Sep 02, 2008 at 08:31:50PM -0300, Thiago Jung Bauermann wrote:
> > Looks OK to me, but I'm really wonderng why you added a '\r' at
> > the end of the expected output in our gdb_test calls.
> 
> That was the closest I could think of to an EOL marker. Using '$' is not
> an option, I believe.

You don't need an EOL marker; gdb_test adds \r\n after the supplied
pattern.

> > > +#include <stdio.h>
> > 
> > Is the use of stdio necessary in this case. If you can do without,
> > then this would allow us to run this testcase in the bareboard case
> > (powerpc-elf). Not strictly necessary, but nice to have...
> 
> I added the printf calls just to make sure GCC doesn't make the 'result'
> variable vanish. Maybe that's not necessary, since the asm blocks
> mention result as an output variable? Or maybe GCC would also nuke the
> asm blocks instead, seeing that they serve no useful purpose if 'result'
> is also not used? I don't know.

GCC won't eliminate user variables at -O0.  If you want the test to
work with optimization, or with non-GCC compilers, try making result a
volatile global.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-09-02 21:55         ` Daniel Jacobowitz
@ 2008-09-03 20:15           ` Thiago Jung Bauermann
  2008-09-03 21:01             ` Daniel Jacobowitz
  0 siblings, 1 reply; 16+ messages in thread
From: Thiago Jung Bauermann @ 2008-09-03 20:15 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Joel Brobecker, gdb-patches ml

El mar, 02-09-2008 a las 17:54 -0400, Daniel Jacobowitz escribió:
> On Fri, Aug 22, 2008 at 03:11:09PM -0300, Thiago Jung Bauermann wrote:
> > +# Run the program, when the prompt comes back it will be for the invalid
> > +# operation breakpoint.
> > +gdb_test "run" "" ""
> 
> This is similar to what Joel said about testing bare metal targets -
> using "run" will break gdbserver testing.  Pick almost any test and you
> can see how this is usually handled, e.g. by gdb_run_cmd or "runto
> main".

I chose gdb_test because it waits for $gdb_prompt to show up, which
seems to be a good way to avoid creating a racy testcase.

But I just changed to use gdb_run_cmd instead. (I'm glad I remembered my
original reasoning, at least one of my testcase gaffes can be
explained!)

> > +# First, verify if FPSCR is all zeroes.
> > +gdb_test "print \$fpscr" " = 0\r" "FPSCR is all zeroes"
> 
> Oh, also there's PowerPC targets without hardware floating
> point... and GDB is sometimes smart enough nowadays to not display
> dummy FP registers.  So having fpscr not exist is legitimate.
> There's also the E500, which does not have a classic FPU.

Good point. What about checking for "= void" when printing the FPSCR to
determine if the register exists? That's what I do below.

This version also incorporates Joel's comments. WDYT?
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center


2008-09-03  Thiago Jung Bauermann  <bauerman@br.ibm.com>

	* 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..841b112
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/ppc-fp.c
@@ -0,0 +1,36 @@
+/* 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/>.  */
+
+int
+main (int argc, char *argv[])
+{
+  double result;
+
+  asm ("fdiv %0, %1, %1\n"	/* Invalid operation.  */
+       : "=f" (result)
+       : "f" (0.0));
+
+  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));
+
+  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..33824f6
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/ppc-fp.exp
@@ -0,0 +1,101 @@
+# 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 floating point 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
+}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quiet debug additional_flags=-O0}] != "" } {
+    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_run_cmd
+
+# First, verify if FPSCR exists and is all zeroes.
+gdb_test_multiple "print \$fpscr" "FPSCR exists" {
+  -re " = 0" { pass "FPSCR is all zeroes" }
+
+  -re " = void" {
+    # There's no FPSCR.  Skip this testcase.
+    verbose "Skipping powerpc floating point register tests."
+    verbose -log "Skipping powerpc floating point register tests."
+    return
+  }
+}
+
+# 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" "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" "FPSCR for division by zero"



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-09-03 20:15           ` Thiago Jung Bauermann
@ 2008-09-03 21:01             ` Daniel Jacobowitz
  2008-09-04  1:26               ` Thiago Jung Bauermann
  0 siblings, 1 reply; 16+ messages in thread
From: Daniel Jacobowitz @ 2008-09-03 21:01 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: Joel Brobecker, gdb-patches ml

On Wed, Sep 03, 2008 at 05:12:25PM -0300, Thiago Jung Bauermann wrote:
> +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quiet debug additional_flags=-O0}] != "" } {

No need for additional_flags here.

> +# Run the program, when the prompt comes back it will be for the invalid
> +# operation breakpoint.
> +gdb_run_cmd

You've got to wait for the prompt explicitly.  If you ever leave expect
in a state where two prompts should be arriving, it won't know which
is which; if it sees them separately, you can get out of sync and all
tests will fail with unknown output.  That's one advantage of using
runto_main followed by an explicit continue.

Looks otherwise OK to me.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-09-03 21:01             ` Daniel Jacobowitz
@ 2008-09-04  1:26               ` Thiago Jung Bauermann
  2008-09-05  0:12                 ` Joel Brobecker
  0 siblings, 1 reply; 16+ messages in thread
From: Thiago Jung Bauermann @ 2008-09-04  1:26 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Joel Brobecker, gdb-patches ml

El mié, 03-09-2008 a las 17:00 -0400, Daniel Jacobowitz escribió:
> You've got to wait for the prompt explicitly.

Waiting for the prompt explicitly, now.

> Looks otherwise OK to me.

Thanks for the review. Posting again since I believe I never directly
used gdb_expect before...
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center


2008-09-03  Thiago Jung Bauermann  <bauerman@br.ibm.com>

	* 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..841b112
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/ppc-fp.c
@@ -0,0 +1,36 @@
+/* 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/>.  */
+
+int
+main (int argc, char *argv[])
+{
+  double result;
+
+  asm ("fdiv %0, %1, %1\n"	/* Invalid operation.  */
+       : "=f" (result)
+       : "f" (0.0));
+
+  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));
+
+  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..1ce4a38
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/ppc-fp.exp
@@ -0,0 +1,102 @@
+# 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 floating point 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
+}
+
+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."]
+
+gdb_run_cmd
+
+# When the prompt comes back we'll be in the invalid operation breakpoint.
+gdb_expect { -re ".*$gdb_prompt $" {} }
+
+# First, verify if FPSCR exists and is all zeroes.
+gdb_test_multiple "print \$fpscr" "FPSCR exists" {
+  -re " = 0" { pass "FPSCR is all zeroes" }
+
+  -re " = void" {
+    # There's no FPSCR.  Skip this testcase.
+    verbose "Skipping powerpc floating point register tests."
+    verbose -log "Skipping powerpc floating point register tests."
+    return
+  }
+}
+
+# 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" "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" "FPSCR for division by zero"



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-09-04  1:26               ` Thiago Jung Bauermann
@ 2008-09-05  0:12                 ` Joel Brobecker
  2008-09-05  3:38                   ` Thiago Jung Bauermann
  0 siblings, 1 reply; 16+ messages in thread
From: Joel Brobecker @ 2008-09-05  0:12 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: gdb-patches ml

> 2008-09-03  Thiago Jung Bauermann  <bauerman@br.ibm.com>
> 
> 	* gdb.arch/ppc-fp.exp: New file.
> 	* gdb.arch/ppc-fp.c: New file.

This looks good to me. Just a question:

On a couple of occasions, you use the "verbose" routine, and then
call it again with the same argument, except for the -log:

> +    verbose "Skipping powerpc floating point register tests."
> +    verbose -log "Skipping powerpc floating point register tests."

I searched throughout the gdb.base directory, and I found only uses
of verbose without -log. In testsuite/lib, I saw uses of both forms,
but never at the same time...

-- 
Joel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-09-05  0:12                 ` Joel Brobecker
@ 2008-09-05  3:38                   ` Thiago Jung Bauermann
  2008-09-05 14:00                     ` Joel Brobecker
  0 siblings, 1 reply; 16+ messages in thread
From: Thiago Jung Bauermann @ 2008-09-05  3:38 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches ml

El jue, 04-09-2008 a las 17:12 -0700, Joel Brobecker escribió:
> > 2008-09-03  Thiago Jung Bauermann  <bauerman@br.ibm.com>
> > 
> > 	* gdb.arch/ppc-fp.exp: New file.
> > 	* gdb.arch/ppc-fp.c: New file.
> 
> This looks good to me. Just a question:
> 
> On a couple of occasions, you use the "verbose" routine, and then
> call it again with the same argument, except for the -log:
> 
> > +    verbose "Skipping powerpc floating point register tests."
> > +    verbose -log "Skipping powerpc floating point register tests."
> 
> I searched throughout the gdb.base directory, and I found only uses
> of verbose without -log. In testsuite/lib, I saw uses of both forms,
> but never at the same time...

No reason. I probably copied the wrong example. I can remove either of
them, at will. :-)
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-09-05  3:38                   ` Thiago Jung Bauermann
@ 2008-09-05 14:00                     ` Joel Brobecker
  2008-09-05 19:30                       ` Thiago Jung Bauermann
  0 siblings, 1 reply; 16+ messages in thread
From: Joel Brobecker @ 2008-09-05 14:00 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: gdb-patches ml

> > > +    verbose "Skipping powerpc floating point register tests."
> > > +    verbose -log "Skipping powerpc floating point register tests."
> > 
> > I searched throughout the gdb.base directory, and I found only uses
> > of verbose without -log. In testsuite/lib, I saw uses of both forms,
> > but never at the same time...
> 
> No reason. I probably copied the wrong example. I can remove either of
> them, at will. :-)

Let's remove the second one, then.

-- 
Joel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [rfc] add ppc testcase to test fpscr
  2008-09-05 14:00                     ` Joel Brobecker
@ 2008-09-05 19:30                       ` Thiago Jung Bauermann
  0 siblings, 0 replies; 16+ messages in thread
From: Thiago Jung Bauermann @ 2008-09-05 19:30 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches ml

El vie, 05-09-2008 a las 06:59 -0700, Joel Brobecker escribió:
> > > > +    verbose "Skipping powerpc floating point register tests."
> > > > +    verbose -log "Skipping powerpc floating point register tests."
> > > 
> > > I searched throughout the gdb.base directory, and I found only uses
> > > of verbose without -log. In testsuite/lib, I saw uses of both forms,
> > > but never at the same time...
> > 
> > No reason. I probably copied the wrong example. I can remove either of
> > them, at will. :-)
> 
> Let's remove the second one, then.

Right. I also noticed that unlike gdb_test, gdb_test_multiple doesn't
wait for the prompt. I explicitly put that into the REs now.

Committed the following. Thanks!
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center


2008-09-05  Thiago Jung Bauermann  <bauerman@br.ibm.com>

	* 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..841b112
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/ppc-fp.c
@@ -0,0 +1,36 @@
+/* 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/>.  */
+
+int
+main (int argc, char *argv[])
+{
+  double result;
+
+  asm ("fdiv %0, %1, %1\n"	/* Invalid operation.  */
+       : "=f" (result)
+       : "f" (0.0));
+
+  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));
+
+  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..170d58c
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/ppc-fp.exp
@@ -0,0 +1,100 @@
+# 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."
+    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
+}
+
+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."]
+
+gdb_run_cmd
+
+# When the prompt comes back we'll be in the invalid operation breakpoint.
+gdb_expect { -re ".*$gdb_prompt $" {} }
+
+# First, verify if FPSCR exists and is all zeroes.
+gdb_test_multiple "print \$fpscr" "FPSCR exists" {
+  -re " = 0\[\r\n\]+$gdb_prompt $" { pass "FPSCR is all zeroes" }
+
+  -re " = void\[\r\n\]+$gdb_prompt $" {
+    # There's no FPSCR.  Skip this testcase.
+    verbose "Skipping powerpc floating point register tests."
+    return
+  }
+}
+
+# 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" "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" "FPSCR for division by zero"



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2008-09-05 19:30 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-21 23:18 [rfc] add ppc testcase to test fpscr 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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox