Re: [RFA] Assuming malloc exists in callfwmall.exp

Michael Elizabeth Chastain
2001-02-14T19:27:00Z

Here's a diff for consideration.

This script tests the following gdb features:

[1] gdb can call functions in the inferior
[2] gdb does not use the inferior's malloc to achieve feature [1].
Thus, [1] works even for inferiors that have no malloc.

callfuncs.exp is incapable of testing [2] because it uses an inferior
program that is guaranteed to contain malloc.

If malloc is present in the inferior, then this script returns UNTESTED,
because it cannot verify [2] using this inferior program. (Well,
it could, with enough work -- for instance, the script could set a
breakpoint on malloc and then FAIL if the breakpoint ever triggers).

If malloc is not present, the script proceeds to test a bunch of things
that we believe should work. It does not test things that we know,
by design, don't work.

Keith, what do you think of this? Does this work for you?

Michael

===

Index: callfwmall.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/callfwmall.exp,v
retrieving revision 1.1.1.3
diff -c -3 -p -r1.1.1.3 callfwmall.exp
*** callfwmall.exp 1999/09/09 00:00:21 1.1.1.3
--- callfwmall.exp 2001/02/15 03:18:14
*************** 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,177 ----
*************** 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'" \
--- 216,221 ----
*************** if { $hp_aCC_compiler } {
*** 274,279 ****
--- 264,296 ----
gdb_suppress_tests;
}
}
+ }
+
+ # The point of this test script is to call a bunch of stuff in the inferior
+ # without using malloc in the inferior. If malloc exists, then this test
+ # is pointless.
+
+ send_gdb "p malloc\n"
+ gdb_expect {
+ -re ".*No symbol \"malloc\".*$gdb_prompt $" {
+ # Cool, this is what I want.
+ pass "probe for malloc in inferior (malloc NOT present)"
+ }
+ -re ".*malloc.*$gdb_prompt $" {
+ untested "probe for malloc in inferior (malloc found, all tests skipped)"
+ remote_close host
+ return -1
+ }
+ -re ".*$gdb_prompt $" {
+ fail "probe for malloc in inferior"
+ remote_close host
+ return -1
+ }
+ timeout {
+ fail "probe for malloc in inferior (timeout)"
+ remote_class host
+ return -1
+ }
}

gdb_test "next" ".*"