From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19870 invoked by alias); 22 Nov 2011 16:08:47 -0000 Received: (qmail 19846 invoked by uid 22791); 22 Nov 2011 16:08:46 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,FROM_12LTRDOM,TW_EG X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Nov 2011 16:08:33 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1RSstc-0002Xm-En from Maciej_Rozycki@mentor.com for gdb-patches@sourceware.org; Tue, 22 Nov 2011 08:08:32 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 22 Nov 2011 08:05:35 -0800 Received: from [172.30.6.30] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Tue, 22 Nov 2011 16:08:30 +0000 Date: Tue, 22 Nov 2011 16:08:00 -0000 From: "Maciej W. Rozycki" To: Subject: [PATCH] Linux/gdbserver: Clean up fetch_register and store_register Message-ID: User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" 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: 2011-11/txt/msg00585.txt.bz2 Hi, More changes to fetch_register and store_register -- the two functions complement each other but their code looks as if they were written independently and then at one point included here together. This is an overall cleanup, although by no means exhaustive -- there are still some minor issues I did not want to address lest I got buried into this cleanup forever. Apart from obvious formatting fixes there are two minor functional changes -- the result of .cannot_store_register is now checked for a non-zero rather than explicit one. This change makes the API of this backend consistent with that of .cannot_fetch_register. The other change moves the retrieval of the PID used by ptrace in fetch_register to immediately precede the loop it is used in, just like in store_register. No regressions on i686-linux-gnu or mips-linux-gnu (like with the previous change I had to force srv_linux_regsets to "no" and deal with some bitrot of that configuration to get indicative results). OK to apply? 2011-11-22 Maciej W. Rozycki gdb/gdbserver/ * linux-low.c (fetch_register, store_register): Make code consistent, fix formatting. Maciej gdb-gdbserver-linux-fetch-store-format.diff Index: gdb-fsf-trunk-quilt/gdb/gdbserver/linux-low.c =================================================================== --- gdb-fsf-trunk-quilt.orig/gdb/gdbserver/linux-low.c 2011-11-18 17:21:54.425560931 +0000 +++ gdb-fsf-trunk-quilt/gdb/gdbserver/linux-low.c 2011-11-18 17:21:54.445622134 +0000 @@ -3745,10 +3745,11 @@ fetch_register (struct regcache *regcach if (regaddr == -1) return; - pid = lwpid_of (get_thread_lwp (current_inferior)); size = ((register_size (regno) + sizeof (PTRACE_XFER_TYPE) - 1) - & - sizeof (PTRACE_XFER_TYPE)); + & -sizeof (PTRACE_XFER_TYPE)); buf = alloca (size); + + pid = lwpid_of (get_thread_lwp (current_inferior)); for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE)) { errno = 0; @@ -3779,16 +3780,15 @@ store_register (struct regcache *regcach if (regno >= the_low_target.num_regs) return; - - if ((*the_low_target.cannot_store_register) (regno) == 1) + if ((*the_low_target.cannot_store_register) (regno)) return; regaddr = register_addr (regno); if (regaddr == -1) return; - errno = 0; - size = (register_size (regno) + sizeof (PTRACE_XFER_TYPE) - 1) - & - sizeof (PTRACE_XFER_TYPE); + + size = ((register_size (regno) + sizeof (PTRACE_XFER_TYPE) - 1) + & -sizeof (PTRACE_XFER_TYPE)); buf = alloca (size); memset (buf, 0, size);