From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27467 invoked by alias); 19 Jun 2009 16:09:27 -0000 Received: (qmail 27454 invoked by uid 22791); 19 Jun 2009 16:09:25 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from qnxmail.qnx.com (HELO qnxmail.qnx.com) (209.226.137.76) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 19 Jun 2009 16:09:20 +0000 Received: from Nebula.ott.qnx.com (nebula.ott.qnx.com [10.42.3.30]) by hub.ott.qnx.com (8.9.3/8.9.3) with ESMTP id MAA09872; Fri, 19 Jun 2009 12:09:12 -0400 Received: from [127.0.0.1] ([10.42.100.129]) by Nebula.ott.qnx.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 19 Jun 2009 12:09:16 -0400 Message-ID: <4A3BB81E.2080503@qnx.com> Date: Fri, 19 Jun 2009 16:09:00 -0000 From: Aleksandar Ristovski User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: gdb-patches@sources.redhat.com CC: Doug Evans , Daniel Jacobowitz Subject: Re: [patch] gdbserver regcache fetch all regs References: <20090619155537.GA23758@caradoc.them.org> In-Reply-To: <20090619155537.GA23758@caradoc.them.org> Content-Type: multipart/mixed; boundary="------------040902070300030205080207" 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-06/txt/msg00511.txt.bz2 This is a multi-part message in MIME format. --------------040902070300030205080207 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1737 Daniel Jacobowitz wrote: > On Fri, Jun 19, 2009 at 08:35:13AM -0700, Doug Evans wrote: >> Hi. At first I thought "Yikes!". :-) >> But it turns out that all fetch_registers routines treat 0 and -1 equivalently. >> I wouldn't hold up this patch (it's fine with me fwiw), though I would >> change the ChangeLog entry to something like: "Use -1 instead of 0 to >> fetch all registers." since passing 0 does actually fetch all >> registers. > > Agreed on all counts. > >> It would be good to remove this oddity and stop the conflation of 0 >> and -1, but I don't know what would break. >> We could run the testsuite and see what happens as a start. >> Does anyone know the history behind this? > > Pretty sure nothing will break - since nothing else calls these > functions. I could be mistaken though. > Ok, this would be a more complete patch (with cleanups in spots where -1 and 0 are used interchangeably). If you think it would be more appropriate to first commit regcache.c change only, and then the cleanup, let me know. ChangeLog: * linux-low.c (usr_fetch_inferior_registers): Remove check for regno 0. * proc-service.c (ps_lgetregs): Pass -1 to fetch all registers. * regcache.c (get_regcache): Likewise. * spu-low.c (spu_fetch_registers): Remove 0 to -1 conversion. * win32-low.c (child_fetch_inferior_registers): Remove check for regno 0. -- Aleksandar Ristovski QNX Software Systems ChangeLog: * linux-low.c (usr_fetch_inferior_registers): Remove check for regno 0. * proc-service.c (ps_lgetregs): Pass -1 to fetch all registers. * regcache.c (get_regcache): Likewise. * spu-low.c (spu_fetch_registers): Remove 0 to -1 conversion. * win32-low.c (child_fetch_inferior_registers): Remove check for regno 0. --------------040902070300030205080207 Content-Type: text/x-patch; name="gdbserver-regcache.c-fetchallregs-20090619.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gdbserver-regcache.c-fetchallregs-20090619.diff" Content-length: 2842 Index: linux-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v retrieving revision 1.105 diff -u -p -r1.105 linux-low.c --- linux-low.c 24 May 2009 17:44:19 -0000 1.105 +++ linux-low.c 19 Jun 2009 15:56:05 -0000 @@ -2054,7 +2054,7 @@ error_exit:; static void usr_fetch_inferior_registers (int regno) { - if (regno == -1 || regno == 0) + if (regno == -1) for (regno = 0; regno < the_low_target.num_regs; regno++) fetch_register (regno); else Index: proc-service.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/proc-service.c,v retrieving revision 1.12 diff -u -p -r1.12 proc-service.c --- proc-service.c 1 Apr 2009 22:50:24 -0000 1.12 +++ proc-service.c 19 Jun 2009 15:56:05 -0000 @@ -110,7 +110,7 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwp save_inferior = current_inferior; current_inferior = reg_inferior; - the_target->fetch_registers (0); + the_target->fetch_registers (-1); gregset_info()->fill_function (gregset); current_inferior = save_inferior; Index: regcache.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/regcache.c,v retrieving revision 1.19 diff -u -p -r1.19 regcache.c --- regcache.c 22 Mar 2009 23:57:10 -0000 1.19 +++ regcache.c 19 Jun 2009 15:56:05 -0000 @@ -53,7 +53,7 @@ get_regcache (struct thread_info *inf, i /* FIXME - fetch registers for INF */ if (fetch && regcache->registers_valid == 0) { - fetch_inferior_registers (0); + fetch_inferior_registers (-1); regcache->registers_valid = 1; } Index: spu-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/spu-low.c,v retrieving revision 1.24 diff -u -p -r1.24 spu-low.c --- spu-low.c 3 Apr 2009 14:38:39 -0000 1.24 +++ spu-low.c 19 Jun 2009 15:56:06 -0000 @@ -471,10 +471,6 @@ spu_fetch_registers (int regno) int fd; CORE_ADDR addr; - /* ??? Some callers use 0 to mean all registers. */ - if (regno == 0) - regno = -1; - /* We must be stopped on a spu_run system call. */ if (!parse_spufs_run (&fd, &addr)) return; Index: win32-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/win32-low.c,v retrieving revision 1.35 diff -u -p -r1.35 win32-low.c --- win32-low.c 1 Apr 2009 22:50:24 -0000 1.35 +++ win32-low.c 19 Jun 2009 15:56:06 -0000 @@ -331,7 +331,7 @@ child_fetch_inferior_registers (int r) { int regno; win32_thread_info *th = thread_rec (current_inferior_ptid (), TRUE); - if (r == -1 || r == 0 || r > NUM_REGS) + if (r == -1 || r > NUM_REGS) child_fetch_inferior_registers (NUM_REGS); else for (regno = 0; regno < r; regno++) --------------040902070300030205080207--