aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog18
-rw-r--r--gdb/remote.c42
-rw-r--r--gdb/thread.c4
3 files changed, 55 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4ad938f..45bbdb7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,21 @@
+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.
diff --git a/gdb/remote.c b/gdb/remote.c
index f7866da..0bcc2dd 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -542,8 +542,8 @@ init_remote_threadtests PARAMS ((void));
/* 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
@@ -555,11 +555,22 @@ static void
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;
@@ -573,7 +584,7 @@ set_thread (th, gen)
buf[0] = 'H';
buf[1] = gen ? 'g' : 'c';
- if (th == 42000)
+ if (th == MAGIC_NULL_PID)
{
buf[2] = '0';
buf[3] = '\0';
@@ -1289,12 +1300,27 @@ remote_newthread_step (ref, context)
#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)
{
int ret;
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 */
@@ -1597,6 +1623,8 @@ remote_start_remote (dummy)
/* 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 */
@@ -1694,7 +1722,7 @@ serial device is attached to the remote system (e.g. /dev/ttya).");
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). */
@@ -1780,9 +1808,9 @@ remote_resume (pid, step, siggnal)
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);
@@ -2038,7 +2066,7 @@ Packet: '%s'\n",
/* 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);
diff --git a/gdb/thread.c b/gdb/thread.c
index 35bccf1..bf4631c 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -465,7 +465,7 @@ info_threads_command (arg, from_tty)
int from_tty;
{
struct thread_info *tp;
- int current_pid = inferior_pid;
+ int current_pid;
struct frame_info *cur_frame;
int saved_frame_level = selected_frame_level;
int counter;
@@ -478,7 +478,7 @@ info_threads_command (arg, from_tty)
#if defined(FIND_NEW_THREADS)
FIND_NEW_THREADS ();
#endif
-
+ current_pid = inferior_pid;
for (tp = thread_list; tp; tp = tp->next)
{
if (tp->pid == current_pid)