multiple-step-overs.exp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. # Copyright (C) 2011-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. # Test that GDB steps over all breakpoints of threads not the stepping
  15. # thread, before actually proceeding with the stepped thread.
  16. standard_testfile
  17. set executable ${testfile}
  18. if [target_info exists gdb,nosignals] {
  19. verbose "Skipping ${testfile}.exp because of nosignals."
  20. return -1
  21. }
  22. if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
  23. executable [list debug "incdir=${objdir}"]] != "" } {
  24. return -1
  25. }
  26. # Prepare environment for test.
  27. proc setup {} {
  28. global executable
  29. global displaced
  30. with_test_prefix "setup" {
  31. clean_restart $executable
  32. if ![runto_main] {
  33. return -1
  34. }
  35. gdb_test_no_output "set displaced-stepping $displaced"
  36. gdb_breakpoint [gdb_get_line_number "set wait-threads breakpoint here"]
  37. gdb_continue_to_breakpoint "run to breakpoint"
  38. gdb_test "info threads" "\\\* 1 .* 2 .* 3 .*" "info threads shows all threads"
  39. gdb_test_no_output "set scheduler-locking on"
  40. gdb_breakpoint [gdb_get_line_number "set breakpoint thread 3 here"]
  41. gdb_breakpoint [gdb_get_line_number "set breakpoint thread 2 here"]
  42. gdb_test "thread 3" "Switching.*"
  43. gdb_continue_to_breakpoint "run to breakpoint in thread 3"
  44. gdb_test "p *myp = 0" " = 0" "unbreak loop in thread 3"
  45. gdb_test "thread 2" "Switching.*"
  46. gdb_continue_to_breakpoint "run to breakpoint in thread 2"
  47. gdb_test "p *myp = 0" " = 0" "unbreak loop in thread 2"
  48. # Disable scheduler locking.
  49. gdb_test_no_output "set scheduler-locking off"
  50. # Now all 3 threads are stopped for a breakpoint that needs to
  51. # be stepped over before thread 1 is resumed.
  52. }
  53. }
  54. foreach displaced { "off" "on" } {
  55. with_test_prefix "displaced=$displaced" {
  56. with_test_prefix "step" {
  57. setup
  58. gdb_test "thread 1" "Switching.*"
  59. gdb_test "step" "in wait_threads .*"
  60. }
  61. with_test_prefix "next" {
  62. setup
  63. gdb_test "thread 1" "Switching.*"
  64. gdb_test "next" "pthread_join.*"
  65. }
  66. with_test_prefix "continue" {
  67. setup
  68. gdb_breakpoint [gdb_get_line_number "EXIT_SUCCESS"]
  69. gdb_test "thread 1" "Switching.*"
  70. gdb_test "continue" "EXIT_SUCCESS.*"
  71. }
  72. # Try continuing with a queued signal in each of the threads
  73. # (one at a time). Should stop at the signal handler, instead
  74. # of re-trapping the breakpoint the threads were already
  75. # stopped at.
  76. foreach thread {1 2 3} {
  77. with_test_prefix "signal thr$thread" {
  78. setup
  79. # Queue a signal in THREAD.
  80. gdb_test "thread $thread" "Switching.*"
  81. gdb_test_no_output "queue-signal SIGUSR1"
  82. # Switch back to thread 1, and continue.
  83. gdb_test "thread 1" "Switching.*" "switch back to thread 1"
  84. gdb_breakpoint "sigusr1_handler" "set break at sigusr1_handler"
  85. set msg "continue to sigusr1_handler"
  86. gdb_test_multiple "continue" $msg {
  87. -re "Breakpoint .* sigusr1_handler .*$gdb_prompt $" {
  88. pass $msg
  89. }
  90. -re "Breakpoint .*$gdb_prompt $" {
  91. if {![can_single_step_to_signal_handler]
  92. && $thread != 1 && $displaced == "off"} {
  93. setup_kfail "gdb/18214" "*-*-*"
  94. }
  95. fail $msg
  96. }
  97. }
  98. }
  99. }
  100. }
  101. }