siginfo-threads.exp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # Copyright 2010-2022 Free Software Foundation, Inc.
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 3 of the License, or
  5. # (at your option) any later version.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. standard_testfile
  15. set executable ${testfile}
  16. if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" \
  17. ${binfile} \
  18. executable \
  19. [list debug additional_flags=-lrt]] != "" } {
  20. return -1
  21. }
  22. clean_restart $testfile
  23. if ![runto_main] {
  24. return -1
  25. }
  26. # `nostop noprint pass' could in some cases report false PASS due to
  27. # the (preempt 'handle') code path in linux-nat.c.
  28. gdb_test "handle SIGUSR1 stop print pass" \
  29. "Signal\[ \t\]+Stop\[ \t\]+Print\[ \t\]+Pass to program\[ \t\]+Description\r\nSIGUSR1\[ \t\]+Yes\[ \t\]+Yes\[ \t\]+Yes\[ \t\].*"
  30. gdb_test "handle SIGUSR2 stop print pass" \
  31. "Signal\[ \t\]+Stop\[ \t\]+Print\[ \t\]+Pass to program\[ \t\]+Description\r\nSIGUSR2\[ \t\]+Yes\[ \t\]+Yes\[ \t\]+Yes\[ \t\].*"
  32. gdb_breakpoint [gdb_get_line_number "break-at-exit"]
  33. set test "get pid"
  34. set pid ""
  35. gdb_test_multiple "p (int) getpid ()" $test {
  36. -re " = (\[0-9\]+)\r\n$gdb_prompt $" {
  37. set pid $expect_out(1,string)
  38. pass $test
  39. }
  40. }
  41. if {$pid == ""} {
  42. untested "failed to get pid"
  43. return
  44. }
  45. for {set sigcount 0} {$sigcount < 4} {incr sigcount} {
  46. set test "catch signal $sigcount"
  47. set sigusr ""
  48. gdb_test_multiple "continue" $test {
  49. -re "Thread .* received signal SIGUSR(\[12\]), User defined signal \[12\]\\.\r\n.*\r\n$gdb_prompt $" {
  50. set sigusr $expect_out(1,string)
  51. pass $test
  52. }
  53. }
  54. if {$sigusr == ""} {
  55. return -1
  56. }
  57. set test "signal $sigcount si_signo"
  58. if {$sigusr == 1} {
  59. set signo 10
  60. } else {
  61. set signo 12
  62. }
  63. gdb_test_multiple {p $_siginfo.si_signo} $test {
  64. -re " = $signo\r\n$gdb_prompt $" {
  65. pass $test
  66. }
  67. -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" {
  68. unsupported $test
  69. }
  70. }
  71. set test "signal $sigcount si_code is SI_TKILL"
  72. gdb_test_multiple {p $_siginfo.si_code} $test {
  73. -re " = -6\r\n$gdb_prompt $" {
  74. pass $test
  75. }
  76. -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" {
  77. unsupported $test
  78. }
  79. }
  80. set test "signal $sigcount si_pid"
  81. gdb_test_multiple {p $_siginfo._sifields._kill.si_pid} $test {
  82. -re " = $pid\r\n$gdb_prompt $" {
  83. pass $test
  84. }
  85. -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" {
  86. unsupported $test
  87. }
  88. }
  89. }
  90. gdb_continue_to_breakpoint break-at-exit ".*break-at-exit.*"