1 # Copyright 2010-2019 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/>.
16 # Test some DWARF piece operators.
18 # This test can only be run on targets which support DWARF-2 and use gas.
19 if {![dwarf2_support]} {
22 # This test can only be run on x86 targets.
23 if {![is_x86_like_target]} {
28 set csrcfile ${testfile}.c
30 if {[prepare_for_testing "failed to prepare" ${testfile} $srcfile]} {
38 # Function f1 tests a particular gdb bug involving DW_OP_piece.
39 proc pieces_test_f1 {} {
41 set line [gdb_get_line_number "f1 breakpoint" $csrcfile]
42 gdb_test "break pieces.c:$line" "Breakpoint 2.*" \
43 "set f1 breakpoint for pieces"
44 gdb_continue_to_breakpoint "continue to f1 breakpoint for pieces"
45 gdb_test "print a" " = {i = 4, j = 14}" "print a in pieces:f1"
46 gdb_test "print a.j" " = 14" "print a.j in pieces:f1"
49 # Function f2 tests for a bug when indexing into an array created
51 proc pieces_test_f2 {} {
53 set line [gdb_get_line_number "f2 breakpoint" $csrcfile]
54 gdb_test "break pieces.c:$line" "Breakpoint 3.*" \
55 "set f2 breakpoint for pieces"
56 gdb_continue_to_breakpoint "continue to f2 breakpoint for pieces"
57 gdb_test "print a" " = .4, 14." "print a in pieces:f2"
58 gdb_test "print a\[0\]" " = 4" "print a\[0\] in pieces:f2"
59 gdb_test "print a\[1\]" " = 14" "print a\[1\] in pieces:f2"
62 # Function f3 tests DW_OP_bit_piece.
63 proc pieces_test_f3 {} {
65 set line [gdb_get_line_number "f3 breakpoint" $csrcfile]
66 gdb_test "break pieces.c:$line" "Breakpoint 4.*" \
67 "set f3 breakpoint for pieces"
68 gdb_continue_to_breakpoint "continue to f3 breakpoint for pieces"
69 gdb_test "print a.i" " = 4" "print a.i in pieces:f3"
70 gdb_test "print a.j" " = 14" "print a.j in pieces:f3"
71 gdb_test "print a.i = 7" " = 7" "set a.i in pieces:f3"
72 gdb_test "print a.i" " = 7" "print new a.i in pieces:f3"
75 # Function f6 tests for an empty DW_OP_piece.
76 proc pieces_test_f6 {} {
78 set line [gdb_get_line_number "f6 breakpoint" $csrcfile]
79 gdb_test "break pieces.c:$line" "Breakpoint 5.*" \
80 "set f6 breakpoint for pieces"
81 gdb_continue_to_breakpoint "continue to f6 breakpoint for pieces"
83 " = {i = 7, j = 8, q = .optimized out.}" \
84 "print a with optimized out piece"
85 # Note: no warning for this case.
86 gdb_test_multiple "print a.i" \
87 "print a.i with optimized out piece" {
88 -re "warning: some bits in computed object" {
89 fail "print a.i with optimized out piece"
92 pass "print a.i with optimized out piece"