Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH] Don't attach to 'target_changed' observer in regcache
Date: Thu, 02 Aug 2012 07:17:00 -0000	[thread overview]
Message-ID: <1343891847-16554-1-git-send-email-yao@codesourcery.com> (raw)

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  <yao@codesourcery.com>

	* 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


             reply	other threads:[~2012-08-02  7:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-02  7:17 Yao Qi [this message]
2012-08-02 14:46 ` Pedro Alves
2012-08-02 15:40   ` Yao Qi
2012-08-08 17:54 ` Mark Kettenis
2012-08-09  3:11   ` Yao Qi
2012-08-09  8:12     ` Mark Kettenis
2012-08-09  8:37       ` Yao Qi
2012-08-21 19:39         ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343891847-16554-1-git-send-email-yao@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox