This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] testsuite/gdb.base/callfuncs.*: Add inferior call testcases


> > > OK, we can try them.  But if they add FAILures everywhere and it is not possible for
> > > us to fix those in a reasonable amount of time we xfail them, agreed?
> > 
> > If it has to be, yes.
> > 
> 
> Maybe it never even gets to that.  

Committed.

> 	* gdb.base/callfuncs.c (main):  Moved to end of file, call
> 	t_double_values to initialize the FPU before inferior calls are made.
> 	* gdb.base/callfuncs.exp:  Test for register preservation after calling
> 	inferior functions.  Add tests for continuining, finishing and
> 	returning from a stop in a call dummy.
> 
> *** ./testsuite/gdb.base/callfuncs.c.orig	Mon Jun 28 18:02:51 1999
> --- ./testsuite/gdb.base/callfuncs.c	Fri Sep 15 21:36:51 2000
> ***************
> *** 172,192 ****
>       (i5 == 5) && (i6 == 6) && (i7 == 7) && (i8 == 8) && (i9 == 9);
>   }
>   
> - 
> - /* Gotta have a main to be able to generate a linked, runnable
> -    executable, and also provide a useful place to set a breakpoint. */
> - extern void * malloc() ;
> - int main ()
> - {
> - #ifdef usestubs
> -   set_debug_traps();
> -   breakpoint();
> - #endif
> -   malloc(1);
> -   t_structs_c(struct_val1);
> -   return 0 ;
> - }
> - 
>   /* Functions that expect specific values to be passed and return 
>      either 0 or 1, depending upon whether the values were
>      passed incorrectly or correctly, respectively. */
> --- 172,177 ----
> ***************
> *** 356,359 ****
> --- 341,360 ----
>   #endif
>   {
>     return ((*func_arg1)(a, b));
> + }
> + 
> + 
> + /* Gotta have a main to be able to generate a linked, runnable
> +    executable, and also provide a useful place to set a breakpoint. */
> + extern void * malloc() ;
> + int main ()
> + {
> + #ifdef usestubs
> +   set_debug_traps();
> +   breakpoint();
> + #endif
> +   malloc(1);
> +   t_double_values(double_val1, double_val2);
> +   t_structs_c(struct_val1);
> +   return 0 ;
>   }
> *** ./testsuite/gdb.base/callfuncs.exp.orig	Thu Jan  6 04:06:51 2000
> --- ./testsuite/gdb.base/callfuncs.exp	Thu Sep 21 20:45:49 2000
> ***************
> *** 237,242 ****
> --- 237,260 ----
>       	"call inferior func with struct - returns char *"
>   }
>   
> + # Procedure to get current content of all registers.
> + global all_registers_content
> + set all_registers_content ""
> + proc do_get_all_registers { } {
> +     global gdb_prompt
> +     global expect_out
> +     global all_registers_content
> + 
> +     set all_registers_content ""
> +     send_gdb "info all-registers\n"
> +     gdb_expect {
> + 	-re "info all-registers\r\n(.*)$gdb_prompt $" {
> + 	    set all_registers_content $expect_out(1,string)
> + 	}
> + 	default {}
> +     }
> + }
> + 
>   # Start with a fresh gdb.
>   
>   gdb_exit
> ***************
> *** 271,277 ****
> --- 289,368 ----
>       }
>   }
>   
> + # Make sure that malloc gets called and that the floating point unit
> + # is initialized via a call to t_double_values.
> + gdb_test "next" "t_double_values\\(double_val1, double_val2\\);.*"
>   gdb_test "next" "t_structs_c\\(struct_val1\\);.*"
> + 
> + # Save all register contents.
> + do_get_all_registers
> + set old_reg_content $all_registers_content
> + 
> + # Perform function calls.
>   do_function_calls
>   
> + # Check if all registers still have the same value.
> + do_get_all_registers
> + set new_reg_content $all_registers_content
> + if ![string compare $old_reg_content $new_reg_content] then {
> +     pass "gdb function calls preserve register contents"
> + } else {
> +     set old_reg_content $all_registers_content
> +     fail "gdb function calls preserve register contents"
> + }
> + 
> + # Set breakpoint at a function we will call from gdb.
> + gdb_breakpoint add
> + 
> + # Call function (causing a breakpoint hit in the call dummy) and do a continue,
> + # make sure we are back at main and still have the same register contents.
> + gdb_test "print add(4,5)" "The program being debugged stopped while.*" ""
> + gdb_test "continue" "Continuing.*" "continue from call dummy breakpoint"
> + if ![gdb_test "bt 2" \
> + 	      "#0  main.*" \
> + 	      "bt after continuing from call dummy breakpoint"] then {
> +     do_get_all_registers
> +     set new_reg_content $all_registers_content
> +     if ![string compare $old_reg_content $new_reg_content] then {
> + 	pass "continue after stop in call dummy preserves register contents"
> +     } else {
> + 	fail "continue after stop in call dummy preserves register contents"
> +     }
> + }
> + 
> + # Call function (causing a breakpoint hit in the call dummy) and do a finish,
> + # make sure we are back at main and still have the same register contents.
> + gdb_test "print add(4,5)" "The program being debugged stopped while.*" ""
> + gdb_test "finish" \
> + 	 "Value returned is.* = 9" \
> + 	 "finish from call dummy breakpoint returns correct value"
> + if ![gdb_test "bt 2" \
> + 	      "#0  main.*" \
> + 	      "bt after finishing from call dummy breakpoint"] then {
> +     do_get_all_registers
> +     set new_reg_content $all_registers_content
> +     if ![string compare $old_reg_content $new_reg_content] then {
> + 	pass "finish after stop in call dummy preserves register contents"
> +     } else {
> + 	fail "finish after stop in call dummy preserves register contents"
> +     }
> + }
> + 
> + # Call function (causing a breakpoint hit in the call dummy) and do a return
> + # with a value, make sure we are back at main with the same register contents.
> + gdb_test "print add(4,5)" "The program being debugged stopped while.*" ""
> + if ![gdb_test "return 7" \
> + 	      "#0  main.*" \
> + 	      "back at main after return from call dummy breakpoint" \
> + 	      "Make add return now. .y or n.*" \
> + 	      "y"] then {
> +     do_get_all_registers
> +     set new_reg_content $all_registers_content
> +     if ![string compare $old_reg_content $new_reg_content] then {
> + 	pass "return after stop in call dummy preserves register contents"
> +     } else {
> + 	fail "return after stop in call dummy preserves register contents"
> +     }
> + }
> + 
>   return 0

-- 
Peter Schauer			pes@regent.e-technik.tu-muenchen.de

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]