This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC][PATCH] Fixes to gdb.mi testsuite
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: <gdb-patches at sourceware dot org>
- Cc: Marc Khouzam <marc dot khouzam at ericsson dot com>
- Date: Tue, 28 May 2013 15:50:55 -0400
- Subject: [RFC][PATCH] Fixes to gdb.mi testsuite
Hi,
Here are two small fixes/improvements to the MI section of the testsuite
that I need in order to write tests for my other patch (Subject: Exit
code of exited inferiors). I'd like to hear your comments about them.
* Add support for args to mi_run_to_main (and the commands that it
depends on, mi_runto, mi_runto_helper). mi_run_cmd_full already
supported arguments, but it didn't work when use_mi_command was set.
* Fix mi_expect_stop for inferiors that exit with non-zero exit codes.
The message is a little bit different when the inferior exits with zero
and non-zero values, this fix takes that into account.
Here is the proposed changelog.
2013-05-28 Simon Marchi <simon.marchi@ericsson.com>
* gdb/testsuite/lib/mi-support.exp (mi_run_to_main): add "args"
parameter.
(mi_runto): Idem.
(mi_runto_helper): Idem.
(mi_run_cmd_full): Call -exec-arguments to set args before
running inferior if use_mi_command is set.
Thanks,
Simon
diff --git a/gdb/testsuite/lib/mi-support.exp
b/gdb/testsuite/lib/mi-support.exp
index 50b926f..db8ae1a 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -846,6 +846,20 @@ proc mi_run_cmd_full {use_mi_command args} {
return 0
}
+ if {$use_mi_command} {
+ if { [llength $args] > 0 } {
+ send_gdb "-exec-arguments $args\n"
+ gdb_expect {
+ -re "=cmd-param-changed,param=\"args\",value=.*" {
+ }
+ default {
+ fail "-exec-arguments output not matched"
+ return -1
+ }
+ }
+ }
+ }
+
send_gdb "${run_prefix}run $args\n"
gdb_expect {
-re
"${run_match}\\^running\r\n(\\*running,thread-id=\"\[^\"\]+\"\r\n|=thread-created,id=\"1\",group-id=\"\[0-9\]+\"\r\n)*(${library_loaded_re})*(${thread_selected_re})?${mi_gdb_prompt}"
{
@@ -882,7 +896,7 @@ proc mi_run_with_cli {args} {
# Just like run-to-main but works with the MI interface
#
-proc mi_run_to_main { } {
+proc mi_run_to_main {args} {
global suppress_flag
if { $suppress_flag } {
return -1
@@ -896,8 +910,7 @@ proc mi_run_to_main { } {
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
-
- mi_runto main
+ eval mi_runto main $args
}
@@ -911,7 +924,7 @@ proc mi_run_to_main { } {
# -1 if test suppressed, failed, timedout
# 0 if test passed
-proc mi_runto_helper {func run_or_continue} {
+proc mi_runto_helper {func run_or_continue args} {
global suppress_flag
if { $suppress_flag } {
return -1
@@ -931,7 +944,7 @@ proc mi_runto_helper {func run_or_continue} {
}
if {$run_or_continue == "run"} {
- if { [mi_run_cmd] < 0 } {
+ if { [eval mi_run_cmd $args] < 0 } {
return -1
}
} else {
@@ -941,8 +954,8 @@ proc mi_runto_helper {func run_or_continue} {
mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { ""
"disp=\"del\"" } $test
}
-proc mi_runto {func} {
- return [mi_runto_helper $func "run"]
+proc mi_runto {func args} {
+ return [eval mi_runto_helper $func "run" $args]
}
# Next to the next statement
@@ -1055,6 +1068,20 @@ proc mi_expect_stop { reason func args file line
extra test } {
return
}
+ if { $reason == "exited" } {
+
+ gdb_expect {
+ -re
"\\*stopped,reason=\"exited\",exit-code=\"\[0-7\]+\"\r\n$prompt_re" {
+ pass "$test"
+ }
+ -re ".*$mi_gdb_prompt$" {fail "continue to end (2)"}
+ timeout {
+ fail "$test (unknown output after running)"
+ }
+ }
+ return
+ }
+
set args "\\\[$args\\\]"
set bn ""