gcore-stale-thread.exp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright 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. standard_testfile
  15. set corefile [standard_output_file ${testfile}.core]
  16. if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug] != ""} {
  17. return -1
  18. }
  19. clean_restart ${testfile}
  20. gdb_test_no_output "set non-stop on"
  21. if { ! [ runto_main ] } then {
  22. return -1
  23. }
  24. gdb_test_multiple "info threads" "threads are supported" {
  25. -re ".* main .*\r\n$gdb_prompt $" {
  26. # OK, threads are supported.
  27. }
  28. -re "\r\n$gdb_prompt $" {
  29. unsupported "gdb does not support threads on this target"
  30. return -1
  31. }
  32. }
  33. gdb_breakpoint ${srcfile}:[gdb_get_line_number "break-here"]
  34. # gdb_continue_to_breakpoint does not work as it uses "$gdb_prompt $" regex
  35. # which does not work due to the output: (gdb) [Thread ... exited]
  36. set name "continue to breakpoint: break-here"
  37. gdb_test_multiple "continue" $name {
  38. -re "Breakpoint .* (at|in) .* break-here .*\r\n$gdb_prompt " {
  39. pass $name
  40. }
  41. }
  42. gdb_gcore_cmd "$corefile" "save a corefile"
  43. # Do not run "info threads" before "gcore" as it could workaround the bug
  44. # by discarding non-current exited threads.
  45. gdb_test "info threads" \
  46. {The current thread <Thread ID 1> has terminated\. See `help thread'\.} \
  47. "exited thread is current due to non-stop"