Handle \r\n in gdbreplay
authorTom Tromey <tromey@adacore.com>
Wed, 20 Feb 2019 21:29:23 +0000 (14:29 -0700)
committerTom Tromey <tromey@adacore.com>
Wed, 27 Feb 2019 18:54:24 +0000 (11:54 -0700)
I tried gdbreplay yesterday, but the remotelogfile I received was made
on Windows, so the lines were terminated with \r\n rather than plain
\n.

This patch changes gdbreplay to allow \r\n line termination when
reading the log file.

gdb/gdbserver/ChangeLog
2019-02-27  Tom Tromey  <tromey@adacore.com>

* gdbreplay.c (logchar): Handle \r\n.

gdb/gdbserver/ChangeLog
gdb/gdbserver/gdbreplay.c

index e9fe5ab03f01cf1167fec8988b1b687b03552aa9..b6086598fa7c2e4255052952b31ec14052bee149 100644 (file)
@@ -1,3 +1,7 @@
+2019-02-27  Tom Tromey  <tromey@adacore.com>
+
+       * gdbreplay.c (logchar): Handle \r\n.
+
 2019-02-07  Alan Hayward  <alan.hayward@arm.com>
 
        * linux-low.c (linux_attach): Add process before lwp.
index 26a55533ff668d7ebd68eb6550a8150104b0def3..bda8095839c6ffd7968dc8338adea94061d2a630 100644 (file)
@@ -316,10 +316,26 @@ logchar (FILE *fp)
   int ch2;
 
   ch = fgetc (fp);
-  fputc (ch, stdout);
-  fflush (stdout);
+  if (ch != '\r')
+    {
+      fputc (ch, stdout);
+      fflush (stdout);
+    }
   switch (ch)
     {
+      /* Treat \r\n as a newline.  */
+    case '\r':
+      ch = fgetc (fp);
+      if (ch == '\n')
+       ch = EOL;
+      else
+       {
+         ungetc (ch, fp);
+         ch = '\r';
+       }
+      fputc (ch == EOL ? '\n' : '\r', stdout);
+      fflush (stdout);
+      break;
     case '\n':
       ch = EOL;
       break;
This page took 0.031559 seconds and 4 git commands to generate.