From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24842 invoked by alias); 4 May 2012 12:32:07 -0000 Received: (qmail 24824 invoked by uid 22791); 4 May 2012 12:32:04 -0000 X-SWARE-Spam-Status: No, hits=-7.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,TW_EG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 04 May 2012 12:31:49 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q44CVkIx017014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 4 May 2012 08:31:46 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q44CVisC030834; Fri, 4 May 2012 08:31:45 -0400 Message-ID: <4FA3CC30.70401@redhat.com> Date: Fri, 04 May 2012 12:32:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120424 Thunderbird/12.0 MIME-Version: 1.0 To: Yao Qi CC: gdb-patches@sourceware.org Subject: Re: [PATCH/gdbserver] Remove current_inferior's save/restore when call get_thread_regcache. References: <1336128707-26498-1-git-send-email-yao@codesourcery.com> In-Reply-To: <1336128707-26498-1-git-send-email-yao@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 2012-05/txt/msg00125.txt.bz2 On 05/04/2012 11:51 AM, Yao Qi wrote: > Hi, > The current_inferior is saved and restored inside get_thread_regcache, > so it is not necessary to save and restore current_inferior out side > of it. > > Regression tested on x86_64-linux. OK to apply? > > > gdb/gdbserver: > > 2012-05-04 Yao Qi > > * linux-low.c (get_pc, linux_wait_for_lwp): Don't save and restore > current_inferior when call get_thread_cache. > * proc-service.c (ps_lgetregs): Likewise. > --- > gdb/gdbserver/linux-low.c | 12 ++---------- > gdb/gdbserver/proc-service.c | 7 +------ > 2 files changed, 3 insertions(+), 16 deletions(-) > > diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c > index 751867b..64d314c 100644 > --- a/gdb/gdbserver/linux-low.c > +++ b/gdb/gdbserver/linux-low.c > @@ -503,23 +503,18 @@ handle_extended_wait (struct lwp_info *event_child, int wstat) > static CORE_ADDR > get_pc (struct lwp_info *lwp) > { > - struct thread_info *saved_inferior; > struct regcache *regcache; > CORE_ADDR pc; > > if (the_low_target.get_pc == NULL) > return 0; > > - saved_inferior = current_inferior; > - current_inferior = get_lwp_thread (lwp); > - > - regcache = get_thread_regcache (current_inferior, 1); > + regcache = get_thread_regcache (get_lwp_thread (lwp), 1); > pc = (*the_low_target.get_pc) (regcache); No, the_low_target.get_pc also needs to go to the right inferior. > > if (debug_threads) > fprintf (stderr, "pc is 0x%lx\n", (long) pc); > > - current_inferior = saved_inferior; > return pc; > } > > @@ -1425,15 +1420,12 @@ retry: > && WIFSTOPPED (*wstatp) > && the_low_target.get_pc != NULL) > { > - struct thread_info *saved_inferior = current_inferior; > struct regcache *regcache; > CORE_ADDR pc; > > - current_inferior = get_lwp_thread (child); > - regcache = get_thread_regcache (current_inferior, 1); > + regcache = get_thread_regcache (get_lwp_thread (child), 1); > pc = (*the_low_target.get_pc) (regcache); Ditto. > fprintf (stderr, "linux_wait_for_lwp: pc is 0x%lx\n", (long) pc); > - current_inferior = saved_inferior; > } > > return child; > diff --git a/gdb/gdbserver/proc-service.c b/gdb/gdbserver/proc-service.c > index 5584dab..d4c17a2 100644 > --- a/gdb/gdbserver/proc-service.c > +++ b/gdb/gdbserver/proc-service.c > @@ -99,20 +99,15 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset) > { > #ifdef HAVE_REGSETS > struct lwp_info *lwp; > - struct thread_info *reg_inferior, *save_inferior; > struct regcache *regcache; > > lwp = find_lwp_pid (pid_to_ptid (lwpid)); > if (lwp == NULL) > return PS_ERR; > > - reg_inferior = get_lwp_thread (lwp); > - save_inferior = current_inferior; > - current_inferior = reg_inferior; > - regcache = get_thread_regcache (current_inferior, 1); > + regcache = get_thread_regcache (get_lwp_thread (lwp), 1); > gregset_info ()->fill_function (regcache, gregset); Ditto the whole gregset_info ()->fill_function line, particularly after my multi-process/multi-arch series, while the fill_function depends on inferior. > > - current_inferior = save_inferior; > return PS_OK; > #else > return PS_ERR; -- Pedro Alves