From patchwork Thu Feb 21 16:06:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31544 Received: (qmail 9243 invoked by alias); 21 Feb 2019 16:07:01 -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 9215 invoked by uid 89); 21 Feb 2019 16:07:01 -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:1923 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 16:06:59 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 3230F1164E1; Thu, 21 Feb 2019 11:06:58 -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 4isVP2yBNZPo; Thu, 21 Feb 2019 11:06:58 -0500 (EST) Received: from murgatroyd (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 B338C1164DD; Thu, 21 Feb 2019 11:06:57 -0500 (EST) From: Tom Tromey To: Eli Zaretskii Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [PATCH] Handle \r\n in gdbreplay References: <20190221140513.29508-1-tromey@adacore.com> <83sgwhfa1o.fsf@gnu.org> Date: Thu, 21 Feb 2019 09:06:57 -0700 In-Reply-To: <83sgwhfa1o.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 21 Feb 2019 17:14:43 +0200") Message-ID: <87y369jfby.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 >>>>> "Eli" == Eli Zaretskii writes: Eli> I'm okay with treating \r\n as a single \n, but do we really want to Eli> treat a single \r as if it were \n? I thought systems which used that Eli> EOL convention are not really widespread, to say the least. I normally handle \r this way out of habit I suppose. It doesn't matter that much to me, I guess \r isn't likely to be seen or made by accident. Tom commit eb7112d0f11809c25f415fa4f48aa6abe5fd84a4 Author: Tom Tromey Date: Wed Feb 20 14:29:23 2019 -0700 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-21 Tom Tromey * gdbreplay.c (logchar): Handle \r\n. diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index e9fe5ab03f0..be0d0e293b2 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,7 @@ +2019-02-21 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;