summaryrefslogtreecommitdiff
path: root/gdb/gdbserver/remote-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/gdbserver/remote-utils.c')
-rw-r--r--gdb/gdbserver/remote-utils.c100
1 files changed, 86 insertions, 14 deletions
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 14734f161bd..c610c4c0e7c 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -42,6 +42,10 @@ struct ui_file *gdb_stdlog;
static int remote_desc;
+/* FIXME headerize? */
+extern int using_threads;
+extern int debug_threads;
+
/* Open a connection to a remote debugger.
NAME is the filename used for communication. */
@@ -296,10 +300,17 @@ putpkt (char *buf)
}
if (remote_debug)
- printf ("putpkt (\"%s\"); [looking for ack]\n", buf2);
+ {
+ fprintf (stderr, "putpkt (\"%s\"); [looking for ack]\n", buf2);
+ fflush (stderr);
+ }
cc = read (remote_desc, buf3, 1);
if (remote_debug)
- printf ("[received '%c' (0x%x)]\n", buf3[0], buf3[0]);
+ {
+ fprintf (stderr, "[received '%c' (0x%x)]\n", buf3[0], buf3[0]);
+ fflush (stderr);
+ }
+
if (cc <= 0)
{
if (cc == 0)
@@ -310,6 +321,10 @@ putpkt (char *buf)
free (buf2);
return -1;
}
+
+ /* Check for an input interrupt while we're here. */
+ if (buf3[0] == '\003')
+ kill ((*the_target->signal_pid) (), SIGINT);
}
while (buf3[0] != '+');
@@ -346,7 +361,7 @@ input_interrupt (int unused)
return;
}
- kill (signal_pid, SIGINT);
+ kill ((*the_target->signal_pid) (), SIGINT);
}
}
@@ -411,7 +426,11 @@ getpkt (char *buf)
if (c == '$')
break;
if (remote_debug)
- printf ("[getpkt: discarding char '%c']\n", c);
+ {
+ fprintf (stderr, "[getpkt: discarding char '%c']\n", c);
+ fflush (stderr);
+ }
+
if (c < 0)
return -1;
}
@@ -441,12 +460,19 @@ getpkt (char *buf)
}
if (remote_debug)
- printf ("getpkt (\"%s\"); [sending ack] \n", buf);
+ {
+ fprintf (stderr, "getpkt (\"%s\"); [sending ack] \n", buf);
+ fflush (stderr);
+ }
write (remote_desc, "+", 1);
if (remote_debug)
- printf ("[sent ack]\n");
+ {
+ fprintf (stderr, "[sent ack]\n");
+ fflush (stderr);
+ }
+
return bp - buf;
}
@@ -499,8 +525,6 @@ convert_ascii_to_int (char *from, char *to, int n)
static char *
outreg (int regno, char *buf)
{
- int regsize = register_size (regno);
-
if ((regno >> 12) != 0)
*buf++ = tohex ((regno >> 12) & 0xf);
if ((regno >> 8) != 0)
@@ -508,14 +532,47 @@ outreg (int regno, char *buf)
*buf++ = tohex ((regno >> 4) & 0xf);
*buf++ = tohex (regno & 0xf);
*buf++ = ':';
- convert_int_to_ascii (register_data (regno), buf, regsize);
- buf += 2 * regsize;
+ collect_register_as_string (regno, buf);
+ buf += 2 * register_size (regno);
*buf++ = ';';
return buf;
}
void
+new_thread_notify (int id)
+{
+ char own_buf[256];
+
+ /* The `n' response is not yet part of the remote protocol. Do nothing. */
+ if (1)
+ return;
+
+ if (server_waiting == 0)
+ return;
+
+ sprintf (own_buf, "n%x", id);
+ disable_async_io ();
+ putpkt (own_buf);
+ enable_async_io ();
+}
+
+void
+dead_thread_notify (int id)
+{
+ char own_buf[256];
+
+ /* The `x' response is not yet part of the remote protocol. Do nothing. */
+ if (1)
+ return;
+
+ sprintf (own_buf, "x%x", id);
+ disable_async_io ();
+ putpkt (own_buf);
+ enable_async_io ();
+}
+
+void
prepare_resume_reply (char *buf, char status, unsigned char signo)
{
int nib, sig;
@@ -538,12 +595,23 @@ prepare_resume_reply (char *buf, char status, unsigned char signo)
regp ++;
}
- /* If the debugger hasn't used any thread features, don't burden it with
- threads. If we didn't check this, GDB 4.13 and older would choke. */
- if (cont_thread != 0)
+ /* Formerly, if the debugger had not used any thread features we would not
+ burden it with a thread status response. This was for the benefit of
+ GDB 4.13 and older. However, in recent GDB versions the check
+ (``if (cont_thread != 0)'') does not have the desired effect because of
+ sillyness in the way that the remote protocol handles specifying a thread.
+ Since thread support relies on qSymbol support anyway, assume GDB can handle
+ threads. */
+
+ if (using_threads)
{
+ /* FIXME right place to set this? */
+ thread_from_wait = ((struct inferior_list_entry *)current_inferior)->id;
+ if (debug_threads)
+ fprintf (stderr, "Writing resume reply for %d\n\n", thread_from_wait);
if (old_thread_from_wait != thread_from_wait)
{
+ general_thread = thread_from_wait;
sprintf (buf, "thread:%x;", thread_from_wait);
buf += strlen (buf);
old_thread_from_wait = thread_from_wait;
@@ -620,7 +688,11 @@ look_up_one_symbol (const char *name, CORE_ADDR *addrp)
{
/* Malformed response. */
if (remote_debug)
- fprintf (stderr, "Malformed response to qSymbol, ignoring.\n");
+ {
+ fprintf (stderr, "Malformed response to qSymbol, ignoring.\n");
+ fflush (stderr);
+ }
+
return -1;
}