Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Don't attach to 'target_changed' observer in regcache
@ 2012-08-02  7:17 Yao Qi
  2012-08-02 14:46 ` Pedro Alves
  2012-08-08 17:54 ` Mark Kettenis
  0 siblings, 2 replies; 8+ messages in thread
From: Yao Qi @ 2012-08-02  7:17 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-08-21 19:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-02  7:17 [PATCH] Don't attach to 'target_changed' observer in regcache Yao Qi
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox