File: funcreturn.exp

package info (click to toggle)
gdb-doc 16.3-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid, trixie
  • size: 244,264 kB
  • sloc: ansic: 2,134,731; asm: 375,582; exp: 206,875; cpp: 73,639; makefile: 70,232; sh: 26,038; python: 13,697; yacc: 11,341; ada: 7,358; xml: 6,098; perl: 5,077; pascal: 3,389; tcl: 2,986; f90: 2,764; lisp: 1,984; cs: 879; lex: 738; sed: 228; awk: 181; objc: 137; fortran: 57
file content (189 lines) | stat: -rw-r--r-- 6,231 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# Copyright 2021-2024 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

require allow_ctf_tests

if [target_info exists no_long_long] {
    set exec_opts [list debug additional_flags=-DNO_LONG_LONG]
} else {
    set exec_opts [list debug]
}

# Some tests require GCC.
set gcc_compiled [is_c_compiler_gcc]

standard_testfile whatis.c

# Using `-gctf` generates full-fledged CTF debug information.
set opts {}
lappend opts additional_flags=-gctf
lappend opts ldflags=-Wl,--export-dynamic
lappend opts nowarning

if { [build_executable "failed to prepare" ${testfile} \
	  [list $srcfile] $opts] } {
    return 0
}

clean_restart
gdb_test_no_output "set always-read-ctf on"
gdb_load $binfile

# test print command with functions return type
set void "(void|)"
gdb_test "print v_char_func" \
    "$decimal = \{char \\(\\)\} 0x\[0-9a-z\]+ <v_char_func>.*" \
    "print char function"

gdb_test "print v_signed_char_func" \
    "$decimal = \{signed char \\(\\)\} 0x\[0-9a-z\]+ <v_signed_char_func>.*" \
    "print signed char function"

gdb_test "print v_unsigned_char_func" \
    "$decimal = \{unsigned char \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_char_func>.*" \
    "print unsigned char function"

gdb_test "print v_short_func" \
    "$decimal = \{short \\(\\)\} 0x\[0-9a-z\]+ <v_short_func>.*" \
    "print short function"

gdb_test "print v_signed_short_func" \
    "$decimal = \{signed short|short \\(\\)\} 0x\[0-9a-z\]+ <v_signed_short_func>.*" \
    "print signed short function"

gdb_test "print v_unsigned_short_func" \
    "$decimal = \{unsigned short \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_short_func>.*" \
    "print unsigned short function"

gdb_test "print v_int_func" \
    "$decimal = \{int \\(\\)\} 0x\[0-9a-z\]+ <v_int_func>.*" \
    "print int function"

gdb_test "print v_signed_int_func" \
    "$decimal = \{signed int|int \\(\\)\} 0x\[0-9a-z\]+ <v_signed_int_func>.*" \
    "print signed int function"

gdb_test "print v_unsigned_int_func" \
    "$decimal = \{unsigned int \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_int_func>.*" \
    "print unsigned int function"

gdb_test "print v_long_func" \
    "$decimal = \{long \\(\\)\} 0x\[0-9a-z\]+ <v_long_func>.*" \
    "print long function"

gdb_test "print v_signed_long_func" \
    "$decimal = \{signed long|long \\(\\)\} 0x\[0-9a-z\]+ <v_signed_long_func>.*" \
    "print signed long function"

gdb_test "print v_unsigned_long_func" \
    "$decimal = \{unsigned long|long \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_long_func>.*" \
    "print unsigned long function"

if ![target_info exists no_long_long] {
    gdb_test "print v_long_long_func" \
	    "$decimal = \{long long \\(\\)\} 0x\[0-9a-z\]+ <v_long_long_func>.*" \
		"print long long function"

    gdb_test "print v_signed_long_long_func" \
	    "$decimal = \{long long \\(\\)\} 0x\[0-9a-z\]+ <v_signed_long_long_func>.*" \
		"print signed long long function"

    gdb_test "print v_unsigned_long_long_func" \
	    "$decimal = \{unsigned long long \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_long_long_func>.*" \
		"print unsigned long long function"
}

# Sun /bin/cc calls this a function returning double.
if {!$gcc_compiled} {setup_xfail "*-sun-sunos4*"}
gdb_test "print v_float_func" \
    "$decimal = \{float \\(\\)\} 0x\[0-9a-z\]+.*" \
    "print float function"

gdb_test "print v_double_func" \
    "$decimal = \{double \\(\\)\} 0x\[0-9a-z\]+.*" \
    "print double function"

# test whatis command with functions return type
gdb_test "whatis v_char_func" \
    "type = (signed |unsigned |)char \\($void\\)" \
    "whatis char function"

gdb_test "whatis v_signed_char_func" \
    "type = (signed |unsigned |)char \\($void\\)" \
    "whatis signed char function"

gdb_test "whatis v_unsigned_char_func" \
    "type = unsigned char \\($void\\)"	\
    "whatis unsigned char function"

gdb_test "whatis v_short_func" \
    "type = short (int |)\\($void\\)" \
    "whatis short function"

gdb_test "whatis v_signed_short_func" \
    "type = (signed |)short (int |)\\($void\\)" \
    "whatis signed short function"

gdb_test "whatis v_unsigned_short_func" \
    "type = (unsigned short|short unsigned int) \\($void\\)" \
    "whatis unsigned short function"

gdb_test "whatis v_int_func" \
    "type = int \\($void\\)" \
    "whatis int function"

gdb_test "whatis v_signed_int_func" \
    "type = (signed |)int \\($void\\)" \
    "whatis signed int function"

gdb_test "whatis v_unsigned_int_func" \
    "type = unsigned int \\($void\\)" \
    "whatis unsigned int function"

gdb_test "whatis v_long_func" \
    "type = (long|int|long int) \\($void\\)" \
    "whatis long function"

gdb_test "whatis v_signed_long_func" \
    "type = (signed |)(int|long|long int) \\($void\\)" \
    "whatis signed long function"

gdb_test "whatis v_unsigned_long_func" \
    "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
    "whatis unsigned long function"

if ![target_info exists no_long_long] {
    gdb_test "whatis v_long_long_func" \
	"type = long long(| int) \\($void\\)" \
	"whatis long long function"

    gdb_test "whatis v_signed_long_long_func" \
	"type = (signed |)long long(| int) \\($void\\)" \
	"whatis signed long long function"

    gdb_test "whatis v_unsigned_long_long_func" \
	"type = (unsigned long long(| int)|long long unsigned int) \\($void\\)" \
	"whatis unsigned long long function"
}

# Sun /bin/cc calls this a function returning double.
if {!$gcc_compiled} {setup_xfail "*-sun-sunos4*"}
gdb_test "whatis v_float_func" \
    "type = float \\($void\\)" \
    "whatis float function"

gdb_test "whatis v_double_func" \
    "type = double \\($void\\)" \
    "whatis double function"