]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/pieces.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / pieces.exp
1 # Copyright 2010-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 load_lib dwarf.exp
16 # Test some DWARF piece operators.
17
18 # This test can only be run on targets which support DWARF-2 and use gas.
19 # This test can only be run on x86 targets.
20 require dwarf2_support is_x86_like_target
21
22 standard_testfile .S
23 set csrcfile ${testfile}.c
24
25 if {[prepare_for_testing "failed to prepare" ${testfile} $srcfile]} {
26 return -1
27 }
28
29 if ![runto_main] {
30 return -1
31 }
32
33 # Function f1 tests a particular gdb bug involving DW_OP_piece.
34 proc pieces_test_f1 {} {
35 global csrcfile
36 set line [gdb_get_line_number "f1 breakpoint" $csrcfile]
37 gdb_test "break pieces.c:$line" "Breakpoint 2.*" \
38 "set f1 breakpoint for pieces"
39 gdb_continue_to_breakpoint "continue to f1 breakpoint for pieces"
40 gdb_test "print a" " = {i = 4, j = 14}" "print a in pieces:f1"
41 gdb_test "print a.j" " = 14" "print a.j in pieces:f1"
42 }
43
44 # Function f2 tests for a bug when indexing into an array created
45 # using DW_OP_piece.
46 proc pieces_test_f2 {} {
47 global csrcfile
48 set line [gdb_get_line_number "f2 breakpoint" $csrcfile]
49 gdb_test "break pieces.c:$line" "Breakpoint 3.*" \
50 "set f2 breakpoint for pieces"
51 gdb_continue_to_breakpoint "continue to f2 breakpoint for pieces"
52 gdb_test "print a" " = .4, 14." "print a in pieces:f2"
53 gdb_test "print a\[0\]" " = 4" "print a\[0\] in pieces:f2"
54 gdb_test "print a\[1\]" " = 14" "print a\[1\] in pieces:f2"
55 }
56
57 # Function f3 tests DW_OP_bit_piece.
58 proc pieces_test_f3 {} {
59 global csrcfile
60 set line [gdb_get_line_number "f3 breakpoint" $csrcfile]
61 gdb_test "break pieces.c:$line" "Breakpoint 4.*" \
62 "set f3 breakpoint for pieces"
63 gdb_continue_to_breakpoint "continue to f3 breakpoint for pieces"
64 gdb_test "print a.i" " = 4" "print a.i in pieces:f3"
65 gdb_test "print a.j" " = 14" "print a.j in pieces:f3"
66 gdb_test "print a.i = 7" " = 7" "set a.i in pieces:f3"
67 gdb_test "print a.i" " = 7" "print new a.i in pieces:f3"
68 }
69
70 # Function f6 tests for an empty DW_OP_piece.
71 proc pieces_test_f6 {} {
72 global csrcfile
73 set line [gdb_get_line_number "f6 breakpoint" $csrcfile]
74 gdb_test "break pieces.c:$line" "Breakpoint 5.*" \
75 "set f6 breakpoint for pieces"
76 gdb_continue_to_breakpoint "continue to f6 breakpoint for pieces"
77 gdb_test "print a" \
78 " = {i = 7, j = 8, q = .optimized out.}" \
79 "print a with optimized out piece"
80 # Note: no warning for this case.
81 gdb_test_multiple "print a.i" \
82 "print a.i with optimized out piece" {
83 -re "warning: some bits in computed object" {
84 fail "print a.i with optimized out piece"
85 }
86 -re " = 7" {
87 pass "print a.i with optimized out piece"
88 }
89 }
90 }
91
92 pieces_test_f1
93 pieces_test_f2
94 pieces_test_f3
95 pieces_test_f6