* ltconfig, ltmain.sh, libtool.m4, ltcf-c.sh, ltcf-cxx.sh,
[deliverable/binutils-gdb.git] / gdb / m3-nat.c
index 79317bcf18298eb53894abad9f9165d38262f80e..3ab160b3cb8dffe690b74b729f60bc95169c231d 100644 (file)
@@ -1,7 +1,8 @@
 /* Interface GDB to Mach 3.0 operating systems.
    (Most) Mach 3.0 related routines live in this file.
 
-   Copyright (C) 1992, 1996, 1999 Free Software Foundation, Inc.
+   Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "value.h"
 #include "language.h"
 #include "target.h"
-#include "wait.h"
+#include "gdb_wait.h"
 #include "gdbcmd.h"
 #include "gdbcore.h"
+#include "regcache.h"
 
 #if 0
 #include <servers/machid_lib.h>
@@ -207,9 +209,7 @@ int debug_level = 0;
 
 /* "Temporary" debug stuff */
 void
-xx_debug (fmt, a, b, c)
-     char *fmt;
-     int a, b, c;
+xx_debug (char *fmt, int a, int b, int c)
 {
   if (debug_level)
     warning (fmt, a, b, c);
@@ -318,10 +318,7 @@ struct obstack *cproc_obstack = &Cproc_obstack;
 port_chain_t notify_chain = (port_chain_t) NULL;
 
 port_chain_t
-port_chain_insert (list, name, type)
-     port_chain_t list;
-     mach_port_t name;
-     int type;
+port_chain_insert (port_chain_t list, mach_port_t name, int type)
 {
   kern_return_t ret;
   port_chain_t new;
@@ -350,7 +347,7 @@ port_chain_insert (list, name, type)
        }
     }
   else
-    abort ();
+    internal_error (__FILE__, __LINE__, "failed internal consistency check");
 
   new = (port_chain_t) obstack_alloc (port_chain_obstack,
                                      sizeof (struct port_chain));
@@ -363,9 +360,7 @@ port_chain_insert (list, name, type)
 }
 
 port_chain_t
-port_chain_delete (list, elem)
-     port_chain_t list;
-     mach_port_t elem;
+port_chain_delete (port_chain_t list, mach_port_t elem)
 {
   if (list)
     if (list->port == elem)
@@ -382,17 +377,14 @@ port_chain_delete (list, elem)
 }
 
 void
-port_chain_destroy (ostack)
-     struct obstack *ostack;
+port_chain_destroy (struct obstack *ostack)
 {
   obstack_free (ostack, 0);
   obstack_init (ostack);
 }
 
 port_chain_t
-port_chain_member (list, elem)
-     port_chain_t list;
-     mach_port_t elem;
+port_chain_member (port_chain_t list, mach_port_t elem)
 {
   while (list)
     {
@@ -404,9 +396,7 @@ port_chain_member (list, elem)
 }
 \f
 int
-map_port_name_to_mid (name, type)
-     mach_port_t name;
-     int type;
+map_port_name_to_mid (mach_port_t name, int type)
 {
   port_chain_t elem;
 
@@ -445,8 +435,7 @@ map_port_name_to_mid (name, type)
 \f
 /* Guard for currently_waiting_for and singlestepped_thread_port */
 static void
-discard_single_step (thread)
-     thread_t thread;
+discard_single_step (thread_t thread)
 {
   currently_waiting_for = inferior_wait_port_set;
 
@@ -455,9 +444,7 @@ discard_single_step (thread)
     setup_single_step (thread, FALSE);
 }
 
-setup_single_step (thread, start_step)
-     thread_t thread;
-     boolean_t start_step;
+setup_single_step (thread_t thread, boolean_t start_step)
 {
   kern_return_t ret;
 
@@ -545,10 +532,7 @@ setup_single_step (thread, start_step)
 }
 \f
 static
-request_notify (name, variant, type)
-     mach_port_t name;
-     mach_msg_id_t variant;
-     int type;
+request_notify (mach_port_t name, mach_msg_id_t variant, int type)
 {
   kern_return_t ret;
   mach_port_t previous_port_dummy = MACH_PORT_NULL;
@@ -574,9 +558,7 @@ request_notify (name, variant, type)
   notify_chain = port_chain_insert (notify_chain, name, type);
 }
 
-reverse_msg_bits (msgp, type)
-     mach_msg_header_t *msgp;
-     int type;
+reverse_msg_bits (mach_msg_header_t *msgp, int type)
 {
   int rbits, lbits;
   rbits = MACH_MSGH_BITS_REMOTE (msgp->msgh_bits);
@@ -612,7 +594,7 @@ mach_port_t original_server_port_name = MACH_PORT_NULL;
 
 /* Called from inferior after FORK but before EXEC */
 static void
-m3_trace_me ()
+m3_trace_me (void)
 {
   kern_return_t ret;
 
@@ -621,17 +603,17 @@ m3_trace_me ()
   ret = task_get_bootstrap_port (mach_task_self (),
                                 &original_server_port_name);
   if (ret != KERN_SUCCESS)
-    abort ();
+    internal_error (__FILE__, __LINE__, "failed internal consistency check");
   ret = mach_port_deallocate (mach_task_self (),
                              original_server_port_name);
   if (ret != KERN_SUCCESS)
-    abort ();
+    internal_error (__FILE__, __LINE__, "failed internal consistency check");
 
   /* Suspend this task to let the parent change my ports.
      Resumed by the debugger */
   ret = task_suspend (mach_task_self ());
   if (ret != KERN_SUCCESS)
-    abort ();
+    internal_error (__FILE__, __LINE__, "failed internal consistency check");
 }
 \f
 /*
@@ -643,8 +625,7 @@ m3_trace_me ()
  */
 
 void
-intercept_exec_calls (exec_counter)
-     int exec_counter;
+intercept_exec_calls (int exec_counter)
 {
   int terminal_initted = 0;
 
@@ -713,7 +694,7 @@ intercept_exec_calls (exec_counter)
   CHK ("mach_port_extract_right (bsd server send)", ret);
 
   if (acquired != MACH_MSG_TYPE_PORT_SEND)
-    error ("Incorrect right extracted, send right to bsd server excpected");
+    error ("Incorrect right extracted, send right to bsd server expected");
 
   ret = mach_port_insert_right (inferior_task,
                                original_server_port_name,
@@ -740,7 +721,7 @@ intercept_exec_calls (exec_counter)
   CHK ("mach_port_extract_right (exec_reply)", ret);
 
   if (acquired != MACH_MSG_TYPE_PORT_SEND_ONCE)
-    error ("Incorrect right extracted, send once excpected for exec reply");
+    error ("Incorrect right extracted, send once expected for exec reply");
 
   ret = mach_port_move_member (mach_task_self (),
                               fake_server,
@@ -878,9 +859,7 @@ intercept_exec_calls (exec_counter)
 }
 
 void
-consume_send_rights (thread_list, thread_count)
-     thread_array_t thread_list;
-     int thread_count;
+consume_send_rights (thread_array_t thread_list, int thread_count)
 {
   int index;
 
@@ -896,9 +875,7 @@ consume_send_rights (thread_list, thread_count)
 }
 
 /* suspend/abort/resume a thread. */
-setup_thread (thread, what)
-     mach_port_t thread;
-     int what;
+setup_thread (mach_port_t thread, int what)
 {
   kern_return_t ret;
 
@@ -918,10 +895,7 @@ setup_thread (thread, what)
 }
 
 int
-map_slot_to_mid (slot, threads, thread_count)
-     int slot;
-     thread_array_t threads;
-     int thread_count;
+map_slot_to_mid (int slot, thread_array_t threads, int thread_count)
 {
   kern_return_t ret;
   int deallocate = 0;
@@ -962,10 +936,7 @@ map_slot_to_mid (slot, threads, thread_count)
 }
 
 static int
-parse_thread_id (arg, thread_count, slots)
-     char *arg;
-     int thread_count;
-     int slots;
+parse_thread_id (char *arg, int thread_count, int slots)
 {
   kern_return_t ret;
   int mid;
@@ -1025,10 +996,7 @@ parse_thread_id (arg, thread_count, slots)
  * 
  */
 kern_return_t
-select_thread (task, thread_id, flag)
-     mach_port_t task;
-     int thread_id;
-     int flag;
+select_thread (mach_port_t task, int thread_id, int flag)
 {
   thread_array_t thread_list;
   int thread_count;
@@ -1144,8 +1112,7 @@ select_thread (task, thread_id, flag)
  * Return it's MID
  */
 int
-switch_to_thread (new_thread)
-     thread_t new_thread;
+switch_to_thread (thread_t new_thread)
 {
   thread_t saved_thread = current_thread;
   int mid;
@@ -1168,8 +1135,7 @@ switch_to_thread (new_thread)
  * Note that the registers are not yet valid in the inferior task.
  */
 static int
-m3_trace_him (pid)
-     int pid;
+m3_trace_him (int pid)
 {
   kern_return_t ret;
 
@@ -1206,7 +1172,7 @@ m3_trace_him (pid)
   return pid;
 }
 
-setup_exception_port ()
+setup_exception_port (void)
 {
   kern_return_t ret;
 
@@ -1266,12 +1232,10 @@ int mach_really_waiting;
 
    There is no other way to exit this loop.
 
-   Returns the inferior_pid for rest of gdb.
+   Returns the inferior_ptid for rest of gdb.
    Side effects: Set *OURSTATUS.  */
-int
-mach_really_wait (pid, ourstatus)
-     int pid;
-     struct target_waitstatus *ourstatus;
+ptid_t
+mach_really_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
 {
   kern_return_t ret;
   int w;
@@ -1347,7 +1311,7 @@ mach_really_wait (pid, ourstatus)
                    }
                }
              store_waitstatus (ourstatus, w);
-             return inferior_pid;
+             return inferior_ptid;
            }
        }
 
@@ -1382,7 +1346,7 @@ mach_really_wait (pid, ourstatus)
          mach3_exception_actions (&w, FALSE, "Task");
 
          store_waitstatus (ourstatus, w);
-         return inferior_pid;
+         return inferior_ptid;
        }
     }
 }
@@ -1391,7 +1355,7 @@ mach_really_wait (pid, ourstatus)
  * This is called just before calling error() to return to command level
  */
 void
-mach3_quit ()
+mach3_quit (void)
 {
   int mid;
   kern_return_t ret;
@@ -1435,7 +1399,7 @@ mach3_quit ()
  * Called by REQUEST_QUIT() from utils.c(request_quit)
  */
 void
-mach3_request_quit ()
+mach3_request_quit (void)
 {
   if (mach_really_waiting)
     immediate_quit = 1;
@@ -1448,8 +1412,7 @@ mach3_request_quit ()
  * gdb to return to the command level like ^C had been typed from terminal.
  */
 int
-gdb_message_server (InP)
-     mach_msg_header_t *InP;
+gdb_message_server (mach_msg_header_t *InP)
 {
   kern_return_t ret;
   int mid;
@@ -1496,7 +1459,7 @@ gdb_message_server (InP)
  * External program "stop-gdb" implements this also.
  */
 void
-stop_inferior_gdb ()
+stop_inferior_gdb (void)
 {
   kern_return_t ret;
 
@@ -1541,8 +1504,7 @@ stop_inferior_gdb ()
  * it is selected and the last exception was a breakpoint.
  */
 int
-mach_thread_for_breakpoint (mid)
-     int mid;
+mach_thread_for_breakpoint (int mid)
 {
   int cmid = map_port_name_to_mid (current_thread, MACH_TYPE_THREAD);
 
@@ -1576,12 +1538,11 @@ mach_thread_for_breakpoint (mid)
  *    slot index. (Since 0 is reserved))
  */
 int
-mach_thread_parse_id (arg)
-     char *arg;
+mach_thread_parse_id (char *arg)
 {
   int mid;
   if (arg == 0)
-    error ("thread id excpected");
+    error ("thread id expected");
   mid = parse_thread_id (arg, 0, 1);
 
   return mid;
@@ -1590,8 +1551,7 @@ mach_thread_parse_id (arg)
 
 #ifdef THREAD_OUTPUT_ID
 char *
-mach_thread_output_id (mid)
-     int mid;
+mach_thread_output_id (int mid)
 {
   static char foobar[20];
 
@@ -1613,10 +1573,11 @@ mach_thread_output_id (mid)
  *  if SELECT_IT is nonzero, reselect the thread that was active when
  *  we stopped at a breakpoint.
  *
+ * Note that this implementation is potentially redundant now that
+ * default_prepare_to_proceed() has been added.  
  */
 
-mach3_prepare_to_proceed (select_it)
-     int select_it;
+mach3_prepare_to_proceed (int select_it)
 {
   if (stop_thread &&
       stop_thread != current_thread &&
@@ -1653,11 +1614,8 @@ mach3_prepare_to_proceed (select_it)
  */
 
 kern_return_t
-catch_exception_raise (port, thread, task, exception, code, subcode)
-     mach_port_t port;
-     thread_t thread;
-     task_t task;
-     int exception, code, subcode;
+catch_exception_raise (mach_port_t port, thread_t thread, task_t task,
+                      int exception, int code, int subcode)
 {
   kern_return_t ret;
   boolean_t signal_thread;
@@ -1683,7 +1641,8 @@ catch_exception_raise (port, thread, task, exception, code, subcode)
     }
 
   if (exception < 0 || exception > MAX_EXCEPTION)
-    internal_error ("catch_exception_raise: unknown exception code %d thread %d",
+    internal_error (__FILE__, __LINE__,
+                   "catch_exception_raise: unknown exception code %d thread %d",
                    exception,
                    mid);
 
@@ -1797,9 +1756,7 @@ catch_exception_raise (port, thread, task, exception, code, subcode)
 }
 \f
 int
-port_valid (port, mask)
-     mach_port_t port;
-     int mask;
+port_valid (mach_port_t port, int mask)
 {
   kern_return_t ret;
   mach_port_type_t type;
@@ -1822,10 +1779,7 @@ boolean_t vm_read_cache_valid = FALSE;
  * Return 0 on failure; number of bytes read otherwise.
  */
 int
-mach3_read_inferior (addr, myaddr, length)
-     CORE_ADDR addr;
-     char *myaddr;
-     int length;
+mach3_read_inferior (CORE_ADDR addr, char *myaddr, int length)
 {
   kern_return_t ret;
   vm_address_t low_address = (vm_address_t) trunc_page (addr);
@@ -1880,13 +1834,8 @@ mach3_read_inferior (addr, myaddr, length)
   return length;
 }
 
-#ifdef __STDC__
 #define CHK_GOTO_OUT(str,ret) \
   do if (ret != KERN_SUCCESS) { errstr = #str; goto out; } while(0)
-#else
-#define CHK_GOTO_OUT(str,ret) \
-  do if (ret != KERN_SUCCESS) { errstr = str; goto out; } while(0)
-#endif
 
 struct vm_region_list
 {
@@ -1903,10 +1852,7 @@ struct obstack region_obstack;
  * in gdb's address space.
  */
 int
-mach3_write_inferior (addr, myaddr, length)
-     CORE_ADDR addr;
-     char *myaddr;
-     int length;
+mach3_write_inferior (CORE_ADDR addr, char *myaddr, int length)
 {
   kern_return_t ret;
   vm_address_t low_address = (vm_address_t) trunc_page (addr);
@@ -2064,14 +2010,11 @@ out:
   return length;
 }
 
-/* Return 0 on failure, number of bytes handled otherwise.  */
+/* Return 0 on failure, number of bytes handled otherwise.  TARGET is
+   ignored. */
 static int
-m3_xfer_memory (memaddr, myaddr, len, write, target)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
-     int write;
-     struct target_ops *target;        /* IGNORED */
+m3_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+               struct target_ops *target)
 {
   int result;
 
@@ -2085,8 +2028,7 @@ m3_xfer_memory (memaddr, myaddr, len, write, target)
 \f
 
 static char *
-translate_state (state)
-     int state;
+translate_state (int state)
 {
   switch (state)
     {
@@ -2106,8 +2048,7 @@ translate_state (state)
 }
 
 static char *
-translate_cstate (state)
-     int state;
+translate_cstate (int state)
 {
   switch (state)
     {
@@ -2129,9 +2070,7 @@ translate_cstate (state)
 /* type == MACH_MSG_TYPE_COPY_SEND || type == MACH_MSG_TYPE_MAKE_SEND */
 
 mach_port_t                    /* no mach_port_name_t found in include files. */
-map_inferior_port_name (inferior_name, type)
-     mach_port_t inferior_name;
-     mach_msg_type_name_t type;
+map_inferior_port_name (mach_port_t inferior_name, mach_msg_type_name_t type)
 {
   kern_return_t ret;
   mach_msg_type_name_t acquired;
@@ -2169,9 +2108,7 @@ map_inferior_port_name (inferior_name, type)
 static char buf[7];
 
 static char *
-get_thread_name (one_cproc, id)
-     gdb_thread_t one_cproc;
-     int id;
+get_thread_name (gdb_thread_t one_cproc, int id)
 {
   if (one_cproc)
     if (one_cproc->cthread == NULL)
@@ -2199,9 +2136,7 @@ get_thread_name (one_cproc, id)
 }
 
 int
-fetch_thread_info (task, mthreads_out)
-     mach_port_t task;
-     gdb_thread_t *mthreads_out;       /* out */
+fetch_thread_info (mach_port_t task, gdb_thread_t *mthreads_out)
 {
   kern_return_t ret;
   thread_array_t th_table;
@@ -2274,8 +2209,7 @@ fetch_thread_info (task, mthreads_out)
  * emulator stack below struct emul_stack_top stuff.
  */
 CORE_ADDR
-fetch_usp_from_emulator_stack (sp)
-     CORE_ADDR sp;
+fetch_usp_from_emulator_stack (CORE_ADDR sp)
 {
   CORE_ADDR stack_pointer;
 
@@ -2303,8 +2237,7 @@ fetch_usp_from_emulator_stack (sp)
 /* Check if the emulator exists at task's address space.
  */
 boolean_t
-have_emulator_p (task)
-     task_t task;
+have_emulator_p (task_t task)
 {
   kern_return_t ret;
 #ifndef EMUL_VECTOR_COUNT
@@ -2352,10 +2285,8 @@ have_emulator_p (task)
 /* Map cprocs to kernel threads and vice versa.  */
 
 void
-map_cprocs_to_kernel_threads (cprocs, mthreads, thread_count)
-     gdb_thread_t cprocs;
-     gdb_thread_t mthreads;
-     int thread_count;
+map_cprocs_to_kernel_threads (gdb_thread_t cprocs, gdb_thread_t mthreads,
+                             int thread_count)
 {
   int index;
   gdb_thread_t scan;
@@ -2471,9 +2402,7 @@ map_cprocs_to_kernel_threads (cprocs, mthreads, thread_count)
 #define TL_HEADER "\n@    MID  Name        KState CState   Where\n"
 
 void
-print_tl_address (stream, pc)
-     GDB_FILE *stream;
-     CORE_ADDR pc;
+print_tl_address (struct ui_file *stream, CORE_ADDR pc)
 {
   if (!lookup_minimal_symbol_by_pc (pc))
     fprintf_filtered (stream, local_hex_format (), pc);
@@ -2494,8 +2423,7 @@ print_tl_address (stream, pc)
 
 /* Returns the address of variable NAME or 0 if not found */
 CORE_ADDR
-lookup_address_of_variable (name)
-     char *name;
+lookup_address_of_variable (char *name)
 {
   struct symbol *sym;
   CORE_ADDR symaddr = 0;
@@ -2522,16 +2450,17 @@ lookup_address_of_variable (name)
 }
 
 static gdb_thread_t
-get_cprocs ()
+get_cprocs (void)
 {
   gdb_thread_t cproc_head;
   gdb_thread_t cproc_copy;
   CORE_ADDR their_cprocs;
-  char *buf[TARGET_PTR_BIT / HOST_CHAR_BIT];
+  char *buf;
   char *name;
   cthread_t cthread;
   CORE_ADDR symaddr;
 
+  buf = alloca (TARGET_PTR_BIT / HOST_CHAR_BIT);
   symaddr = lookup_address_of_variable ("cproc_list");
 
   if (!symaddr)
@@ -2636,8 +2565,7 @@ get_cprocs ()
 #define FETCH_CPROC_STATE(mth) mach3_cproc_state (mth)
 
 int
-mach3_cproc_state (mthread)
-     gdb_thread_t mthread;
+mach3_cproc_state (gdb_thread_t mthread)
 {
   int context;
 
@@ -2674,7 +2602,7 @@ mach3_cproc_state (mthread)
 \f
 
 void
-thread_list_command ()
+thread_list_command (void)
 {
   thread_basic_info_data_t ths;
   int thread_count;
@@ -2893,9 +2821,7 @@ thread_list_command ()
 }
 \f
 void
-thread_select_command (args, from_tty)
-     char *args;
-     int from_tty;
+thread_select_command (char *args, int from_tty)
 {
   int mid;
   thread_array_t thread_list;
@@ -2932,9 +2858,7 @@ thread_select_command (args, from_tty)
                                                   MACH_TYPE_THREAD) : mid);
 }
 \f
-thread_trace (thread, set)
-     mach_port_t thread;
-     boolean_t set;
+thread_trace (mach_port_t thread, boolean_t set)
 {
   int flavor = TRACE_FLAVOR;
   unsigned int stateCnt = TRACE_FLAVOR_SIZE;
@@ -2980,8 +2904,7 @@ thread_trace (thread, set)
    This definitely includes breakpoints, for instance, or else we
    end up looping in mysterious Bpt traps */
 
-flush_inferior_icache (pc, amount)
-     CORE_ADDR pc;
+flush_inferior_icache (CORE_ADDR pc, int amount)
 {
   vm_machine_attribute_val_t flush = MATTR_VAL_ICACHE_FLUSH;
   kern_return_t ret;
@@ -2999,8 +2922,7 @@ flush_inferior_icache (pc, amount)
 \f
 
 static
-suspend_all_threads (from_tty)
-     int from_tty;
+suspend_all_threads (int from_tty)
 {
   kern_return_t ret;
   thread_array_t thread_list;
@@ -3052,9 +2974,7 @@ suspend_all_threads (from_tty)
 }
 
 void
-thread_suspend_command (args, from_tty)
-     char *args;
-     int from_tty;
+thread_suspend_command (char *args, int from_tty)
 {
   kern_return_t ret;
   int mid;
@@ -3103,8 +3023,7 @@ thread_suspend_command (args, from_tty)
   current_thread = saved_thread;
 }
 
-resume_all_threads (from_tty)
-     int from_tty;
+resume_all_threads (int from_tty)
 {
   kern_return_t ret;
   thread_array_t thread_list;
@@ -3157,9 +3076,7 @@ resume_all_threads (from_tty)
 }
 
 void
-thread_resume_command (args, from_tty)
-     char *args;
-     int from_tty;
+thread_resume_command (char *args, int from_tty)
 {
   int mid;
   mach_port_t saved_thread;
@@ -3218,9 +3135,7 @@ out:
 }
 
 void
-thread_kill_command (args, from_tty)
-     char *args;
-     int from_tty;
+thread_kill_command (char *args, int from_tty)
 {
   int mid;
   kern_return_t ret;
@@ -3282,9 +3197,7 @@ thread_kill_command (args, from_tty)
 /* Task specific commands; add more if you like */
 
 void
-task_resume_command (args, from_tty)
-     char *args;
-     int from_tty;
+task_resume_command (char *args, int from_tty)
 {
   kern_return_t ret;
   task_basic_info_data_t ta_info;
@@ -3328,9 +3241,7 @@ task_resume_command (args, from_tty)
 
 
 void
-task_suspend_command (args, from_tty)
-     char *args;
-     int from_tty;
+task_suspend_command (char *args, int from_tty)
 {
   kern_return_t ret;
   task_basic_info_data_t ta_info;
@@ -3359,8 +3270,7 @@ task_suspend_command (args, from_tty)
 }
 
 static char *
-get_size (bytes)
-     int bytes;
+get_size (int bytes)
 {
   static char size[30];
   int zz = bytes / 1024;
@@ -3375,9 +3285,7 @@ get_size (bytes)
 
 /* Does this require the target task to be suspended?? I don't think so. */
 void
-task_info_command (args, from_tty)
-     char *args;
-     int from_tty;
+task_info_command (char *args, int from_tty)
 {
   int mid = -5;
   mach_port_t task;
@@ -3454,9 +3362,7 @@ task_info_command (args, from_tty)
  */
 
 static void
-exception_command (args, from_tty)
-     char *args;
-     int from_tty;
+exception_command (char *args, int from_tty)
 {
   char *scan = args;
   int exception;
@@ -3505,8 +3411,7 @@ exception_command (args, from_tty)
 }
 
 static void
-print_exception_info (exception)
-     int exception;
+print_exception_info (int exception)
 {
   boolean_t forward = exception_map[exception].forward;
 
@@ -3524,9 +3429,7 @@ print_exception_info (exception)
 }
 
 void
-exception_info (args, from_tty)
-     char *args;
-     int from_tty;
+exception_info (char *args, int from_tty)
 {
   int exception;
 
@@ -3546,10 +3449,7 @@ exception_info (args, from_tty)
 \f
 /* Check for actions for mach exceptions.
  */
-mach3_exception_actions (w, force_print_only, who)
-     WAITTYPE *w;
-     boolean_t force_print_only;
-     char *who;
+mach3_exception_actions (WAITTYPE *w, boolean_t force_print_only, char *who)
 {
   boolean_t force_print = FALSE;
 
@@ -3598,13 +3498,13 @@ mach3_exception_actions (w, force_print_only, who)
                           stop_code);
          break;
        default:
-         internal_error ("Unknown exception");
+         internal_error (__FILE__, __LINE__,
+                         "Unknown exception");
        }
     }
 }
 \f
-setup_notify_port (create_new)
-     int create_new;
+setup_notify_port (int create_new)
 {
   kern_return_t ret;
 
@@ -3624,13 +3524,15 @@ setup_notify_port (create_new)
                                MACH_PORT_RIGHT_RECEIVE,
                                &our_notify_port);
       if (ret != KERN_SUCCESS)
-       internal_error ("Creating notify port %s", mach_error_string (ret));
+       internal_error (__FILE__, __LINE__,
+                       "Creating notify port %s", mach_error_string (ret));
 
       ret = mach_port_move_member (mach_task_self (),
                                   our_notify_port,
                                   inferior_wait_port_set);
       if (ret != KERN_SUCCESS)
-       internal_error ("initial move member %s", mach_error_string (ret));
+       internal_error (__FILE__, __LINE__,
+                       "initial move member %s", mach_error_string (ret));
     }
 }
 
@@ -3649,9 +3551,7 @@ setup_notify_port (create_new)
 char registered_name[MAX_NAME_LEN];
 
 void
-message_port_info (args, from_tty)
-     char *args;
-     int from_tty;
+message_port_info (char *args, int from_tty)
 {
   if (registered_name[0])
     printf_filtered ("gdb's message port name: '%s'\n",
@@ -3661,9 +3561,7 @@ message_port_info (args, from_tty)
 }
 
 void
-gdb_register_port (name, port)
-     char *name;
-     mach_port_t port;
+gdb_register_port (char *name, mach_port_t port)
 {
   kern_return_t ret;
   static int already_signed = 0;
@@ -3715,9 +3613,7 @@ struct cmd_list_element *cmd_task_list;
 
 /*ARGSUSED */
 static void
-thread_command (arg, from_tty)
-     char *arg;
-     int from_tty;
+thread_command (char *arg, int from_tty)
 {
   printf_unfiltered ("\"thread\" must be followed by the name of a thread command.\n");
   help_list (cmd_thread_list, "thread ", -1, gdb_stdout);
@@ -3725,15 +3621,13 @@ thread_command (arg, from_tty)
 
 /*ARGSUSED */
 static void
-task_command (arg, from_tty)
-     char *arg;
-     int from_tty;
+task_command (char *arg, int from_tty)
 {
   printf_unfiltered ("\"task\" must be followed by the name of a task command.\n");
   help_list (cmd_task_list, "task ", -1, gdb_stdout);
 }
 
-add_mach_specific_commands ()
+add_mach_specific_commands (void)
 {
   /* Thread handling commands */
 
@@ -3814,9 +3708,7 @@ Normally \"keep\" is used to return to GDB on exception.");
 }
 
 kern_return_t
-do_mach_notify_dead_name (notify, name)
-     mach_port_t notify;
-     mach_port_t name;
+do_mach_notify_dead_name (mach_port_t notify, mach_port_t name)
 {
   kern_return_t kr = KERN_SUCCESS;
 
@@ -3875,9 +3767,7 @@ do_mach_notify_dead_name (notify, name)
 }
 
 kern_return_t
-do_mach_notify_msg_accepted (notify, name)
-     mach_port_t notify;
-     mach_port_t name;
+do_mach_notify_msg_accepted (mach_port_t notify, mach_port_t name)
 {
   warning ("do_mach_notify_msg_accepted : notify %x, name %x",
           notify, name);
@@ -3885,9 +3775,7 @@ do_mach_notify_msg_accepted (notify, name)
 }
 
 kern_return_t
-do_mach_notify_no_senders (notify, mscount)
-     mach_port_t notify;
-     mach_port_mscount_t mscount;
+do_mach_notify_no_senders (mach_port_t notify, mach_port_mscount_t mscount)
 {
   warning ("do_mach_notify_no_senders : notify %x, mscount %x",
           notify, mscount);
@@ -3895,9 +3783,7 @@ do_mach_notify_no_senders (notify, mscount)
 }
 
 kern_return_t
-do_mach_notify_port_deleted (notify, name)
-     mach_port_t notify;
-     mach_port_t name;
+do_mach_notify_port_deleted (mach_port_t notify, mach_port_t name)
 {
   warning ("do_mach_notify_port_deleted : notify %x, name %x",
           notify, name);
@@ -3905,9 +3791,7 @@ do_mach_notify_port_deleted (notify, name)
 }
 
 kern_return_t
-do_mach_notify_port_destroyed (notify, rights)
-     mach_port_t notify;
-     mach_port_t rights;
+do_mach_notify_port_destroyed (mach_port_t notify, mach_port_t rights)
 {
   warning ("do_mach_notify_port_destroyed : notify %x, rights %x",
           notify, rights);
@@ -3915,8 +3799,7 @@ do_mach_notify_port_destroyed (notify, rights)
 }
 
 kern_return_t
-do_mach_notify_send_once (notify)
-     mach_port_t notify;
+do_mach_notify_send_once (mach_port_t notify)
 {
 #ifdef DUMP_SYSCALL
   /* MANY of these are generated. */
@@ -3928,18 +3811,18 @@ do_mach_notify_send_once (notify)
 
 /* Kills the inferior. It's gone when you call this */
 static void
-kill_inferior_fast ()
+kill_inferior_fast (void)
 {
   WAITTYPE w;
 
-  if (inferior_pid == 0 || inferior_pid == 1)
+  if (PIDGET (inferior_ptid) == 0 || PIDGET (inferior_ptid) == 1)
     return;
 
   /* kill() it, since the Unix server does not otherwise notice when
    * killed with task_terminate().
    */
-  if (inferior_pid > 0)
-    kill (inferior_pid, SIGKILL);
+  if (PIDGET (inferior_ptid) > 0)
+    kill (PIDGET (inferior_ptid), SIGKILL);
 
   /* It's propably terminate already */
   (void) task_terminate (inferior_task);
@@ -3953,7 +3836,7 @@ kill_inferior_fast ()
 }
 
 static void
-m3_kill_inferior ()
+m3_kill_inferior (void)
 {
   kill_inferior_fast ();
   target_mourn_inferior ();
@@ -3962,7 +3845,7 @@ m3_kill_inferior ()
 /* Clean up after the inferior dies.  */
 
 static void
-m3_mourn_inferior ()
+m3_mourn_inferior (void)
 {
   unpush_target (&m3_ops);
   generic_mourn_inferior ();
@@ -3972,10 +3855,7 @@ m3_mourn_inferior ()
 /* Fork an inferior process, and start debugging it.  */
 
 static void
-m3_create_inferior (exec_file, allargs, env)
-     char *exec_file;
-     char *allargs;
-     char **env;
+m3_create_inferior (char *exec_file, char *allargs, char **env)
 {
   fork_inferior (exec_file, allargs, env, m3_trace_me, m3_trace_him, NULL, NULL);
   /* We are at the first instruction we care about.  */
@@ -3986,7 +3866,7 @@ m3_create_inferior (exec_file, allargs, env)
 /* Mark our target-struct as eligible for stray "run" and "attach"
    commands.  */
 static int
-m3_can_run ()
+m3_can_run (void)
 {
   return 1;
 }
@@ -3994,8 +3874,7 @@ m3_can_run ()
 /* Mach 3.0 does not need ptrace for anything
  * Make sure nobody uses it on mach.
  */
-ptrace (a, b, c, d)
-     int a, b, c, d;
+ptrace (int a, int b, int c, int d)
 {
   error ("Lose, Lose! Somebody called ptrace\n");
 }
@@ -4005,10 +3884,7 @@ ptrace (a, b, c, d)
    If SIGNAL is nonzero, give it that signal.  */
 
 void
-m3_resume (pid, step, signal)
-     int pid;
-     int step;
-     enum target_signal signal;
+m3_resume (ptid_t ptid, int step, enum target_signal signal)
 {
   kern_return_t ret;
 
@@ -4037,8 +3913,8 @@ m3_resume (pid, step, signal)
 
   vm_read_cache_valid = FALSE;
 
-  if (signal && inferior_pid > 0)      /* Do not signal, if attached by MID */
-    kill (inferior_pid, target_signal_to_host (signal));
+  if (signal && PIDGET (inferior_ptid) > 0)    /* Do not signal, if attached by MID */
+    kill (PIDGET (inferior_ptid), target_signal_to_host (signal));
 
   if (step)
     {
@@ -4066,8 +3942,7 @@ m3_resume (pid, step, signal)
 
 /* Start debugging the process with the given task */
 void
-task_attach (tid)
-     task_t tid;
+task_attach (task_t tid)
 {
   kern_return_t ret;
   inferior_task = tid;
@@ -4097,14 +3972,13 @@ task_attach (tid)
  * (Someone must have killed it))
  */
 void
-attach_to_thread ()
+attach_to_thread (void)
 {
   if (select_thread (inferior_task, 0, 1) != KERN_SUCCESS)
     error ("Could not select any threads to attach to");
 }
 
-mid_attach (mid)
-     int mid;
+mid_attach (int mid)
 {
   kern_return_t ret;
 
@@ -4125,8 +3999,7 @@ mid_attach (mid)
  * "atta pidself". Anyway, the latter is allowed by specifying a MID.
  */
 static int
-m3_do_attach (pid)
-     int pid;
+m3_do_attach (int pid)
 {
   kern_return_t ret;
 
@@ -4141,10 +4014,10 @@ m3_do_attach (pid)
     {
       mid_attach (-(pid));
 
-      /* inferior_pid will be NEGATIVE! */
-      inferior_pid = pid;
+      /* inferior_ptid will be NEGATIVE! */
+      inferior_ptid = pid_to_ptid (pid);
 
-      return inferior_pid;
+      return PIDGET (inferior_ptid);
     }
 
   inferior_task = task_by_pid (pid);
@@ -4153,18 +4026,16 @@ m3_do_attach (pid)
 
   task_attach (inferior_task);
 
-  inferior_pid = pid;
+  inferior_ptid = pid_to_ptid (pid);
 
-  return inferior_pid;
+  return PIDGET (inferior_ptid);
 }
 
 /* Attach to process PID, then initialize for debugging it
    and wait for the trace-trap that results from attaching.  */
 
 static void
-m3_attach (args, from_tty)
-     char *args;
-     int from_tty;
+m3_attach (char *args, int from_tty)
 {
   char *exec_file;
   int pid;
@@ -4182,20 +4053,22 @@ m3_attach (args, from_tty)
       exec_file = (char *) get_exec_file (0);
 
       if (exec_file)
-       printf_unfiltered ("Attaching to program `%s', %s\n", exec_file, target_pid_to_str (pid));
+       printf_unfiltered ("Attaching to program `%s', %s\n", exec_file,
+                          target_pid_to_str (pid_to_ptid (pid)));
       else
-       printf_unfiltered ("Attaching to %s\n", target_pid_to_str (pid));
+       printf_unfiltered ("Attaching to %s\n",
+                          target_pid_to_str (pid_to_ptid (pid)));
 
       gdb_flush (gdb_stdout);
     }
 
-  m3_do_attach (pid);
-  inferior_pid = pid;
+  m3_do_attach (pid_to_ptid (pid));
+  inferior_ptid = pid_to_ptid (pid);
   push_target (&m3_ops);
 }
 \f
 void
-deallocate_inferior_ports ()
+deallocate_inferior_ports (void)
 {
   kern_return_t ret;
   thread_array_t thread_list;
@@ -4251,8 +4124,7 @@ deallocate_inferior_ports ()
    SIGNAL = 0 means just continue it.  */
 
 static void
-m3_do_detach (signal)
-     int signal;
+m3_do_detach (int signal)
 {
   kern_return_t ret;
 
@@ -4279,8 +4151,8 @@ m3_do_detach (signal)
   if (remove_breakpoints ())
     warning ("Could not remove breakpoints when detaching");
 
-  if (signal && inferior_pid > 0)
-    kill (inferior_pid, signal);
+  if (signal && PIDGET (inferior_ptid) > 0)
+    kill (PIDGET (inferior_ptid), signal);
 
   /* the task might be dead by now */
   (void) task_resume (inferior_task);
@@ -4299,9 +4171,7 @@ m3_do_detach (signal)
    started via fork.  */
 
 static void
-m3_detach (args, from_tty)
-     char *args;
-     int from_tty;
+m3_detach (char *args, int from_tty)
 {
   int siggnal = 0;
 
@@ -4311,14 +4181,14 @@ m3_detach (args, from_tty)
       if (exec_file == 0)
        exec_file = "";
       printf_unfiltered ("Detaching from program: %s %s\n",
-                        exec_file, target_pid_to_str (inferior_pid));
+                        exec_file, target_pid_to_str (inferior_ptid));
       gdb_flush (gdb_stdout);
     }
   if (args)
     siggnal = atoi (args);
 
   m3_do_detach (siggnal);
-  inferior_pid = 0;
+  inferior_ptid = null_ptid;
   unpush_target (&m3_ops);     /* Pop out of handling an inferior */
 }
 #endif /* ATTACH_DETACH */
@@ -4330,7 +4200,7 @@ m3_detach (args, from_tty)
    debugged.  */
 
 static void
-m3_prepare_to_store ()
+m3_prepare_to_store (void)
 {
 #ifdef CHILD_PREPARE_TO_STORE
   CHILD_PREPARE_TO_STORE ();
@@ -4340,28 +4210,21 @@ m3_prepare_to_store ()
 /* Print status information about what we're accessing.  */
 
 static void
-m3_files_info (ignore)
-     struct target_ops *ignore;
+m3_files_info (struct target_ops *ignore)
 {
   /* FIXME: should print MID and all that crap.  */
   printf_unfiltered ("\tUsing the running image of %s %s.\n",
-      attach_flag ? "attached" : "child", target_pid_to_str (inferior_pid));
+      attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid));
 }
 
 static void
-m3_open (arg, from_tty)
-     char *arg;
-     int from_tty;
+m3_open (char *arg, int from_tty)
 {
   error ("Use the \"run\" command to start a Unix child process.");
 }
 
 #ifdef DUMP_SYSCALL
-#ifdef __STDC__
 #define STR(x) #x
-#else
-#define STR(x) "x"
-#endif
 
 char *bsd1_names[] =
 {
@@ -4435,11 +4298,7 @@ char *bsd1_names[] =
 int bsd1_nnames = sizeof (bsd1_names) / sizeof (bsd1_names[0]);
 
 char *
-name_str (name, buf)
-
-     int name;
-     char *buf;
-
+name_str (int name, char *buf)
 {
   switch (name)
     {
@@ -4464,11 +4323,7 @@ name_str (name, buf)
 }
 
 char *
-id_str (id, buf)
-
-     int id;
-     char *buf;
-
+id_str (int id, char *buf)
 {
   char *p;
   if (id >= 101000 && id < 101000 + bsd1_nnames)
@@ -4484,8 +4339,7 @@ id_str (id, buf)
   return buf;
 }
 
-print_msg (mp)
-     mach_msg_header_t *mp;
+print_msg (mach_msg_header_t *mp)
 {
   char *fmt_x = "%20s : 0x%08x\n";
   char *fmt_d = "%20s : %10d\n";
@@ -4550,10 +4404,7 @@ print_msg (mp)
     }
 }
 
-print_data (p, size, number)
-
-     char *p;
-
+print_data (char *p, int size, int number)
 {
   int *ip;
   short *sp;
@@ -4587,21 +4438,20 @@ print_data (p, size, number)
 #endif /* DUMP_SYSCALL */
 
 static void
-m3_stop ()
+m3_stop (void)
 {
   error ("to_stop target function not implemented");
 }
 
 static char *
-m3_pid_to_exec_file (pid)
-     int pid;
+m3_pid_to_exec_file (int pid)
 {
   error ("to_pid_to_exec_file target function not implemented");
   return NULL;                 /* To keep all compilers happy. */
 }
 
 static void
-init_m3_ops ()
+init_m3_ops (void)
 {
   m3_ops.to_shortname = "mach";
   m3_ops.to_longname = "Mach child process";
@@ -4610,7 +4460,7 @@ init_m3_ops ()
   m3_ops.to_attach = m3_attach;
   m3_ops.to_detach = m3_detach;
   m3_ops.to_resume = m3_resume;
-  m3_ops.to_wait = mach_really__wait;
+  m3_ops.to_wait = mach_really_wait;
   m3_ops.to_fetch_registers = fetch_inferior_registers;
   m3_ops.to_store_registers = store_inferior_registers;
   m3_ops.to_prepare_to_store = m3_prepare_to_store;
@@ -4639,7 +4489,7 @@ init_m3_ops ()
 }
 
 void
-_initialize_m3_nat ()
+_initialize_m3_nat (void)
 {
   kern_return_t ret;
 
@@ -4650,7 +4500,8 @@ _initialize_m3_nat ()
                            MACH_PORT_RIGHT_PORT_SET,
                            &inferior_wait_port_set);
   if (ret != KERN_SUCCESS)
-    internal_error ("initial port set %s", mach_error_string (ret));
+    internal_error (__FILE__, __LINE__,
+                   "initial port set %s", mach_error_string (ret));
 
   /* mach_really_wait now waits for this */
   currently_waiting_for = inferior_wait_port_set;
This page took 0.110799 seconds and 4 git commands to generate.