From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25534 invoked by alias); 12 Jul 2009 18:10:12 -0000 Received: (qmail 25526 invoked by uid 22791); 12 Jul 2009 18:10:11 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN X-Spam-Check-By: sourceware.org Received: from smtp-outbound-2.vmware.com (HELO smtp-outbound-2.vmware.com) (65.115.85.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 12 Jul 2009 18:10:04 +0000 Received: from mailhost4.vmware.com (mailhost4.vmware.com [10.16.67.124]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id B54A4F005; Sun, 12 Jul 2009 11:10:02 -0700 (PDT) Received: from [10.20.94.141] (msnyder-server.eng.vmware.com [10.20.94.141]) by mailhost4.vmware.com (Postfix) with ESMTP id A839BC9D0A; Sun, 12 Jul 2009 11:10:02 -0700 (PDT) Message-ID: <4A5A25F4.10201@vmware.com> Date: Mon, 13 Jul 2009 00:38:00 -0000 From: Michael Snyder User-Agent: Thunderbird 1.5.0.12 (X11/20080411) MIME-Version: 1.0 To: paawan oza CC: "gdb-patches@sourceware.org" , Pedro Alves , "teawater@gmail.com" Subject: Re: i386.record.floating.point.patch : with more testing and assurity References: <9950.73333.qm@web112504.mail.gq1.yahoo.com> In-Reply-To: <9950.73333.qm@web112504.mail.gq1.yahoo.com> Content-Type: multipart/mixed; boundary="------------020605080800070703020504" 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: 2009-07/txt/msg00349.txt.bz2 This is a multi-part message in MIME format. --------------020605080800070703020504 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1611 paawan oza wrote: > Hi, > Thank you very much for your elaborated reply. > I will integrate the test example with test suite by next week-end. > And, also take of all yours and Hui's formatting comments. > I will come up with the final up to date patch with integrated test-suite. > Thank you again for your response. : ) > I start working towards it. > Regards, > Oza. Excellent. Now let's talk about what the test should test. I don't think it is necessary to test each individual instruction (unless you really want to). We don't usually go to that extreme. What we want to establish is "does the patch do what it's intended to do", so let's make a statement about what it's intended to do. You correct me if I'm wrong, but in my impression, it can be summed up as: preserve and restore the state of the standard Intel floating point unit during record and replay". So you just need to test that the FP machine state is preserved, and that when we go backwards, the state is restored to what it was before. I think that means mainly the '387' registers, or the state that is displayed when we say "info float". To help you get started, I've attached a simple gdb test that checks to see if we can save and restore one register ('st0'). This will show you in general how it is done, and if you want to, you can use it as a starting point, and add tests for the rest of the registers. The subroutines that we use, such as "gdb_test", are mostly defined in gdb/testsuite/lib/gdb.exp, if you need to look at them. There's some documentation in the comments, and also in gdb/doc/gdbint.texinfo. --------------020605080800070703020504 Content-Type: text/x-csrc; name="i387-float-reverse.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="i387-float-reverse.c" Content-length: 958 /* Reverse debugging of floating point registers. Copyright 2009, 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 (void) { int i = 0; /* BEGIN I387-FLOAT-REVERSE */ asm ("fldz"); /* test st0 register */ asm ("fld1"); asm ("nop"); return i; /* END I387-FLOAT-REVERSE */ } --------------020605080800070703020504 Content-Type: text/plain; name="i387-float-reverse.exp" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="i387-float-reverse.exp" Content-length: 2632 # Copyright 2009 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 . # This file is part of the gdb testsuite. if $tracelevel { strace $tracelevel } set prms_id 0 set bug_id 0 if ![istarget "i?86-*linux*"] then { verbose "Skipping i387 reverse float tests." return } set testfile "i387-float-reverse" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} # some targets have leading underscores on assembly symbols. # TODO: detect this automatically set additional_flags "" if [istarget "i?86-*-cygwin*"] then { set additional_flags "additional_flags=-DSYMBOL_PREFIX=\"_\"" } if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } { untested i387-float-reverse return -1 } # Get things started. gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} runto main # Record to end of main set location [gdb_get_line_number "END I387-FLOAT-REVERSE"] gdb_test "record" "" "Turn on process record" gdb_test "until $location" ".*/$srcfile:$location.*" \ "record to end of main" # Now rewind to beginning so we can begin testing. set location [gdb_get_line_number "BEGIN I387-FLOAT-REVERSE"] gdb_test "set exec-dir reverse" "" "set reverse direction" gdb_test "until $location" ".*/$srcfile:$location.*" \ "rewind to beginning of main" gdb_test "set exec-dir forward" "" "set forward direction" # Test st0 register set location [gdb_get_line_number "test st0 register"] gdb_test "until $location" ".*/$srcfile:$location.*asm.*fldz.*" \ "begin test st0" gdb_test "stepi" "asm.*fld1.*" "set st0 == 0" gdb_test "info register st0" "st0 *0\t.*" "verify st0 == 0" gdb_test "stepi" "asm.*nop.*" "set st0 == 1" gdb_test "info register st0" "st0 *1\t.*" "verify st0 == 1" # Now step backward, and check that st0 value reverts to zero. gdb_test "reverse-stepi" "asm.*fld1.*" "undo set st0 == 1" gdb_test "info register st0" "st0 *0\t.*" "verify st0 == 0 again" --------------020605080800070703020504--