From patchwork Thu Feb 21 14:05:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31541 Received: (qmail 100408 invoked by alias); 21 Feb 2019 14:05:24 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 100365 invoked by uid 89); 21 Feb 2019 14:05:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1106, HContent-Transfer-Encoding:8bit X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Feb 2019 14:05:19 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 962B4116239; Thu, 21 Feb 2019 09:05:17 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 2OMVPYOh4rc5; Thu, 21 Feb 2019 09:05:17 -0500 (EST) Received: from murgatroyd.Home (75-166-72-210.hlrn.qwest.net [75.166.72.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 42F7F116219; Thu, 21 Feb 2019 09:05:17 -0500 (EST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Handle \r\n in gdbreplay Date: Thu, 21 Feb 2019 07:05:13 -0700 Message-Id: <20190221140513.29508-1-tromey@adacore.com> MIME-Version: 1.0 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 or \r\n line termination when reading the log file. gdb/gdbserver/ChangeLog 2019-02-21 Tom Tromey * gdbreplay.c (logchar): Handle \r and \r\n. --- gdb/gdbserver/ChangeLog | 4 ++++ gdb/gdbserver/gdbreplay.c | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gdb/gdbserver/gdbreplay.c b/gdb/gdbserver/gdbreplay.c index 26a55533ff6..b1a9401909c 100644 --- a/gdb/gdbserver/gdbreplay.c +++ b/gdb/gdbserver/gdbreplay.c @@ -316,10 +316,21 @@ logchar (FILE *fp) int ch2; ch = fgetc (fp); - fputc (ch, stdout); - fflush (stdout); + if (ch != '\r') + { + fputc (ch, stdout); + fflush (stdout); + } switch (ch) { + /* Treat all of \r, \n, and \r\n as a newline. */ + case '\r': + ch = fgetc (fp); + if (ch != '\n') + ungetc (ch, fp); + fputc ('\n', stdout); + fflush (stdout); + /* Fall through. */ case '\n': ch = EOL; break;