dw2-align.exp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Copyright 2018-2022 Free Software Foundation, Inc.
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 3 of the License, or
  5. # (at your option) any later version.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. load_lib dwarf.exp
  15. # This test can only be run on targets which support DWARF-2 and use gas.
  16. if {![dwarf2_support]} {
  17. return 0
  18. }
  19. standard_testfile main.c -dw.S
  20. # Make some DWARF for the test.
  21. set asm_file [standard_output_file $srcfile2]
  22. Dwarf::assemble $asm_file {
  23. global srcdir subdir srcfile
  24. cu {} {
  25. DW_TAG_compile_unit {
  26. {DW_AT_language @DW_LANG_C_plus_plus}
  27. {DW_AT_name $srcfile}
  28. {DW_AT_comp_dir /tmp}
  29. } {
  30. declare_labels itype ptype
  31. itype: DW_TAG_base_type {
  32. {DW_AT_byte_size 4 DW_FORM_sdata}
  33. {DW_AT_encoding @DW_ATE_signed}
  34. {DW_AT_name int_4096}
  35. {DW_AT_alignment 4096 DW_FORM_sdata}
  36. }
  37. ptype: DW_TAG_pointer_type {
  38. {DW_AT_byte_size 8 DW_FORM_sdata}
  39. {DW_AT_type :$itype}
  40. {DW_AT_alignment 4096 DW_FORM_sdata}
  41. }
  42. DW_TAG_typedef {
  43. {DW_AT_name ptr_4096}
  44. {DW_AT_type :$ptype}
  45. }
  46. DW_TAG_structure_type {
  47. {DW_AT_name "struct_4096"}
  48. {DW_AT_byte_size 4096 DW_FORM_sdata}
  49. {DW_AT_alignment 4096 DW_FORM_udata}
  50. } {
  51. member {
  52. {name a}
  53. {type :$itype}
  54. {data_member_location 0 data1}
  55. }
  56. }
  57. }
  58. }
  59. }
  60. if { [prepare_for_testing "failed to prepare" ${testfile} \
  61. [list $srcfile $asm_file] {nodebug}] } {
  62. return -1
  63. }
  64. if ![runto_main] {
  65. return -1
  66. }
  67. gdb_test_no_output "set lang c++"
  68. gdb_test "print alignof(int_4096)" " = 4096"
  69. gdb_test "print alignof(ptr_4096)" " = 4096"
  70. gdb_test "print alignof(struct_4096)" " = 4096"