2007-07-02 Markus Deuling <deuling@de.ibm.com>
[deliverable/binutils-gdb.git] / gdb / aix-thread.c
index 65c9e81495952cafbf6d166a1dd1e43697c0c243..4ad6a479a968d7ab27812260b9979f1e8fc93856 100644 (file)
@@ -50,6 +50,7 @@
 #include "gdbcmd.h"
 #include "ppc-tdep.h"
 #include "gdb_string.h"
+#include "observer.h"
 
 #include <procinfo.h>
 #include <sys/types.h>
@@ -129,11 +130,6 @@ static int pd_active = 0;
 
 static int arch64;
 
-/* Saved pointer to previous owner of
-   deprecated_target_new_objfile_hook.  */
-
-static void (*target_new_objfile_chain)(struct objfile *);
-
 /* Forward declarations for pthdb callbacks.  */
 
 static int pdc_symbol_addrs (pthdb_user_t, pthdb_symbol_t *, int);
@@ -925,7 +921,7 @@ pd_disable (void)
   unpush_target (&aix_thread_ops);
 }
 
-/* deprecated_target_new_objfile_hook callback.
+/* new_objfile observer callback.
 
    If OBJFILE is non-null, check whether a threaded application is
    being debugged, and if so, prepare for thread debugging.
@@ -939,9 +935,6 @@ new_objfile (struct objfile *objfile)
     pd_enable ();
   else
     pd_disable ();
-
-  if (target_new_objfile_chain)
-    target_new_objfile_chain (objfile);
 }
 
 /* Attach to process specified by ARGS.  */
@@ -1020,8 +1013,9 @@ aix_thread_wait (ptid_t ptid, struct target_waitstatus *status)
 
   /* Check whether libpthdebug might be ready to be initialized.  */
   if (!pd_active && status->kind == TARGET_WAITKIND_STOPPED &&
-      status->value.sig == TARGET_SIGNAL_TRAP &&
-      read_pc_pid (ptid) - DECR_PC_AFTER_BREAK == pd_brk_addr)
+      status->value.sig == TARGET_SIGNAL_TRAP
+      && read_pc_pid (ptid)
+        - gdbarch_decr_pc_after_break (current_gdbarch) == pd_brk_addr)
     return pd_activate (0);
 
   return pd_update (0);
@@ -1071,7 +1065,7 @@ special_register_p (int regno)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
 
-  return regno == PC_REGNUM
+  return regno == gdbarch_pc_regnum (current_gdbarch)
       || regno == tdep->ppc_ps_regnum
       || regno == tdep->ppc_cr_regnum
       || regno == tdep->ppc_lr_regnum
@@ -1093,7 +1087,8 @@ supply_sprs64 (struct regcache *regcache,
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
 
-  regcache_raw_supply (regcache, PC_REGNUM, (char *) &iar);
+  regcache_raw_supply (regcache, gdbarch_pc_regnum (current_gdbarch),
+                      (char *) &iar);
   regcache_raw_supply (regcache, tdep->ppc_ps_regnum, (char *) &msr);
   regcache_raw_supply (regcache, tdep->ppc_cr_regnum, (char *) &cr);
   regcache_raw_supply (regcache, tdep->ppc_lr_regnum, (char *) &lr);
@@ -1115,7 +1110,8 @@ supply_sprs32 (struct regcache *regcache,
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
 
-  regcache_raw_supply (regcache, PC_REGNUM, (char *) &iar);
+  regcache_raw_supply (regcache, gdbarch_pc_regnum (current_gdbarch),
+                      (char *) &iar);
   regcache_raw_supply (regcache, tdep->ppc_ps_regnum, (char *) &msr);
   regcache_raw_supply (regcache, tdep->ppc_cr_regnum, (char *) &cr);
   regcache_raw_supply (regcache, tdep->ppc_lr_regnum, (char *) &lr);
@@ -1270,22 +1266,22 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
    thread/process specified by inferior_ptid.  */
 
 static void
-aix_thread_fetch_registers (int regno)
+aix_thread_fetch_registers (struct regcache *regcache, int regno)
 {
   struct thread_info *thread;
   pthdb_tid_t tid;
 
   if (!PD_TID (inferior_ptid))
-    base_target.to_fetch_registers (regno);
+    base_target.to_fetch_registers (regcache, regno);
   else
     {
       thread = find_thread_pid (inferior_ptid);
       tid = thread->private->tid;
 
       if (tid == PTHDB_INVALID_TID)
-       fetch_regs_user_thread (current_regcache, thread->private->pdtid);
+       fetch_regs_user_thread (regcache, thread->private->pdtid);
       else
-       fetch_regs_kernel_thread (current_regcache, regno, tid);
+       fetch_regs_kernel_thread (regcache, regno, tid);
     }
 }
 
@@ -1349,10 +1345,12 @@ fill_sprs64 (const struct regcache *regcache,
      they're not, then either GDB has been built incorrectly, or
      there's some other kind of internal error.  To be really safe,
      we should check all of the sizes.   */
-  gdb_assert (sizeof (*iar) == register_size (current_gdbarch, PC_REGNUM));
+  gdb_assert (sizeof (*iar) == register_size
+                                (current_gdbarch,
+                                 gdbarch_pc_regnum (current_gdbarch)));
 
-  if (regcache_valid_p (regcache, PC_REGNUM))
-    regcache_raw_collect (regcache, PC_REGNUM, iar);
+  if (regcache_valid_p (regcache, gdbarch_pc_regnum (current_gdbarch)))
+    regcache_raw_collect (regcache, gdbarch_pc_regnum (current_gdbarch), iar);
   if (regcache_valid_p (regcache, tdep->ppc_ps_regnum))
     regcache_raw_collect (regcache, tdep->ppc_ps_regnum, msr);
   if (regcache_valid_p (regcache, tdep->ppc_cr_regnum))
@@ -1381,10 +1379,12 @@ fill_sprs32 (const struct regcache *regcache,
      they're not, then either GDB has been built incorrectly, or
      there's some other kind of internal error.  To be really safe,
      we should check all of the sizes.  */
-  gdb_assert (sizeof (*iar) == register_size (current_gdbarch, PC_REGNUM));
+  gdb_assert (sizeof (*iar) == register_size (current_gdbarch,
+                                             gdbarch_pc_regnum
+                                             (current_gdbarch)));
 
-  if (regcache_valid_p (regcache, PC_REGNUM))
-    regcache_raw_collect (regcache, PC_REGNUM, iar);
+  if (regcache_valid_p (regcache, gdbarch_pc_regnum (current_gdbarch)))
+    regcache_raw_collect (regcache, gdbarch_pc_regnum (current_gdbarch), iar);
   if (regcache_valid_p (regcache, tdep->ppc_ps_regnum))
     regcache_raw_collect (regcache, tdep->ppc_ps_regnum, msr);
   if (regcache_valid_p (regcache, tdep->ppc_cr_regnum))
@@ -1465,7 +1465,7 @@ store_regs_user_thread (const struct regcache *regcache, pthdb_pthread_t pdtid)
 
       fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr, &tmp_ctr,
                             &tmp_xer, &tmp_fpscr);
-      if (regcache_valid_p (regcache, PC_REGNUM))
+      if (regcache_valid_p (regcache, gdbarch_pc_regnum (current_gdbarch)))
        ctx.iar = tmp_iar;
       if (regcache_valid_p (regcache, tdep->ppc_ps_regnum))
        ctx.msr = tmp_msr;
@@ -1602,22 +1602,22 @@ store_regs_kernel_thread (const struct regcache *regcache, int regno,
    thread/process specified by inferior_ptid.  */
 
 static void
-aix_thread_store_registers (int regno)
+aix_thread_store_registers (struct regcache *regcache, int regno)
 {
   struct thread_info *thread;
   pthdb_tid_t tid;
 
   if (!PD_TID (inferior_ptid))
-    base_target.to_store_registers (regno);
+    base_target.to_store_registers (regcache, regno);
   else
     {
       thread = find_thread_pid (inferior_ptid);
       tid = thread->private->tid;
 
       if (tid == PTHDB_INVALID_TID)
-       store_regs_user_thread (current_regcache, thread->private->pdtid);
+       store_regs_user_thread (regcache, thread->private->pdtid);
       else
-       store_regs_kernel_thread (current_regcache, regno, tid);
+       store_regs_kernel_thread (regcache, regno, tid);
     }
 }
 
@@ -1792,8 +1792,7 @@ _initialize_aix_thread (void)
   add_target (&aix_thread_ops);
 
   /* Notice when object files get loaded and unloaded.  */
-  target_new_objfile_chain = deprecated_target_new_objfile_hook;
-  deprecated_target_new_objfile_hook = new_objfile;
+  observer_attach_new_objfile (new_objfile);
 
   add_setshow_boolean_cmd ("aix-thread", class_maintenance, &debug_aix_thread,
                            _("Set debugging of AIX thread module."),
This page took 0.026243 seconds and 4 git commands to generate.