* dwarf2read.c (dwarf_stack_op_name): Add DW_OP_GNU_encoded_addr,
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / pieces.exp
CommitLineData
0b302171 1# Copyright 2010-2012 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
27set testfile "pieces"
28set srcfile ${testfile}.S
29set csrcfile ${testfile}.c
30set binfile ${objdir}/${subdir}/${testfile}.x
31
32if {[prepare_for_testing ${testfile}.exp ${testfile}.x $srcfile]} {
33 return -1
34}
35
36if ![runto_main] {
37 return -1
38}
39
40# Function f1 tests a particular gdb bug involving DW_OP_piece.
41proc pieces_test_f1 {} {
42 global csrcfile
43 set line [gdb_get_line_number "f1 breakpoint" $csrcfile]
44 gdb_test "break pieces.c:$line" "Breakpoint 2.*" \
45 "set f1 breakpoint for pieces"
46 gdb_continue_to_breakpoint "continue to f1 breakpoint for pieces"
47 gdb_test "print a" " = {i = 4, j = 14}" "print a in pieces:f1"
48 gdb_test "print a.j" " = 14" "print a.j in pieces:f1"
49}
50
74de6778
TT
51# Function f2 tests for a bug when indexing into an array created
52# using DW_OP_piece.
53proc pieces_test_f2 {} {
54 global csrcfile
55 set line [gdb_get_line_number "f2 breakpoint" $csrcfile]
56 gdb_test "break pieces.c:$line" "Breakpoint 3.*" \
57 "set f2 breakpoint for pieces"
58 gdb_continue_to_breakpoint "continue to f2 breakpoint for pieces"
59 gdb_test "print a" " = .4, 14." "print a in pieces:f2"
60 gdb_test "print a\[0\]" " = 4" "print a\[0\] in pieces:f2"
61 gdb_test "print a\[1\]" " = 14" "print a\[1\] in pieces:f2"
62}
63
d3b1e874
TT
64# Function f3 tests DW_OP_bit_piece.
65proc pieces_test_f3 {} {
66 global csrcfile
67 set line [gdb_get_line_number "f3 breakpoint" $csrcfile]
68 gdb_test "break pieces.c:$line" "Breakpoint 4.*" \
69 "set f3 breakpoint for pieces"
70 gdb_continue_to_breakpoint "continue to f3 breakpoint for pieces"
71 gdb_test "print a.i" " = 4" "print a.i in pieces:f3"
72 gdb_test "print a.j" " = 14" "print a.j in pieces:f3"
d3b1e874
TT
73 gdb_test "print a.i = 7" " = 7" "set a.i in pieces:f3"
74 gdb_test "print a.i" " = 7" "print new a.i in pieces:f3"
75}
76
cb826367
TT
77# Function f6 tests for an empty DW_OP_piece.
78proc pieces_test_f6 {} {
79 global csrcfile
80 set line [gdb_get_line_number "f6 breakpoint" $csrcfile]
d3b1e874 81 gdb_test "break pieces.c:$line" "Breakpoint 5.*" \
cb826367
TT
82 "set f6 breakpoint for pieces"
83 gdb_continue_to_breakpoint "continue to f6 breakpoint for pieces"
84 gdb_test "print a" \
585fdaa1 85 " = {i = 7, j = 8, q = .optimized out.}" \
cb826367
TT
86 "print a with optimized out piece"
87 # Note: no warning for this case.
88 gdb_test_multiple "print a.i" \
89 "print a.i with optimized out piece" {
90 -re "warning: some bits in computed object" {
91 fail "print a.i with optimized out piece"
92 }
93 -re " = 7" {
94 pass "print a.i with optimized out piece"
95 }
96 }
97}
98
afd74c5f 99pieces_test_f1
74de6778 100pieces_test_f2
d3b1e874 101pieces_test_f3
cb826367 102pieces_test_f6
This page took 0.301658 seconds and 4 git commands to generate.