+Tue Jan 5 11:13:36 1999 Michael Snyder <msnyder@cleaver.cygnus.com>
+
+ * remote.c (record_curthread): Must not modify inferior_pid when
+ called from wait_for_inferior. Instead, if a new thread-id is
+ detected, call add_thread. (MAGIC_NULL_PID): new macro, use
+ instead of the magic number "42000". (remote_find_new_threads):
+ if inferior_pid is unknown, get and use the current thread id.
+ (remote_start_remote): on connecting, attempt to get the current
+ thread id for inferior_pid. (remote_resume): If pid == -1,
+ then resume any-thread (not the current thread specifically).
+ Also some cosmetic fixups.
+
+ * thread.c (info_threads_command): don't initialize current_pid
+ until after call to FIND_NEW_THREADS (which may change inferior_pid).
+ Also some cosmetic fixups.
+ * infrun.c: cosmetic fixups and casts to avoid warnings.
+ * infcmd.c: cosmetic fixups, mainly long lines.
+
Tue Jan 5 11:55:57 1999 David Taylor <taylor@texas.cygnus.com>
* target.c (noprocess): terminate sentence with a period.
/* These are the threads which we last sent to the remote system.
-1 for all or -2 for not sent yet. */
-int general_thread;
-int cont_thread;
+static int general_thread;
+static int cont_thread;
/* Call this function as a result of
1) A halt indication (T packet) containing a thread id
record_currthread (currthread)
int currthread;
{
+#if 0 /* target_wait must not modify inferior_pid! */
inferior_pid = currthread;
+#endif
general_thread = currthread;
+#if 0 /* setting cont_thread has a different meaning
+ from having the target report its thread id. */
cont_thread = currthread;
+#endif
+ /* If this is a new thread, add it to GDB's thread list.
+ If we leave it up to WFI to do this, bad things will happen. */
+ if (!in_thread_list (currthread))
+ add_thread (currthread);
}
+#define MAGIC_NULL_PID 42000
+
static void
set_thread (th, gen)
int th;
buf[0] = 'H';
buf[1] = gen ? 'g' : 'c';
- if (th == 42000)
+ if (th == MAGIC_NULL_PID)
{
buf[2] = '0';
buf[3] = '\0';
#define CRAZY_MAX_THREADS 1000
+int
+remote_current_thread (int oldpid)
+{
+ char buf[PBUFSIZ];
+
+ putpkt ("qC");
+ getpkt (buf, 0);
+ if (buf[0] == 'Q' && buf[1] == 'C')
+ return strtol (&buf[2], NULL, 16);
+ else
+ return oldpid;
+}
+
int
remote_find_new_threads (void)
{
ret = remote_threadlist_iterator (remote_newthread_step, 0,
CRAZY_MAX_THREADS);
+ if (inferior_pid == MAGIC_NULL_PID) /* ack ack ack */
+ inferior_pid = remote_current_thread (inferior_pid);
return ret;
} /* remote_find_new_threads */
/* Let the stub know that we want it to return the thread. */
set_thread (-1, 0);
+ inferior_pid = remote_current_thread (inferior_pid);
+
get_offsets (); /* Get text, data & bss offsets */
putpkt ("?"); /* initiate a query from remote machine */
variables, especially since GDB will someday have a notion of debugging
several processes. */
- inferior_pid = 42000;
+ inferior_pid = MAGIC_NULL_PID;
/* Start the remote connection; if error (0), discard this target.
In particular, if the user quits, be sure to discard it
(we'd be in an inconsistent state otherwise). */
char buf[PBUFSIZ];
if (pid == -1)
- set_thread (inferior_pid, 0);
+ set_thread (0, 0); /* run any thread */
else
- set_thread (pid, 0);
+ set_thread (pid, 0); /* run this thread */
dcache_flush (remote_dcache);
/* Initial thread value can only be acquired via wait, so deal with
this marker which is used before the first thread value is
acquired. */
- if (inferior_pid == 42000)
+ if (inferior_pid == MAGIC_NULL_PID)
{
inferior_pid = thread_num;
add_thread (inferior_pid);