unc_arr_ptr_in_var_rec.exp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Copyright 2012-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. load_lib "ada.exp"
  16. if { [skip_ada_tests] } { return -1 }
  17. standard_ada_testfile foo
  18. foreach_with_prefix scenario {all minimal} {
  19. set flags [list debug additional_flags=-fgnat-encodings=$scenario]
  20. if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != ""} {
  21. return -1
  22. }
  23. clean_restart ${testfile}
  24. set bp_location [gdb_get_line_number "STOP1" ${testdir}/foo.adb]
  25. runto "foo.adb:$bp_location"
  26. # Print My_Object and My_Object.Ptr when Ptr is null...
  27. gdb_test "print my_object" \
  28. "= \\(n => 3, ptr => 0x0, data => \\(3, 5, 8\\)\\)" \
  29. "print My_Object with null Ptr"
  30. gdb_test "print my_object.ptr" \
  31. "= \\(foo.table_access\\) 0x0" \
  32. "print My_Object.Ptr when null"
  33. # Same for My_P_Object...
  34. gdb_test "print my_p_object" \
  35. "= \\(n => 3, ptr => 0x0, data => \\(3, 5, 8\\)\\)" \
  36. "print My_P_Object with null Ptr"
  37. gdb_test "print my_p_object.ptr" \
  38. "\\(foo.p_table_access\\) 0x0" \
  39. "print My_P_Object.Ptr when null"
  40. # Continue until the Ptr component of both objects get allocated.
  41. set bp_location [gdb_get_line_number "STOP2" ${testdir}/foo.adb]
  42. gdb_breakpoint "foo.adb:$bp_location"
  43. gdb_test "continue" \
  44. "Breakpoint $decimal, foo \\(\\) at .*foo.adb:$decimal.*" \
  45. "continue to STOP2"
  46. # Inspect My_Object again...
  47. gdb_test "print my_object" \
  48. "= \\(n => 3, ptr => $hex, data => \\(3, 5, 8\\)\\)" \
  49. "print my_object after setting Ptr"
  50. gdb_test "print my_object.ptr" \
  51. "\\(foo.table_access\\) $hex" \
  52. "print my_object.ptr when no longer null"
  53. gdb_test "print my_object.ptr.all" \
  54. "= \\(13, 21, 34\\)"
  55. # Same with My_P_Object...
  56. gdb_test "print my_p_object" \
  57. "= \\(n => 3, ptr => $hex, data => \\(3, 5, 8\\)\\)" \
  58. "print my_p_object after setting Ptr"
  59. gdb_test "print my_p_object.ptr" \
  60. "= \\(foo.p_table_access\\) $hex" \
  61. "print My_P_Object.Ptr when no longer null"
  62. gdb_test "print my_p_object.ptr.all" \
  63. "\\(13, 21, 34\\)"
  64. }