This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Improve MI inferior output check / mi-console.exp


On 10/28/2013 01:08 PM, Pedro Alves wrote:
On 10/28/2013 02:19 AM, Luis Machado wrote:
Hi,

The situation here is that the output from the target/inferior arrives
differently (or not at all) depending on permutations of local/remote
and the no-inferior-io setting.

The mi-console.c testcase writes a string 'Hello \"!' one char at a time.

In the case of a spawned inferior, to which we connect, we see that
string. In the case of remote/semi-hosted target we see the following:

@"H"
@"e"
@"l"
@"l"
@"o"
@" "
@"\\"
@"\""
@"!"
@"\r"
@"\n"

In the case of a remote target with noinferiorio set, we assume no
access to the output and thus this test is unsupported.

The attached patch modifies mi-console.exp to furnish the two different
patterns, and mi-support.exp to check for more cases.

Regression tested on x86-64.

Ok?


mi_output.diff


2013-10-27  Iain Sandoe  <iain@codesourcery.com>
	    Luis Machado  <lgustavo@codesourcery.com>

        gdb/testsuite
        * lib/mi-support.exp (mi_gdb_test): Expect different formats
        of inferior output for remote and native sessions.
        * gdb.mi/mi-console.exp: Check for additional inferior output
        pattern.

diff --git a/gdb/testsuite/gdb.mi/mi-console.exp b/gdb/testsuite/gdb.mi/mi-console.exp
index b7643e7..d7b6db4 100644
--- a/gdb/testsuite/gdb.mi/mi-console.exp
+++ b/gdb/testsuite/gdb.mi/mi-console.exp
@@ -37,10 +37,20 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
  mi_run_to_main

  # Next over the hello() call which will produce lots of output
+# The output we get from the target depends on how it is hosted.
+# If we are local, we just see the executable's output.
+# If we are remote (and the configuration supports it), we see the
+# target responses encapsulated by gdb's annotation.
+if [target_info exists use_gdb_stub] {

Hmm, this predicate doesn't look right.

# This test only works when talking to a target that routes its output
# through GDB.  Check that we're either talking to a simulator or a
# remote target.

And indeed I think the sim will route output likewise:

  remote-sim.c:  ui_file_write (gdb_stdtarg, buf, len);
  remote-sim.c:  gdb_flush (gdb_stdtarg);
  remote-sim.c:      fputs_unfiltered (b, gdb_stdtargerr);
  remote-sim.c:  gdb_flush (gdb_stdtargerr);

Also, when testing in extended-remote mode, use_gdb_stub
will be off.

So it seems to me that e.g., with the sim, the test
will now timeout?


*sigh*, that is true. I think fiddling with these checks may not be ideal.

What about this simpler version that just checks for both patterns without other changes?

Luis
2013-10-28  Iain Sandoe  <iain@codesourcery.com>
	    Luis Machado  <lgustavo@codesourcery.com>

	gdb/testsuite
	* gdb.mi/mi-console.exp: Check for an additional inferior
	output pattern.

diff --git a/gdb/testsuite/gdb.mi/mi-console.exp b/gdb/testsuite/gdb.mi/mi-console.exp
index b7643e7..c9a1a84 100644
--- a/gdb/testsuite/gdb.mi/mi-console.exp
+++ b/gdb/testsuite/gdb.mi/mi-console.exp
@@ -36,11 +36,20 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 mi_run_to_main
 
+# The output we get from the target depends on how it is hosted.
+# If we are local, we just see the executable's output.
+# If we are remote (and the configuration supports semihosting),
+# we see the target responses encapsulated by gdb's annotation.
+# Therefore we consider two patterns here.
+set remote_output "@\"H\"\r\n@\"e\"\r\n@\"l\"\r\n@\"l\"\r\n@\"o\"\r\n@\" \"\r\n@\"\\\\\\\\\"\r\n@\"\\\\\"\"\r\n@\"!\"\r\n@\"\\\\r\"\r\n@\"\\\\n\"\r\n"
+set output "Hello \\\\\"!\[\r\n\]+"
+set both_patterns "($remote_output|$output)"
+
 # Next over the hello() call which will produce lots of output
 mi_gdb_test "220-exec-next" \
 	    "220\\^running(\r\n\\*running,thread-id=\"all\")?" \
 	    "Testing console output" \
-	    "Hello \\\\\"!\[\r\n\]+"
+	    $both_patterns
 
 mi_expect_stop "end-stepping-range" "main" "" ".*mi-console.c" "14" "" \
     "finished step over hello"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]