Handle \r\n in gdbreplay

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.
This commit is contained in:
Tom Tromey 2019-02-20 14:29:23 -07:00
parent 5862844d0f
commit 43ac54fca3
2 changed files with 22 additions and 2 deletions

View 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.

View 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;