This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [RFC][PATCH] Fixes to gdb.mi testsuite
- From: Marc Khouzam <marc dot khouzam at ericsson dot com>
- To: Simon Marchi <simon dot marchi at ericsson dot com>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Tue, 28 May 2013 20:08:47 +0000
- Subject: RE: [RFC][PATCH] Fixes to gdb.mi testsuite
- References: <51A50A9F dot 9080107 at ericsson dot com>
> -----Original Message-----
> From: Simon Marchi
> Sent: Tuesday, May 28, 2013 3:51 PM
> To: gdb-patches@sourceware.org
> Cc: Marc Khouzam
> 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)*(${lib
> rary_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" {
Since the exit-code is in octal format, how about explicitely putting the
first 0? That will help quickly notice if someone changes the format
from octal to something else by mistake.
I didn't try it, but I was thinking:
"\\*stopped,reason=\"exited\",exit-code=\"0\[0-7\]+\"\r\n$prompt_re" {
My impression is that it is safe to keep the + pattern since there should
never be an exit code of 0 in this case, I believe.
> + pass "$test"
> + }
> + -re ".*$mi_gdb_prompt$" {fail "continue to end (2)"}
> + timeout {
> + fail "$test (unknown output after running)"
> + }
> + }
> + return
> + }
> +
> set args "\\\[$args\\\]"
>
> set bn ""
>
>