#include "target.h"
#include "wait.h"
#include "gdbcmd.h"
+#include "gdbcore.h"
+#if 0
#include <servers/machid_lib.h>
+#else
+#define MACH_TYPE_TASK 1
+#define MACH_TYPE_THREAD 2
+#endif
/* Included only for signal names and NSIG
*
#define NULL_CLEANUP (struct cleanup *)0
struct cleanup *cleanup_step = NULL_CLEANUP;
+\f
+extern struct target_ops m3_ops;
\f
#if 0
#define MACH_TYPE_EXCEPTION_PORT -1
if (ret != KERN_SUCCESS)
{
warning ("Can not select a thread from a dead task");
- kill_inferior ();
+ m3_kill_inferior ();
return KERN_FAILURE;
}
if (! port_valid (inferior_task, MACH_PORT_TYPE_SEND))
{
- kill_inferior ();
+ m3_kill_inferior ();
error ("Inferior killed (task port invalid)");
}
else
{
warning ("Error getting inferior's thread list:%s",
mach_error_string(ret));
- kill_inferior ();
+ m3_kill_inferior ();
return -1;
}
int index;
gdb_thread_t scan;
boolean_t all_mapped = TRUE;
+ LONGEST stack_base;
+ LONGEST stack_size;
for (scan = cprocs; scan; scan = scan->next)
{
/* Check if the cproc is found by its stack */
for (index = 0; index < thread_count; index++)
{
- LONGEST stack_base =
- extract_signed_integer (scan.raw_cproc + CPROC_BASE_OFFSET,
+ stack_base =
+ extract_signed_integer (scan->raw_cproc + CPROC_BASE_OFFSET,
CPROC_BASE_SIZE);
- LONGEST stack_size =
- extract_signed_integer (scan.raw_cproc + CPROC_SIZE_OFFSET,
+ stack_size =
+ extract_signed_integer (scan->raw_cproc + CPROC_SIZE_OFFSET,
CPROC_SIZE_SIZE);
if ((mthreads + index)->sp > stack_base &&
(mthreads + index)->sp <= stack_base + stack_size)
* the user stack pointer saved in the
* emulator.
*/
- if (scan->reverse_map == -1 &&
- usp > scan->stack_base &&
- usp <= scan->stack_base + scan->stack_size)
+ if (scan->reverse_map == -1)
{
- mthread->cproc = scan;
- scan->reverse_map = index;
- break;
+ stack_base =
+ extract_signed_integer
+ (scan->raw_cproc + CPROC_BASE_OFFSET,
+ CPROC_BASE_SIZE);
+ stack_size =
+ extract_signed_integer
+ (scan->raw_cproc + CPROC_SIZE_OFFSET,
+ CPROC_SIZE_SIZE);
+ if (usp > stack_base &&
+ usp <= stack_base + stack_size)
+ {
+ mthread->cproc = scan;
+ scan->reverse_map = index;
+ break;
+ }
}
}
}
msymbol = lookup_minimal_symbol (name, (struct objfile *) NULL);
if (msymbol && msymbol->type == mst_data)
- symaddr = msymbol->address;
+ symaddr = SYMBOL_VALUE_ADDRESS (msymbol);
}
return symaddr;
sizeof (struct gdb_thread));
if (!mach3_read_inferior (their_cprocs,
- &cproc_copy.raw_cproc[0],
+ &cproc_copy->raw_cproc[0],
CPROC_SIZE))
error("Can't read next cproc at 0x%x.", their_cprocs);
- cproc_copy = extract_address (buf, TARGET_PTR_BIT / HOST_CHAR_BIT);
their_cprocs =
- extract_address (cproc_copy.raw_cproc + CPROC_LIST_OFFSET,
+ extract_address (cproc_copy->raw_cproc + CPROC_LIST_OFFSET,
CPROC_LIST_SIZE);
cproc_copy_incarnation =
- extract_address (cproc_copy.raw_cproc + CPROC_INCARNATION_OFFSET,
+ extract_address (cproc_copy->raw_cproc + CPROC_INCARNATION_OFFSET,
CPROC_INCARNATION_SIZE);
if (cproc_copy_incarnation == (CORE_ADDR)0)
{
int context;
- if (! mthread || !mthread->cproc || !mthread->cproc->context)
+ if (! mthread || !mthread->cproc)
return -1;
context = extract_signed_integer
(mthread->cproc->raw_cproc + CPROC_CONTEXT_OFFSET,
CPROC_CONTEXT_SIZE);
+ if (context == 0)
+ return -1;
mthread->sp = context + MACHINE_CPROC_SP_OFFSET;
int mid;
char buf[10];
char slot[3];
+ int cproc_state =
+ extract_signed_integer
+ (scan->raw_cproc + CPROC_STATE_OFFSET, CPROC_STATE_SIZE);
selected = ' ';
kthread->in_emulator ? "E" : "",
translate_state (ths.run_state),
buf,
- translate_cstate (scan->state),
+ translate_cstate (cproc_state),
wired);
print_tl_address (gdb_stdout, kthread->pc);
}
"",
"-", /* kernel state */
"",
- translate_cstate (scan->state),
+ translate_cstate (cproc_state),
"");
state.cproc = scan;
if (ret != KERN_SUCCESS)
{
warning ("Could not suspend inferior threads.");
- kill_inferior ();
+ m3_kill_inferior ();
return_to_top_level ();
}
ret = task_threads (inferior_task, &thread_list, &thread_count);
if (ret != KERN_SUCCESS)
{
- kill_inferior ();
+ m3_kill_inferior ();
error("task_threads", mach_error_string( ret));
}
if (exception_map[stop_exception].print || force_print)
{
- int giveback = grab_terminal ();
+ target_terminal_ours ();
printf_filtered ("\n%s received %s exception : ",
who,
default:
fatal ("Unknown exception");
}
-
- if (giveback)
- terminal_inferior ();
}
}
\f
char *allargs;
char **env;
{
- fork_inferior (exec_file, allargs, env, m3_trace_m3, m3_trace_him, NULL);
+ fork_inferior (exec_file, allargs, env, m3_trace_me, m3_trace_him, NULL);
/* We are at the first instruction we care about. */
/* Pedal to the metal... */
proceed ((CORE_ADDR) -1, 0, 0);
m3_do_attach (pid);
inferior_pid = pid;
- push_target (&procfs_ops);
+ push_target (&m3_ops);
}
\f
void
}
#endif /* ATTACH_DETACH */
+/* Get ready to modify the registers array. On machines which store
+ individual registers, this doesn't need to do anything. On machines
+ which store all the registers in one fell swoop, this makes sure
+ that registers contains all the registers from the program being
+ debugged. */
+
+static void
+m3_prepare_to_store ()
+{
+#ifdef CHILD_PREPARE_TO_STORE
+ CHILD_PREPARE_TO_STORE ();
+#endif
+}
+
+/* Print status information about what we're accessing. */
+
+static void
+m3_files_info (ignore)
+ 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));
+}
+
static void
m3_open (arg, from_tty)
char *arg;
mach_really_wait, /* to_wait */
fetch_inferior_registers, /* to_fetch_registers */
store_inferior_registers, /* to_store_registers */
- child_prepare_to_store, /* to_prepare_to_store */
+ m3_prepare_to_store, /* to_prepare_to_store */
m3_xfer_memory, /* to_xfer_memory */
-
- /* FIXME: Should print MID and all that crap. */
- child_files_info, /* to_files_info */
-
+ m3_files_info, /* to_files_info */
memory_insert_breakpoint, /* to_insert_breakpoint */
memory_remove_breakpoint, /* to_remove_breakpoint */
terminal_init_inferior, /* to_terminal_init */