1 # Copyright 2023-2024 Free Software Foundation, Inc.
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.
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.
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/>.
18 # This test can only be run on targets which support DWARF-2 and use gas.
19 require dwarf2_support
21 standard_testfile main.c -dw.S
23 # Make some DWARF for the test.
24 set asm_file [standard_output_file $srcfile2]
25 Dwarf::assemble $asm_file {
28 declare_labels uinteger_label discr_1_label
29 declare_labels one_label two_label simple_label
34 {language @DW_LANG_Rust}
36 uinteger_label: DW_TAG_base_type {
37 {DW_AT_byte_size 1 DW_FORM_sdata}
38 {DW_AT_encoding @DW_ATE_unsigned}
39 {DW_AT_name {unsigned integer}}
42 one_label: structure_type {
44 {byte_size 1 DW_FORM_sdata}
48 {type :$uinteger_label}
49 {data_member_location 0 data1}
53 two_label: structure_type {
55 {byte_size 1 DW_FORM_sdata}
59 {type :$uinteger_label}
60 {data_member_location 0 data1}
64 simple_label: structure_type {
66 {byte_size 2 DW_FORM_sdata}
69 {discr :$discr_1_label DW_FORM_ref4}
71 discr_1_label: member {
72 {type :$uinteger_label}
73 {data_member_location 0 data1}
74 {artificial 1 DW_FORM_flag_present}
78 {discr_value 65 udata}
82 {data_member_location 1 data1}
90 {data_member_location 1 data1}
96 # In PR rust/31005, a constant Rust enum value could not
97 # be correctly resolved.
99 {name constant_variable}
100 {const_value 0x4141 udata}
101 {type :$simple_label}
104 {name constant_variable2}
105 {const_value "AA" DW_FORM_block1}
106 {type :$simple_label}
112 if { [prepare_for_testing "failed to prepare" ${testfile} \
113 [list $srcfile $asm_file] {nodebug}] } {
117 gdb_test_no_output "set language rust"
119 gdb_test "print constant_variable" [string_to_regexp "One(65)"]
120 gdb_test "print constant_variable2" [string_to_regexp "One(65)"]