task_watch.exp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Copyright 2009-2022 Free Software Foundation, Inc.
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. # Test task-specific watchpoints.
  16. load_lib "ada.exp"
  17. if { [skip_ada_tests] } { return -1 }
  18. standard_ada_testfile foo
  19. if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
  20. return -1
  21. }
  22. clean_restart ${testfile}
  23. set bp_location [gdb_get_line_number "STOP_HERE" ${testdir}/foo.adb]
  24. runto "foo.adb:$bp_location"
  25. # Make sure that all tasks appear in the "info tasks" listing, and
  26. # that the active task is the environment task.
  27. gdb_test "info tasks" \
  28. [join {" +ID +TID P-ID Pri State +Name" \
  29. "\\* +1 .* main_task" \
  30. " +2 .* task_list\\(1\\)" \
  31. " +3 .* task_list\\(2\\)" \
  32. " +4 .* task_list\\(3\\)"} \
  33. "\r\n"] \
  34. "info tasks before inserting breakpoint"
  35. # Insert a watchpoint that should stop only if task 3 stops, and
  36. # extract its number.
  37. set bp_number -1
  38. set test "watch -location value task 3"
  39. gdb_test_multiple $test $test {
  40. -re "atchpoint ($decimal): -location value\r\n$gdb_prompt $" {
  41. set bp_number $expect_out(1,string)
  42. pass $test
  43. }
  44. }
  45. if {$bp_number < 0} {
  46. return
  47. }
  48. # Continue to that watchpoint. Task 2 should hit it first, and GDB
  49. # is expected to ignore that hit and resume the execution. Only then
  50. # task 3 will hit our watchpoint, and GDB is expected to stop at that
  51. # point. Also make sure that GDB reports the correct watchpoint number.
  52. gdb_test "continue" \
  53. ".* hit .*atchpoint $bp_number: -location value.*Old value = 1.*New value = 2.*" \
  54. "continue to watchpoint"
  55. # Check that it is indeed task 3 that hit the watchpoint by checking
  56. # which is the active task.
  57. gdb_test "info tasks" \
  58. [join {" +ID +TID P-ID Pri State +Name" \
  59. " +1 .* main_task" \
  60. " +2 .* task_list\\(1\\)" \
  61. "\\* +3 .* task_list\\(2\\)" \
  62. " +4 .* task_list\\(3\\)"} \
  63. "\r\n"] \
  64. "info tasks after hitting watchpoint"
  65. # Now, resume the execution and make sure that GDB does not stop when
  66. # task 4 hits the watchpoint. Continuing thus results in our program
  67. # running to completion.
  68. set bp_location [gdb_get_line_number "STOP_HERE_2" ${testdir}/foo.adb]
  69. gdb_breakpoint foo.adb:$bp_location
  70. gdb_continue_to_breakpoint second ".*foo.adb:$bp_location.*null; -- STOP_HERE_2"