This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[Patch ping]: testcase to verify common commands work ok with fortrancode
- From: Wu Zhou <woodzltc at cn dot ibm dot com>
- To: gdb-patches at sources dot redhat dot com
- Cc: drow at false dot org
- Date: Mon, 14 Nov 2005 11:53:53 +0800 (CST)
- Subject: [Patch ping]: testcase to verify common commands work ok with fortrancode
- References: <Pine.LNX.4.63.0511091422040.21980@linux.site>
Hello maintainers,
Any idea on this patch? Is it worthwhile to add this into the testsuite?
I believe that it is good for these Fortran developers, which is still a
big group. Or any suggestion for improvemnet?
If possible, I am very happy to see that it is in the incoming 6.4
release.
Regards
- Wu Zhou
P.S: Here is the link to the original link:
http://sources.redhat.com/ml/gdb-patches/2005-11/msg00099.html
On Wed, 9 Nov 2005, Wu Zhou wrote:
> Hello maintainers,
>
> As we all know, there are not too many compilable tests against Fortran
> language. Thus it is hard for us to say how good the latest GDB works
> with Fortran code. I coded a new testcase to verify that the commonly-used
> commands (such as breakpoint operation, source displaying, stack examining,
> data examining etc) work well with Fortran code, mainly for g77 and gfortran
> code at this time.
>
> Here goes the patch. I had tested it on FC4 against both g77 and
> gfortran. Both reported 30 PASS and 1 XFAIL (for PR/822). Any comments
> and advices are highly appreciated.
>
> 2005-11-09 Wu Zhou <woodzltc@cn.ibm.com>
>
> * fbase.exp: New testcase.
> * fmain.f: The main source for fbase.exp.
> * fsub.f: The secondary source for fbase.exp
>
> Index: gdb.fortran/fmain.f
> ===================================================================
> RCS file: gdb.fortran/fmain.f
> diff -N gdb.fortran/fmain.f
> *** /dev/null 1 Jan 1970 00:00:00 -0000
> --- gdb.fortran/fmain.f 9 Nov 2005 06:06:57 -0000
> ***************
> *** 0 ****
> --- 1,29 ----
> + c Copyright 2005 Free Software Foundation, Inc.
> +
> + c This program is free software; you can redistribute it and/or modify
> + c it under the terms of the GNU General Public License as published by
> + c the Free Software Foundation; either version 2 of the License, or
> + c (at your option) any later version.
> + c
> + c This program is distributed in the hope that it will be useful,
> + c but WITHOUT ANY WARRANTY; without even the implied warranty of
> + c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + c GNU General Public License for more details.
> + c
> + c You should have received a copy of the GNU General Public License
> + c along with this program; if not, write to the Free Software
> + c Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
> +
> + c Start of the main code
> +
> + PROGRAM fbase
> + dimension a(10)
> +
> + write(*,*) 'Test begin.'
> + call sub(a,10)
> + write(*,*) a
> +
> + stop
> +
> + END PROGRAM fbase
> +
> Index: gdb.fortran/fsub.f
> ===================================================================
> RCS file: gdb.fortran/fsub.f
> diff -N gdb.fortran/fsub.f
> *** /dev/null 1 Jan 1970 00:00:00 -0000
> --- gdb.fortran/fsub.f 9 Nov 2005 06:06:57 -0000
> ***************
> *** 0 ****
> --- 1,33 ----
> + c Copyright 2005 Free Software Foundation, Inc.
> +
> + c This program is free software; you can redistribute it and/or modify
> + c it under the terms of the GNU General Public License as published by
> + c the Free Software Foundation; either version 2 of the License, or
> + c (at your option) any later version.
> + c
> + c This program is distributed in the hope that it will be useful,
> + c but WITHOUT ANY WARRANTY; without even the implied warranty of
> + c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + c GNU General Public License for more details.
> + c
> + c You should have received a copy of the GNU General Public License
> + c along with this program; if not, write to the Free Software
> + c Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
> +
> + c Start of the sub code
> +
> + subroutine sub(a,n)
> + dimension a(n)
> + do i = 1, n
> + a(i) = sqr(i)
> + end do
> + return
> + end subroutine
> +
> + function sqr(m)
> + integer tmp1, tmp2
> + DATA tmp1/0/, tmp2/0/
> + tmp1 = m
> + tmp2 = m * m
> + sqr = tmp2
> + end function
> Index: gdb.fortran/fbase.exp
> ===================================================================
> RCS file: gdb.fortran/fbase.exp
> diff -N gdb.fortran/fbase.exp
> *** /dev/null 1 Jan 1970 00:00:00 -0000
> --- gdb.fortran/fbase.exp 9 Nov 2005 06:06:57 -0000
> ***************
> *** 0 ****
> --- 1,233 ----
> + # Copyright 2005 Free Software Foundation, Inc.
> +
> + # This program is free software; you can redistribute it and/or modify
> + # it under the terms of the GNU General Public License as published by
> + # the Free Software Foundation; either version 2 of the License, or
> + # (at your option) any later version.
> + #
> + # This program is distributed in the hope that it will be useful,
> + # but WITHOUT ANY WARRANTY; without even the implied warranty of
> + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + # GNU General Public License for more details.
> + #
> + # You should have received a copy of the GNU General Public License
> + # along with this program; if not, write to the Free Software
> + # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
> +
> + # This file was written by Wu Zhou. (woodzltc@cn.ibm.com)
> +
> + # This file is part of the gdb testsuite. It contains test for verifying
> + # that the basic commands of GDB work well with fortran code (mainly with
> + # g77 and gfortran as compiler at this time)
> +
> + if $tracelevel then {
> + strace $tracelevel
> + }
> +
> + set testfile "fbase"
> + set main "fmain"
> + set sub "fsub"
> + set mainobj ${objdir}/${subdir}/${main}.o
> + set subobj ${objdir}/${subdir}/${sub}.o
> + set binfile ${objdir}/${subdir}/${testfile}
> +
> + if { [gdb_compile "${srcdir}/${subdir}/${main}.f" ${mainobj} object {debug f77 quiet}] != "" } {
> + untested "Couldn't compile ${mainfile}"
> + return -1
> + }
> +
> + if { [gdb_compile "${srcdir}/${subdir}/${sub}.f" ${subobj} object {debug f77 quiet}] != "" } {
> + untested "Couldn't compile ${mainfile}"
> + return -1
> + }
> +
> + if { [gdb_compile "${mainobj} ${subobj}" ${binfile} executable {debug f77 quiet}] != "" } {
> + untested "Couldn't compile ${mainfile}"
> + return -1
> + }
> +
> + gdb_exit
> + gdb_start
> + gdb_reinitialize_dir $srcdir/$subdir
> + gdb_load ${binfile}
> +
> + # To test "show language"
> +
> + gdb_test_multiple "show language" "show language" {
> + -re "The current source language is.*currently fortran.*$gdb_prompt $" {
> + xpass "show language just after the loading of the code"
> + }
> + -re "The current source language is.*currently c.*$gdb_prompt $" {
> + xfail "show language just after the loading of the code"
> + }
> + }
> +
> + # To test listsize setting and showing
> +
> + gdb_test "set listsize 1" "" "set listsize 1"
> + gdb_test "show listsize" "Number of source lines gdb will list by default is 1.*" "listsize is correctly set to 1"
> +
> + # To test different kinds of source listing commands
> +
> + gdb_test_multiple "list" "list" {
> + -re ".*c Copyright 2005 Free Software Foundation, Inc.*$gdb_prompt $" {
> + pass "list just after the loading of the code"
> + }
> + -re ".*No such file or directory.*$gdb_prompt $" {
> + # PR/822
> + xfail "list just after the loading of the code"
> + }
> + -re ".*$gdb_prompt $" {
> + fail "list just after the loading of the code"
> + }
> + }
> +
> + set main_start [gdb_get_line_number "Start of the main code" "${main}.f"]
> + set sub_start [gdb_get_line_number "Start of the sub code" "${sub}.f"]
> +
> + gdb_test "list fmain.f:$main_start" "c Start of the main code.*"
> + gdb_test "list fsub.f:$sub_start" "c Start of the sub code"
> + gdb_test "list fsub.f:sub_" ".*subroutine sub\\(a,n\\).*" "list fsub.f:sub_"
> + gdb_test "list sub_" ".*subroutine sub\\(a,n\\).*" "list sub_"
> + gdb_test "list sqr_" ".*function sqr\\(m\\)" "list sqr_"
> +
> + if ![runto MAIN__] then {
> + perror "couldn't run to breakpoint MAIN__"
> + continue
> + }
> +
> + # To test "show language" again
> +
> + gdb_test_multiple "show language" "show language" {
> + -re "The current source language is.*currently fortran.*$gdb_prompt $" {
> + pass "show language after the starting of the code"
> + }
> + -re ".*$gdb_prompt $" {
> + fail "show language after the starting of the code"
> + }
> + }
> +
> + # To test basic stepping commands, including next, step, finish and continue
> +
> + gdb_test "next" \
> + ".*call sub\\(a\\,10\\).*" \
> + "test 'next'"
> + gdb_test "step" \
> + "sub_ \\(a=.*\\, n=.*\\) at.*fsub\\.f.*\[0-9\]+.*do i = 1, n.*" \
> + "test 'step' into subroutine"
> + gdb_test "finish" \
> + "Run till exit from \\#0 sub_ \\(a=.*, n=.*\\) at.*fsub\\.f.*in MAIN__.*at.*fmain\\.f.*" \
> + "test 'finish'"
> + gdb_test "continue" \
> + ".*Program exited normally.*" \
> + "test 'continue'"
> +
> + # To test breakpoint operations, such as breakpoints displaying,
> + # setting (different methods), hit testing, deleting and so on
> +
> + gdb_test "info break" \
> + "Num Type\[ \]+Disp Enb Address\[ \]+What.*
> + \[0-9\]+\[\t \]+breakpoint keep y.* in MAIN__ at .*${srcdir}/${subdir}/${main}.f.*" \
> + "test 'info break'"
> +
> + # Delete old breakpoints and set new one at sqr and restart the code
> + send_gdb "delete breakpoints\n"
> + gdb_expect {
> + -re "Delete all breakpoints.*$" {
> + send_gdb "y\n"
> + gdb_expect {
> + -re "$gdb_prompt $" {
> + pass "Delete all breakpoints"
> + }
> + timeout { fail "Delete all breakpoints(timeout)" }
> + }
> + }
> + -re ".*$gdb_prompt $" { fail "Delete all breakpoints" }
> + timeout { fail "Delete all breakpoints(timeout)" }
> + }
> + gdb_test "break sqr_" \
> + "Breakpoint 2 at.*file ${srcdir}/${subdir}/${sub}.f.*" \
> + "test 'break function_name'"
> + gdb_test "info break" \
> + "Num Type\[ \]+Disp Enb Address\[ \]+What.*
> + \[0-9\]+\[\t \]+breakpoint keep y.* in sqr_ at .*${srcdir}/${subdir}/${sub}.f.*" \
> + "test 'info break'"
> + gdb_test "run" \
> + "Starting program:.*$testfile.*
> + Breakpoint.*sqr_ \\(m=.*\\) at .*${srcdir}/${subdir}/${sub}.f.*
> + \[0-9]+.*tmp1 = m" \
> + "Program restarted and breakpoint sqr_ is hitted"
> +
> + set bp_location [gdb_get_line_number "return" "${sub}.f"]
> + gdb_test "break $bp_location" \
> + "Breakpoint 3 at.*file ${srcdir}/${subdir}/${sub}.f, line $bp_location.*" \
> + "test 'break line_number'"
> + gdb_test "info break" \
> + "Num Type\[ \]+Disp Enb Address\[ \]+What.*
> + \[0-9\]+\[\t \]+breakpoint keep y.* in sqr_ at .*${srcdir}/${subdir}/${sub}.f.*
> + \[0-9\]+\[\t \]+breakpoint keep y.* in sub_ at .*${srcdir}/${subdir}/${sub}.f\:$bp_location.*" \
> + "test 'info break'"
> +
> + # To test stack operations, including backtrace, info frame
> + # frame movement, info locals, info args and so on
> +
> + gdb_test "backtrace" \
> + "\\#0 sqr_ \\(m=.*\\) at .*${srcdir}/${subdir}/${sub}.f.*
> + \\#1 0x.* in sub_ \\(a=.*\\, n=.*\\) at .*${srcdir}/${subdir}/${sub}.f.*
> + \\#2 0x.* in MAIN__ \\(\\) at ${srcdir}/${subdir}/${main}.f.*" \
> + "test 'backtrace'"
> + gdb_test "info frame" \
> + "Stack level 0, frame at 0x.*
> + eip = 0x.* in sqr_.*\\; saved eip 0x.*
> + called by frame at 0x.*
> + source language fortran.*
> + Arglist at 0x.*, args: m=.*
> + Locals at 0x.*, Previous frame's sp is 0x.*
> + Saved registers.*
> + ebp at 0x.*, eip at 0x.*" \
> + "test 'info frame'"
> +
> + gdb_test_multiple "info args" "info args" {
> + -re "m = \\(PTR TO -> \\( integer \\)\\) 0x.*$gdb_prompt $" {
> + pass "test 'info args' (g77 style)"
> + }
> + -re "m = \\(REF TO -> \\( int4 \\)\\) \\@0x.*$gdb_prompt $" {
> + pass "test 'info args' (gfortran style)"
> + }
> + -re ".*$gdb_prompt $" {
> + fail "test 'info args'"
> + }
> + }
> + gdb_test_multiple "info locals" "info locals" {
> + -re ".*tmp1 = 0.*tmp2 = 0.*$gdb_prompt $" {
> + pass "test 'info locals' (g77 style)"
> + }
> + -re ".*tmp2 = 0.*tmp1 = 0.*$gdb_prompt $" {
> + pass "test 'info locals' (gfortran style)"
> + }
> + -re ".*$gdb_prompt $" {
> + fail "test 'info locals'"
> + }
> + }
> +
> + gdb_test "up 2" \
> + "#2 0x.*in MAIN__ \\(\\) at ${srcdir}/${subdir}/${main}.f.*
> + \[0-9\]+.*call sub\\(a,10\\).*" \
> + "test 'up 2'"
> + gdb_test "down" \
> + "#1 0x.* in sub_ \\(a=.*\\, n=.*\\) at ${srcdir}/${subdir}/${sub}.f.*
> + \[0-9\]+.*a\\(i\\) = sqr\\(i\\).*" \
> + "test 'down'"
> + gdb_test "frame 0" \
> + "#0 sqr_ \\(m=.*\\) at .*${srcdir}/${subdir}/${sub}.f.*
> + \[0-9\]+.*tmp1 = m.*" \
> + "test 'frame #number'"
> +
> + # To test data examining
> +
> + gdb_test "advance +2" \
> + "sqr_ \\(m=.*\\) at .*${srcdir}/${subdir}/${sub}.f.*
> + \[0-9\]+.*sqr = tmp2.*" \
> + "advanced to the end of sqr"
> + gdb_test "print tmp1" "\\$\[0-9\] = 1.*" "print tmp1"
> + gdb_test "print tmp2" "\\$\[0-9\] = 1.*" "print tmp2"
>
> Regards
> - Wu Zhou
>
>