Protoization.
[deliverable/binutils-gdb.git] / gdb / hpux-thread.c
index 5064d6869a1cb4194bb052d8747bb2ac3d239daa..940ba9a338c89507a1d75fc052895a5ddfe98ec6 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
@@ -102,26 +100,25 @@ static struct target_ops hpux_thread_ops;
 
 
 static struct cleanup *
-save_inferior_pid ()
+save_inferior_pid (void)
 {
   return make_cleanup (restore_inferior_pid, inferior_pid);
 }
 
 static void
-restore_inferior_pid (pid)
-     int pid;
+restore_inferior_pid (int 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;
 static cma__t_int_tcb cached_tcb;
 
 static int
-find_active_thread ()
+find_active_thread (void)
 {
   static cma__t_int_tcb tcb;
   CORE_ADDR tcb_ptr;
@@ -138,11 +135,10 @@ 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)
-     int thread;
+find_tcb (int thread)
 {
   cma__t_known_object queue_header;
   cma__t_queue *queue_ptr;
@@ -181,9 +177,7 @@ find_tcb (thread)
 
 /* ARGSUSED */
 static void
-hpux_thread_open (arg, from_tty)
-     char *arg;
-     int from_tty;
+hpux_thread_open (char *arg, int from_tty)
 {
   child_ops.to_open (arg, from_tty);
 }
@@ -192,9 +186,7 @@ hpux_thread_open (arg, from_tty)
    and wait for the trace-trap that results from attaching.  */
 
 static void
-hpux_thread_attach (args, from_tty)
-     char *args;
-     int from_tty;
+hpux_thread_attach (char *args, int from_tty)
 {
   child_ops.to_attach (args, from_tty);
 
@@ -210,9 +202,7 @@ hpux_thread_attach (args, from_tty)
    started via the normal ptrace (PTRACE_TRACEME).  */
 
 static void
-hpux_thread_detach (args, from_tty)
-     char *args;
-     int from_tty;
+hpux_thread_detach (char *args, int from_tty)
 {
   child_ops.to_detach (args, from_tty);
 }
@@ -223,10 +213,7 @@ hpux_thread_detach (args, from_tty)
    for procfs.  */
 
 static void
-hpux_thread_resume (pid, step, signo)
-     int pid;
-     int step;
-     enum target_signal signo;
+hpux_thread_resume (int pid, int step, enum target_signal signo)
 {
   struct cleanup *old_chain;
 
@@ -255,9 +242,7 @@ hpux_thread_resume (pid, step, signo)
    to a LWP id, and vice versa on the way out.  */
 
 static int
-hpux_thread_wait (pid, ourstatus)
-     int pid;
-     struct target_waitstatus *ourstatus;
+hpux_thread_wait (int pid, struct target_waitstatus *ourstatus)
 {
   int rtnval;
   struct cleanup *old_chain;
@@ -305,8 +290,7 @@ static char regmap[NUM_REGS] =
 };
 
 static void
-hpux_thread_fetch_registers (regno)
-     int regno;
+hpux_thread_fetch_registers (int regno)
 {
   cma__t_int_tcb tcb, *tcb_ptr;
   struct cleanup *old_chain;
@@ -368,8 +352,7 @@ hpux_thread_fetch_registers (regno)
 }
 
 static void
-hpux_thread_store_registers (regno)
-     int regno;
+hpux_thread_store_registers (int regno)
 {
   cma__t_int_tcb tcb, *tcb_ptr;
   struct cleanup *old_chain;
@@ -444,7 +427,7 @@ hpux_thread_store_registers (regno)
    debugged.  */
 
 static void
-hpux_thread_prepare_to_store ()
+hpux_thread_prepare_to_store (void)
 {
   child_ops.to_prepare_to_store ();
 }
@@ -474,21 +457,19 @@ hpux_thread_xfer_memory (memaddr, myaddr, len, dowrite, target)
 /* Print status information about what we're accessing.  */
 
 static void
-hpux_thread_files_info (ignore)
-     struct target_ops *ignore;
+hpux_thread_files_info (struct target_ops *ignore)
 {
   child_ops.to_files_info (ignore);
 }
 
 static void
-hpux_thread_kill_inferior ()
+hpux_thread_kill_inferior (void)
 {
   child_ops.to_kill ();
 }
 
 static void
-hpux_thread_notice_signals (pid)
-     int pid;
+hpux_thread_notice_signals (int pid)
 {
   child_ops.to_notice_signals (pid);
 }
@@ -496,10 +477,7 @@ hpux_thread_notice_signals (pid)
 /* Fork an inferior process, and start debugging it with /proc.  */
 
 static void
-hpux_thread_create_inferior (exec_file, allargs, env)
-     char *exec_file;
-     char *allargs;
-     char **env;
+hpux_thread_create_inferior (char *exec_file, char *allargs, char **env)
 {
   child_ops.to_create_inferior (exec_file, allargs, env);
 
@@ -521,40 +499,49 @@ 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;
+hpux_thread_new_objfile (struct objfile *objfile)
 {
   struct minimal_symbol *ms;
 
   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.  */
 
 static void
-hpux_thread_mourn_inferior ()
+hpux_thread_mourn_inferior (void)
 {
   child_ops.to_mourn_inferior ();
 }
@@ -562,20 +549,19 @@ hpux_thread_mourn_inferior ()
 /* Mark our target-struct as eligible for stray "run" and "attach" commands.  */
 
 static int
-hpux_thread_can_run ()
+hpux_thread_can_run (void)
 {
   return child_suppress_run;
 }
 
 static int
-hpux_thread_alive (pid)
-     int pid;
+hpux_thread_alive (int pid)
 {
   return 1;
 }
 
 static void
-hpux_thread_stop ()
+hpux_thread_stop (void)
 {
   child_ops.to_stop ();
 }
@@ -583,8 +569,7 @@ hpux_thread_stop ()
 /* Convert a pid to printable form. */
 
 char *
-hpux_pid_to_str (pid)
-     int pid;
+hpux_pid_to_str (int pid)
 {
   static char buf[100];
 
@@ -594,7 +579,7 @@ hpux_pid_to_str (pid)
 }
 \f
 static void
-init_hpux_thread_ops ()
+init_hpux_thread_ops (void)
 {
   hpux_thread_ops.to_shortname = "hpux-threads";
   hpux_thread_ops.to_longname = "HPUX threads and pthread.";
@@ -633,10 +618,13 @@ init_hpux_thread_ops ()
 }
 
 void
-_initialize_hpux_thread ()
+_initialize_hpux_thread (void)
 {
   init_hpux_thread_ops ();
   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;
 }
This page took 0.026721 seconds and 4 git commands to generate.