/* 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 (C) 1992, 1996, 1999-2000 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"
/* "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);
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;
}
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)
}
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)
{
}
\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;
\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;
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;
}
\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;
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);
/* Called from inferior after FORK but before EXEC */
static void
-m3_trace_me ()
+m3_trace_me (void)
{
kern_return_t ret;
*/
void
-intercept_exec_calls (exec_counter)
- int exec_counter;
+intercept_exec_calls (int exec_counter)
{
int terminal_initted = 0;
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,
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,
}
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;
}
/* 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;
}
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;
}
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;
*
*/
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;
* 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;
* 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;
return pid;
}
-setup_exception_port ()
+setup_exception_port (void)
{
kern_return_t ret;
Returns the inferior_pid for rest of gdb.
Side effects: Set *OURSTATUS. */
int
-mach_really_wait (pid, ourstatus)
- int pid;
- struct target_waitstatus *ourstatus;
+mach_really_wait (int pid, struct target_waitstatus *ourstatus)
{
kern_return_t ret;
int w;
* This is called just before calling error() to return to command level
*/
void
-mach3_quit ()
+mach3_quit (void)
{
int mid;
kern_return_t ret;
* Called by REQUEST_QUIT() from utils.c(request_quit)
*/
void
-mach3_request_quit ()
+mach3_request_quit (void)
{
if (mach_really_waiting)
immediate_quit = 1;
* 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;
* External program "stop-gdb" implements this also.
*/
void
-stop_inferior_gdb ()
+stop_inferior_gdb (void)
{
kern_return_t ret;
* 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);
* 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;
#ifdef THREAD_OUTPUT_ID
char *
-mach_thread_output_id (mid)
- int mid;
+mach_thread_output_id (int mid)
{
static char foobar[20];
*
*/
-mach3_prepare_to_proceed (select_it)
- int select_it;
+mach3_prepare_to_proceed (int select_it)
{
if (stop_thread &&
stop_thread != current_thread &&
*/
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;
}
\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;
* 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);
* 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);
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;
\f
static char *
-translate_state (state)
- int state;
+translate_state (int state)
{
switch (state)
{
}
static char *
-translate_cstate (state)
- int state;
+translate_cstate (int state)
{
switch (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;
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)
}
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;
* 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;
/* 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
/* 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;
#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);
/* 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;
}
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)
#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;
\f
void
-thread_list_command ()
+thread_list_command (void)
{
thread_basic_info_data_t ths;
int thread_count;
}
\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;
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;
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;
\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;
}
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;
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;
}
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;
}
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;
/* 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;
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;
}
static char *
-get_size (bytes)
- int bytes;
+get_size (int bytes)
{
static char size[30];
int zz = bytes / 1024;
/* 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;
*/
static void
-exception_command (args, from_tty)
- char *args;
- int from_tty;
+exception_command (char *args, int from_tty)
{
char *scan = args;
int exception;
}
static void
-print_exception_info (exception)
- int exception;
+print_exception_info (int exception)
{
boolean_t forward = exception_map[exception].forward;
}
void
-exception_info (args, from_tty)
- char *args;
- int from_tty;
+exception_info (char *args, int from_tty)
{
int exception;
\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;
}
}
\f
-setup_notify_port (create_new)
- int create_new;
+setup_notify_port (int create_new)
{
kern_return_t ret;
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",
}
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;
/*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);
/*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 */
}
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;
}
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);
}
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);
}
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);
}
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);
}
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. */
/* Kills the inferior. It's gone when you call this */
static void
-kill_inferior_fast ()
+kill_inferior_fast (void)
{
WAITTYPE w;
}
static void
-m3_kill_inferior ()
+m3_kill_inferior (void)
{
kill_inferior_fast ();
target_mourn_inferior ();
/* Clean up after the inferior dies. */
static void
-m3_mourn_inferior ()
+m3_mourn_inferior (void)
{
unpush_target (&m3_ops);
generic_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. */
/* Mark our target-struct as eligible for stray "run" and "attach"
commands. */
static int
-m3_can_run ()
+m3_can_run (void)
{
return 1;
}
/* 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");
}
If SIGNAL is nonzero, give it that signal. */
void
-m3_resume (pid, step, signal)
- int pid;
- int step;
- enum target_signal signal;
+m3_resume (int pid, int step, enum target_signal signal)
{
kern_return_t ret;
/* 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;
* (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;
* "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;
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;
}
\f
void
-deallocate_inferior_ports ()
+deallocate_inferior_ports (void)
{
kern_return_t ret;
thread_array_t thread_list;
SIGNAL = 0 means just continue it. */
static void
-m3_do_detach (signal)
- int signal;
+m3_do_detach (int signal)
{
kern_return_t ret;
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;
debugged. */
static void
-m3_prepare_to_store ()
+m3_prepare_to_store (void)
{
#ifdef CHILD_PREPARE_TO_STORE
CHILD_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",
}
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.");
}
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)
{
}
char *
-id_str (id, buf)
-
- int id;
- char *buf;
-
+id_str (int id, char *buf)
{
char *p;
if (id >= 101000 && id < 101000 + bsd1_nnames)
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";
}
}
-print_data (p, size, number)
-
- char *p;
-
+print_data (char *p, int size, int number)
{
int *ip;
short *sp;
#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";
}
void
-_initialize_m3_nat ()
+_initialize_m3_nat (void)
{
kern_return_t ret;