non-ldr-exc-2.exp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Copyright 2009-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 when a thread other than the main thread execs, we follow
  15. # through to the new incarnation of the main thread, even if the main
  16. # thread had already exited before the exec.
  17. standard_testfile
  18. set executable ${testfile}
  19. if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
  20. return -1
  21. }
  22. proc do_test { lock_sched nonstop } {
  23. global executable
  24. save_vars { GDBFLAGS } {
  25. append GDBFLAGS " -ex \"set non-stop $nonstop\""
  26. clean_restart ${executable}
  27. }
  28. if ![runto_main] {
  29. return -1
  30. }
  31. gdb_breakpoint [gdb_get_line_number "break-here"]
  32. gdb_continue_to_breakpoint "break-here" ".* break-here .*"
  33. if { $nonstop == "on" } {
  34. gdb_test "thread 2" "Switching.*"
  35. }
  36. gdb_test "info threads" \
  37. "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \
  38. "single thread left"
  39. # Also test with sched-lock to make sure we can follow the
  40. # non-leader thread execing even though the main thread wasn't
  41. # resumed before the exec.
  42. if { $lock_sched } {
  43. gdb_test_no_output "set scheduler-locking on"
  44. }
  45. gdb_test "continue" \
  46. ".*is executing new program.*Breakpoint 1, main.* at .*" \
  47. "continue over exec"
  48. }
  49. foreach_with_prefix nonstop {"on" "off"} {
  50. foreach_with_prefix schedlock {"on" "off"} {
  51. if {$schedlock == "on" && $nonstop == "on"} {
  52. # Schedule locking has no effect in nonstop mode.
  53. continue
  54. }
  55. do_test $schedlock $nonstop
  56. }
  57. }