This commit was generated by cvs2svn to track changes on a CVS vendor
[binutils-gdb.git] / gdb / hpux-thread.c
index 5064d6869a1cb4194bb052d8747bb2ac3d239daa..f27d12b72f2e5a91c1fa91ed287749c32a9d0cc0 100644 (file)
 #include "target.h"
 #include "inferior.h"
 #include <fcntl.h>
-#include <unistd.h>
 #include <sys/stat.h>
 #include "gdbcore.h"
 
 extern int child_suppress_run;
 extern struct target_ops child_ops;    /* target vector for inftarg.c */
 
-extern void _initialize_hpux_thread PARAMS ((void));
+extern void _initialize_hpux_thread (void);
 
 struct string_map
   {
@@ -62,14 +61,13 @@ static int main_pid;                /* Real process ID */
 static CORE_ADDR P_cma__g_known_threads;
 static CORE_ADDR P_cma__g_current_thread;
 
-static struct cleanup *save_inferior_pid PARAMS ((void));
+static struct cleanup *save_inferior_pid (void);
 
-static void restore_inferior_pid PARAMS ((int pid));
+static void restore_inferior_pid (int pid);
 
-static void hpux_thread_resume PARAMS ((int pid, int step,
-                                       enum target_signal signo));
+static void hpux_thread_resume (int pid, int step, enum target_signal signo);
 
-static void init_hpux_thread_ops PARAMS ((void));
+static void init_hpux_thread_ops (void);
 
 static struct target_ops hpux_thread_ops;
 \f
@@ -114,7 +112,7 @@ restore_inferior_pid (pid)
   inferior_pid = pid;
 }
 \f
-static int find_active_thread PARAMS ((void));
+static int find_active_thread (void);
 
 static int cached_thread;
 static int cached_active_thread;
@@ -138,7 +136,7 @@ find_active_thread ()
   return (cma_thread_get_unique (&tcb.prolog.client_thread) << 16) | main_pid;
 }
 
-static cma__t_int_tcb *find_tcb PARAMS ((int thread));
+static cma__t_int_tcb *find_tcb (int thread);
 
 static cma__t_int_tcb *
 find_tcb (thread)
@@ -521,6 +519,13 @@ hpux_thread_create_inferior (exec_file, allargs, env)
    those variables don't show up until the library gets mapped and the symbol
    table is read in.  */
 
+/* This new_objfile event is now managed by a chained function pointer. 
+ * It is the callee's responsability to call the next client on the chain.
+ */
+
+/* Saved pointer to previous owner of the new_objfile event. */
+static void (*target_new_objfile_chain) (struct objfile *);
+
 void
 hpux_thread_new_objfile (objfile)
      struct objfile *objfile;
@@ -530,25 +535,28 @@ hpux_thread_new_objfile (objfile)
   if (!objfile)
     {
       hpux_thread_active = 0;
-
-      return;
+      goto quit;
     }
 
   ms = lookup_minimal_symbol ("cma__g_known_threads", NULL, objfile);
 
   if (!ms)
-    return;
+    goto quit;
 
   P_cma__g_known_threads = SYMBOL_VALUE_ADDRESS (ms);
 
   ms = lookup_minimal_symbol ("cma__g_current_thread", NULL, objfile);
 
   if (!ms)
-    return;
+    goto quit;
 
   P_cma__g_current_thread = SYMBOL_VALUE_ADDRESS (ms);
 
   hpux_thread_active = 1;
+quit:
+  /* Call predecessor on chain, if any. */
+  if (target_new_objfile_chain)
+    target_new_objfile_chain (objfile);
 }
 
 /* Clean up after the inferior dies.  */
@@ -639,4 +647,7 @@ _initialize_hpux_thread ()
   add_target (&hpux_thread_ops);
 
   child_suppress_run = 1;
+  /* Hook into new_objfile notification. */
+  target_new_objfile_chain = target_new_objfile_hook;
+  target_new_objfile_hook  = hpux_thread_new_objfile;
 }