intbits.exp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. # Copyright 2020-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. # Test support for non-byte-sized integer base types.
  15. load_lib dwarf.exp
  16. # This test can only be run on targets which support DWARF-2 and use gas.
  17. if {![dwarf2_support]} {
  18. return 0
  19. }
  20. standard_testfile .c .S
  21. set executable ${testfile}
  22. set asm_file [standard_output_file ${srcfile2}]
  23. if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] {
  24. return -1
  25. }
  26. # Create the DWARF.
  27. Dwarf::assemble ${asm_file} {
  28. cu {} {
  29. DW_TAG_compile_unit {
  30. {DW_AT_language @DW_LANG_C_plus_plus}
  31. } {
  32. declare_labels i7_type u1_type u17_type u31_type \
  33. u31_1_type u32_0_type u0_0_type be30_1_type
  34. i7_type: DW_TAG_base_type {
  35. {DW_AT_encoding @DW_ATE_signed}
  36. {DW_AT_endianity @DW_END_little}
  37. {DW_AT_name "i7"}
  38. {DW_AT_byte_size 2 DW_FORM_udata}
  39. {DW_AT_bit_size 7 DW_FORM_udata}
  40. }
  41. DW_TAG_variable {
  42. {DW_AT_name "v_i16_m1"}
  43. {DW_AT_type :${i7_type}}
  44. {DW_AT_external 1 DW_FORM_flag}
  45. {DW_AT_location {DW_OP_addr [gdb_target_symbol "i16_m1"]}
  46. SPECIAL_expr}
  47. }
  48. u1_type: DW_TAG_base_type {
  49. {DW_AT_encoding @DW_ATE_boolean}
  50. {DW_AT_endianity @DW_END_little}
  51. {DW_AT_name "u1"}
  52. {DW_AT_byte_size 2 DW_FORM_udata}
  53. {DW_AT_bit_size 1 DW_FORM_udata}
  54. {DW_AT_data_bit_offset 2 DW_FORM_udata}
  55. }
  56. DW_TAG_variable {
  57. {DW_AT_name "v_u16_1"}
  58. {DW_AT_type :${u1_type}}
  59. {DW_AT_external 1 DW_FORM_flag}
  60. {DW_AT_location {DW_OP_addr [gdb_target_symbol "u16_1"]}
  61. SPECIAL_expr}
  62. }
  63. u17_type: DW_TAG_base_type {
  64. {DW_AT_encoding @DW_ATE_signed}
  65. {DW_AT_endianity @DW_END_little}
  66. {DW_AT_name "u17"}
  67. {DW_AT_byte_size 4 DW_FORM_udata}
  68. {DW_AT_bit_size 17 DW_FORM_udata}
  69. }
  70. DW_TAG_variable {
  71. {DW_AT_name "v_u32_m2"}
  72. {DW_AT_type :${u17_type}}
  73. {DW_AT_external 1 DW_FORM_flag}
  74. {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_m2"]}
  75. SPECIAL_expr}
  76. }
  77. u31_type: DW_TAG_base_type {
  78. {DW_AT_encoding @DW_ATE_unsigned}
  79. {DW_AT_endianity @DW_END_little}
  80. {DW_AT_name "u31"}
  81. {DW_AT_byte_size 4 DW_FORM_udata}
  82. {DW_AT_bit_size 31 DW_FORM_udata}
  83. }
  84. DW_TAG_variable {
  85. {DW_AT_name "v_u32_1"}
  86. {DW_AT_type :${u31_type}}
  87. {DW_AT_external 1 DW_FORM_flag}
  88. {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_1"]}
  89. SPECIAL_expr}
  90. }
  91. u31_1_type: DW_TAG_base_type {
  92. {DW_AT_encoding @DW_ATE_unsigned}
  93. {DW_AT_endianity @DW_END_little}
  94. {DW_AT_name "u31_1"}
  95. {DW_AT_byte_size 4 DW_FORM_udata}
  96. {DW_AT_bit_size 31 DW_FORM_udata}
  97. {DW_AT_data_bit_offset 1 DW_FORM_udata}
  98. }
  99. DW_TAG_variable {
  100. {DW_AT_name "v_u32_1_off"}
  101. {DW_AT_type :${u31_1_type}}
  102. {DW_AT_external 1 DW_FORM_flag}
  103. {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_1_off"]}
  104. SPECIAL_expr}
  105. }
  106. be30_1_type: DW_TAG_base_type {
  107. {DW_AT_encoding @DW_ATE_unsigned}
  108. {DW_AT_endianity @DW_END_big}
  109. {DW_AT_name "be30_1"}
  110. {DW_AT_byte_size 4 DW_FORM_udata}
  111. {DW_AT_bit_size 30 DW_FORM_udata}
  112. {DW_AT_data_bit_offset 1 DW_FORM_udata}
  113. }
  114. DW_TAG_variable {
  115. {DW_AT_name "v_be30_1_off"}
  116. {DW_AT_type :${be30_1_type}}
  117. {DW_AT_external 1 DW_FORM_flag}
  118. {DW_AT_location {DW_OP_addr [gdb_target_symbol "be30_1_off"]}
  119. SPECIAL_expr}
  120. }
  121. u32_0_type: DW_TAG_base_type {
  122. {DW_AT_encoding @DW_ATE_unsigned}
  123. {DW_AT_endianity @DW_END_little}
  124. {DW_AT_name "u32_0"}
  125. {DW_AT_byte_size 4 DW_FORM_udata}
  126. {DW_AT_bit_size 0 DW_FORM_udata}
  127. }
  128. DW_TAG_variable {
  129. {DW_AT_name "v_u32_0"}
  130. {DW_AT_type :${u32_0_type}}
  131. {DW_AT_external 1 DW_FORM_flag}
  132. {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_0"]}
  133. SPECIAL_expr}
  134. }
  135. u0_0_type: DW_TAG_base_type {
  136. {DW_AT_encoding @DW_ATE_unsigned}
  137. {DW_AT_endianity @DW_END_little}
  138. {DW_AT_name "u0_0"}
  139. {DW_AT_byte_size 0 DW_FORM_udata}
  140. }
  141. DW_TAG_variable {
  142. {DW_AT_name "v_u0_0"}
  143. {DW_AT_type :${u0_0_type}}
  144. {DW_AT_external 1 DW_FORM_flag}
  145. {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_0"]}
  146. SPECIAL_expr}
  147. }
  148. }
  149. }
  150. }
  151. if {[prepare_for_testing "failed to prepare" ${executable} \
  152. [list ${asm_file} ${srcfile}] {}]} {
  153. return -1
  154. }
  155. if {![runto_main]} {
  156. return -1
  157. }
  158. gdb_test "print v_i16_m1" "= -1"
  159. gdb_test "print v_u16_1" "= true"
  160. gdb_test "print v_u32_m2" "= -2"
  161. gdb_test "print v_u32_1" "= 1"
  162. gdb_test "print v_u32_0" "= 0"
  163. gdb_test "print v_u0_0" "= 0"
  164. gdb_test "print v_i16_m1 = 7" "= 7"
  165. gdb_test "print v_i16_m1" "= 7" "print v_i16_m1 after assignment"
  166. gdb_test "print v_u32_1_off" "= 1"
  167. gdb_test "print v_u32_1_off = 7" " = 7"
  168. gdb_test "x/4xb &v_u32_1_off" ":\t0x0e\t0x00\t0x00\t0x00"
  169. gdb_test "print v_be30_1_off" "= 1"
  170. gdb_test "print v_be30_1_off = 7" " = 7"
  171. gdb_test "x/4xb &v_be30_1_off" ":\t0x00\t0x00\t0x00\t0x0e"