This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Don't attach to 'target_changed' observer in regcache


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]