funcall_ref.exp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Copyright 2008-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. # Note we don't test the "none" (no -fgnat-encodings option) scenario
  19. # here, because "all" and "minimal" cover the cases, and this way we
  20. # don't have to update the test when gnat changes its default.
  21. foreach_with_prefix scenario {all minimal} {
  22. set flags [list debug additional_flags=-fgnat-encodings=$scenario]
  23. if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != ""} {
  24. return -1
  25. }
  26. clean_restart ${testfile}
  27. set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
  28. runto "foo.adb:$bp_location"
  29. # Test printing and type-printing of a discriminated record that a function
  30. # returns by reference.
  31. # Currently, GCC describes such functions as returning pointers (instead of
  32. # references).
  33. set pass_re [multi_line "type = <ref> record" \
  34. " n: natural;" \
  35. " s: array \\(1 \\.\\. n\\) of character;" \
  36. "end record"]
  37. # With DWARF we get debuginfo that could in theory show "1..n" for
  38. # the range:
  39. # <3><1230>: Abbrev Number: 15 (DW_TAG_member)
  40. # <1231> DW_AT_name : n
  41. # ...
  42. # <4><1257>: Abbrev Number: 18 (DW_TAG_subrange_type)
  43. # <1258> DW_AT_type : <0x126e>
  44. # <125c> DW_AT_upper_bound : <0x1230>
  45. # However, we don't currently record the needed information in the
  46. # location batons. In the meantime, we accept and kfail the
  47. # compromise output.
  48. set dwarf_kfail_re [multi_line "type = <ref> record" \
  49. " n: natural;" \
  50. " s: array \\(<>\\) of character;" \
  51. "end record"]
  52. set unsupported_re [multi_line "type = access record" \
  53. " n: natural;" \
  54. " s: access array \\(1 \\.\\. n\\) of character;" \
  55. "end record"]
  56. set supported 1
  57. gdb_test_multiple "ptype get(\"Hello world!\")" "" {
  58. -re -wrap $pass_re {
  59. pass $gdb_test_name
  60. }
  61. -re -wrap $dwarf_kfail_re {
  62. if {$scenario == "minimal"} {
  63. setup_kfail "symbolic names in location batons" *-*-*
  64. }
  65. fail $gdb_test_name
  66. set supported 0
  67. }
  68. -re -wrap $unsupported_re {
  69. unsupported $gdb_test_name
  70. set supported 0
  71. }
  72. }
  73. if { $supported == 0 } {
  74. return 0
  75. }
  76. gdb_test "p get(\"Hello world!\")" \
  77. "= \\(n => 12, s => \"Hello world!\"\\)"
  78. }