Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] native mingw32 gdb, eol format
@ 2013-07-16  1:07 Yao Qi
  2013-07-16  2:50 ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Yao Qi @ 2013-07-16  1:07 UTC (permalink / raw)
  To: gdb-patches

Hello,
I see the following fail on a remote windows host for mingw32 native
gdb,

info tracepoints^M
Num     Type           Disp Enb Address    What^M^M
1       tracepoint     keep y   0x0040143f in gdb_c_test at actions.c:74^M^M
        not installed on target^M^M
2       tracepoint     keep y   0x00401687 in gdb_asm_test at actions.c:121^M^M
        not installed on target^M^M
3       tracepoint     keep y   0x004013d2 in gdb_recursion_test at actions.c:61^M^M
        not installed on target^M^M
(gdb) FAIL: gdb.trace/deltrace.exp: 3.1a: set three tracepoints

this fail is caused by an extra '\r' at end of each line.

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

This patch, which was written by Pedro, is to force stdout/stderr to
binary mode prevents that expansion.  This patch gets much
improvement on the test result of  mingw native gdb.  Is it OK?

                === gdb Summary ===

-# of expected passes           11845
-# of unexpected failures       2931
-# of expected failures         22
-# of unknown successes         1
-# of known failures            20
-# of unresolved testcases      911
-# of untested testcases                131
-# of unsupported tests         84
+# of expected passes           14613
+# of unexpected failures       780
+# of unexpected successes      1
+# of expected failures         37
+# of known failures            35
+# of unresolved testcases      23
+# of untested testcases                130
+# of unsupported tests         94


gdb:

2013-07-16  Pedro Alves  <pedro@codesourcery.com>
	    Yao Qi  <yao@codesourcery.com>

	* mingw-hdep.c (_initialize_mingw_hdep): If stdout and stderr
	are pipes, set them to binary mode.
---
 gdb/mingw-hdep.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/gdb/mingw-hdep.c b/gdb/mingw-hdep.c
index efc9848..3b29495 100644
--- a/gdb/mingw-hdep.c
+++ b/gdb/mingw-hdep.c
@@ -271,5 +271,24 @@ extern initialize_file_ftype _initialize_mingw_hdep;
 void
 _initialize_mingw_hdep (void)
 {
+  int out = fileno (stdout);
+  int err = fileno (stderr);
+  HANDLE hout = (HANDLE) _get_osfhandle (out);
+  HANDLE herr = (HANDLE) _get_osfhandle (err);
+
+  /* In textmode, a '\n' is automatically expanded into "\r\n".  When
+     driving the testsuite from a linux host, the '\n' is also
+     expanded into "\r\n".  This results in expect seeing "\r\r\n".
+     The tests aren't prepared currently for other forms of eol.  As a
+     workaround, we force the output to binary mode.  Do this only if
+     the files are pipes (cygwin ttys are Windows pipes behind the
+     scenes).  */
+  if (GetFileType (hout) == FILE_TYPE_PIPE
+      && GetFileType (herr) == FILE_TYPE_PIPE)
+    {
+      setmode (out, O_BINARY);
+      setmode (err, O_BINARY);
+    }
+
   sigint_event = CreateEvent (0, FALSE, FALSE, 0);
 }
-- 
1.7.7.6


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] native mingw32 gdb, eol format
  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
  0 siblings, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2013-07-16  2:50 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

> From: Yao Qi <yao@codesourcery.com>
> Date: Tue, 16 Jul 2013 09:06:07 +0800
> 
> This patch, which was written by Pedro, is to force stdout/stderr to
> binary mode prevents that expansion.  This patch gets much
> improvement on the test result of  mingw native gdb.  Is it OK?

No, it's not.  A MinGW GDB is a native Windows program, and should
behave like one.  Windows programs generally don't expect text coming
through pipes to have Unix EOL format.  Also, it is terribly confusing
to have GDB behave differently with its standard handles redirected to
a pipe as opposed to disk files or the console device.

This is a problem with the test suite, so please fix it in the test
suite.  If you _must_ make the change in GDB, please introduce some
specialized option to do that.  But changing the default behavior like
that is IMO a no-starter.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] native mingw32 gdb, eol format
  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
  0 siblings, 2 replies; 19+ messages in thread
From: Yao Qi @ 2013-07-20  0:38 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On 07/16/2013 10:50 AM, Eli Zaretskii wrote:
> No, it's not.  A MinGW GDB is a native Windows program, and should
> behave like one.  Windows programs generally don't expect text coming
> through pipes to have Unix EOL format.  Also, it is terribly confusing
> to have GDB behave differently with its standard handles redirected to
> a pipe as opposed to disk files or the console device.
> 

OK, that makes sense.  I also find something similar was discussed in
2009,

  [RFC] Improve testsuite for poor expect behavior
  http://sourceware.org/ml/gdb-patches/2009-06/msg00346.html

but patches didn't go in then.  I withdraw this patch.

> This is a problem with the test suite, so please fix it in the test
> suite.  If you_must_  make the change in GDB, please introduce some
> specialized option to do that.  But changing the default behavior like
> that is IMO a no-starter.

Looks fixing the testsuite to allow '\r\r\n' is a promising approach,
however it is not a small piece of work.  The patch below is a
proof-of-concept implementation, and we need to apply the change (\r
-> ${cr}) to the testsuite.  Please let me know is it what you
want, and then I can evaluate how much efforts are needed here.

-- 
Yao (齐尧)

gdb/testsuite:

	* gdb.trace/deltrace.exp: Match $cr at the end of each line.
	* lib/gdb.exp: Set cr.
---
 gdb/testsuite/gdb.trace/deltrace.exp |   20 ++++++++++----------
 gdb/testsuite/lib/gdb.exp            |    8 ++++++++
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/gdb/testsuite/gdb.trace/deltrace.exp b/gdb/testsuite/gdb.trace/deltrace.exp
index 1053629..3f2a8b7 100644
--- a/gdb/testsuite/gdb.trace/deltrace.exp
+++ b/gdb/testsuite/gdb.trace/deltrace.exp
@@ -82,12 +82,12 @@ if { $trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0 } then {
 
 gdb_test "info tracepoints" \
     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
+\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+${cr}
+\[\t \]+not installed on target${cr}
+\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+${cr}
+\[\t \]+not installed on target${cr}
+\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+${cr}
+\[\t \]+not installed on target${cr}" \
 			"3.2a: set three tracepoints"
 
 #gdb_test_no_output "delete tracepoint $trcpt1" ""
@@ -105,10 +105,10 @@ gdb_test_multiple "delete tracepoint $trcpt1" "3.2b: delete first tracepoint" {
 
 gdb_test "info tracepoints" \
     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
+\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+${cr}
+\[\t \]+not installed on target${cr}
+\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+${cr}
+\[\t \]+not installed on target${cr}" \
 			"3.2c: verify delete first tracepoint"
 
 #gdb_test_no_output "delete tracepoint $trcpt2" ""
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index cb92a94..5d2ad15 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -102,6 +102,14 @@ set octal "\[0-7\]+"
 
 set inferior_exited_re "(\\\[Inferior \[0-9\]+ \\(.*\\) exited)"
 
+# GDB configured for mingw or cygwin host can be run in a Cygwin PTY,
+# which expands '\n' to '\r\n', so the EOL ('\r\n') becomes '\r\r\n'.
+if { [ishost *-*-mingw*] || [ishost *cygwin*] } {
+    set cr "\r+"
+} else {
+    set cr "\r"
+}
+
 ### Only procedures should come after this point.
 
 #
-- 
1.7.7.6


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] native mingw32 gdb, eol format
  2013-07-20  0:38   ` Yao Qi
@ 2013-07-20  6:55     ` Eli Zaretskii
  2013-07-23 19:03     ` Tom Tromey
  1 sibling, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2013-07-20  6:55 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

> Date: Sat, 20 Jul 2013 08:37:40 +0800
> From: Yao Qi <yao@codesourcery.com>
> CC: <gdb-patches@sourceware.org>
> 
> > This is a problem with the test suite, so please fix it in the test
> > suite.  If you_must_  make the change in GDB, please introduce some
> > specialized option to do that.  But changing the default behavior like
> > that is IMO a no-starter.
> 
> Looks fixing the testsuite to allow '\r\r\n' is a promising approach,
> however it is not a small piece of work.  The patch below is a
> proof-of-concept implementation, and we need to apply the change (\r
> -> ${cr}) to the testsuite.  Please let me know is it what you
> want, and then I can evaluate how much efforts are needed here.

It is fine with me, but I don't know enough about the test suite to
give you a definitive approval.  I'm sure others will respond.

Thanks.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] native mingw32 gdb, eol format
  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-09-17 13:07       ` [PATCH 0/4] Match \r\r\n in testsuite Yao Qi
  1 sibling, 2 replies; 19+ messages in thread
From: Tom Tromey @ 2013-07-23 19:03 UTC (permalink / raw)
  To: Yao Qi; +Cc: Eli Zaretskii, gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> Looks fixing the testsuite to allow '\r\r\n' is a promising approach,
Yao> however it is not a small piece of work.  The patch below is a
Yao> proof-of-concept implementation, and we need to apply the change (\r
Yao> -> ${cr}) to the testsuite.  Please let me know is it what you
Yao> want, and then I can evaluate how much efforts are needed here.

Ouch.  That seems quite painful to do.

I wouldn't mind it, but I wonder whether there is another way.
Can we somehow use stty to set the terminal to adapt to this?
Could we maybe run gdb with a wrapper program (perhaps even another
instance of expect) to do the translation?
I looked a little at using Tcl's fconfigure on the fd opened by expect,
but that didn't seem useful in the end.

Tom


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] native mingw32 gdb, eol format
  2013-07-23 19:03     ` Tom Tromey
@ 2013-07-23 19:08       ` Eli Zaretskii
  2013-07-23 20:58         ` Tom Tromey
  2013-09-17 13:07       ` [PATCH 0/4] Match \r\r\n in testsuite Yao Qi
  1 sibling, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2013-07-23 19:08 UTC (permalink / raw)
  To: Tom Tromey; +Cc: yao, gdb-patches

> From: Tom Tromey <tromey@redhat.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, <gdb-patches@sourceware.org>
> Date: Tue, 23 Jul 2013 13:03:07 -0600
> 
> >>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:
> 
> Yao> Looks fixing the testsuite to allow '\r\r\n' is a promising approach,
> Yao> however it is not a small piece of work.  The patch below is a
> Yao> proof-of-concept implementation, and we need to apply the change (\r
> Yao> -> ${cr}) to the testsuite.  Please let me know is it what you
> Yao> want, and then I can evaluate how much efforts are needed here.
> 
> Ouch.  That seems quite painful to do.
> 
> I wouldn't mind it, but I wonder whether there is another way.
> Can we somehow use stty to set the terminal to adapt to this?
> Could we maybe run gdb with a wrapper program (perhaps even another
> instance of expect) to do the translation?

How about a special option to GDB, which would switch the GDB standard
streams to binary mode?


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] native mingw32 gdb, eol format
  2013-07-23 19:08       ` Eli Zaretskii
@ 2013-07-23 20:58         ` Tom Tromey
  2013-07-24  3:46           ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Tom Tromey @ 2013-07-23 20:58 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: yao, gdb-patches

>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

Eli> How about a special option to GDB, which would switch the GDB standard
Eli> streams to binary mode?

I wouldn't even mind that, though I think an option that is only
useful to the test suite is not as nice as localizing the fix to the
test suite somehow.

Tom


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] native mingw32 gdb, eol format
  2013-07-23 20:58         ` Tom Tromey
@ 2013-07-24  3:46           ` Eli Zaretskii
  2013-07-24  9:09             ` Yao Qi
  0 siblings, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2013-07-24  3:46 UTC (permalink / raw)
  To: Tom Tromey; +Cc: yao, gdb-patches

> From: Tom Tromey <tromey@redhat.com>
> Cc: yao@codesourcery.com, gdb-patches@sourceware.org
> Date: Tue, 23 Jul 2013 14:58:09 -0600
> 
> >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
> 
> Eli> How about a special option to GDB, which would switch the GDB standard
> Eli> streams to binary mode?
> 
> I wouldn't even mind that, though I think an option that is only
> useful to the test suite is not as nice as localizing the fix to the
> test suite somehow.

If the fix can be localized, I agree.

Btw, the same option could also take care of the buffering issue,
which was discussed elsewhere yesterday.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] native mingw32 gdb, eol format
  2013-07-24  3:46           ` Eli Zaretskii
@ 2013-07-24  9:09             ` Yao Qi
  0 siblings, 0 replies; 19+ messages in thread
From: Yao Qi @ 2013-07-24  9:09 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Tom Tromey, gdb-patches

On 07/24/2013 11:46 AM, Eli Zaretskii wrote:
> Btw, the same option could also take care of the buffering issue,
> which was discussed elsewhere yesterday.

Yes, we can add one option to take care of these two issues.  I'll post 
a patch.

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 4/4] Replace "." with "\r+".
  2013-09-17 13:07       ` [PATCH 0/4] Match \r\r\n in testsuite Yao Qi
                           ` (2 preceding siblings ...)
  2013-09-17 13:07         ` [PATCH 1/4] Use gdb_test_sequence to test "info tracepoints" Yao Qi
@ 2013-09-17 13:07         ` Yao Qi
  2013-09-17 13:35         ` [PATCH 0/4] Match \r\r\n in testsuite Joel Brobecker
  4 siblings, 0 replies; 19+ messages in thread
From: Yao Qi @ 2013-09-17 13:07 UTC (permalink / raw)
  To: gdb-patches

These "gdb_test" can't be replaced by "gdb_test_sequence" because
variables are used in patterns, and variables can't be expanded.
We replace "." with "\r+" one by one.

gdb/testsuite:

2013-09-17  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/tracecmd.exp (gdb_delete_tracepoints): Replace "."
	with "\r+" in patterns.
	* gdb.trace/while-stepping.exp: Likewise.
---
 gdb/testsuite/gdb.trace/tracecmd.exp       |   12 ++++++------
 gdb/testsuite/gdb.trace/while-stepping.exp |    2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/gdb.trace/tracecmd.exp b/gdb/testsuite/gdb.trace/tracecmd.exp
index 81dc1ed..a239d75 100644
--- a/gdb/testsuite/gdb.trace/tracecmd.exp
+++ b/gdb/testsuite/gdb.trace/tracecmd.exp
@@ -62,7 +62,7 @@ gdb_delete_tracepoints
 gdb_test "trace $srcfile:$testline2" \
 	"Tracepoint $decimal at $hex: file.*$srcfile, line $testline2." \
 	"1.1a: set tracepoint at sourceline"
-gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2.
+gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2\r+
 \[\t \]+not installed on target." \
 	"1.1b: trace sourcefile:line"
 
@@ -86,7 +86,7 @@ gdb_delete_tracepoints
 gdb_test "trace gdb_recursion_test" \
 	"Tracepoint $decimal at $hex: file.*$srcfile, line $testline1." \
 	"1.4a: trace function by name"
-gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1.
+gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1\r+
 \[\t \]+not installed on target." \
 	"1.4b: trace function by name"
 
@@ -124,7 +124,7 @@ gdb_delete_tracepoints
 gdb_test "trace \*gdb_recursion_test" \
 	"Tracepoint $decimal at .*$c_test_addr.*" \
 	"1.7a: trace at function label (before prologue)"
-gdb_test "info trace" "$c_test_addr.*in gdb_recursion_test.*:$baseline.
+gdb_test "info trace" "$c_test_addr.*in gdb_recursion_test.*:$baseline\r+
 \[\t \]+not installed on target." \
 	"1.7b: verify trace at specific address"
 
@@ -142,9 +142,9 @@ gdb_delete_tracepoints
 gdb_test "trace gdb_recursion_test if q1 > 0" \
 	"Tracepoint $decimal at $hex: file.*$srcfile, line $testline1." \
 	"1.11a: conditional tracepoint"
-gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1.
-\[\t \]+trace only if q1 > 0.
-\[\t \]+not installed on target." \
+gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1\r+
+\[\t \]+trace only if q1 > 0\r+
+\[\t \]+not installed on target\r+" \
 	"1.11b: verify conditional tracepoint"
 
 # 1.12 set tracepoint in prologue
diff --git a/gdb/testsuite/gdb.trace/while-stepping.exp b/gdb/testsuite/gdb.trace/while-stepping.exp
index 3202ea5..77dba1d 100644
--- a/gdb/testsuite/gdb.trace/while-stepping.exp
+++ b/gdb/testsuite/gdb.trace/while-stepping.exp
@@ -97,7 +97,7 @@ gdb_trace_setactions "5.16: step without collecting anything" \
 
 gdb_test "info tracepoints" \
     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
+\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+\r+
 .*while-stepping $stepcount.*
 .*end.*" \
 	"5.16: confirm actions, step without collecting anything"
-- 
1.7.7.6


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 0/4] Match \r\r\n in testsuite
  2013-07-23 19:03     ` Tom Tromey
  2013-07-23 19:08       ` Eli Zaretskii
@ 2013-09-17 13:07       ` Yao Qi
  2013-09-17 13:07         ` [PATCH 2/4] Transform "\r\n" in pattern to "\r+\n" Yao Qi
                           ` (4 more replies)
  1 sibling, 5 replies; 19+ messages in thread
From: Yao Qi @ 2013-09-17 13:07 UTC (permalink / raw)
  To: gdb-patches

This is a follow-up to the thread

  [PATCH] native mingw32 gdb, eol format
  https://sourceware.org/ml/gdb-patches/2013-07/msg00358.html

At the very beginning, I proposed to either add a new option or set
stderr/stdout to binary mode, neither is acceptable because of its
drawback.  We don't want to add a new option only for running
testsuite on a certain configuration, and don't want to change GDB's
output behavior.

Then, I restarted from the beginning again, and see if we can fix the
problem by modifying testsuite.  The requirement expressed in the
previous patch review is that we should localize the changes to
testsuite to match \r\r\n.

This patch series is to change testsuite to match both \r\n and
\r\r\n by modifying pattern to \r+\n in a localized manner.  Patch 1/4
is to replace gdb_test with gdb_test_sequence to match the output of
"info tracepoints", so that the assumption of last character of each
line is removed, so these patterns can be matched on all targets.
Patch 2/4 is to transform \r\n in patterns to \r+\n, but \r\n in
variables can't be transformed.  Patch 3/4 transforms \r\n in variables.

The whole series are tested on mingw32 native gdb, and compared with
running gdb with stdout/stderr setting to binary mode.  No extra fails.

*** BLURB HERE ***

Yao Qi (4):
  Use gdb_test_sequence to test "info tracepoints"
  Transform "\r\n" in pattern to "\r+\n"
  Transform \r\n in MI variables
  Replace "." with "\r+".

 gdb/testsuite/gdb.trace/actions.exp        |  119 +++++++++--------
 gdb/testsuite/gdb.trace/deltrace.exp       |   78 ++++++------
 gdb/testsuite/gdb.trace/infotrace.exp      |   36 +++---
 gdb/testsuite/gdb.trace/passcount.exp      |  200 ++++++++++++++-------------
 gdb/testsuite/gdb.trace/tracecmd.exp       |   12 +-
 gdb/testsuite/gdb.trace/while-stepping.exp |   25 ++--
 gdb/testsuite/lib/gdb.exp                  |   22 +++
 gdb/testsuite/lib/mi-support.exp           |   12 +-
 8 files changed, 273 insertions(+), 231 deletions(-)

-- 
1.7.7.6


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 2/4] Transform "\r\n" in pattern to "\r+\n"
  2013-09-17 13:07       ` [PATCH 0/4] Match \r\r\n in testsuite Yao Qi
@ 2013-09-17 13:07         ` Yao Qi
  2013-09-17 23:11           ` Pierre Muller
  2013-09-17 13:07         ` [PATCH 3/4] Transform \r\n in MI variables Yao Qi
                           ` (3 subsequent siblings)
  4 siblings, 1 reply; 19+ messages in thread
From: Yao Qi @ 2013-09-17 13:07 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/4] Use gdb_test_sequence to test "info tracepoints"
  2013-09-17 13:07       ` [PATCH 0/4] Match \r\r\n in testsuite Yao Qi
  2013-09-17 13:07         ` [PATCH 2/4] Transform "\r\n" in pattern to "\r+\n" Yao Qi
  2013-09-17 13:07         ` [PATCH 3/4] Transform \r\n in MI variables Yao Qi
@ 2013-09-17 13:07         ` Yao Qi
  2013-09-17 13:07         ` [PATCH 4/4] Replace "." with "\r+" Yao Qi
  2013-09-17 13:35         ` [PATCH 0/4] Match \r\r\n in testsuite Joel Brobecker
  4 siblings, 0 replies; 19+ messages in thread
From: Yao Qi @ 2013-09-17 13:07 UTC (permalink / raw)
  To: gdb-patches

This patch replaces 'gdb_test' with 'gdb_test_sequence' to match the
output of "info tracepoints", which has multiple lines.  With this
patch, these tests become more readable.

On the other hand, these tests have an assumption that there is one
"\r" at the end of the line, shown as below,

gdb_test "info tracepoints" \
    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
                                                                           ^^^
\[\t \]+not installed on target." \
                               ^^
	"5.12: set a tracepoint, stepcount is zero"

The period is to match "\r" in the output.  However, when running mingw32
native GDB, the end-of-line becomes "\r\r\n", so the single period in
the pattern can't match.  Replacing with 'gdb_test_sequence' get rid
of this assumption, and these tests pass on mingw32 as a result.  On
the other hand, it is easier to maintain the cases using
'gdb_test_sequence', IMO.

gdb/testsuite:

2013-09-17  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/actions.exp: Use proc gdb_test_sequence to test
	"info tracepoints".
	* gdb.trace/infotrace.exp: Likewise.
	* gdb.trace/passcount.exp: Likewise.
	* gdb.trace/while-stepping.exp: Likewise.
---
 gdb/testsuite/gdb.trace/actions.exp        |  119 +++++++++--------
 gdb/testsuite/gdb.trace/deltrace.exp       |   78 ++++++------
 gdb/testsuite/gdb.trace/infotrace.exp      |   36 +++---
 gdb/testsuite/gdb.trace/passcount.exp      |  200 ++++++++++++++-------------
 gdb/testsuite/gdb.trace/while-stepping.exp |   23 ++--
 5 files changed, 237 insertions(+), 219 deletions(-)

diff --git a/gdb/testsuite/gdb.trace/actions.exp b/gdb/testsuite/gdb.trace/actions.exp
index becfc4c..86a53da 100644
--- a/gdb/testsuite/gdb.trace/actions.exp
+++ b/gdb/testsuite/gdb.trace/actions.exp
@@ -76,49 +76,52 @@ gdb_trace_setactions "5.1b: set actions for first tracepoint" \
 	"$trcpt1" \
 	"collect gdb_char_test" "^$"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_char_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-		"5.1c: verify actions set for first tracepoint"
+gdb_test_sequence "info tracepoints" \
+    "5.1c: verify actions set for first tracepoint" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]        collect gdb_char_test"
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]3       tracepoint     keep y.* in gdb_recursion_test at "
+	"\[\r\n\]\tnot installed on target"
+    }
 
 gdb_trace_setactions "5.1d: set actions for second tracepoint" \
 	"$trcpt2" \
 	"collect gdb_short_test" "^$"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_char_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_short_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-		"5.1e: verify actions set for second tracepoint"
+gdb_test_sequence "info tracepoints" \
+    "5.1e: verify actions set for second tracepoint" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]        collect gdb_char_test"
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+	"\[\r\n\]        collect gdb_short_test"
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]3       tracepoint     keep y.* in gdb_recursion_test at "
+	"\[\r\n\]\tnot installed on target"
+    }
 
 gdb_trace_setactions "5.2a: set actions for last (default) tracepoint" \
 	"" \
 	"collect gdb_long_test" "^$"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_char_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_short_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_long_test.
-\[\t \]+not installed on target." \
-		"5.2b: verify actions set for second tracepoint"
+gdb_test_sequence "info tracepoints" \
+    "5.2b: verify actions set for second tracepoint" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]        collect gdb_char_test"
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+	"\[\r\n\]        collect gdb_short_test"
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]3       tracepoint     keep y.* in gdb_recursion_test at "
+	"\[\r\n\]        collect gdb_long_test"
+	"\[\r\n\]\tnot installed on target"
+    }
 
 # 5.3 replace actions set earlier
 
@@ -126,18 +129,19 @@ gdb_trace_setactions "5.3a: reset actions for first tracepoint" \
 	"$trcpt1" \
 	"collect gdb_struct1_test" "^$"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_struct1_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_short_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_long_test.
-\[\t \]+not installed on target." \
-		"5.3b: verify actions set for first tracepoint"
+gdb_test_sequence "info tracepoints" \
+    "5.3b: verify actions set for first tracepoint" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]        collect gdb_struct1_test"
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+	"\[\r\n\]        collect gdb_short_test"
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]3       tracepoint     keep y.* in gdb_recursion_test at "
+	"\[\r\n\]        collect gdb_long_test"
+	"\[\r\n\]\tnot installed on target"
+    }
 
 #
 # test end command (all by itself)
@@ -222,18 +226,19 @@ gdb_trace_setactions "5.10a: set teval action for second tracepoint" \
 	"$trcpt2" \
 	"teval \$tsv += 1" "^$"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+teval gdb_char_test.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+teval \\\$tsv \\\+= 1.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+collect gdb_long_test.
-\[\t \]+not installed on target." \
-		"5.10a: verify teval actions set for two tracepoints"
+gdb_test_sequence "info tracepoints" \
+    "5.10a: verify teval actions set for two tracepoints" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]        teval gdb_char_test"
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+	"\[\r\n\]        teval \\\$tsv \\\+= 1"
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]3       tracepoint     keep y.* in gdb_recursion_test at "
+	"\[\r\n\]        collect gdb_long_test"
+	"\[\r\n\]\tnot installed on target"
+    }
 
 gdb_test "break main"
 gdb_run_cmd
diff --git a/gdb/testsuite/gdb.trace/deltrace.exp b/gdb/testsuite/gdb.trace/deltrace.exp
index 1053629..f89332d 100644
--- a/gdb/testsuite/gdb.trace/deltrace.exp
+++ b/gdb/testsuite/gdb.trace/deltrace.exp
@@ -53,15 +53,15 @@ gdb_test "trace gdb_c_test"   "Tracepoint \[0-9\]+ at .*" "set tracepoint 1"
 gdb_test "trace gdb_asm_test" "Tracepoint \[0-9\]+ at .*" "set tracepoint 2"
 gdb_test "trace $testline1"   "Tracepoint \[0-9\]+ at .*" "set tracepoint 3"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-			"3.1a: set three tracepoints"
+gdb_test_sequence "info tracepoints" "3.1a: set three tracepoints" {
+    "\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+    "\[\r\n\]1       tracepoint     keep y .* in gdb_c_test at "
+    "\[\r\n\]\tnot installed on target"
+    "\[\r\n\]2       tracepoint     keep y .* in gdb_asm_test at "
+    "\[\r\n\]\tnot installed on target"
+    "\[\r\n\]3       tracepoint     keep y .* in gdb_recursion_test at "
+    "\[\r\n\]\tnot installed on target"
+}
 
 gdb_test "delete tracepoints" \
     "" \
@@ -80,15 +80,15 @@ if { $trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0 } then {
     return
 }
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-			"3.2a: set three tracepoints"
+gdb_test_sequence "info tracepoints" "3.2a: set three tracepoints" {
+    "\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+    "\[\r\n\]4       tracepoint     keep y .* in gdb_c_test at "
+    "\[\r\n\]\tnot installed on target"
+    "\[\r\n\]5       tracepoint     keep y.* in gdb_asm_test at "
+    "\[\r\n\]\tnot installed on target"
+    "\[\r\n\]6       tracepoint     keep y.* in gdb_recursion_test at "
+    "\[\r\n\]\tnot installed on target"
+}
 
 #gdb_test_no_output "delete tracepoint $trcpt1" ""
 gdb_test_multiple "delete tracepoint $trcpt1" "3.2b: delete first tracepoint" {
@@ -103,13 +103,13 @@ gdb_test_multiple "delete tracepoint $trcpt1" "3.2b: delete first tracepoint" {
     }
 }
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-			"3.2c: verify delete first tracepoint"
+gdb_test_sequence "info tracepoints" "3.2c: verify delete first tracepoint" {
+    "Num     Type\[ \]+Disp Enb Address\[ \]+What"
+    "\[\r\n\]5       tracepoint     keep y.* in gdb_asm_test at "
+    "\[\r\n]\tnot installed on target"
+    "\[\r\n\]6       tracepoint     keep y.* in gdb_recursion_test at "
+    "\[\r\n]\tnot installed on target"
+}
 
 #gdb_test_no_output "delete tracepoint $trcpt2" ""
 gdb_test_multiple "delete tracepoint $trcpt2" "3.2d: delete second tracepoint" {
@@ -124,11 +124,11 @@ gdb_test_multiple "delete tracepoint $trcpt2" "3.2d: delete second tracepoint" {
     }
 }
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-			"3.2e: verify delete second tracepoint"
+gdb_test_sequence "info tracepoints" "3.2e: verify delete second tracepoint" {
+    "\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+    "\[\r\n\]6       tracepoint     keep y.* in gdb_recursion_test at "
+    "\[\r\n\]\tnot installed on target"
+}
 
 #gdb_test_no_output "delete tracepoint $trcpt3" ""
 gdb_test_multiple "delete tracepoint $trcpt3" "3.2f: delete third tracepoint" {
@@ -158,15 +158,15 @@ if { $trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0 } then {
     return
 }
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-			"3.3a: set three tracepoints"
+gdb_test_sequence "info tracepoints" "3.3a: set three tracepoints" {
+    "\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+    "\[\r\n\]7       tracepoint     keep y.* in gdb_c_test at "
+    "\[\r\n\]\tnot installed on target"
+    "\[\r\n\]8       tracepoint     keep y.* in gdb_asm_test at "
+    "\[\r\n\]\tnot installed on target"
+    "\[\r\n\]9       tracepoint     keep y.* in gdb_recursion_test at "
+    "\[\r\n\]\tnot installed on target"
+}
 
 #gdb_test_no_output "delete tracepoint $trcpt1 $trcpt2 $trcpt3" ""
 gdb_test_multiple "delete tracepoint $trcpt1 $trcpt2 $trcpt3" \
diff --git a/gdb/testsuite/gdb.trace/infotrace.exp b/gdb/testsuite/gdb.trace/infotrace.exp
index 3a586cd..0cd168e 100644
--- a/gdb/testsuite/gdb.trace/infotrace.exp
+++ b/gdb/testsuite/gdb.trace/infotrace.exp
@@ -47,26 +47,28 @@ if { $c_test_num <= 0 || $asm_test_num <= 0 } then {
 }
 
 # 2.1 info tracepoints (all)
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-    "2.1: info tracepoints (all)"
+gdb_test_sequence "info tracepoints" "2.1: info tracepoints (all)" {
+    "\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+    "\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+    "\[\r\n\]\tnot installed on target"
+    "\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+    "\[\r\n\]\tnot installed on target"
+}
 
 # 2.2 info tracepoint (specific)
-gdb_test "info tracepoint $c_test_num" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-    "2.2a: info tracepoint $c_test_num (gdb_c_test)"
+gdb_test_sequence "info tracepoint $c_test_num" \
+    "2.2a: info tracepoint $c_test_num (gdb_c_test)" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]\tnot installed on target"
+    }
 
-gdb_test "info tracepoint $asm_test_num" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-    "2.2b: info tracepoint $asm_test_num (gdb_asm_test)"
+gdb_test_sequence "info tracepoint $asm_test_num" \
+    "2.2b: info tracepoint $asm_test_num (gdb_asm_test)" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+	"\[\r\n\]\tnot installed on target."
+    }
 
 # 2.3 info tracepoint (invalid tracepoint number)
 gdb_test "info tracepoint [expr $c_test_num + $asm_test_num]" \
diff --git a/gdb/testsuite/gdb.trace/passcount.exp b/gdb/testsuite/gdb.trace/passcount.exp
index a179021..35231e4 100644
--- a/gdb/testsuite/gdb.trace/passcount.exp
+++ b/gdb/testsuite/gdb.trace/passcount.exp
@@ -58,46 +58,48 @@ if { $trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0 } then {
 
 # 4.1 passcount of specified tracepoint
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-			"4.1a: set three tracepoints, passcounts all zero"
+gdb_test_sequence "info tracepoints" \
+    "4.1a: set three tracepoints, passcounts all zero" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]3       tracepoint     keep y.* in gdb_recursion_test at "
+	"\[\r\n\]\tnot installed on target"
+    }
 
 gdb_test "passcount 2 $trcpt1" \
 	"Setting tracepoint $trcpt1.s passcount to 2" \
 	"4.1b: set 1st tracepoint's passcount to two"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 2 .
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-	"4.1c: verify 1st tracepoint's passcount set to two"
-
+gdb_test_sequence "info tracepoints" \
+    "4.1c: verify 1st tracepoint's passcount set to two" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]\tpass count 2 "
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]3       tracepoint     keep y.* in gdb_recursion_test at "
+	"\[\r\n\]\tnot installed on target"
+    }
 gdb_test "passcount 4 $trcpt2" \
 	"Setting tracepoint $trcpt2.s passcount to 4" \
 	"4.1d: set 2nd tracepoint's passcount to four"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 2 .
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 4 .
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-	"4.1c: verify 2nd tracepoint's passcount set to four"
+gdb_test_sequence "info tracepoints" \
+    "4.1c: verify 2nd tracepoint's passcount set to four" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]\tpass count 2 "
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+	"\[\r\n\]\tpass count 4 "
+	"\[\r\n\]\tnot installed on target"
+	"\[\r\n\]3       tracepoint     keep y.* in gdb_recursion_test at "
+	"\[\r\n\]\tnot installed on target"
+}
 
 # 4.2 passcount of last (default) tracepoint
 
@@ -105,15 +107,16 @@ gdb_test "passcount 6" \
 	"Setting tracepoint $trcpt3.s passcount to 6" \
 	"4.2b: set last (default) tp's passcount to six"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 2 .*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 4 .*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 6 .*" \
-	"4.2b: verify last (default) tp's passcount set to six"
+gdb_test_sequence "info tracepoints" \
+    "4.2b: verify last (default) tp's passcount set to six" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]\tpass count 2 "
+	"\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+	"\[\r\n\]\tpass count 4 "
+	"\[\r\n\]3       tracepoint     keep y.* in gdb_recursion_test at "
+	"\[\r\n\]\tpass count 6 "
+    }
 
 # 4.3 run until stopped explicitly by user
 #     [deferred to dynamic test section]
@@ -124,29 +127,31 @@ gdb_test "passcount 7" \
 	"Setting tracepoint $trcpt3.s passcount to 7" \
 	"4.4a: reset last (default) tp's passcount to seven"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 2 .*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 4 .*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 7 .*" \
-	"4.4a: verify reset last (default) tp's passcount to seven"
+gdb_test_sequence "info tracepoints" \
+    "4.4a: verify reset last (default) tp's passcount to seven" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]\tpass count 2 "
+	"\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+	"\[\r\n\]\tpass count 4 "
+	"\[\r\n\]3       tracepoint     keep y.* in gdb_recursion_test at "
+	"\[\r\n\]\tpass count 7 "
+    }
 
 gdb_test "passcount 5 $trcpt2" \
 	"Setting tracepoint $trcpt2.s passcount to 5" \
 	"4.4b: reset second tracepoint's passcount to five"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 2 .*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 5 .*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 7 .*" \
-	"4.4c: verify reset second tracepoint's passcount to five"
+gdb_test_sequence "info tracepoints" \
+    "4.4c: verify reset second tracepoint's passcount to five" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]\tpass count 2 "
+	"\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+	"\[\r\n\]\tpass count 5 "
+	"\[\r\n\]3       tracepoint     keep y.* in gdb_recursion_test at "
+	"\[\r\n\]\tpass count 7 "
+    }
 
 # 4.20 <FIXME test number> passcount for "all"
 
@@ -154,29 +159,31 @@ gdb_test "passcount 3 all" \
 	".*$trcpt1.s pass.* 3.*$trcpt2.s pass.* 3.*$trcpt3.s pass.* 3" \
 	"4.20a: set all three passcounts to three"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 3 .*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 3 .*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 3 .*"  \
-	"4.20a: set all three passcounts to three"
+gdb_test_sequence "info tracepoints" \
+    "4.20a: set all three passcounts to three" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y .* in gdb_c_test at "
+	"\[\r\n\]\tpass count 3 "
+	"\[\r\n\]2       tracepoint     keep y .* in gdb_asm_test at "
+	"\[\r\n\]\tpass count 3 "
+	"\[\r\n\]3       tracepoint     keep y .* in gdb_recursion_test at "
+	"\[\r\n\]\tpass count 3 "
+    }
 
 gdb_test "passcount 4 all" \
 	".*$trcpt1.s pass.* 4.*$trcpt2.s pass.* 4.*$trcpt3.s pass.* 4" \
 	"4.20a: reset all three passcounts to four"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 4 .*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 4 .*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 4 .*"  \
-	"4.20b: reset all three passcounts to four"
+gdb_test_sequence "info tracepoints" \
+    "4.20b: reset all three passcounts to four" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]\tpass count 4 "
+	"\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+	"\[\r\n\]\tpass count 4 "
+	"\[\r\n\]3       tracepoint     keep y.* in gdb_recursion_test at "
+	"\[\r\n\]\tpass count 4 "
+    }
 
 # 4.5 Verify trace stops on first "satisfied" passcount
 #     [deferred to dynamic test section]
@@ -187,17 +194,17 @@ gdb_test "passcount 0 $trcpt1" \
 	"Setting tracepoint $trcpt1.s passcount to 0" \
 	"4.6: set passcount to zero"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 4 .
-\[\t \]+not installed on target.
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 4 .
-\[\t \]+not installed on target."  \
-	"4.6: set passcount to zero"
+gdb_test_sequence "info tracepoints" "4.6: set passcount to zero" {
+    "\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+    "\[\r\n\]1       tracepoint     keep y .* in gdb_c_test at "
+    "\[\r\n\]\tnot installed on target"
+    "\[\r\n\]2       tracepoint     keep y .* in gdb_asm_test at "
+    "\[\r\n\]\tpass count 4 "
+    "\[\r\n\]\tnot installed on target"
+    "\[\r\n\]3       tracepoint     keep y .* in gdb_recursion_test at "
+    "\[\r\n\]\tpass count 4 "
+    "\[\r\n\]\tnot installed on target"
+}
 
 # 4.7 (test a very large passcount)
 
@@ -205,15 +212,16 @@ gdb_test "passcount 32767 $trcpt1" \
 	"Setting tracepoint $trcpt1.s passcount to 32767" \
 	"4.7: set passcount to large number (32767)"
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 32767 .*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 4 .*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+.
-\[\t \]+pass count 4 .*"  \
-	"4.7: set passcount to large number (32767)"
+gdb_test_sequence "info tracepoints" \
+    "4.7: set passcount to large number (32767)" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]\tpass count 32767 "
+	"\[\r\n\]2       tracepoint     keep y.* in gdb_asm_test at "
+	"\[\r\n\]\tpass count 4 "
+	"\[\r\n\]3       tracepoint     keep y.* in gdb_recursion_test at "
+	"\[\r\n\]\tpass count 4 "
+    }
 
 # 4.8 set passcount for invalid tracepoint
 
diff --git a/gdb/testsuite/gdb.trace/while-stepping.exp b/gdb/testsuite/gdb.trace/while-stepping.exp
index 3e60587..3202ea5 100644
--- a/gdb/testsuite/gdb.trace/while-stepping.exp
+++ b/gdb/testsuite/gdb.trace/while-stepping.exp
@@ -47,11 +47,13 @@ if { $trcpt1 <= 0 } then {
 
 # 5.12 basic while-stepping command (collect regs)
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+not installed on target." \
-	"5.12: set a tracepoint, stepcount is zero"
+gdb_test_sequence "info tracepoints" \
+    "5.12: set a tracepoint, stepcount is zero" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]\tnot installed on target"
+    }
+
 
 set stepcount 12
 
@@ -61,11 +63,12 @@ gdb_trace_setactions "5.12: set stepcount to $stepcount" \
 	"collect \$regs" "^$" \
 	"end" ""
 
-gdb_test "info tracepoints" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+tracepoint     keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
-\[\t \]+while-stepping 12.*" \
-	"5.12: info trace shows \"while-stepping\""
+gdb_test_sequence "info tracepoints" \
+    "5.12: info trace shows \"while-stepping\"" {
+	"\[\r\n\]Num     Type\[ \]+Disp Enb Address\[ \]+What"
+	"\[\r\n\]1       tracepoint     keep y.* in gdb_c_test at "
+	"\[\r\n\]        while-stepping 12"
+    }
 
 # 5.13 step out of context while collecting local variable
 #      [deferred to dynamic test section]
-- 
1.7.7.6


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 3/4] Transform \r\n in MI variables
  2013-09-17 13:07       ` [PATCH 0/4] Match \r\r\n in testsuite Yao Qi
  2013-09-17 13:07         ` [PATCH 2/4] Transform "\r\n" in pattern to "\r+\n" Yao Qi
@ 2013-09-17 13:07         ` Yao Qi
  2013-09-17 13:07         ` [PATCH 1/4] Use gdb_test_sequence to test "info tracepoints" Yao Qi
                           ` (2 subsequent siblings)
  4 siblings, 0 replies; 19+ messages in thread
From: Yao Qi @ 2013-09-17 13:07 UTC (permalink / raw)
  To: gdb-patches

The previous patch can't transform \r\n in variables, so this patch
update these variables which have \r\n in MI.

gdb/testsuite:

2013-09-17  Yao Qi  <yao@codesourcery.com>

	* lib/mi-support.exp (mi_gdb_prompt): Replace "\r\n" with
	"\r+\n".
	(thread_selected_re): Likewise.
	(gdbindex_warning_re): Likewise.
	(library_loaded_re): Likewise.
	(breakpoint_re): Likewise.
---
 gdb/testsuite/lib/mi-support.exp |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index a9b22c2..86f91ac 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -21,7 +21,7 @@
 # Set it if it is not already set.
 global mi_gdb_prompt
 if ![info exists mi_gdb_prompt] then {
-    set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
+    set mi_gdb_prompt "\[(\]gdb\[)\] \r+\n"
 }
 
 global mi_inferior_spawn_id
@@ -29,10 +29,10 @@ global mi_inferior_tty_name
 
 set MIFLAGS "-i=mi"
 
-set thread_selected_re "=thread-selected,id=\"\[0-9\]+\"\r\n"
-set gdbindex_warning_re "&\"warning: Skipping \[^\r\n\]+ \.gdb_index section in \[^\r\n\]+\"\r\n(?:&\"\\\\n\"\r\n)?"
-set library_loaded_re "=library-loaded\[^\n\]+\"\r\n(?:$gdbindex_warning_re)?"
-set breakpoint_re "=(?:breakpoint-created|breakpoint-deleted)\[^\n\]+\"\r\n"
+set thread_selected_re "=thread-selected,id=\"\[0-9\]+\"\r+\n"
+set gdbindex_warning_re "&\"warning: Skipping \[^\r\n\]+ \.gdb_index section in \[^\r\n\]+\"\r+\n(?:&\"\\\\n\"\r+\n)?"
+set library_loaded_re "=library-loaded\[^\n\]+\"\r+\n(?:$gdbindex_warning_re)?"
+set breakpoint_re "=(?:breakpoint-created|breakpoint-deleted)\[^\n\]+\"\r+\n"
 
 #
 # mi_gdb_exit -- exit the GDB, killing the target program if necessary
-- 
1.7.7.6


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/4] Match \r\r\n in testsuite
  2013-09-17 13:07       ` [PATCH 0/4] Match \r\r\n in testsuite Yao Qi
                           ` (3 preceding siblings ...)
  2013-09-17 13:07         ` [PATCH 4/4] Replace "." with "\r+" Yao Qi
@ 2013-09-17 13:35         ` Joel Brobecker
  2013-09-17 13:59           ` Yao Qi
  4 siblings, 1 reply; 19+ messages in thread
From: Joel Brobecker @ 2013-09-17 13:35 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

> Then, I restarted from the beginning again, and see if we can fix the
> problem by modifying testsuite.  The requirement expressed in the
> previous patch review is that we should localize the changes to
> testsuite to match \r\r\n.
> 
> This patch series is to change testsuite to match both \r\n and
> \r\r\n by modifying pattern to \r+\n in a localized manner.  Patch 1/4
> is to replace gdb_test with gdb_test_sequence to match the output of
> "info tracepoints", so that the assumption of last character of each
> line is removed, so these patterns can be matched on all targets.
> Patch 2/4 is to transform \r\n in patterns to \r+\n, but \r\n in
> variables can't be transformed.  Patch 3/4 transforms \r\n in variables.

How about we introduce a new official variable, similar to $hex,
$decimal, etc, which would correctly match new-line output based
on the host?  I propose $eol, which is already used, but only in
2 testcases, so easy to adjust (remove "set eol ..." in those two
testcases).

-- 
Joel


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/4] Match \r\r\n in testsuite
  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
  0 siblings, 1 reply; 19+ messages in thread
From: Yao Qi @ 2013-09-17 13:59 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On 09/17/2013 09:35 PM, Joel Brobecker wrote:
> How about we introduce a new official variable, similar to $hex,
> $decimal, etc, which would correctly match new-line output based
> on the host?  I propose $eol, which is already used, but only in
> 2 testcases, so easy to adjust (remove "set eol ..." in those two
> testcases).

Yeah, that is fine to me.  Considering patch 4/4, I'd like introduce two 
variables, $cr and $eol, which can be defined like this,

if [istarget "*-*-mingw*"] {
   set cr "\r\r"
} else {
   set cr "\r"
}

set eol "${cr}\n"

In this way, patch 3/4 can be updated to something like,

-    set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
+    set mi_gdb_prompt "\[(\]gdb\[)\] ${eol}"

and patch 4/4 can be updated to something like,

-gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2.
+gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2${cr}

patch 1/4/ and 2/4 can be unchanged.  What do you think?

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/4] Match \r\r\n in testsuite
  2013-09-17 13:59           ` Yao Qi
@ 2013-09-17 14:06             ` Joel Brobecker
  2013-09-18  8:21               ` Yao Qi
  0 siblings, 1 reply; 19+ messages in thread
From: Joel Brobecker @ 2013-09-17 14:06 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

> Yeah, that is fine to me.  Considering patch 4/4, I'd like introduce
> two variables, $cr and $eol, which can be defined like this,
> 
> if [istarget "*-*-mingw*"] {
>   set cr "\r\r"
> } else {
>   set cr "\r"
> }
> 
> set eol "${cr}\n"
> 
> In this way, patch 3/4 can be updated to something like,
> 
> -    set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
> +    set mi_gdb_prompt "\[(\]gdb\[)\] ${eol}"
> 
> and patch 4/4 can be updated to something like,
> 
> -gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2.
> +gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2${cr}
> 
> patch 1/4/ and 2/4 can be unchanged.  What do you think?

Can we look at fixing gdb_test to use that $eol instead? Is that
even necessary? I see the implementation is:

    return [gdb_test_multiple $command $message {
        -re "\[\r\n\]*($pattern)\[\r\n\]+$gdb_prompt $" {
            if ![string match "" $message] then {
                pass "$message"
            }
        }

It seems to me that it should match ${eol} already, no?

-- 
Joel


^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH 2/4] Transform "\r\n" in pattern to "\r+\n"
  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
  0 siblings, 0 replies; 19+ messages in thread
From: Pierre Muller @ 2013-09-17 23:11 UTC (permalink / raw)
  To: 'Yao Qi', gdb-patches

  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


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/4] Match \r\r\n in testsuite
  2013-09-17 14:06             ` Joel Brobecker
@ 2013-09-18  8:21               ` Yao Qi
  0 siblings, 0 replies; 19+ messages in thread
From: Yao Qi @ 2013-09-18  8:21 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On 09/17/2013 10:06 PM, Joel Brobecker wrote:
> Can we look at fixing gdb_test to use that $eol instead? Is that
> even necessary? I see the implementation is:
>
>      return [gdb_test_multiple $command $message {
>          -re "\[\r\n\]*($pattern)\[\r\n\]+$gdb_prompt $" {
>              if ![string match "" $message] then {
>                  pass "$message"
>              }
>          }
>
> It seems to me that it should match ${eol} already, no?

Yes, this pattern above should match ${eol}.  However, how about the
code using gdb_test_mulitiple or gdb_expect to match?  We have to fix
them too.  We don't want to replace all instances of \r\n with ${eol},
which is painful.

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2013-09-18  8:21 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 2/4] Transform "\r\n" in pattern to "\r+\n" Yao Qi
2013-09-17 23:11           ` Pierre Muller
2013-09-17 13:07         ` [PATCH 3/4] Transform \r\n in MI variables 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 4/4] Replace "." with "\r+" Yao Qi
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox