public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Bruno Larsen <blarsen@redhat.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH v2 03/11] change gdb.base/skip.exp to use finish instead of step
Date: Tue, 12 Apr 2022 15:11:20 -0300	[thread overview]
Message-ID: <69c2dae1-f8b1-17f1-c7e2-2ba78b6335ef@redhat.com> (raw)
In-Reply-To: <20220411201333.81453-4-blarsen@redhat.com>

Further testing showed that this version of the patch is racy, because of when gdb_test_multiple were getting the outputs. Changing the following regexps:

".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*"
".*test_skip_file_and_function \\(\\).*"

with


".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);\r\n$gdb_prompt $"
".*test_skip_file_and_function \\(\\);\r\n$gdb_prompt $"

I've made these changes locally. Please keep this in mind when reviewing the patch.

Cheers!
Bruno Larsen

On 4/11/22 17:13, Bruno Larsen wrote:
> skip.exp was making use of a fixed amount of step commands to exit
> some functions.  This caused some problems when testing GDB with clang,
> as it doesn't add epilogue information for functions, along with some
> unreliable results depending on the version of GCC, as sometimes gdb
> could stop in either of the 2 lines after 2 steps:
> 
> x = bax ((bar (), foo ()))
> test_skip_file_and_function ();
> 
> whereas using clang will always stop on the second line after 1 step.
> To deal with GCC unreliability, this test case used to use the question
> mechanism from gdb_test, but Pedro mentioned that this is a mis-use of
> that feature, and it doesn't deal with the clang case.  This commit
> changes it to use gdb_test_multiple and deal with all possible cases,
> only considering it a pass when test_skip_file_and_function () is
> reached.
> ---
>   gdb/testsuite/gdb.base/skip.exp | 164 +++++++++++++++++++++++++-------
>   1 file changed, 131 insertions(+), 33 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.base/skip.exp b/gdb/testsuite/gdb.base/skip.exp
> index 7c71bb07a84..5021b696668 100644
> --- a/gdb/testsuite/gdb.base/skip.exp
> +++ b/gdb/testsuite/gdb.base/skip.exp
> @@ -117,9 +117,23 @@ with_test_prefix "step after deleting 1" {
>   	return
>       }
>   
> -    gdb_test "step" "foo \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2" ; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 3"
> +    gdb_test "step" "foo \\(\\) at.*" "step"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   # Now disable the skiplist entry for  skip1.c.  We should now
> @@ -137,13 +151,27 @@ with_test_prefix "step after disabling 3" {
>       }
>   
>       gdb_test "step" "bar \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from bar()
> -    # With gcc 9.2.0 we jump once back to main before entering foo here.
> -    # If that happens try to step a second time.
> -    gdb_test "step" "foo \\(\\) at.*" "step 3" \
> -	"main \\(\\) at .*\r\n$gdb_prompt " "step"
> -    gdb_test "step" ".*" "step 4"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 5"
> +    # guarantee that we jump once back to main before entering foo here.
> +    # This makes behavior more consistent over different compilers and
> +    # different compiler versions
> +    gdb_test "finish" ".*" "finish 1"; # Return to main()
> +    gdb_test "step" "foo \\(\\) at.*" "step 2"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   # Enable skiplist entry 3 and make sure we step over it like before.
> @@ -159,9 +187,23 @@ with_test_prefix "step after enable 3" {
>   	return
>       }
>   
> -    gdb_test "step" "foo \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 3"
> +    gdb_test "step" "foo \\(\\) at.*" "step"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   # Admin tests (disable,enable,delete).
> @@ -230,9 +272,23 @@ with_test_prefix "step using -fi" {
>   
>       gdb_test_no_output "skip disable"
>       gdb_test_no_output "skip enable 5"
> -    gdb_test "step" "foo \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 3"
> +    gdb_test "step" "foo \\(\\) at.*" "step"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   with_test_prefix "step using -gfi" {
> @@ -242,9 +298,23 @@ with_test_prefix "step using -gfi" {
>   
>       gdb_test_no_output "skip disable"
>       gdb_test_no_output "skip enable 6"
> -    gdb_test "step" "foo \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 3"
> +    gdb_test "step" "foo \\(\\) at.*" "step"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   with_test_prefix "step using -fu for baz" {
> @@ -255,13 +325,27 @@ with_test_prefix "step using -fu for baz" {
>       gdb_test_no_output "skip disable"
>       gdb_test_no_output "skip enable 7"
>       gdb_test "step" "bar \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from bar()
> -    # With gcc 9.2.0 we jump once back to main before entering foo here.
> -    # If that happens try to step a second time.
> -    gdb_test "step" "foo \\(\\) at.*" "step 3" \
> -	"main \\(\\) at .*\r\n$gdb_prompt " "step"
> -    gdb_test "step" ".*" "step 4"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 5"
> +    # guarantee that we jump once back to main before entering foo here.
> +    # This makes behavior more consistent over different compilers and
> +    # different compiler versions
> +    gdb_test "finish" ".*" "finish 1"; # Return to main()
> +    gdb_test "step" "foo \\(\\) at.*" "step 2"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   with_test_prefix "step using -rfu for baz" {
> @@ -272,13 +356,27 @@ with_test_prefix "step using -rfu for baz" {
>       gdb_test_no_output "skip disable"
>       gdb_test_no_output "skip enable 8"
>       gdb_test "step" "bar \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from bar()
> -    # With gcc 9.2.0 we jump once back to main before entering foo here.
> -    # If that happens try to step a second time.
> -    gdb_test "step" "foo \\(\\) at.*" "step 3" \
> -	"main \\(\\) at .*\r\n$gdb_prompt " "step"
> -    gdb_test "step" ".*" "step 4"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 5"
> +    # guarantee that we jump once back to main before entering foo here.
> +    # This makes behavior more consistent over different compilers and
> +    # different compiler versions
> +    gdb_test "finish" ".*" "finish 1"; # Return to main()
> +    gdb_test "step" "foo \\(\\) at.*" "step 2"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   # Test -fi + -fu.


  reply	other threads:[~2022-04-12 18:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11 20:13 [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 01/11] gdb/testsuite: introduce gdb_step_until_regexp Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 02/11] Change gdb.base/skip-solib.exp deal with lack of epilogue information Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 03/11] change gdb.base/skip.exp to use finish instead of step Bruno Larsen
2022-04-12 18:11   ` Bruno Larsen [this message]
2022-05-17 16:38   ` Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 04/11] change gdb.base/symbol-alias to xfail with clang Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 05/11] change gdb.base/nodebug.c to not fail " Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 06/11] update gdb.base/info-program.exp " Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 07/11] fix gdb.base/access-mem-running.exp for clang testing Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 08/11] Fix gdb.base/call-ar-st to work with Clang Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 09/11] add xfails to gdb.base/complex-parts.exp when testing with clang Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 10/11] gdb/testsuite: fix gdb.base/msym-bp-shl when running with Clang Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 11/11] explicitly test for stderr in gdb.base/dprintf.exp Bruno Larsen
2022-04-26 13:17 ` [PING] [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
2022-05-03 20:43   ` [PINGv2] " Bruno Larsen
2022-05-10 20:06     ` [PINGv3] " Bruno Larsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=69c2dae1-f8b1-17f1-c7e2-2ba78b6335ef@redhat.com \
    --to=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).