]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/DW_OP_piece_with_DW_OP_GNU_uninit.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / DW_OP_piece_with_DW_OP_GNU_uninit.exp
1 # Copyright 2023-2024 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 use of DW_OP_GNU_uninit with DW_OP_piece. For this case, GDB
17 # should not print:
18 #
19 # DWARF-2 expression error: DW_OP_GNU_uninit must always be the very last op.
20
21 load_lib dwarf.exp
22
23 require dwarf2_support
24
25 standard_testfile main.c -dw.S
26
27 set asm_file [standard_output_file $srcfile2]
28
29 set c64 6639779683436459270
30 set c32 1779823878
31
32 Dwarf::assemble $asm_file {
33 cu {} {
34 compile_unit {} {
35 declare_labels i64_type i32_type
36
37 i64_type: base_type {
38 {name "int64_t"}
39 {encoding @DW_ATE_signed}
40 {byte_size 8 DW_FORM_sdata}
41 }
42
43 i32_type: base_type {
44 {name "int32_t"}
45 {encoding @DW_ATE_signed}
46 {byte_size 4 DW_FORM_sdata}
47 }
48
49 DW_TAG_variable {
50 {name i64_var}
51 {type :$i64_type}
52 {location {
53 DW_OP_constu $::c64
54 DW_OP_stack_value
55 DW_OP_GNU_uninit
56 DW_OP_piece 8
57 } SPECIAL_expr}
58 }
59
60 DW_TAG_variable {
61 {name i32_var}
62 {type :$i32_type}
63 {location {
64 DW_OP_constu $::c32
65 DW_OP_stack_value
66 DW_OP_GNU_uninit
67 DW_OP_piece 4
68 } SPECIAL_expr}
69 }
70 }
71 }
72 }
73
74 if {[build_executable ${testfile}.exp ${testfile} \
75 [list $srcfile $asm_file] {nodebug}]} {
76 return -1
77 }
78
79 clean_restart ${testfile}
80
81 if {![runto_main]} {
82 return -1
83 }
84
85 set cmd "print i64_var"
86 if { [is_64_target] } {
87 gdb_test $cmd \
88 " = +\\\[uninitialized\\\] $c64"
89 } else {
90 unsupported $cmd
91 }
92
93 gdb_test "print i32_var" \
94 " = +\\\[uninitialized\\\] $c32"