vfork-follow-child-exec.exp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright (C) 2019-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 following a vfork child that execs, when the vfork parent is a
  15. # threaded program, and it's a non-main thread that vforks.
  16. standard_testfile
  17. if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}]} {
  18. return -1
  19. }
  20. # DETACH indicates whether "set detach-on-fork" is enabled. It is
  21. # either "on" or "off".
  22. proc test_vfork {detach} {
  23. global binfile
  24. clean_restart $binfile
  25. if ![runto_main] then {
  26. return 0
  27. }
  28. delete_breakpoints
  29. gdb_test_no_output "set follow-fork-mode child"
  30. gdb_test_no_output "set detach-on-fork $detach"
  31. if {$detach == "off"} {
  32. gdb_test "continue" \
  33. [multi_line \
  34. "Attaching after .* vfork to child .*" \
  35. ".*New inferior 2 .*" \
  36. ".* is executing new program: .*" \
  37. ".*Inferior 2 .* exited normally.*"]
  38. } else {
  39. gdb_test "continue" \
  40. [multi_line \
  41. "Attaching after .* vfork to child .*" \
  42. ".*New inferior 2 .*" \
  43. ".*Detaching vfork parent process .* after child exec.*" \
  44. ".*Inferior 1 .* detached.*" \
  45. ".*is executing new program: .*" \
  46. ".*Inferior 2 .*exited normally.*"]
  47. }
  48. }
  49. foreach_with_prefix detach-on-fork {"off" "on"} {
  50. test_vfork ${detach-on-fork}
  51. }