2008-08-19 Pedro Alves * remote-mips.c: Include "gdbthread.h". (remote_mips_ptid): New. (common_open): Set inferior_ptid to remote_mips_ptid and add it as a thread to GDB's thread list. (mips_close): Delete remote_mips_ptid from GDB's thread list. (mips_create_inferior): Remove FIXME note. (mips_load): Don't delete symtab users, or reset inferior_ptid. (_initialize_remote_mips): Initialize remote_mips_ptid. --- gdb/remote-mips.c | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) Index: src/gdb/remote-mips.c =================================================================== --- src.orig/gdb/remote-mips.c 2008-08-19 20:04:11.000000000 +0100 +++ src/gdb/remote-mips.c 2008-08-19 20:04:40.000000000 +0100 @@ -36,6 +36,7 @@ #include #include "mips-tdep.h" #include +#include "gdbthread.h" /* Breakpoint types. Values 0, 1, and 2 must agree with the watch @@ -457,6 +458,11 @@ struct lsi_error lsi_error_table[] = 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-sim target don't have a notion or + 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) @@ -1584,6 +1590,9 @@ device is attached to the target board ( /* Try to figure out the processor model if possible. */ deprecated_mips_set_processor_regs_hack (); + inferior_ptid = remote_mips_ptid; + add_thread_silent (remote_mips_ptid); + /* This is really the job of start_remote however, that makes an assumption that the target is about to print out a status message of some sort. That doesn't happen here (in fact, it may not be @@ -1655,6 +1664,8 @@ mips_close (int quitting) close_ports (); } + + delete_thread_silent (remote_mips_ptid); } /* Detach from the remote board. */ @@ -2264,8 +2275,6 @@ Can't pass arguments to remote MIPS boar init_wait_for_inferior (); - /* FIXME: Should we set inferior_ptid here? */ - write_pc (entry_pt); } @@ -3343,18 +3352,37 @@ mips_load (char *file, int from_tty) } if (exec_bfd) write_pc (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. */ - clear_symtab_users (); +static int +mips_thread_alive (ptid_t ptid) +{ + if (ptid_equal (ptid, remote_mips_ptid)) + /* The monitor's task is always alive. */ + return 1; + + return 0; } +/* Convert a thread ID to a string. Returns the string in a static + buffer. */ + +static char * +mips_pid_to_str (ptid_t ptid) +{ + static char buf[64]; + + if (ptid_equal (remote_mips_ptid, ptid)) + { + xsnprintf (buf, sizeof buf, "Thread
"); + return buf; + } + + return normal_pid_to_str (ptid); +} /* Pass the command argument as a packet to PMON verbatim. */ @@ -3399,6 +3427,8 @@ _initialize_remote_mips (void) 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 = 1; @@ -3506,4 +3536,8 @@ Use \"on\" to enable the masking and \"o NULL, NULL, /* FIXME: i18n: */ &setlist, &showlist); + + /* Yes, 42000 is arbitrary. The only sense out of it, is that it + isn't 0. */ + remote_mips_ptid = ptid_build (42000, 0, 42000); }