|
| 1 | +# Copyright 2025 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 | + |
| 16 | +# Test DW_AT_data_bit_offset with an expression. This is a DWARF |
| 17 | +# extension, but expected to be in DWARF 6. See |
| 18 | +# https://dwarfstd.org/issues/250501.1.html |
| 19 | + |
| 20 | +load_lib dwarf.exp |
| 21 | + |
| 22 | +# This test can only be run on targets which support DWARF-2 and use gas. |
| 23 | +require dwarf2_support |
| 24 | + |
| 25 | +standard_testfile ada-array-bound.c -debug.S |
| 26 | + |
| 27 | +# Set up the DWARF for the test. |
| 28 | + |
| 29 | +set asm_file [standard_output_file $srcfile2] |
| 30 | +Dwarf::assemble $asm_file { |
| 31 | + global srcdir subdir srcfile |
| 32 | + |
| 33 | + cu {} { |
| 34 | + DW_TAG_compile_unit { |
| 35 | + {DW_AT_language @DW_LANG_Ada95} |
| 36 | + {DW_AT_name $srcfile} |
| 37 | + } { |
| 38 | + declare_labels byte array struct |
| 39 | + |
| 40 | + byte: DW_TAG_base_type { |
| 41 | + {DW_AT_byte_size 1 DW_FORM_sdata} |
| 42 | + {DW_AT_encoding @DW_ATE_unsigned} |
| 43 | + {DW_AT_name byte} |
| 44 | + } |
| 45 | + |
| 46 | + array: DW_TAG_array_type { |
| 47 | + {DW_AT_name array_type} |
| 48 | + {DW_AT_type :$byte} |
| 49 | + } { |
| 50 | + DW_TAG_subrange_type { |
| 51 | + {DW_AT_type :$byte} |
| 52 | + {DW_AT_upper_bound 3 DW_FORM_sdata} |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + struct: DW_TAG_structure_type { |
| 57 | + {DW_AT_name discriminated} |
| 58 | + {DW_AT_byte_size 4 DW_FORM_sdata} |
| 59 | + } { |
| 60 | + DW_TAG_member { |
| 61 | + {DW_AT_name disc} |
| 62 | + {DW_AT_type :$byte} |
| 63 | + {DW_AT_data_member_location 0 DW_FORM_sdata} |
| 64 | + } |
| 65 | + |
| 66 | + # We know this is always at offset 1 but use an |
| 67 | + # expression just to test this code path. This is a |
| 68 | + # DWARF extension. See |
| 69 | + # https://dwarfstd.org/issues/250501.1.html. |
| 70 | + DW_TAG_member { |
| 71 | + {DW_AT_name nums} |
| 72 | + {DW_AT_type :$array} |
| 73 | + {DW_AT_data_bit_offset {DW_OP_lit8} SPECIAL_expr} |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + DW_TAG_variable { |
| 78 | + {DW_AT_name "value"} |
| 79 | + {DW_AT_type :$struct} |
| 80 | + {DW_AT_external 1 DW_FORM_flag} |
| 81 | + {DW_AT_location {DW_OP_addr [gdb_target_symbol "our_data"]} |
| 82 | + SPECIAL_expr} |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +if {[prepare_for_testing "failed to prepare" ${testfile} \ |
| 89 | + [list $srcfile $asm_file] {nodebug}]} { |
| 90 | + return -1 |
| 91 | +} |
| 92 | + |
| 93 | +gdb_test_no_output "set language ada" |
| 94 | +gdb_test "print value" \ |
| 95 | + [string_to_regexp " = (disc => 3, nums => (7, 11, 13))"] |
0 commit comments