schedlock-thread-exit.exp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright 2021-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 handles well a thread exiting with sched-lock on. A buggy GDB
  15. # would hang, a fixed GDB shows the "No unwaited-for children left" message and
  16. # shows the prompt.
  17. #
  18. # The explanation for the original bug involved some threads with a pending
  19. # wait status, so we launch multiple threads, which very likely gives us that.
  20. standard_testfile
  21. if { [build_executable "failed to prepare" ${testfile} ${srcfile} \
  22. {debug pthreads additional_flags=-std=c99}] } {
  23. return
  24. }
  25. proc do_test { } {
  26. clean_restart $::binfile
  27. # One of the launched threads will report a stop on thread_func. Some
  28. # others will also stop on thread_func and have a pending status.
  29. if { ![runto "thread_func"] } {
  30. return
  31. }
  32. gdb_test_no_output "set scheduler-locking on"
  33. gdb_test "continue" "No unwaited-for children left."
  34. }
  35. do_test