Do not run for targets which do not support shared objects.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / structs.exp
CommitLineData
b6ba6518 1# Copyright 1996, 1997, 1999 Free Software Foundation, Inc.
74cf1395
JM
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 2 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, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# This file was written by Jeff Law. (law@cygnus.com)
21
22if $tracelevel then {
23 strace $tracelevel
24}
25
26set prms_id 0
27set bug_id 0
28
29set prototypes 1
30set testfile "structs"
31set srcfile ${testfile}.c
32set binfile ${objdir}/${subdir}/${testfile}
33
34# build the first test case
35if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
36 # built the second test case since we can't use prototypes
37 warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
38if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DNO_PROTOTYPES}] != "" } {
39 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
40 }
41 set prototypes 0
42}
43
44# Create and source the file that provides information about the compiler
45# used to compile the test case.
46if [get_compiler_info ${binfile}] {
47 return -1;
48}
49
9fbfe2dc
AC
50
51# Some targets can't call functions, so don't even bother with this
52# test.
53if [target_info exists gdb,cannot_call_functions] {
54 setup_xfail "*-*-*" 2416
55 fail "This target can not call functions"
74cf1395
JM
56 continue
57}
58
f2e54a80
JB
59
60# Call FUNC with no arguments, and expect to see the regexp RESULT in
61# the output. If we get back the error message "Function return value
62# unknown", call that an unsupported test; on some architectures, it's
63# impossible to find structs returned by value reliably.
64proc call_struct_func { func result } {
65 global gdb_prompt
66
67 set command "p ${func}()"
68 send_gdb "${command}\n"
69 gdb_expect {
70 -re "$result\[\r\n\]+$gdb_prompt $" {
71 pass "$command"
72 }
73 -re "Function return value unknown.\[\r\n\]+$gdb_prompt $" {
74 unsupported "$command"
75 }
76 -re "$gdb_prompt $" {
77 fail "$command"
78 }
79 timeout {
80 fail "$command (timeout)"
81 }
82 }
83}
84
74cf1395
JM
85# FIXME: Before calling this proc, we should probably verify that
86# we can call inferior functions and get a valid integral value
87# returned.
88# Note that it is OK to check for 0 or 1 as the returned values, because C
89# specifies that the numeric value of a relational or logical expression
90# (computed in the inferior) is 1 for true and 0 for false.
91
92proc do_function_calls {} {
93 global prototypes
94 global gcc_compiled
95 global gdb_prompt
96
97 # First, call the "fun" functions and examine the value they return.
f2e54a80
JB
98 call_struct_func "fun1" " = {a = 49 '1'}"
99 call_struct_func "fun2" " = {a = 97 'a', b = 98 'b'}"
100 call_struct_func "fun3" " = {a = 65 'A', b = 66 'B', c = 67 'C'}"
101 call_struct_func "fun4" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4'}"
102 call_struct_func "fun5" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e'}"
103 call_struct_func "fun6" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F'}"
104 call_struct_func "fun7" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7'}"
105 call_struct_func "fun8" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8'}"
106 call_struct_func "fun9" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i'}"
107 call_struct_func "fun10" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J'}"
108 call_struct_func "fun11" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8', i = 57 '9', j = 65 'A', k = 66 'B'}"
109 call_struct_func "fun12" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J', k = 75 'K', l = 76 'L'}"
110 call_struct_func "fun16" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i', j = 106 'j', k = 107 'k', l = 108 'l', m = 109 'm', n = 110 'n', o = 111 'o', p = 112 'p'}"
74cf1395
JM
111
112 # Now call the Fun functions to set the L* variables. This
113 # tests that gdb properly passes structures to functions.
114 gdb_test "p Fun1(foo1)" " = (void|0)"
115 gdb_test "p Fun2(foo2)" " = (void|0)"
116 gdb_test "p Fun3(foo3)" " = (void|0)"
117 gdb_test "p Fun4(foo4)" " = (void|0)"
118 gdb_test "p Fun5(foo5)" " = (void|0)"
119 gdb_test "p Fun6(foo6)" " = (void|0)"
120 gdb_test "p Fun7(foo7)" " = (void|0)"
121 gdb_test "p Fun8(foo8)" " = (void|0)"
122 gdb_test "p Fun9(foo9)" " = (void|0)"
123 gdb_test "p Fun10(foo10)" " = (void|0)"
124 gdb_test "p Fun11(foo11)" " = (void|0)"
125 gdb_test "p Fun12(foo12)" " = (void|0)"
126 gdb_test "p Fun16(foo16)" " = (void|0)"
127
128 # Now print the L* variables and examine their values.
129 gdb_test "p L1" " = {a = 49 '1'}"
130 gdb_test "p L2" " = {a = 97 'a', b = 98 'b'}"
131 gdb_test "p L3" " = {a = 65 'A', b = 66 'B', c = 67 'C'}"
132 gdb_test "p L4" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4'}"
74cf1395 133 gdb_test "p L5" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e'}"
74cf1395 134 gdb_test "p L6" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F'}"
74cf1395
JM
135 gdb_test "p L7" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7'}"
136 gdb_test "p L8" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8'}"
137 gdb_test "p L9" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i'}"
138 gdb_test "p L10" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J'}"
139 gdb_test "p L11" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8', i = 57 '9', j = 65 'A', k = 66 'B'}"
140 gdb_test "p L12" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J', k = 75 'K', l = 76 'L'}"
141 gdb_test "p L16" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i', j = 106 'j', k = 107 'k', l = 108 'l', m = 109 'm', n = 110 'n', o = 111 'o', p = 112 'p'}"
142}
143# Start with a fresh gdb.
144
145gdb_start
146gdb_reinitialize_dir $srcdir/$subdir
147gdb_load ${binfile}
148
a0b3c4fd
JM
149gdb_test "set print sevenbit-strings" ""
150gdb_test "set print address off" ""
151gdb_test "set width 0" ""
74cf1395
JM
152
153if [target_info exists gdb,cannot_call_functions] {
154 setup_xfail "*-*-*" 2416
155 fail "This target can not call functions"
156 return 0
157}
158
159if { ![runto_main] } then {
160 gdb_suppress_tests;
161}
162
163do_function_calls;
164
165gdb_stop_suppressing_tests;
166
167return 0
This page took 0.385089 seconds and 4 git commands to generate.