From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11970 invoked by alias); 6 Dec 2001 23:48:34 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 11757 invoked from network); 6 Dec 2001 23:48:27 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 6 Dec 2001 23:48:27 -0000 Received: from cse.cygnus.com (cse.cygnus.com [205.180.230.236]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id PAA04124 for ; Thu, 6 Dec 2001 15:48:24 -0800 (PST) Received: (from kev@localhost) by cse.cygnus.com (8.9.3/8.9.3) id QAA08668 for gdb-patches@sources.redhat.com; Thu, 6 Dec 2001 16:48:07 -0700 Date: Thu, 06 Dec 2001 15:48:00 -0000 From: Kevin Buettner Message-Id: <1011206234806.ZM8667@ocotillo.lan> X-Mailer: Z-Mail (4.0.1 13Jan97 Caldera) To: gdb-patches@sources.redhat.com Subject: [PATCH RFA] Fix x86 floating point vs. thread problem MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2001-12/txt/msg00183.txt.bz2 The patch below fixes the problem reported by David Relson in http://sources.redhat.com/ml/gdb/2001-12/msg00001.html An impressive test matrix regarding this bug has been provided by Emmanuel Blindauer at http://manu.agat.net/bug.html Anyway, the problem is that GDB is computing the fpxregs version of the tag value incorrectly. The fpxregs version of the tag value is simply a bitmask (of eight bits) which indicate which of the floating point registers is in use. i387_fill_fxsave() was incorrectly shifting by twice the the number of bits that it should have. * i387-nat.c (i387_fill_fxsave): Change type of ``val'' from char to short so that we don't memcpy() beyond the end of this buffer. Also, change shift value used in computing val to account for the fact that only eight bits are used. Index: i387-nat.c =================================================================== RCS file: /cvs/src/src/gdb/i387-nat.c,v retrieving revision 1.7 diff -u -p -r1.7 i387-nat.c --- i387-nat.c 2001/11/12 22:27:35 1.7 +++ i387-nat.c 2001/12/06 23:19:05 @@ -270,7 +270,7 @@ i387_fill_fxsave (char *fxsave, int regn { /* Converting back is much easier. */ - unsigned char val = 0; + unsigned short val = 0; unsigned short ftag; int fpreg; @@ -281,7 +281,7 @@ i387_fill_fxsave (char *fxsave, int regn int tag = (ftag >> (fpreg * 2)) & 3; if (tag != 3) - val |= (1 << (fpreg * 2)); + val |= (1 << fpreg); } memcpy (FXSAVE_ADDR (fxsave, i), &val, 2);