1 |
106 |
markom |
# Copyright (C) 1996, 1997 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 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 |
|
|
|
22 |
|
|
if $tracelevel then {
|
23 |
|
|
strace $tracelevel
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
set prms_id 0
|
27 |
|
|
set bug_id 0
|
28 |
|
|
|
29 |
|
|
set prototypes 1
|
30 |
|
|
set testfile "structs"
|
31 |
|
|
set srcfile ${testfile}.c
|
32 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
33 |
|
|
|
34 |
|
|
# build the first test case
|
35 |
|
|
if { [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"
|
38 |
|
|
if { [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.
|
46 |
|
|
if [get_compiler_info ${binfile}] {
|
47 |
|
|
return -1;
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
# The a29k can't call functions, so don't even bother with this test.
|
51 |
|
|
if [istarget "a29k-*-udi"] then {
|
52 |
|
|
setup_xfail "a29k-*-udi" 2416
|
53 |
|
|
fail "a29k-*-udi can not call functions"
|
54 |
|
|
continue
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
# FIXME: Before calling this proc, we should probably verify that
|
58 |
|
|
# we can call inferior functions and get a valid integral value
|
59 |
|
|
# returned.
|
60 |
|
|
# Note that it is OK to check for 0 or 1 as the returned values, because C
|
61 |
|
|
# specifies that the numeric value of a relational or logical expression
|
62 |
|
|
# (computed in the inferior) is 1 for true and 0 for false.
|
63 |
|
|
|
64 |
|
|
proc do_function_calls {} {
|
65 |
|
|
global prototypes
|
66 |
|
|
global gcc_compiled
|
67 |
|
|
global gdb_prompt
|
68 |
|
|
|
69 |
|
|
# First, call the "fun" functions and examine the value they return.
|
70 |
|
|
gdb_test "p fun1()" " = {a = 49 '1'}"
|
71 |
|
|
gdb_test "p fun2()" " = {a = 97 'a', b = 98 'b'}"
|
72 |
|
|
gdb_test "p fun3()" " = {a = 65 'A', b = 66 'B', c = 67 'C'}"
|
73 |
|
|
gdb_test "p fun4()" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4'}"
|
74 |
|
|
gdb_test "p fun5()" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e'}"
|
75 |
|
|
gdb_test "p fun6()" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F'}"
|
76 |
|
|
gdb_test "p fun7()" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7'}"
|
77 |
|
|
gdb_test "p 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'}"
|
78 |
|
|
gdb_test "p 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'}"
|
79 |
|
|
gdb_test "p 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'}"
|
80 |
|
|
gdb_test "p 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'}"
|
81 |
|
|
gdb_test "p 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'}"
|
82 |
|
|
gdb_test "p 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'}"
|
83 |
|
|
|
84 |
|
|
# Now call the Fun functions to set the L* variables. This
|
85 |
|
|
# tests that gdb properly passes structures to functions.
|
86 |
|
|
gdb_test "p Fun1(foo1)" " = (void|0)"
|
87 |
|
|
gdb_test "p Fun2(foo2)" " = (void|0)"
|
88 |
|
|
gdb_test "p Fun3(foo3)" " = (void|0)"
|
89 |
|
|
gdb_test "p Fun4(foo4)" " = (void|0)"
|
90 |
|
|
gdb_test "p Fun5(foo5)" " = (void|0)"
|
91 |
|
|
gdb_test "p Fun6(foo6)" " = (void|0)"
|
92 |
|
|
gdb_test "p Fun7(foo7)" " = (void|0)"
|
93 |
|
|
gdb_test "p Fun8(foo8)" " = (void|0)"
|
94 |
|
|
gdb_test "p Fun9(foo9)" " = (void|0)"
|
95 |
|
|
gdb_test "p Fun10(foo10)" " = (void|0)"
|
96 |
|
|
gdb_test "p Fun11(foo11)" " = (void|0)"
|
97 |
|
|
gdb_test "p Fun12(foo12)" " = (void|0)"
|
98 |
|
|
gdb_test "p Fun16(foo16)" " = (void|0)"
|
99 |
|
|
|
100 |
|
|
# Now print the L* variables and examine their values.
|
101 |
|
|
gdb_test "p L1" " = {a = 49 '1'}"
|
102 |
|
|
gdb_test "p L2" " = {a = 97 'a', b = 98 'b'}"
|
103 |
|
|
gdb_test "p L3" " = {a = 65 'A', b = 66 'B', c = 67 'C'}"
|
104 |
|
|
gdb_test "p L4" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4'}"
|
105 |
|
|
if {$gcc_compiled} then {
|
106 |
|
|
setup_xfail "hppa*-*-*"
|
107 |
|
|
}
|
108 |
|
|
gdb_test "p L5" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e'}"
|
109 |
|
|
if {$gcc_compiled} then {
|
110 |
|
|
setup_xfail "hppa*-*-*"
|
111 |
|
|
}
|
112 |
|
|
gdb_test "p L6" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F'}"
|
113 |
|
|
if {$gcc_compiled} then {
|
114 |
|
|
setup_xfail "hppa*-*-*"
|
115 |
|
|
}
|
116 |
|
|
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'}"
|
117 |
|
|
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'}"
|
118 |
|
|
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'}"
|
119 |
|
|
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'}"
|
120 |
|
|
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'}"
|
121 |
|
|
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'}"
|
122 |
|
|
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'}"
|
123 |
|
|
}
|
124 |
|
|
# Start with a fresh gdb.
|
125 |
|
|
|
126 |
|
|
gdb_start
|
127 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
128 |
|
|
gdb_load ${binfile}
|
129 |
|
|
|
130 |
|
|
gdb_test "set print sevenbit-strings" ""
|
131 |
|
|
gdb_test "set print address off" ""
|
132 |
|
|
gdb_test "set width 0" ""
|
133 |
|
|
|
134 |
|
|
if [target_info exists gdb,cannot_call_functions] {
|
135 |
|
|
setup_xfail "*-*-*" 2416
|
136 |
|
|
fail "This target can not call functions"
|
137 |
|
|
return 0
|
138 |
|
|
}
|
139 |
|
|
|
140 |
|
|
if { ![runto_main] } then {
|
141 |
|
|
gdb_suppress_tests;
|
142 |
|
|
}
|
143 |
|
|
|
144 |
|
|
do_function_calls;
|
145 |
|
|
|
146 |
|
|
gdb_stop_suppressing_tests;
|
147 |
|
|
|
148 |
|
|
return 0
|