Re: [RFA]: Fix gdb.base/callfwmall.exp for platforms without malloc

Michael Snyder
2001-05-21T10:43:00Z

Stephane Carrez wrote:
>
> Hi!
>
> The test gdb.base/callfwmall.exp checks for the GDB ability to
> 'call/print' a function of the inferior. Several print commands
> require the program to have 'malloc' so that GDB allocates a string
> for input parameters. The 'callfwmall.c' file does not have any
> reference to malloc, which means that the final executable may not
> have it. This is my case for HC11. This means that the test fails
> with:
>
> (gdb) FAIL: gdb.base/callfwmall.exp: p t_string_values("string 1","string 2")
> p t_string_values("string 1",string_val2)
> evaluation of this expression requires the program to have a function "malloc".

This is the whole purpose of the callfwmall.c test. The name stands for
"call functions without malloc". It tests whether GDB can call functions
without the presence of malloc, and if it cannot (as in your case),
then the test should fail. Or else be skipped.

> The following patch uses a new 'gdb,nomalloc' configuration variable
> to check whether these 't_string_values' tests can be made or not.
>
> Can you approve this patch?

No -- but perhaps we could approve a patch that would cause this
test to be skipped (or xfailed) for targets in which we know it
cannot pass.

>
> Stephane
>
> 2001-05-20 Stephane Carrez <Stephane.Carrez@worldnet.fr>
>
> * gdb.base/callfwmall.exp (do_function_calls): Check for gdb,nomalloc
> and don't execute the tests that require the program to have malloc.
>
> ----------------------------------------------------------------------------------------------------
> Index: testsuite/gdb.base/callfwmall.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.base/callfwmall.exp,v
> retrieving revision 1.2
> diff -u -p -r1.2 callfwmall.exp
> --- callfwmall.exp 2001/03/06 08:21:50 1.2
> +++ callfwmall.exp 2001/05/20 11:39:27
> @@ -167,18 +167,24 @@ proc do_function_calls {} {
>
> }
>
> - 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"
> -
> + # Calling a function with a string as parameter requires the
> + # program to provide malloc(). The string is allocated in
> + # malloc area (and... by the way never freed!!!).
> + # Don't execute this test on platforms that don't provide malloc.
> + if ![target_info exists gdb,nomalloc] {
> + 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"
> -
> + if ![target_info exists gdb,nomalloc] {
> + 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"
> gdb_test "p t_func_values(func_val2,func_val1)" " = 0"
> @@ -222,10 +228,12 @@ proc do_function_calls {} {
> 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"
> + if ![target_info exists gdb,nomalloc] {
> + 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'" \