exec_changed.exp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # Copyright 2005-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. load_lib "ada.exp"
  15. if { [skip_ada_tests] } { return -1 }
  16. # This testcase verifies the behavior of the `start' command, which
  17. # does not work when we use the gdb stub...
  18. if [use_gdb_stub] {
  19. untested "skipping tests due to use_gdb_stub"
  20. return
  21. }
  22. standard_ada_testfile first
  23. # Build the first test program (note that cygwin needs the $EXEEXT).
  24. if {[gdb_compile_ada "${srcfile}" "${binfile}$EXEEXT" executable {debug}] != ""} {
  25. return -1
  26. }
  27. # Build the second test program
  28. set srcfile2 ${srcdir}/${subdir}/${testdir}/second.adb
  29. set binfile2 [standard_output_file second$EXEEXT]
  30. if {[gdb_compile_ada "${srcfile2}" "${binfile2}" executable {debug}] != ""} {
  31. return -1
  32. }
  33. # Start with a fresh gdb.
  34. set common_binfile [standard_output_file common$EXEEXT]
  35. gdb_start
  36. gdb_reinitialize_dir $srcdir/$subdir
  37. # Load the first executable.
  38. gdb_test "shell mv ${binfile} ${common_binfile}" ".*" ""
  39. gdb_load ${common_binfile}
  40. # Start the program, we should land in the program main procedure
  41. if { [gdb_start_cmd] < 0 } {
  42. untested start
  43. return -1
  44. }
  45. gdb_test "" \
  46. "first \\(\\) at .*first.adb.*" \
  47. "start first"
  48. # Restore first executable to its original name, and move
  49. # second executable into its place. Ensure that the new
  50. # executable is at least a second newer than the old.
  51. gdb_test "shell mv ${common_binfile} ${binfile}" ".*" ""
  52. gdb_test "shell mv ${binfile2} ${common_binfile}" ".*" ""
  53. gdb_test "shell sleep 1" ".*" ""
  54. gdb_test "shell touch ${common_binfile}" ".*" ""
  55. # Start the program a second time, GDB should land in procedure Second
  56. # this time.
  57. if { [gdb_start_cmd] < 0 } {
  58. fail "start second"
  59. } else {
  60. gdb_test "" \
  61. "second \\(\\) at .*second.adb.*" \
  62. "start second"
  63. }
  64. # Try again, this time with just changing the file time of first.
  65. clean_restart "${binfile}$EXEEXT"
  66. # Ensure we don't accidently use the main symbol cache.
  67. gdb_test_no_output "mt set symbol-cache-size 0"
  68. # Put something in the symbol lookup cache that will get looked up when
  69. # starting after having re-read symbols. PR 17855.
  70. gdb_breakpoint break_me
  71. gdb_test "shell touch ${binfile}$EXEEXT" ".*" ""
  72. gdb_test "shell sleep 1" ".*" ""
  73. if { [gdb_start_cmd] < 0 } {
  74. # PR 17855: At this point gdb may have crashed or gotten an internal
  75. # error, but we still need to detect this. Just issue any simple command
  76. # to verify gdb is still running. This will establish in gdb.log whether
  77. # gdb is still running.
  78. gdb_test_no_output "set \$check_gdb_running = 0" "check gdb running"
  79. fail "start just first"
  80. } else {
  81. gdb_test "" \
  82. "first \\(\\) at .*first.adb.*" \
  83. "start just first"
  84. }