From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14154 invoked by alias); 26 Mar 2005 00:43:19 -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 13827 invoked from network); 26 Mar 2005 00:43:09 -0000 Received: from unknown (HELO priv-edtnes57.telusplanet.net) (199.185.220.220) by sourceware.org with SMTP; 26 Mar 2005 00:43:09 -0000 Received: from takamaka.act-europe.fr ([142.179.108.108]) by priv-edtnes57.telusplanet.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050326004308.YBIP15184.priv-edtnes57.telusplanet.net@takamaka.act-europe.fr> for ; Fri, 25 Mar 2005 17:43:08 -0700 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id 0ABE647DC0; Fri, 25 Mar 2005 16:43:08 -0800 (PST) Date: Sat, 26 Mar 2005 00:43:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: [RFA] Fix problem fetching/setting FSR register (IRIX) Message-ID: <20050326004308.GH2545@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="xHFwDpU9dbj6ez1V" Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2005-03/txt/msg00330.txt.bz2 --xHFwDpU9dbj6ez1V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 759 Hello, The attached patch fixes the problem reported at: http://sources.redhat.com/ml/gdb-patches/2005-03/msg00294.html The explaination of the actual problem is detailed at: http://sources.redhat.com/ml/gdb-patches/2005-03/msg00309.html I have also added some comments in the code, and included Mark's comments. 2005-03-25 Joel Brobecker * irix5-nat.c (supply_fpregset): Fix bug that caused the FSR register value to be incorrectly written in the regcache. (fill_fpregset): Fix bug that caused the FSR register value to be incorrectly read from the regcache. Fixes [E223-028]. Tested on mips-irix. No regression. OK to apply? (I will submit a testcase for this asap) Thanks, -- Joel --xHFwDpU9dbj6ez1V Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="irix5-nat.c.diff" Content-length: 2310 Index: irix5-nat.c =================================================================== RCS file: /cvs/src/src/gdb/irix5-nat.c,v retrieving revision 1.38 diff -u -p -r1.38 irix5-nat.c --- irix5-nat.c 11 Feb 2005 04:05:56 -0000 1.38 +++ irix5-nat.c 26 Mar 2005 00:37:49 -0000 @@ -139,6 +139,7 @@ supply_fpregset (fpregset_t *fpregsetp) { int regi; static char zerobuf[32] = {0}; + char fsrbuf[8]; /* FIXME, this is wrong for the N32 ABI which has 64 bit FP regs. */ @@ -146,9 +147,17 @@ supply_fpregset (fpregset_t *fpregsetp) regcache_raw_supply (current_regcache, FP0_REGNUM + regi, (char *) &fpregsetp->fp_r.fp_regs[regi]); + /* We can't supply the FSR register directly to the regcache, + because there is a size issue: On one hand, fpregsetp->fp_csr + is 32bits long, while the regcache expects a 64bits long value. + So we use a buffer of the correct size and copy into it the register + value at the proper location. */ + memset (fsrbuf, 0, 4); + memcpy (fsrbuf + 4, &fpregsetp->fp_csr, 4); + regcache_raw_supply (current_regcache, mips_regnum (current_gdbarch)->fp_control_status, - (char *) &fpregsetp->fp_csr); + fsrbuf); /* FIXME: how can we supply FCRIR? SGI doesn't tell us. */ regcache_raw_supply (current_regcache, @@ -173,11 +182,22 @@ fill_fpregset (fpregset_t *fpregsetp, in } } - if ((regno == -1) - || (regno == mips_regnum (current_gdbarch)->fp_control_status)) - regcache_raw_read (current_regcache, - mips_regnum (current_gdbarch)->fp_control_status, - &fpregsetp->fp_csr); + if (regno == -1 + || regno == mips_regnum (current_gdbarch)->fp_control_status) + { + char fsrbuf[8]; + + /* We can't fill the FSR register directly from the regcache, + because there is a size issue: On one hand, fpregsetp->fp_csr + is 32bits long, while the regcache expects a 64bits long buffer. + So we use a buffer of the correct size and copy the register + value from that buffer. */ + regcache_raw_read (current_regcache, + mips_regnum (current_gdbarch)->fp_control_status, + fsrbuf); + + memcpy (&fpregsetp->fp_csr, fsrbuf + 4, 4); + } } --xHFwDpU9dbj6ez1V--