From 43ac54fca353ea8d77d56dc5ad9e049bbb9a81fb Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 20 Feb 2019 14:29:23 -0700 Subject: [PATCH] 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 * gdbreplay.c (logchar): Handle \r\n. --- gdb/gdbserver/ChangeLog | 4 ++++ gdb/gdbserver/gdbreplay.c | 20 ++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index e9fe5ab03f0..b6086598fa7 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,7 @@ +2019-02-27 Tom Tromey + + * gdbreplay.c (logchar): Handle \r\n. + 2019-02-07 Alan Hayward * linux-low.c (linux_attach): Add process before lwp. diff --git a/gdb/gdbserver/gdbreplay.c b/gdb/gdbserver/gdbreplay.c index 26a55533ff6..bda8095839c 100644 --- a/gdb/gdbserver/gdbreplay.c +++ b/gdb/gdbserver/gdbreplay.c @@ -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; -- 2.30.2