aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/gdbreplay.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2010-08-26 16:24:41 +0000
committerPedro Alves <palves@redhat.com>2010-08-26 16:24:41 +0000
commite581f2b4a7a47be66f64098c6bb8b2aaf7f34fe2 (patch)
tree0e585b77febbefcbd1106982767f3a0e460c37ff /gdb/gdbserver/gdbreplay.c
parent2ed91d1b8bf1075a9d827094f8cf3f1035b2fba4 (diff)
downloadgdb-e581f2b4a7a47be66f64098c6bb8b2aaf7f34fe2.zip
gdb-e581f2b4a7a47be66f64098c6bb8b2aaf7f34fe2.tar.gz
gdb-e581f2b4a7a47be66f64098c6bb8b2aaf7f34fe2.tar.bz2
* gdbreplay.c (remote_error): New.
(gdbchar): New. (expect): Use gdbchar. Check for error reading from GDB. Clarify sync error output. (play): Check for errors writing to GDB. * linux-low.c (sigchld_handler): Really ignore `write' errors. * remote-utils.c (getpkt): Check for errors writing to the remote descriptor.
Diffstat (limited to 'gdb/gdbserver/gdbreplay.c')
-rw-r--r--gdb/gdbserver/gdbreplay.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/gdb/gdbserver/gdbreplay.c b/gdb/gdbserver/gdbreplay.c
index 3ae8051..44e325b 100644
--- a/gdb/gdbserver/gdbreplay.c
+++ b/gdb/gdbserver/gdbreplay.c
@@ -163,6 +163,14 @@ sync_error (FILE *fp, char *desc, int expect, int got)
}
static void
+remote_error (const char *desc)
+{
+ fprintf (stderr, "\n%s\n", desc);
+ fflush (stderr);
+ exit (1);
+}
+
+static void
remote_close (void)
{
#ifdef USE_WIN32API
@@ -339,6 +347,17 @@ logchar (FILE *fp)
return (ch);
}
+static int
+gdbchar (int desc)
+{
+ unsigned char fromgdb;
+
+ if (read (desc, &fromgdb, 1) != 1)
+ return -1;
+ else
+ return fromgdb;
+}
+
/* Accept input from gdb and match with chars from fp (after skipping one
blank) up until a \n is read from fp (which is not matched) */
@@ -346,7 +365,7 @@ static void
expect (FILE *fp)
{
int fromlog;
- unsigned char fromgdb;
+ int fromgdb;
if ((fromlog = logchar (fp)) != ' ')
{
@@ -357,15 +376,16 @@ expect (FILE *fp)
{
fromlog = logchar (fp);
if (fromlog == EOL)
- {
- break;
- }
- read (remote_desc, &fromgdb, 1);
+ break;
+ fromgdb = gdbchar (remote_desc);
+ if (fromgdb < 0)
+ remote_error ("Error during read from gdb");
}
while (fromlog == fromgdb);
+
if (fromlog != EOL)
{
- sync_error (fp, "Sync error during read of gdb packet", fromlog,
+ sync_error (fp, "Sync error during read of gdb packet from log", fromlog,
fromgdb);
}
}
@@ -387,7 +407,8 @@ play (FILE *fp)
while ((fromlog = logchar (fp)) != EOL)
{
ch = fromlog;
- write (remote_desc, &ch, 1);
+ if (write (remote_desc, &ch, 1) != 1)
+ remote_error ("Error during write to gdb");
}
}