From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1672 invoked by alias); 4 May 2012 13:08:29 -0000 Received: (qmail 1584 invoked by uid 22791); 4 May 2012 13:08:27 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,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; Fri, 04 May 2012 13:08:14 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1SQIF2-0003Fu-Vf from Yao_Qi@mentor.com ; Fri, 04 May 2012 06:08:13 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 4 May 2012 06:08:12 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.1.289.1; Fri, 4 May 2012 06:08:11 -0700 Message-ID: <4FA3D4B6.2040502@codesourcery.com> Date: Fri, 04 May 2012 13:08:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120412 Thunderbird/11.0.1 MIME-Version: 1.0 To: Pedro Alves CC: 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> <4FA3CC30.70401@redhat.com> In-Reply-To: <4FA3CC30.70401@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-IsSubscribed: yes 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/msg00127.txt.bz2 On 05/04/2012 08:31 PM, Pedro Alves wrote: >> > - 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. > I thought the_low_target.get_pc is to extract value of pc from regcache, so inferior is not needed. I examined linux-foo-low.c files again, and find only ppc_get_pc needs the right inferior, sigh. >> > >> > 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. > So any code needs inferior should be wrapped in the follow manner? save_inferior = current_inferior; current_inferior = reg_inferior; .... .... current_inferior = save_inferior; The following question is what functions need inferior? AFAICS, all the methods in the_low_target and functions in `struct regset_info' need inferior. Anything else? If methods in the_low_target may need inferior, all the usage of the_low_target methods should be wrapped by the block above. Is it correct? I hope I am wrong :) -- Yao (齐尧)