This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
[RFA] Assuming malloc exists in callfwmall.exp
- To: gdb at sources dot redhat dot com
- Subject: [RFA] Assuming malloc exists in callfwmall.exp
- From: Keith Seitz <keiths at cygnus dot com>
- Date: Tue, 13 Feb 2001 17:11:36 -0800 (PST)
Hi,
The problem: When doing an inferior function call with a
struct/array/string argument (aka 'print foo({2,1})' or 'print
foo("bar")', gdb requires "malloc" in the executable... This leads to
some trivial testsuite failures.
2001-02-13 Keith Seitz <kseitz@nwlink.com>
* gdb.base/callfwmall.exp: Check for the existence of
malloc.
(do_function_calls): Do not do an inferior function
call which requires malloc if malloc doesn't exist.
Patch:
Index: testsuite/gdb.base/callfwmall.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/callfwmall.exp,v
retrieving revision 1.1.1.3
diff -p -r1.1.1.3 callfwmall.exp
*** testsuite/gdb.base/callfwmall.exp 1999/09/09 00:00:21 1.1.1.3
--- testsuite/gdb.base/callfwmall.exp 2001/02/14 01:11:52
*************** proc set_lang_c {} {
*** 99,105 ****
proc do_function_calls {} {
global prototypes
global gcc_compiled
! global gdb_prompt
# We need to up this because this can be really slow on some boards.
set timeout 60;
--- 99,105 ----
proc do_function_calls {} {
global prototypes
global gcc_compiled
! global gdb_prompt have_malloc_p
# We need to up this because this can be really slow on some boards.
set timeout 60;
*************** proc do_function_calls {} {
*** 169,183 ****
gdb_test "p t_string_values(string_val2,string_val1)" " = 0"
gdb_test "p t_string_values(string_val1,string_val2)" " = 1"
! gdb_test "p t_string_values(\"string 1\",\"string 2\")" " = 1"
! gdb_test "p t_string_values(\"string 1\",string_val2)" " = 1"
! gdb_test "p t_string_values(string_val1,\"string 2\")" " = 1"
gdb_test "p t_char_array_values(char_array_val2,char_array_val1)" " = 0"
gdb_test "p t_char_array_values(char_array_val1,char_array_val2)" " = 1"
! gdb_test "p t_char_array_values(\"carray 1\",\"carray 2\")" " = 1"
! gdb_test "p t_char_array_values(\"carray 1\",char_array_val2)" " = 1"
! gdb_test "p t_char_array_values(char_array_val1,\"carray 2\")" " = 1"
gdb_test "p doubleit(4)" " = 8"
gdb_test "p add(4,5)" " = 9"
--- 169,187 ----
gdb_test "p t_string_values(string_val2,string_val1)" " = 0"
gdb_test "p t_string_values(string_val1,string_val2)" " = 1"
! if {$have_malloc_p} {
! gdb_test "p t_string_values(\"string 1\",\"string 2\")" " = 1"
! gdb_test "p t_string_values(\"string 1\",string_val2)" " = 1"
! gdb_test "p t_string_values(string_val1,\"string 2\")" " = 1"
! }
gdb_test "p t_char_array_values(char_array_val2,char_array_val1)" " = 0"
gdb_test "p t_char_array_values(char_array_val1,char_array_val2)" " = 1"
! if {$have_malloc_p} {
! gdb_test "p t_char_array_values(\"carray 1\",\"carray 2\")" " = 1"
! gdb_test "p t_char_array_values(\"carray 1\",char_array_val2)" " = 1"
! gdb_test "p t_char_array_values(char_array_val1,\"carray 2\")" " = 1"
! }
gdb_test "p doubleit(4)" " = 8"
gdb_test "p add(4,5)" " = 9"
*************** proc do_function_calls {} {
*** 222,231 ****
gdb_test "p t_enum_value2(enum_val2)" " = 1"
gdb_test "p t_enum_value2(enum_val1)" " = 0"
! gdb_test "p sum_args(1,{2})" " = 2"
! gdb_test "p sum_args(2,{2,3})" " = 5"
! gdb_test "p sum_args(3,{2,3,4})" " = 9"
! gdb_test "p sum_args(4,{2,3,4,5})" " = 14"
gdb_test "p sum10 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)" " = 55"
gdb_test "p t_structs_c(struct_val1)" "= 120 'x'" \
--- 226,237 ----
gdb_test "p t_enum_value2(enum_val2)" " = 1"
gdb_test "p t_enum_value2(enum_val1)" " = 0"
! if {$have_malloc_p} {
! gdb_test "p sum_args(1,{2})" " = 2"
! gdb_test "p sum_args(2,{2,3})" " = 5"
! gdb_test "p sum_args(3,{2,3,4})" " = 9"
! gdb_test "p sum_args(4,{2,3,4,5})" " = 14"
! }
gdb_test "p sum10 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)" " = 55"
gdb_test "p t_structs_c(struct_val1)" "= 120 'x'" \
*************** gdb_load ${binfile}
*** 255,260 ****
--- 261,273 ----
gdb_test "set print sevenbit-strings" ""
gdb_test "set print address off" ""
gdb_test "set width 0" ""
+
+ # Note whether malloc exists
+ set have_malloc_p 1
+ send_gdb "p malloc\n"
+ gdb_expect {
+ "No symbol \"malloc\"" { set have_malloc_p 0 }
+ }
if { $hp_aCC_compiler } {
# Do not set language explicitly to 'C'. This will cause aCC