]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/pieces.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / pieces.exp
1 # Copyright 2010-2013 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 if {![dwarf2_support]} {
20 return 0
21 }
22 # This test can only be run on x86 targets.
23 if {![is_x86_like_target]} {
24 return 0
25 }
26
27 standard_testfile .S
28 set csrcfile ${testfile}.c
29
30 if {[prepare_for_testing ${testfile}.exp ${testfile} $srcfile]} {
31 return -1
32 }
33
34 if ![runto_main] {
35 return -1
36 }
37
38 # Function f1 tests a particular gdb bug involving DW_OP_piece.
39 proc pieces_test_f1 {} {
40 global csrcfile
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"
47 }
48
49 # Function f2 tests for a bug when indexing into an array created
50 # using DW_OP_piece.
51 proc pieces_test_f2 {} {
52 global csrcfile
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"
60 }
61
62 # Function f3 tests DW_OP_bit_piece.
63 proc pieces_test_f3 {} {
64 global csrcfile
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"
73 }
74
75 # Function f6 tests for an empty DW_OP_piece.
76 proc pieces_test_f6 {} {
77 global csrcfile
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"
82 gdb_test "print a" \
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"
90 }
91 -re " = 7" {
92 pass "print a.i with optimized out piece"
93 }
94 }
95 }
96
97 pieces_test_f1
98 pieces_test_f2
99 pieces_test_f3
100 pieces_test_f6