From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7161 invoked by alias); 4 May 2012 10:52:11 -0000 Received: (qmail 7148 invoked by uid 22791); 4 May 2012 10:52:10 -0000 X-SWARE-Spam-Status: No, hits=-3.1 required=5.0 tests=AWL,BAYES_00,FROM_12LTRDOM,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,SUBJ_OBFU_PUNCT_FEW,SUBJ_OBFU_PUNCT_MANY,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 10:51:53 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1SQG76-0007Ax-GF from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Fri, 04 May 2012 03:51:52 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 4 May 2012 03:51:52 -0700 Received: from localhost.localdomain (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.1.289.1; Fri, 4 May 2012 03:51:51 -0700 From: Yao Qi To: Subject: [PATCH/gdbserver] Remove current_inferior's save/restore when call get_thread_regcache. Date: Fri, 04 May 2012 10:52:00 -0000 Message-ID: <1336128707-26498-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain 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/msg00123.txt.bz2 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); 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); 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); - current_inferior = save_inferior; return PS_OK; #else return PS_ERR; -- 1.7.0.4