Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / queue-signal.exp
CommitLineData
88b9d363 1# Copyright (C) 2014-2022 Free Software Foundation, Inc.
81219e53
DE
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16standard_testfile
17
18if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
19 executable { debug }] != "" } {
20 return -1
21}
22
23clean_restart ${binfile}
24
25if ![runto_main] {
bc6c7af4 26 fail "can't run to main"
81219e53
DE
27 return 0
28}
29
30gdb_test "handle SIGUSR1 stop print pass"
31gdb_test "handle SIGUSR2 stop print pass"
32gdb_test "handle SIGABRT stop print pass"
33
34gdb_breakpoint "all_threads_running"
35gdb_continue_to_breakpoint "all_threads_running"
36
37# Find out which of threads 2,3 are for sigusr1,2.
38set sigusr1_thread 0
39set sigusr2_thread 0
40gdb_test "thread 2"
41gdb_test_multiple "bt" "determine thread functions" {
42 -re "sigusr1.*$gdb_prompt $" {
43 set sigusr1_thread 2
44 set sigusr2_thread 3
45 }
46 -re "sigusr2.*$gdb_prompt $" {
47 set sigusr1_thread 3
48 set sigusr2_thread 2
49 }
50}
51
52# No point in continuing if we couldn't figure out which thread is which.
53if { $sigusr1_thread == 0 } {
54 # FAIL already recorded.
55 return 0
56}
57
58# Advance each thread to where we want them one at a time.
59gdb_test_no_output "set scheduler-locking on"
60gdb_test_no_output "set var ready = 1"
61
62# Thread sigusr1_thread gets a SIGUSR1 which we leave alone.
f302f9e2
AB
63gdb_test "thread $sigusr1_thread" "" \
64 "switch to SIGUSR1 thread"
65gdb_test "continue" "SIGUSR1.*" \
66 "continue until we get SIGUSR1"
81219e53
DE
67
68# Inject SIGUSR2 into thread sigusr2_thread.
f302f9e2
AB
69gdb_test "thread $sigusr2_thread" "" \
70 "switch to SIGUSR2 thread"
81219e53
DE
71gdb_test_no_output "queue-signal SIGUSR2"
72
73# The main thread gets SIGABRT which we then throw away.
74gdb_test "thread 1" ""
f302f9e2
AB
75gdb_test "continue" "SIGABRT.*" \
76 "continue until we get SIGABRT"
81219e53
DE
77gdb_test_no_output "queue-signal 0"
78
79# Now let every thread run.
80gdb_test_no_output "set scheduler-locking off"
81
82gdb_breakpoint "all_threads_done"
83gdb_continue_to_breakpoint "all_threads_done"
84
85# Verify SIGUSR1, SIGUSR2 were received, and SIGABRT was discarded.
86gdb_test "p sigusr1_received" "= 1"
87gdb_test "p sigusr2_received" "= 1"
88gdb_test "p sigabrt_received" "= 0"
89
90# Before we finish up verify the queueing of nopass signals flags an error.
91gdb_test "queue-signal SIGINT" \
92 "Signal handling set to not pass this signal to the program."
93
94# Verify program is able to finish.
95gdb_continue_to_end
This page took 1.246586 seconds and 4 git commands to generate.