public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Don Breazeal <donb@codesourcery.com>, gdb-patches@sourceware.org
Subject: [PATCH] Tighten gdb.base/disp-step-syscall.exp (was: Re: [PATCH v5 0/6] Remote fork events)
Date: Mon, 02 Mar 2015 20:18:00 -0000	[thread overview]
Message-ID: <54F4C5A4.40503@redhat.com> (raw)
In-Reply-To: <1424997977-13316-1-git-send-email-donb@codesourcery.com>

On 02/27/2015 12:46 AM, Don Breazeal wrote:
>  - There are a couple of tests that show new failures that actually
>    fail in the current mainline.  Details of these are as follows:
> 
>    * when vfork events are enabled, gdb.base/disp-step-syscall.exp
>      shows PASS => FAIL in .sum diffs.  The test actually always
>      fails.  With native/master, we see
> 
>       stepi^M
>       FAIL: gdb.base/disp-step-syscall.exp: vfork: stepi vfork insn
> (timeout)
> 

Hmm, I don't see that here.  I get a full pass on x86_64 Fedora 20.
Can you try "set debug infrun 1" / "set debug lin-lwp 1" / "set debug displaced 1"
to check if there's a gdb or kernel bug here?

>      With remote and extended-remote/master, we see a bogus PASS result:
>       stepi^M
>       [Inferior 1 (process 9399) exited normally]^M
>       (gdb) PASS: gdb.base/disp-step-syscall.exp: vfork: stepi vfork insn
> 
>     The criteria to pass that test are pretty lax:
>       gdb_test "stepi" ".*" "stepi $syscall insn"

Yeah.  I see several other problems.  Here's a patch to improve it.

Comments?

Unfortunately, with your full series applied, I get this:

 (gdb) PASS: gdb.base/disp-step-syscall.exp: vfork: get hexadecimal valueof "$pc"
 stepi
 Detaching from process 29944
 Killing process(es): 29942 29944
 /home/pedro/gdb/mygit/src/gdb/gdbserver/linux-low.c:998: A problem internal to GDBserver has been detected.
 kill_wait_lwp: Assertion `res > 0' failed.
 /home/pedro/gdb/mygit/src/gdb/thread.c:1182: internal-error: switch_to_thread: Assertion `inf != NULL' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 Quit this debugging session? (y or n) FAIL: gdb.base/disp-step-syscall.exp: vfork: stepi vfork insn (GDB internal error)
 Resyncing due to internal error.
 n

Note, you'll need this one:

 https://sourceware.org/ml/gdb-patches/2015-03/msg00045.html

for that internal error to result in a quick bail...

----------
From 1f825812d3f17a2940065d0de38592700e7437bc Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Mon, 2 Mar 2015 20:16:23 +0000
Subject: [PATCH] Tighten gdb.base/disp-step-syscall.exp

This fixes several problems with this test.

E.g,. with --target_board=native-extended-gdbserver on
x86_64 Fedora 20, I get:

 Running /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/disp-step-syscall.exp ...
 FAIL: gdb.base/disp-step-syscall.exp: vfork: get hexadecimal valueof "$pc" (timeout)
 FAIL: gdb.base/disp-step-syscall.exp: vfork: single step over vfork final pc
 FAIL: gdb.base/disp-step-syscall.exp: vfork: delete break vfork insn
 FAIL: gdb.base/disp-step-syscall.exp: vfork: continue to marker (vfork) (the program is no longer running)

And with --target=native-gdbserver, I get:

 Running /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/disp-step-syscall.exp ...
 KPASS: gdb.base/disp-step-syscall.exp: vfork: single step over vfork (PRMS server/13796)
 FAIL: gdb.base/disp-step-syscall.exp: vfork: get hexadecimal valueof "$pc" (timeout)
 FAIL: gdb.base/disp-step-syscall.exp: vfork: single step over vfork final pc
 FAIL: gdb.base/disp-step-syscall.exp: vfork: delete break vfork insn
 FAIL: gdb.base/disp-step-syscall.exp: vfork: continue to marker (vfork) (the program is no longer running)

First, the lack of fork support on remote targets is supposed to be
kfailed, so the KPASS is obviously bogus.  The extended-remote board
should have KFAILed too.

The problem is that the test is using "is_remote" instead of
gdb_is_target_remote.

And then, I get:

 (gdb) PASS: gdb.base/disp-step-syscall.exp: vfork: set displaced-stepping on
 stepi

 Program terminated with signal SIGSEGV, Segmentation fault.
 The program no longer exists.
 (gdb) PASS: gdb.base/disp-step-syscall.exp: vfork: single step over vfork

Obviously, that should be a FAIL.  The problem is that the test only
expects SIGILL, not SIGSEGV.  It also doesn't bail correctly if an
internal error or some other pattern caught by gdb_test_multiple
matches.  The test doesn't really need to match specific exits/crashes
patterns, if the PASS regex is improved, like in ...

... this and the other "stepi" tests are a bit too lax, passing on
".*".  This tightens those up to expect "x/i" and the "=>" current PC
indicator, like in:

 1: x/i $pc
 => 0x3b36abc9e2 <vfork+34>:     syscall

On x86_64 Fedora 20, I now get a quick KFAIL instead of timeouts with
both the native-extended-gdbserver and native-gdbserver boards:

 PASS: gdb.base/disp-step-syscall.exp: vfork: delete break vfork
 PASS: gdb.base/disp-step-syscall.exp: vfork: continue to syscall insn vfork
 PASS: gdb.base/disp-step-syscall.exp: vfork: set displaced-stepping on
 KFAIL: gdb.base/disp-step-syscall.exp: vfork: single step over vfork (PRMS: server/13796)

and a full pass with native testing.

gdb/testsuite/
2015-03-02  Pedro Alves  <palves@redhat.com>

	* gdb.base/disp-step-syscall.exp (disp_step_cross_syscall.exp):
	Use gdb_is_target_remote instead of is_remote.  Use
	gdb_test_multiple instead of gdb_expect.  Exit early if
	gdb_test_multiple hits its internal matches.  Tighten stepi tests
	expected output.  Fail on exit with any signal, instead of just
	SIGILL.
---
 gdb/testsuite/gdb.base/disp-step-syscall.exp | 53 ++++++++++++++--------------
 1 file changed, 26 insertions(+), 27 deletions(-)

diff --git a/gdb/testsuite/gdb.base/disp-step-syscall.exp b/gdb/testsuite/gdb.base/disp-step-syscall.exp
index ff66f83..b13dce4 100644
--- a/gdb/testsuite/gdb.base/disp-step-syscall.exp
+++ b/gdb/testsuite/gdb.base/disp-step-syscall.exp
@@ -49,6 +49,8 @@ proc disp_step_cross_syscall { syscall } {
 	    return
 	}
 
+	set is_target_remote [gdb_is_target_remote]
+
 	# Delete the breakpoint on main.
 	gdb_test_no_output "delete break 1"
 
@@ -77,27 +79,34 @@ proc disp_step_cross_syscall { syscall } {
 	gdb_test "display/i \$pc" ".*"
 
 
-	# Single step until we see sysall insn or we reach the upper bound of loop
-	# iterations.
-	set see_syscall_insn 0
-
-	for {set i 0} {$i < 1000 && $see_syscall_insn == 0} {incr i} {
-	    send_gdb "stepi\n"
-	    gdb_expect {
-		-re ".*$syscall_insn.*$gdb_prompt $" {
-		    set see_syscall_insn 1
+	# Single step until we see a syscall insn or we reach the
+	# upper bound of loop iterations.
+	set msg "find syscall insn in $syscall"
+	set steps 0
+	set max_steps 1000
+	gdb_test_multiple "stepi" $msg {
+	    -re ".*$syscall_insn.*$gdb_prompt $" {
+		pass $msg
+	    }
+	    -re "x/i .*=>.*\r\n$gdb_prompt $" {
+		incr steps
+		if {$steps == $max_steps} {
+		    fail $msg
+		} else {
+		    send_gdb "stepi\n"
+		    exp_continue
 		}
-		-re ".*$gdb_prompt $" {}
 	    }
 	}
 
-	if {$see_syscall_insn == 0} then {
-	    fail "find syscall insn in $syscall"
+	if {$steps == $max_steps} {
 	    return -1
 	}
 
 	set syscall_insn_addr [get_hexadecimal_valueof "\$pc" "0"]
-	gdb_test "stepi" ".*" "stepi $syscall insn"
+	if {[gdb_test "stepi" "x/i .*=>.*" "stepi $syscall insn"] != 0} {
+	    return -1
+	}
 	set syscall_insn_next_addr [get_hexadecimal_valueof "\$pc" "0"]
 
 	gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \
@@ -121,22 +130,12 @@ proc disp_step_cross_syscall { syscall } {
 	gdb_test_no_output "set displaced-stepping on"
 
 	# Check the address of next instruction of syscall.
-	if {$syscall == "vfork" && [is_remote target]} {
+	if {$syscall == "vfork" && $is_target_remote} {
 	    setup_kfail server/13796 "*-*-*"
 	}
-	set test "single step over $syscall"
-	gdb_test_multiple "stepi" $test {
-	    -re "Program terminated with signal SIGILL,.*\r\n$gdb_prompt $" {
-		fail $test
-		return
-	    }
-	    -re "\\\[Inferior .* exited normally\\\].*\r\n$gdb_prompt $" {
-		fail $test
-		return
-	    }
-	    -re "\r\n$gdb_prompt $" {
-		pass $test
-	    }
+
+	if {[gdb_test "stepi" "x/i .*=>.*" "single step over $syscall"] != 0} {
+	    return -1
 	}
 
 	set syscall_insn_next_addr_found [get_hexadecimal_valueof "\$pc" "0"]
-- 
1.9.3


  parent reply	other threads:[~2015-03-02 20:18 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201501252151.t0PLo3jE018308@mx0b-0013c101.pphosted.com>
2015-01-26  4:43 ` [PATCH v4 0/7] Remote fork events Breazeal, Don
2015-02-06 20:02   ` Breazeal, Don
2015-02-27  0:46   ` [PATCH v5 0/6] " Don Breazeal
2015-02-27  0:46     ` [PATCH v5 01/06] Identify remote fork event support Don Breazeal
2015-02-27  0:47     ` [PATCH v5 05/06] Remote follow vfork Don Breazeal
2015-02-27  0:47     ` [PATCH v5 03/06] Extended-remote Linux follow fork Don Breazeal
2015-02-27  0:47     ` [PATCH v5 02/06] Clone remote breakpoints Don Breazeal
2015-02-27  0:47     ` [PATCH v5 04/06] Arch-specific remote follow fork Don Breazeal
2015-02-27  7:37       ` Eli Zaretskii
2015-02-27  0:48     ` [PATCH v5 06/06] Remote fork catch Don Breazeal
2015-03-02 18:29     ` [PATCH v5 0/6] Remote fork events Pedro Alves
2015-03-02 20:18     ` Pedro Alves [this message]
2015-03-03  6:20       ` [PATCH] Tighten gdb.base/disp-step-syscall.exp Breazeal, Don
2015-03-03 15:01         ` Pedro Alves
2015-03-17 21:18       ` Breazeal, Don
2015-03-18 19:37         ` Pedro Alves
2015-03-17 20:56     ` [PATCH v6 0/6] Remote fork events Don Breazeal
2015-03-17 20:56       ` [PATCH v6 1/6] Identify remote fork event support Don Breazeal
2015-03-24 10:57         ` Pedro Alves
2015-03-26 19:00           ` [PATCH v5 01/06] " Don Breazeal
2015-03-27 11:14             ` Pedro Alves
2015-03-17 20:57       ` [PATCH v6 4/6] Arch-specific remote follow fork Don Breazeal
2015-03-17 20:57       ` [PATCH v6 2/6] Clone remote breakpoints Don Breazeal
2015-03-17 20:57       ` [PATCH v6 3/6] Extended-remote Linux follow fork Don Breazeal
2015-03-24 12:17         ` Pedro Alves
2015-04-07 17:35           ` Pedro Alves
2015-03-17 20:58       ` [PATCH v6 5/6] Remote follow vfork Don Breazeal
2015-03-24 12:28         ` Pedro Alves
2015-03-17 20:58       ` [PATCH v6 6/6] Remote fork catch Don Breazeal
2015-03-24 12:47         ` Pedro Alves

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=54F4C5A4.40503@redhat.com \
    --to=palves@redhat.com \
    --cc=donb@codesourcery.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).