]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - 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
CommitLineData
8acc9f48 1# Copyright 2010-2013 Free Software Foundation, Inc.
afd74c5f
TT
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/>.
810cfdbb 15load_lib dwarf.exp
afd74c5f
TT
16# Test some DWARF piece operators.
17
18# This test can only be run on targets which support DWARF-2 and use gas.
810cfdbb 19if {![dwarf2_support]} {
afd74c5f
TT
20 return 0
21}
22# This test can only be run on x86 targets.
6edba76f 23if {![is_x86_like_target]} {
afd74c5f
TT
24 return 0
25}
26
c83ee902 27standard_testfile .S
afd74c5f 28set csrcfile ${testfile}.c
afd74c5f 29
c83ee902 30if {[prepare_for_testing ${testfile}.exp ${testfile} $srcfile]} {
afd74c5f
TT
31 return -1
32}
33
34if ![runto_main] {
35 return -1
36}
37
38# Function f1 tests a particular gdb bug involving DW_OP_piece.
39proc 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
74de6778
TT
49# Function f2 tests for a bug when indexing into an array created
50# using DW_OP_piece.
51proc 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
d3b1e874
TT
62# Function f3 tests DW_OP_bit_piece.
63proc 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"
d3b1e874
TT
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
cb826367
TT
75# Function f6 tests for an empty DW_OP_piece.
76proc pieces_test_f6 {} {
77 global csrcfile
78 set line [gdb_get_line_number "f6 breakpoint" $csrcfile]
d3b1e874 79 gdb_test "break pieces.c:$line" "Breakpoint 5.*" \
cb826367
TT
80 "set f6 breakpoint for pieces"
81 gdb_continue_to_breakpoint "continue to f6 breakpoint for pieces"
82 gdb_test "print a" \
585fdaa1 83 " = {i = 7, j = 8, q = .optimized out.}" \
cb826367
TT
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
afd74c5f 97pieces_test_f1
74de6778 98pieces_test_f2
d3b1e874 99pieces_test_f3
cb826367 100pieces_test_f6