unchecked_union.exp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Copyright 2019-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 ptype of an unchecked union.
  16. load_lib "ada.exp"
  17. if { [skip_ada_tests] } { return -1 }
  18. standard_ada_testfile unchecked_union
  19. proc multi_line_string {str} {
  20. set result {}
  21. foreach line [split $str \n] {
  22. lappend result [string_to_regexp $line]
  23. }
  24. return [eval multi_line $result]
  25. }
  26. set inner_string { case ? is
  27. when 0 =>
  28. small: range 0 .. 255;
  29. second: range 0 .. 255;
  30. when ? =>
  31. bval: range 0 .. 255;
  32. when others =>
  33. large: range 255 .. 510;
  34. more: range 255 .. 510;
  35. end case;
  36. }
  37. set inner_full "type = record (?) is\n${inner_string}end record"
  38. set pair_string { case ? is
  39. when ? =>
  40. field_one: range 0 .. 255;
  41. when ? =>
  42. field_two: range 255 .. 510;
  43. end case;
  44. }
  45. set pair_full "type = record\n${inner_string}${pair_string}end record"
  46. foreach_with_prefix scenario {none all minimal} {
  47. set flags {debug}
  48. if {$scenario != "none"} {
  49. lappend flags additional_flags=-fgnat-encodings=$scenario
  50. }
  51. if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != ""} {
  52. return -1
  53. }
  54. clean_restart ${testfile}
  55. set bp_location [gdb_get_line_number "BREAK" ${testdir}/unchecked_union.adb]
  56. runto "unchecked_union.adb:$bp_location"
  57. gdb_test "ptype Pair" [multi_line_string $pair_full]
  58. gdb_test "ptype Inner" [multi_line_string $inner_full]
  59. }