Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: "'Yao Qi'" <yao@codesourcery.com>, <gdb-patches@sourceware.org>
Subject: RE: [PATCH 2/4] Transform "\r\n" in pattern to "\r+\n"
Date: Tue, 17 Sep 2013 23:11:00 -0000	[thread overview]
Message-ID: <006001ceb3fb$226d8890$674899b0$@muller@ics-cnrs.unistra.fr> (raw)
In-Reply-To: <1379423179-8515-3-git-send-email-yao@codesourcery.com>

  Hi Yao,

  I tried this some time ago, see:
https://sourceware.org/ml/gdb-patches/2010-06/msg00039.html

but I ended up with something much more complicated ...
The primary reason is that your code below will also change
[\r\n] into [\r+\n] which is not really what it should do...
It could also interfere with messages (not patterns)
in expcode that contain \r\n sequences...

  Finally, I think that there is also a completely orthogonal
solution to the problem you mention, which is to force
GDB to use binary mode for stdout and stderr instead of text mode.

  Your patch to fix the ordering of stderr versus stdout output seem to
work, so the only remaining specific mingw host is that GDB uses text mode
for its stdout and stderr.

  This is an adaptation/simplification of a previous idea I proposed, to
add:
maint set testsuite-mode on/off
command, which was both setting stdout and stderr to binary mode and 
disabled any buffering for this handles.

https://sourceware.org/ml/gdb-patches/2013-07/msg00701.html

I will try to submit this patch shortly.


Pierre Muller


> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Yao Qi
> Envoyé : mardi 17 septembre 2013 15:06
> À : gdb-patches@sourceware.org
> Objet : [PATCH 2/4] Transform "\r\n" in pattern to "\r+\n"
> 
> This patch transforms the "\r\n" in pattern to "\r+\n".  Note that
> "\r\n" in variable can't be transformed by this patch.
> 
> gdb/testsuite:
> 
> 2013-09-17  Yao Qi  <yao@codesourcery.com>
> 
> 	* lib/gdb.exp (gdb_transform_eol): New proc.
> 	(gdb_expect): Invoke gdb_transform_eol.
> 	* lib/mi-support.exp (mi_gdb_test): Likewise.
> ---
>  gdb/testsuite/lib/gdb.exp        |   22 ++++++++++++++++++++++
>  gdb/testsuite/lib/mi-support.exp |    2 ++
>  2 files changed, 24 insertions(+), 0 deletions(-)
> 
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 9b319e2..30d8755 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -2903,6 +2903,26 @@ proc send_gdb { string } {
>      return [remote_send host "$string"]
>  }
> 
> +# Transform the end-of-line in PATTERN.  In test cases, we assume
> +# that end-of-line is "\r\n", but that is not true on some targets.
> +# this proc transforms "\r\n" to the desired form.
> +
> +proc gdb_transform_eol { pattern } {
> +
> +    if [ishost "i?86-*-mingw*"] {
> +	# On Windows, when a file is opened in text mode, a "\n" is
> +	# always expanded to "\r\n", so gdb on Windows is outputting
> +	# "\r\n", and when that goes through the PTY, the '\n' is
> +	# being expanded to "\r\n", hence "\r\r\n".
> +	# Expand "\r\n" in $expcode to "\r+\n" in order to match
> +	# "\r\r\n".
> +	regsub -all {\\r\\n} $pattern {\\r+\\n} pattern
> +	regsub -all {\r\n} $pattern {\r+\n} pattern
> +    }
> +
> +    return $pattern
> +}
> +
>  #
>  #
> 
> @@ -2914,6 +2934,8 @@ proc gdb_expect { args } {
>  	set expcode $args
>      }
> 
> +    set expcode [gdb_transform_eol $expcode]
> +
>      upvar timeout timeout
> 
>      if [target_info exists gdb,timeout] {
> diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-
> support.exp
> index 86a0fd6..a9b22c2 100644
> --- a/gdb/testsuite/lib/mi-support.exp
> +++ b/gdb/testsuite/lib/mi-support.exp
> @@ -597,6 +597,8 @@ proc mi_gdb_test { args } {
>  	set question_string "^FOOBAR$"
>      }
> 
> +    set pattern [gdb_transform_eol $pattern]
> +
>      if $verbose>2 then {
>  	send_user "Sending \"$command\" to gdb\n"
>  	send_user "Looking to match \"$pattern\"\n"
> --
> 1.7.7.6


  reply	other threads:[~2013-09-17 23:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-16  1:07 [PATCH] native mingw32 gdb, eol format Yao Qi
2013-07-16  2:50 ` Eli Zaretskii
2013-07-20  0:38   ` Yao Qi
2013-07-20  6:55     ` Eli Zaretskii
2013-07-23 19:03     ` Tom Tromey
2013-07-23 19:08       ` Eli Zaretskii
2013-07-23 20:58         ` Tom Tromey
2013-07-24  3:46           ` Eli Zaretskii
2013-07-24  9:09             ` Yao Qi
2013-09-17 13:07       ` [PATCH 0/4] Match \r\r\n in testsuite Yao Qi
2013-09-17 13:07         ` [PATCH 4/4] Replace "." with "\r+" Yao Qi
2013-09-17 13:07         ` [PATCH 1/4] Use gdb_test_sequence to test "info tracepoints" Yao Qi
2013-09-17 13:07         ` [PATCH 3/4] Transform \r\n in MI variables Yao Qi
2013-09-17 13:07         ` [PATCH 2/4] Transform "\r\n" in pattern to "\r+\n" Yao Qi
2013-09-17 23:11           ` Pierre Muller [this message]
2013-09-17 13:35         ` [PATCH 0/4] Match \r\r\n in testsuite Joel Brobecker
2013-09-17 13:59           ` Yao Qi
2013-09-17 14:06             ` Joel Brobecker
2013-09-18  8:21               ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='006001ceb3fb$226d8890$674899b0$@muller@ics-cnrs.unistra.fr' \
    --to=pierre.muller@ics-cnrs.unistra.fr \
    --cc=gdb-patches@sourceware.org \
    --cc=yao@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox