next-bp-other-thread.exp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright (C) 2014-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 behaves correctly when a "next" steps over a call, and
  15. # another thread hits a breakpoint that doesn't cause a user visible
  16. # stop (and so needs to be stepped over). GDB used to trip on an
  17. # invalid assertion - PR17408.
  18. standard_testfile
  19. if {[build_executable "failed to prepare" $testfile $srcfile \
  20. {debug pthreads}] == -1} {
  21. return -1
  22. }
  23. # Test all "set scheduler-locking" variants.
  24. foreach schedlock {"off" "step" "on" } {
  25. with_test_prefix "schedlock=$schedlock" {
  26. clean_restart $binfile
  27. if ![runto_main] {
  28. continue
  29. }
  30. gdb_breakpoint [gdb_get_line_number "set wait-thread breakpoint here"]
  31. gdb_continue_to_breakpoint "run to wait-thread breakpoint"
  32. gdb_test "info threads" "\\\* 1 .* 2 .*" "info threads shows all threads"
  33. delete_breakpoints
  34. gdb_breakpoint [gdb_get_line_number "set breakpoint child here"]
  35. # Give it a condition that always fails.
  36. gdb_test "condition \$bpnum global_zero == 1" ".*"
  37. gdb_test_no_output "set scheduler-locking $schedlock"
  38. # While stepping over the sleep call, the other thread hits a
  39. # breakpoint that doesn't cause a user visible stop (and so
  40. # needs to be stepped over). The next should complete as if
  41. # that breakpoint never triggered.
  42. gdb_test "next" "EXIT_SUCCESS.*" "next over function call"
  43. }
  44. }