From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25865 invoked by alias); 3 Sep 2008 20:15:45 -0000 Received: (qmail 25856 invoked by uid 22791); 3 Sep 2008 20:15:43 -0000 X-Spam-Check-By: sourceware.org Received: from igw2.br.ibm.com (HELO igw2.br.ibm.com) (32.104.18.25) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 03 Sep 2008 20:14:51 +0000 Received: from mailhub3.br.ibm.com (mailhub3 [9.18.232.110]) by igw2.br.ibm.com (Postfix) with ESMTP id 7304917F485 for ; Wed, 3 Sep 2008 16:59:56 -0300 (BRT) Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.18.232.47]) by mailhub3.br.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m83KChx71699848 for ; Wed, 3 Sep 2008 17:12:43 -0300 Received: from d24av02.br.ibm.com (loopback [127.0.0.1]) by d24av02.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m83KCYNX002673 for ; Wed, 3 Sep 2008 17:12:35 -0300 Received: from [9.8.3.110] ([9.8.3.110]) by d24av02.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m83KCRXW002517; Wed, 3 Sep 2008 17:12:31 -0300 Subject: Re: [rfc] add ppc testcase to test fpscr From: Thiago Jung Bauermann To: Daniel Jacobowitz Cc: Joel Brobecker , gdb-patches ml In-Reply-To: <20080902215458.GB25623@caradoc.them.org> References: <1219360611.8989.6.camel@localhost.localdomain> <20080821233115.GA1239@caradoc.them.org> <1219362081.29526.2.camel@localhost.localdomain> <20080822024659.GA12951@caradoc.them.org> <1219428669.8167.2.camel@localhost.localdomain> <20080902215458.GB25623@caradoc.them.org> Content-Type: text/plain; charset=UTF-8 Date: Wed, 03 Sep 2008 20:15:00 -0000 Message-Id: <1220472745.9671.13.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-09/txt/msg00051.txt.bz2 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 * 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 . */ + +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 . +# +# 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"