no-unwaited-for-left.exp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Copyright (C) 2007-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. # Exit of a thread when there are other threads in the inferior should
  15. # not hang GDB.
  16. standard_testfile
  17. set executable ${testfile}
  18. if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
  19. return -1
  20. }
  21. clean_restart ${executable}
  22. if ![runto_main] {
  23. return -1
  24. }
  25. gdb_breakpoint $srcfile:[gdb_get_line_number "break-here"]
  26. gdb_continue_to_breakpoint "break-here" ".* break-here .*"
  27. # Resume only the second thread
  28. gdb_test_no_output "set scheduler-locking on" \
  29. "enable scheduler-locking, for thread 2"
  30. # Continue. Thread 2 exits, and the main thread was already stopped.
  31. gdb_test "continue" \
  32. "No unwaited-for children left." \
  33. "continue stops when thread 2 exits"
  34. gdb_test "info threads" \
  35. "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *1 *Thread \[^\r\n\]* \[^\r\n\]*.*The current thread <Thread ID 2> has terminated.*" \
  36. "only main thread left, thread 2 terminated"
  37. # Select the main thread, let the third thread start, and stop at the
  38. # main thread breakpoint.
  39. gdb_test "thread 1" "" "select main thread"
  40. gdb_test_no_output "set scheduler-locking off" \
  41. "disable scheduler-locking, letting new thread start"
  42. gdb_breakpoint $srcfile:[gdb_get_line_number "break-here-2"]
  43. gdb_continue_to_breakpoint "break-here-2" ".* break-here-2 .*"
  44. # Let the main thread continue alone.
  45. gdb_test_no_output "set scheduler-locking on" \
  46. "enable scheduler-locking, for main thread"
  47. # The main thread exits, and thread 3 was already stopped.
  48. gdb_test "continue" \
  49. "No unwaited-for children left." \
  50. "continue stops when the main thread exits"
  51. gdb_test "info threads" \
  52. "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *3 *Thread \[^\r\n\]* \[^\r\n\]*.*The current thread <Thread ID 1> has terminated.*" \
  53. "only thread 3 left, main thread terminated"
  54. # Make sure thread apply all works when we have exited threads in the
  55. # list.
  56. gdb_test "thread apply all print 999" " = 999" "thread apply all with exited thread"