aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.threads
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-04-13 16:15:34 +0100
committerPedro Alves <palves@redhat.com>2017-04-13 16:18:16 +0100
commit5fd69d0ab2c42d2be0781bf3a5d60e1d5b8d05dc (patch)
treef72ab8b59b357d1c6d8842fd000810a25f808ff7 /gdb/testsuite/gdb.threads
parentc6609450b33960a0e9f8c1df045b02f0677e866a (diff)
downloadgdb-5fd69d0ab2c42d2be0781bf3a5d60e1d5b8d05dc.zip
gdb-5fd69d0ab2c42d2be0781bf3a5d60e1d5b8d05dc.tar.gz
gdb-5fd69d0ab2c42d2be0781bf3a5d60e1d5b8d05dc.tar.bz2
Improve coverage of the PR threads/13217 regression test
- 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: 2017-04-13 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.
Diffstat (limited to 'gdb/testsuite/gdb.threads')
-rw-r--r--gdb/testsuite/gdb.threads/threadapply.exp31
1 files changed, 30 insertions, 1 deletions
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
+}