This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] testsuite/gdb.base/callfuncs.*: Add inferior call testcases
- To: "Peter.Schauer" <Peter dot Schauer at regent dot e-technik dot tu-muenchen dot de>
- Subject: Re: [RFA] testsuite/gdb.base/callfuncs.*: Add inferior call testcases
- From: Michael Snyder <msnyder at redhat dot com>
- Date: Wed, 27 Sep 2000 13:54:30 -0700
- CC: Fernando Nasser <fnasser at cygnus dot com>, gdb-patches at sourceware dot cygnus dot com
- Organization: Red Hat, Inc.
- References: <200009231034.MAA01447@reisser.regent.e-technik.tu-muenchen.de>
Peter.Schauer wrote:
>
> > OK, suppose we xfail it for all targets except the ones you've already verified?
> > We still get the other targets tested and it will either show as a XFAIL or a
> > XPASS (if we are that lucky). No FAILs will be added and, with the *known problem*
> > comment added we can check it in as a start point for some improvements on this area.
> >
> > Sounds reasonable?
>
> I beg to differ.
> XFAILs do not show up in the testsuite output and have a tendency to be
> `forgotten' (e.g. many of the XFAILs in virtfunc.exp are real regressions from
> gdb-4.17, making C++ debugging somewhat impossible on larger C++ projects, and
> have not been fixed for nearly two years).
>
> The new testcases uncovered a serious bug on Linux x86 (calling an inferior
> function which used the FPU clobbered the FPU state of the current process),
> and a problem with the target Orjan Friberg is working on (which is now solved,
> due to the new testcases).
>
> Any problems that show up on other targets might be serious, and should be
> clearly visible. If the problem can't be fixed immediately (or if the target
> maintainer is lazy), we still have the option to xfail it for specific
> targets.
I will remark that now that I've reviewed them, I like your
new tests very much. I would like to see them run on all targets,
and if they fail, I would like to see the target fixed. I think
if these fail it means they have uncovered a serious bug.
Michael Snyder
>
> > P.S.: I believe there is still one maintainer that have not answered regarding to one
> > of the bug fixes in your patch. You should wait to check at least these fixes n with
> > it. Maybe ping the maintainer directly in case he missed the posting thinking t was
> > only a testsuite patch and not related to the specific target.
>
> Even if you accept the callfuncs.* changes below, I will not check them in,
> until the bug fixes (I have sent in a proper RFA for them by now) are accepted
> or properly reworked.
>
> * 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