arraydim.exp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Copyright 2013-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. set cfile "inc"
  19. set csrcfile ${srcdir}/${subdir}/${testdir}/${cfile}.c
  20. set cobject [standard_output_file ${cfile}.o]
  21. gdb_compile "${csrcfile}" "${cobject}" object [list debug]
  22. if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-largs additional_flags=${cobject} additional_flags=-margs]] != "" } {
  23. return -1
  24. }
  25. clean_restart ${testfile}
  26. set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
  27. runto "foo.adb:$bp_location"
  28. gdb_test "ptype m" \
  29. "array \\(1 \\.\\. 1, 2 \\.\\. 3, 4 \\.\\. 6\\) of integer"
  30. gdb_test "print m'first" " = 1"
  31. gdb_test "print m'last" " = 1"
  32. gdb_test "print m'length" " = 1"
  33. gdb_test "print m'first(1)" " = 1"
  34. gdb_test "print m'last(1)" " = 1"
  35. gdb_test "print m'length(1)" " = 1"
  36. gdb_test "print m'first(2)" " = 2"
  37. gdb_test "print m'last(2)" " = 3"
  38. gdb_test "print m'length(2)" " = 2"
  39. gdb_test "print m'first(3)" " = 4"
  40. gdb_test "print m'last(3)" " = 6"
  41. gdb_test "print m'length(3)" " = 3"
  42. gdb_test "ptype global_3dim_for_gdb_testing" \
  43. "array \\(0 \\.\\. 0, 0 \\.\\. 1, 0 \\.\\. 2\\) of int"
  44. gdb_test "print global_3dim_for_gdb_testing'first" " = 0"
  45. gdb_test "print global_3dim_for_gdb_testing'last" " = 0"
  46. gdb_test "print global_3dim_for_gdb_testing'length" " = 1"
  47. gdb_test "print global_3dim_for_gdb_testing'first(1)" " = 0"
  48. gdb_test "print global_3dim_for_gdb_testing'last(1)" " = 0"
  49. gdb_test "print global_3dim_for_gdb_testing'length(1)" " = 1"
  50. gdb_test "print global_3dim_for_gdb_testing'first(2)" " = 0"
  51. gdb_test "print global_3dim_for_gdb_testing'last(2)" " = 1"
  52. gdb_test "print global_3dim_for_gdb_testing'length(2)" " = 2"
  53. gdb_test "print global_3dim_for_gdb_testing'first(3)" " = 0"
  54. gdb_test "print global_3dim_for_gdb_testing'last(3)" " = 2"
  55. gdb_test "print global_3dim_for_gdb_testing'length(3)" " = 3"