From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14554 invoked by alias); 2 Aug 2012 07:17:54 -0000 Received: (qmail 14541 invoked by uid 22791); 2 Aug 2012 07:17:52 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,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; Thu, 02 Aug 2012 07:17:39 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1Swpf8-0007X7-KQ from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Thu, 02 Aug 2012 00:17:38 -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); Thu, 2 Aug 2012 00:17:38 -0700 Received: from qiyao.dyndns.org.dyndns.org (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; Thu, 2 Aug 2012 00:17:37 -0700 From: Yao Qi To: Subject: [PATCH] Don't attach to 'target_changed' observer in regcache Date: Thu, 02 Aug 2012 07:17:00 -0000 Message-ID: <1343891847-16554-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-08/txt/msg00053.txt.bz2 Hi, When I am modifying 'target_changed' observer, I don't understand why we attach regcache_observer_target_changed to 'target_changed' observer, and invalidates all regcache. 'target_changed' observer is notified in valops.c:value_assign, before that, register is modified by calling either gdbarch_value_to_register or put_frame_register_bytes. Looks like regcache is in a good state, why do we have to invalidate them? The code that invalidates all regcache was added by this patch, Multiplexed registers and invalidating the register cache http://sourceware.org/ml/gdb-patches/2004-04/msg00282.html The author (Orjan) tried to support "changing the bank select register changes the contents (and meaning) for a whole set of other registers." The requirement is quite specific to Orjan's own port, so the better solution is to attach a function which invalidates all regcache in Orjan's backend, instead of doing it in target-independent part. With this patch, I can see that the number of regcache allocation/release is reduced (16 -> 15) in test case (mi-cli.exp). For a large multi-threaded app, we'll get better gain. Regression tested on x86_64-linux native and gdbserver. OK for HEAD? gdb: 2012-08-02 Yao Qi * regcache.c (regcache_observer_target_changed): Remove. (_initialize_regcache): Don't call observer_attach_target_changed. --- gdb/regcache.c | 10 ---------- 1 files changed, 0 insertions(+), 10 deletions(-) diff --git a/gdb/regcache.c b/gdb/regcache.c index c716280..3f83cfa 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -512,15 +512,6 @@ get_current_regcache (void) return get_thread_regcache (inferior_ptid); } - -/* Observer for the target_changed event. */ - -static void -regcache_observer_target_changed (struct target_ops *target) -{ - registers_changed (); -} - /* Update global variables old ptids to hold NEW_PTID if they were holding OLD_PTID. */ static void @@ -1405,7 +1396,6 @@ _initialize_regcache (void) regcache_descr_handle = gdbarch_data_register_post_init (init_regcache_descr); - observer_attach_target_changed (regcache_observer_target_changed); observer_attach_thread_ptid_changed (regcache_thread_ptid_changed); add_com ("flushregs", class_maintenance, reg_flush_command, -- 1.7.7.6