Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/8] Improve coverage of the PR threads/13217 regression test
Date: Tue, 11 Apr 2017 23:56:00 -0000	[thread overview]
Message-ID: <1491954673-29172-5-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1491954673-29172-1-git-send-email-palves@redhat.com>

- Make sure we end up with no thread selected after the detach.

- Test both "thread apply all" and "thread apply $some_threads", for
  completeness.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	PR threads/13217
	* gdb.threads/threadapply.exp (thr_apply_detach): New procedure.
	(top level): Call it twice, with different thread sets.
---
 gdb/testsuite/gdb.threads/threadapply.exp | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.threads/threadapply.exp b/gdb/testsuite/gdb.threads/threadapply.exp
index 789b283..959e8b9 100644
--- a/gdb/testsuite/gdb.threads/threadapply.exp
+++ b/gdb/testsuite/gdb.threads/threadapply.exp
@@ -63,4 +63,33 @@ gdb_test "step" "thread_function.*" "step to the thread_function"
 gdb_test "up" ".*in main.*" "go up in the stack frame" 
 gdb_test "thread apply all print 1"  "Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1" "run a simple print command on all threads"
 gdb_test "down" "#0.*thread_function.*" "go down and check selected frame"
-gdb_test "thread apply all detach" "Thread .*"
+
+# Make sure that GDB doesn't crash when the previously selected thread
+# exits due to the command run via thread apply.  Regression test for
+# PR threads/13217.
+
+proc thr_apply_detach {thread_set} {
+    with_test_prefix "thread apply $thread_set" {
+	global binfile
+	global break_line
+
+	clean_restart ${binfile}
+
+	if ![runto_main] {
+	    fail "can't run to main"
+	    return -1
+	}
+
+	gdb_breakpoint "$break_line"
+	gdb_continue_to_breakpoint "all threads started"
+
+	gdb_test "thread apply $thread_set detach" "Thread .*"
+	gdb_test "thread" "No thread selected" "switched to no thread selected"
+    }
+}
+
+# Test both "all" and a thread list, because those are implemented as
+# different commands in GDB.
+foreach thread_set {"all" "1.1 1.2 1.3"} {
+    thr_apply_detach $thread_set
+}
-- 
2.5.5


  parent reply	other threads:[~2017-04-11 23:56 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-11 23:51 [PATCH 0/8] Fix removing inferiors from within "thread apply" commands Pedro Alves
2017-04-11 23:51 ` [PATCH 2/8] Fix follow-fork latent bug Pedro Alves
2017-04-13  9:58   ` Yao Qi
2017-04-13 12:09     ` Pedro Alves
2017-04-13 15:33       ` Yao Qi
2017-04-11 23:51 ` [PATCH 1/8] watch_command_1: Fix dangling frame access Pedro Alves
2017-04-13  9:34   ` Yao Qi
2017-04-13 15:26     ` Pedro Alves
2017-04-11 23:51 ` [PATCH 6/8] Make inferior a class with cdtors, and use new/delete Pedro Alves
2017-04-13 10:24   ` Yao Qi
2017-04-11 23:51 ` [PATCH 8/8] Fix removing inferiors from within "thread apply" commands Pedro Alves
2017-04-13 11:33   ` Yao Qi
2017-04-13 12:22     ` Pedro Alves
2017-04-13 14:49       ` Pedro Alves
2017-04-19  8:23         ` Yao Qi
2017-04-19 12:15           ` Pedro Alves
2017-04-19 12:20             ` Pedro Alves
2017-04-13 15:31       ` Yao Qi
2017-04-11 23:51 ` [PATCH 3/8] C++fy thread_apply_all_command Pedro Alves
2017-04-13 10:06   ` Yao Qi
2017-04-11 23:51 ` [PATCH 7/8] Make inferior::detaching a bool, and introduce scoped_restore::release() Pedro Alves
2017-04-11 23:56 ` [PATCH 5/8] GC inferior.c:init_inferior_list Pedro Alves
2017-04-13 10:10   ` Yao Qi
2017-04-11 23:56 ` Pedro Alves [this message]
2017-04-13 10:09   ` [PATCH 4/8] Improve coverage of the PR threads/13217 regression test Yao Qi

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=1491954673-29172-5-git-send-email-palves@redhat.com \
    --to=palves@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