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]

Fully anchor mi_gdb_test expected results.


Hi,

This testsuite change simply does several simple things. First, when
creating a new pty for the inferior, this change turn's terminal
echo'ing off. This allows the expected results back from GDB/MI to not
have to have the command sent to GDB in it. The surprising thing with 
this change is that even when GDB shares the terminal's PTY with the 
inferior, not putting the echo'd data in the expected command still
works.

The only other notable change here is this,

   -   -re "\[\r\n\]*($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*$" {
   +   -re "^(.*$pattern\[\r\n\]+$mi_gdb_prompt\[ \]*)$" {

that is the change that fully anchor's the output from GDB. The reason
this is necessary is because with this change, I can grab the full
response from GDB for a command. With this response I can do syntax
checking with the parser that I wrote.

What does everyone think?

Thanks,
Bob Rossi



Index: gdb/testsuite/ChangeLog
+	* gdb.mi/mi-disassemble.exp, gdb.mi/mi2-disassemble.exp: Remove .* 
+	from test.  Escape the | in mi_gdb_test call.
+	* lib/mi-support.exp: If using inferior pty, turn terminal echo off.
+	Remove arbitrary .* from test.  Remove terminal echo'd data from
+	expected test results.  
+	(mi_gdb_test): Fully anchor GDB/MI expected results in mi_gdb_test.

Index: gdb/testsuite/gdb.mi/mi-disassemble.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-disassemble.exp,v
retrieving revision 1.13
diff -u -r1.13 mi-disassemble.exp
--- gdb/testsuite/gdb.mi/mi-disassemble.exp	15 Aug 2004 10:15:58 -0000	1.13
+++ gdb/testsuite/gdb.mi/mi-disassemble.exp	4 Aug 2005 02:44:42 -0000
@@ -163,7 +163,7 @@
     # -data-disassembly -f basics.c -l 32 -- 9
 
     mi_gdb_test "123-data-disassemble -f foo -l abc -n 0 -- 0" \
-             ".*123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \
+             "123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \
              "data-disassemble bogus filename"
 
     mi_gdb_test "321-data-disassemble -s foo -e bar -- 0" \
@@ -171,7 +171,7 @@
              "data-disassemble bogus address"
 
     mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \
-             "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. | .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
+             "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. \\| .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
              "data-disassemble mix different args"
 
     mi_gdb_test "789-data-disassemble -f basics.c -l $line_main_body -- 9" \
Index: gdb/testsuite/gdb.mi/mi2-disassemble.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-disassemble.exp,v
retrieving revision 1.3
diff -u -r1.3 mi2-disassemble.exp
--- gdb/testsuite/gdb.mi/mi2-disassemble.exp	15 Aug 2004 10:15:58 -0000	1.3
+++ gdb/testsuite/gdb.mi/mi2-disassemble.exp	4 Aug 2005 02:44:42 -0000
@@ -163,7 +163,7 @@
     # -data-disassembly -f basics.c -l 32 -- 9
 
     mi_gdb_test "123-data-disassemble -f foo -l abc -n 0 -- 0" \
-             ".*123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \
+             "123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \
              "data-disassemble bogus filename"
 
     mi_gdb_test "321-data-disassemble -s foo -e bar -- 0" \
@@ -171,7 +171,7 @@
              "data-disassemble bogus address"
 
     mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \
-             "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. | .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
+             "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. \\| .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
              "data-disassemble mix different args"
 
     mi_gdb_test "789-data-disassemble -f basics.c -l $line_main_body -- 9" \
Index: gdb/testsuite/lib/mi-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
retrieving revision 1.29
diff -u -r1.29 mi-support.exp
--- gdb/testsuite/lib/mi-support.exp	4 Aug 2005 01:52:31 -0000	1.29
+++ gdb/testsuite/lib/mi-support.exp	4 Aug 2005 02:44:42 -0000
@@ -225,6 +225,17 @@
 	    	warning "Couldn't redirect inferior output." 2
 	    }
     	}
+
+	# tell GDB not to echo
+	send_gdb "103-interpreter-exec console \"shell stty -echo\"\n"
+	gdb_expect 10 {
+	    -re ".*$mi_gdb_prompt$" {
+		verbose "turning off the terminal echoing" 2
+	    }
+	    timeout {
+		warning "Couldn't turn off the terminal's echoing."
+	    }
+	}
     }
 
     return 0;
@@ -246,7 +257,7 @@
 	    send_gdb "y\n";
 	    exp_continue
          }
-	 -re ".*102-break-delete\r\n102\\\^done\r\n$mi_gdb_prompt$" {
+	 -re "102\\\^done\r\n$mi_gdb_prompt$" {
             # This happens if there were no breakpoints
 	 }
 	 timeout { perror "Delete all breakpoints in mi_delete_breakpoints (timeout)" ; return }
@@ -256,9 +267,9 @@
 # empty BreakpointTable. Also, a query is not acceptable with mi.
     send_gdb "103-break-list\n"
     gdb_expect 30 {
-	 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{\}\r\n$mi_gdb_prompt$" {}
-	 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[\\\]\}" {}
-	 -re "103-break-list\r\n103\\\^doneNo breakpoints or watchpoints.\r\n\r\n$mi_gdb_prompt$" {warning "Unexpected console text received"}
+	 -re "103\\\^done,BreakpointTable=\{\}\r\n$mi_gdb_prompt$" {}
+	 -re "103\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[\\\]\}" {}
+	 -re "103\\\^doneNo breakpoints or watchpoints.\r\n\r\n$mi_gdb_prompt$" {warning "Unexpected console text received"}
 	 -re "$mi_gdb_prompt$" { perror "Breakpoints not deleted" ; return }
 	 -re "Delete all breakpoints.*or n.*$" {
 	    warning "Unexpected prompt for breakpoints deletion";
@@ -433,7 +444,7 @@
             perror "($arg) No such file or directory\n"
             return -1
         }
-        -re "105-file-exec-and-symbols .*\r\n105\\\^done\r\n$mi_gdb_prompt$" {
+        -re "105\\\^done\r\n$mi_gdb_prompt$" {
             # We (MI) are just giving the prompt back for now, instead of giving
 	    # some acknowledgement.
 	    return 0
@@ -659,7 +670,8 @@
 	    gdb_start
 	    set result -1
 	}
-	 -re "\[\r\n\]*($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*$" {
+	 -re "^(.*$pattern\[\r\n\]+$mi_gdb_prompt\[ \]*)$" {
+
 	    if ![string match "" $message] then {
 		pass "$message"
 	    }
@@ -917,11 +929,11 @@
     global fullname_syntax
     send_gdb "220-$cmd\n"
     gdb_expect {
-	-re ".*220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=$args,file=\".*$file\",fullname=\"${fullname_syntax}$file\",line=\"$line\"\}$extra\r\n$mi_gdb_prompt$" {
+	-re "220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=$args,file=\".*$file\",fullname=\"${fullname_syntax}$file\",line=\"$line\"\}$extra\r\n$mi_gdb_prompt$" {
 	    pass "$test"
 	    return 0
 	}
-	-re ".*220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\".*\",args=\[\\\[\{\].*\[\\\]\}\],file=\".*\",fullname=\"${fullname_syntax}.*\",line=\"\[0-9\]*\"\}.*\r\n$mi_gdb_prompt$" {
+	-re "220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\".*\",args=\[\\\[\{\].*\[\\\]\}\],file=\".*\",fullname=\"${fullname_syntax}.*\",line=\"\[0-9\]*\"\}.*\r\n$mi_gdb_prompt$" {
 	    fail "$test (stopped at wrong place)"
 	    return -1
 	}


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