+2010-03-05 Kevin Buettner <kevinb@redhat.com>
+ Pedro Alves <pedro@codesourcery.com>
+
+ * remote-mips.c (gdbthread.h): Include.
+ (remote_mips_ptid): Declare.
+ (mips_error): Only mourn the inferior when inferior_ptid is non-null.
+ (common_open): Set inferior_ptid, add it as an inferior, and
+ as a thread too. Delete FIXME comment regarding start_remote().
+ (mips_close): Invoke generic_mourn_inferior().
+ (mips_kill): Make sure that target_mourn_inferior is invoked.
+ (mips_mourn_inferior): Don't invoke generic_mourn_inferior, as
+ it's now invoked from mips_close().
+ (mips_load): Don't null out inferior_ptid. Don't call
+ clear_symtab_users().
+ (mips_thread_alive, mips_pid_to_str): New functions.
+ (_initialize_remote_mips): Initialize remote_mips_ptid. Initialize
+ to_thread_alive and to_pid_to_str operations.
+
2010-03-04 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (skip_one_die) <DW_FORM_ref_addr>: Use offset size
#include "regcache.h"
#include <ctype.h>
#include "mips-tdep.h"
+#include "gdbthread.h"
\f
/* Breakpoint types. Values 0, 1, and 2 must agree with the watch
of warnings returned by PMON when hardware breakpoints are used. */
static int monitor_warnings;
+/* This is the ptid we use while we're connected to the remote. Its
+ value is arbitrary, as the remote-mips target doesn't have a notion of
+ processes or threads, but we need something non-null to place in
+ inferior_ptid. */
+static ptid_t remote_mips_ptid;
static void
close_ports (void)
close_ports ();
printf_unfiltered ("Ending remote MIPS debugging.\n");
- target_mourn_inferior ();
+ if (!ptid_equal (inferior_ptid, null_ptid))
+ target_mourn_inferior ();
deprecated_throw_reason (RETURN_ERROR);
}
/* Switch to using remote target now. */
push_target (ops);
- /* FIXME: Should we call start_remote here? */
+ inferior_ptid = remote_mips_ptid;
+ inferior_appeared (current_inferior (), ptid_get_pid (inferior_ptid));
+ add_thread_silent (inferior_ptid);
/* Try to figure out the processor model if possible. */
deprecated_mips_set_processor_regs_hack ();
close_ports ();
}
+
+ generic_mourn_inferior ();
}
/* Detach from the remote board. */
mips_kill (struct target_ops *ops)
{
if (!mips_wait_flag)
- return;
+ {
+ target_mourn_inferior ();
+ return;
+ }
interrupt_count++;
serial_send_break (mips_desc);
+ target_mourn_inferior ();
+
#if 0
if (mips_is_open)
{
init_wait_for_inferior ();
- /* FIXME: Should we set inferior_ptid here? */
-
regcache_write_pc (get_current_regcache (), entry_pt);
}
-/* Clean up after a process. Actually nothing to do. */
+/* Clean up after a process. The bulk of the work is done in mips_close(),
+ which is called when unpushing the target. */
static void
mips_mourn_inferior (struct target_ops *ops)
{
if (current_ops != NULL)
unpush_target (current_ops);
- generic_mourn_inferior ();
}
\f
/* We can write a breakpoint and read the shadow contents in one
}
if (exec_bfd)
regcache_write_pc (regcache, bfd_get_start_address (exec_bfd));
+}
- inferior_ptid = null_ptid; /* No process now */
-
-/* This is necessary because many things were based on the PC at the time that
- we attached to the monitor, which is no longer valid now that we have loaded
- new code (and just changed the PC). Another way to do this might be to call
- normal_stop, except that the stack may not be valid, and things would get
- horribly confused... */
+/* Check to see if a thread is still alive. */
+
+static int
+mips_thread_alive (struct target_ops *ops, ptid_t ptid)
+{
+ if (ptid_equal (ptid, remote_mips_ptid))
+ /* The monitor's task is always alive. */
+ return 1;
- clear_symtab_users ();
+ return 0;
}
+/* Convert a thread ID to a string. Returns the string in a static
+ buffer. */
+
+static char *
+mips_pid_to_str (struct target_ops *ops, ptid_t ptid)
+{
+ static char buf[64];
+
+ if (ptid_equal (ptid, remote_mips_ptid))
+ {
+ xsnprintf (buf, sizeof buf, "Thread <main>");
+ return buf;
+ }
+
+ return normal_pid_to_str (ptid);
+}
/* Pass the command argument as a packet to PMON verbatim. */
mips_ops.to_load = mips_load;
mips_ops.to_create_inferior = mips_create_inferior;
mips_ops.to_mourn_inferior = mips_mourn_inferior;
+ mips_ops.to_thread_alive = mips_thread_alive;
+ mips_ops.to_pid_to_str = mips_pid_to_str;
mips_ops.to_log_command = serial_log_command;
mips_ops.to_stratum = process_stratum;
mips_ops.to_has_all_memory = default_child_has_all_memory;
NULL,
NULL, /* FIXME: i18n: */
&setlist, &showlist);
+ remote_mips_ptid = ptid_build (42000, 0, 42000);
}