From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28644 invoked by alias); 26 Jul 2012 14:45:42 -0000 Received: (qmail 28604 invoked by uid 22791); 26 Jul 2012 14:45:40 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_EG,T_FILL_THIS_FORM_SHORT 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; Thu, 26 Jul 2012 14:45:17 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1SuPJV-00003j-3m from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Thu, 26 Jul 2012 07:45:17 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 26 Jul 2012 07:45:17 -0700 Received: from qiyao.dyndns.org.dyndns.org (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; Thu, 26 Jul 2012 07:45:15 -0700 From: Yao Qi To: Subject: [PATCH] remove registers_changed from switch_to_thread Date: Thu, 26 Jul 2012 14:45:00 -0000 Message-ID: <1343313892-30424-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-07/txt/msg00616.txt.bz2 Hi, When reading the code, I find registers_changed is called from switch_to_thread, which confuses me a little bit. We have regcache, and each thread has its own regcache. Why do we have to invalidate all regcaches during thread switch? The line of calling registers_changed in switch_to_thread is quite old, it was written in gdb 4.10 (1993). At that time, we didn't have regcache, and register state is a global state. There is also a global variable 'registers_pid' associated with the global register state. When thread switches, 'registers_pid' should be updated. That is the reason why registers_changed should be called in switch_to_thread. So we don't have to do it now. This patch is to remove this line. Regression tested on x86_64 native and gdbserver. OK to apply? Note that this patch hightly reduced the allocation and deallocation of regcache, especially in multi-threaded program. Here are some statistics data I collected when running testsuite. (gdb) PASS: gdb.multi/base.exp: check remove-inferiors maintenance info statistics^M Name Allocate Free ^M frame info 19 8 ^M -regcache 36 35 ^M +regcache 8 7 (gdb) PASS: gdb.threads/create-fail.exp: iteration 3: run till end maintenance info statistics^M Name Allocate Free ^M frame info 156 78 ^M -regcache 269 269 ^M +regcache 103 103 ^M (gdb) PASS: gdb.threads/create-fail.exp: iteration 4: run till end maintenance info statistics^M Name Allocate Free ^M frame info 156 78 ^M -regcache 315 315 ^M +regcache 96 96 ^M gdb: 2012-07-26 Yao Qi * thread.c (switch_to_thread): Don't call registers_changed. --- gdb/thread.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/gdb/thread.c b/gdb/thread.c index ff5220d..7e8eec5 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -987,7 +987,6 @@ switch_to_thread (ptid_t ptid) inferior_ptid = ptid; reinit_frame_cache (); - registers_changed (); /* We don't check for is_stopped, because we're called at times while in the TARGET_RUNNING state, e.g., while handling an -- 1.7.7.6