public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: [PATCH 6/7] Testcase for previous handle_no_resumed fixes
Date: Mon,  6 Jul 2020 20:02:51 +0100	[thread overview]
Message-ID: <20200706190252.22552-7-pedro@palves.net> (raw)
In-Reply-To: <20200706190252.22552-1-pedro@palves.net>

This adds a testcase that covers the scenarios described in the
previous two commits.

gdb/testsuite/ChangeLog:

	PR gdb/26199
	* gdb.multi/multi-target.c (exit_thread): New.
	(thread_start): Break loop if EXIT_THREAD.
	* gdb.multi/multi-target.exp (test_no_unwaited_for): New proc.
	(top level) Call test_no_resumed.
---
 gdb/testsuite/gdb.multi/multi-target.c   |  4 +-
 gdb/testsuite/gdb.multi/multi-target.exp | 76 ++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.multi/multi-target.c b/gdb/testsuite/gdb.multi/multi-target.c
index 23ec6bd600..b337e59a11 100644
--- a/gdb/testsuite/gdb.multi/multi-target.c
+++ b/gdb/testsuite/gdb.multi/multi-target.c
@@ -26,12 +26,14 @@
 
 static pthread_barrier_t barrier;
 
+volatile int exit_thread;
+
 static void *
 thread_start (void *arg)
 {
   pthread_barrier_wait (&barrier);
 
-  while (1)
+  while (!exit_thread)
     sleep (1);
   return NULL;
 }
diff --git a/gdb/testsuite/gdb.multi/multi-target.exp b/gdb/testsuite/gdb.multi/multi-target.exp
index b519eda4e8..d19cee6595 100644
--- a/gdb/testsuite/gdb.multi/multi-target.exp
+++ b/gdb/testsuite/gdb.multi/multi-target.exp
@@ -439,6 +439,77 @@ proc test_info_inferiors {multi_process} {
     }
 }
 
+# Test that when there's a foreground execution command in progress, a
+# TARGET_WAITKIND_NO_RESUMED for a particular target is ignored when
+# other targets are still resumed.
+
+proc test_no_resumed {} {
+    proc test_no_resumed_infs {inf_A inf_B} {
+	global gdb_prompt
+
+	if {![setup "off"]} {
+	    untested "setup failed"
+	    return
+	}
+
+	gdb_test "thread $inf_A.2" "Switching to thread $inf_A\.2 .*" \
+	    "select thread of target A"
+
+	gdb_test_no_output "set scheduler-locking on"
+
+	gdb_test_multiple "continue &" "" {
+	    -re "Continuing.*$gdb_prompt " {
+		pass $gdb_test_name
+	    }
+	}
+
+	gdb_test "thread $inf_B.2" "Switching to thread $inf_B\.2 .*" \
+	    "select thread of target B"
+	gdb_test "p exit_thread = 1" " = 1" \
+	    "set the thread to exit on resumption"
+
+	# Wait 3 seconds.  If we see any response from GDB, such as
+	# "No unwaited-for children left." it's a bug.
+	gdb_test_multiple "continue" "continue" {
+	    -timeout 3
+	    timeout {
+		pass $gdb_test_name
+	    }
+	}
+
+	# Now stop the program (all targets).
+	send_gdb "\003"
+	gdb_test_multiple "" "send_gdb control C" {
+	    -re "received signal SIGINT.*$gdb_prompt $" {
+		pass $gdb_test_name
+	    }
+	}
+
+	gdb_test_multiple "info threads" "all threads stopped" {
+	    -re "\\\(running\\\).*$gdb_prompt $" {
+		fail $gdb_test_name
+	    }
+	    -re "$gdb_prompt $" {
+		pass $gdb_test_name
+	    }
+	}
+    }
+
+    # inferior 1 -> native
+    # inferior 2 -> extended-remote 1
+    # inferior 5 -> extended-remote 2
+    set inferiors {1 2 5}
+    foreach_with_prefix inf_A $inferiors {
+	foreach_with_prefix inf_B $inferiors {
+	    if {$inf_A == $inf_B} {
+		continue
+	    }
+	    test_no_resumed_infs $inf_A $inf_B
+	}
+    }
+}
+
+
 # Make a core file with two threads upfront.  Several tests load the
 # same core file.
 prepare_core
@@ -467,4 +538,9 @@ with_test_prefix "info-inferiors" {
     }
 }
 
+# Test TARGET_WAITKIND_NO_RESUMED handling with multiple targets.
+with_test_prefix "no-resumed" {
+    test_no_resumed
+}
+
 cleanup_gdbservers
-- 
2.14.5


  parent reply	other threads:[~2020-07-06 19:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06 19:02 [PATCH 0/7] GDB busy loop when interrupting non-stop program (PR 26199) Pedro Alves
2020-07-06 19:02 ` [PATCH 1/7] Fix spurious unhandled remote %Stop notifications Pedro Alves
2020-12-12 22:13   ` Andrew Burgess
2020-12-13  0:46     ` Simon Marchi
2020-07-06 19:02 ` [PATCH 2/7] Fix latent bug in target_pass_ctrlc Pedro Alves
2020-07-06 19:02 ` [PATCH 3/7] Avoid constant stream of TARGET_WAITKIND_NO_RESUMED Pedro Alves
2020-07-06 19:02 ` [PATCH 4/7] Fix handle_no_resumed w/ multiple targets Pedro Alves
2020-07-06 19:02 ` [PATCH 5/7] Make handle_no_resumed transfer terminal Pedro Alves
2020-07-06 19:02 ` Pedro Alves [this message]
2020-07-06 19:02 ` [PATCH 7/7] Fix GDB busy loop when interrupting non-stop program (PR 26199) Pedro Alves
2020-07-06 21:28 ` [PATCH 0/7] " Simon Marchi
2020-07-07  0:25   ` Pedro Alves
2020-07-07  1:27     ` Pedro Alves
2020-07-07  1:29       ` Pedro Alves
2020-07-10 23:02 ` 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=20200706190252.22552-7-pedro@palves.net \
    --to=pedro@palves.net \
    --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).