Proposed patches to g77

Toon Moene toon@moene.indiv.nluug.nl
Mon Jul 17 12:32:00 GMT 2000


Andy, could you look into these patches and see if they:

1. Are an update to your solution to the COMMON block debug information.

2. Might solve the remaining EQUIVALENCE debug problem.

Thanks in advance,

.... 3. Anyone who knows enough about STABs to be able to see if the
        update below - to dbxout.c - is correct ?

G. Helffrich wrote:
> 
> Dear Maintainers -
> 
>       Two proposed patches follow that fix deficiencies in the Fortran compiler.
> A sample program that illustrates both of the problems also follows.  They
> pertain to this version of the compilation suite:
> 
> g77 version 2.95.2 19991024 (release) (from FSF-g77 version 0.5.25 19991024 (release))
> GNU F77 version 2.95.2 19991024 (release) (i586-pc-linux-gnulibc1) compiled by GNU C version 2.95.2 19991024 (release).
> GNU Fortran Front End version 0.5.25 19991024 (release)
> 
> I initially developed and tested these patches for the egcs-1.1.2 release of
> g77.  They also work with gcc 2.95.2, which appears to behave similarly to
> egcs-1.1.2 in these areas.
> 
> Patch one fixes two problems:
> 
> 1.  Enabling code to emit stabs debugging information for EQUIVALENCE and
>     COMMON variables works, but only emits debugging info for COMMON
>     in the program block where the COMMON is first encountered.  The patch
>     causes debugging info to be emitted in all program blocks where the
>     COMMON symbols get used.
> 
>     The symbol information emitted in stabs works fine with gdb-4.16.
> 
> 2.  Using EQUIVALENCE variables causes f771 to drop core under -g -O and -g -O2
>     on account of the equivalenced variables being assigned to registers.
>     The patch fixes this by forcing the variables to storage by making them
>     addressable.
> 
> Patch two fixes a problem with debugging information for Fortran COMPLEX
> variables.  This problem emerges under -fno-emulate-complex.  The length
> information of the complex variable only includes the length of the base type
> rather than the length of the pair of values.
> 
> Test program and patches follow.
> 
>                                         George Helffrich
>                                         (george@geology.bristol.ac.uk)
> 
> ------Test program
> C     Test program for debugger.  Compile with -g, and -g -O and -g -O2.
>       complex c(5), cc
>       real y(5)
>       common x,y,z
> 
>       character ec(4)*1
>       integer*2 eh(2)
>       integer ew
>       equivalence (ec,eh,ew)
> 
>       character name*256
> 
>       eh(1) = 1
>       eh(2) = 1
>       write(*,*) 'ew (word equivalence) is ',ew,
>      &   ', and value should be ',2**16+1
> 
>       x = 1.0
>       z = 3.0
>       do 10 i=1,5
>          c(i) = cmplx(float(i),5.-i)
>          y(i) = float(i)
> 10    continue
>       cc = (0.,1.)
>       name = 'Funny '' and something rather long$'
>       call subr(name)
>       write(*,*) 'Done!'
>       end
>       subroutine subr(str)
>       character str*(*)
>       common z,x,y
>       common /csubr/ a,b
>       real x(5)
> 
>       write(*,*) 'string length is ',index(str,'$'),' max is ',len(str)
>       write(*,*) 'string value: ',str(1:index(str,'$')-1)
>       write(*,*) 'Common block value is ',y
>       a = 1.0
>       b = 2.0
>       call subcom(x,5)
>       end
>       subroutine subcom(v,n)
>       real v(n)
>       common /csubr/ a,b
>       write(*,*) 'In subcom, a and b are:',a,b
>       write(*,*) 'In subcom, n and v are:',n,v
>       end
> 
> ------Patch 1
> *** gcc/f/com.c.orig    Thu Oct  8 07:34:34 1998
> --- gcc/f/com.c Thu Jul 13 16:05:30 2000
> ***************
> *** 9221,9232 ****
> 
>     /* If we already have declared this common block for a previous program
>        unit, and either we already initialized it or we don't have new
> !      initialization for it, just return what we have without changing it.  */
> 
>     if ((cbt != NULL_TREE)
>         && (!is_init
> !         || !DECL_EXTERNAL (cbt)))
> !     return;
> 
>     /* Process inits.  */
> 
> --- 9221,9236 ----
> 
>     /* If we already have declared this common block for a previous program
>        unit, and either we already initialized it or we don't have new
> !      initialization for it, just return what we have without changing it.
> !      However, make sure that pointer to common block is set up for
> !      debug symbol emission later in ffecom_member_phase2_ . */
> 
>     if ((cbt != NULL_TREE)
>         && (!is_init
> !         || !DECL_EXTERNAL (cbt))) {
> !       if (!ffestorag_hook (st)) ffestorag_set_hook (st, cbt);
> !       return;
> !   }
> 
>     /* Process inits.  */
> 
> *** gcc/f/com.c.orig    Thu Oct  8 07:34:34 1998
> --- gcc/f/com.c Thu Jul 13 16:05:30 2000
> ***************
> *** 9447,9452 ****
> --- 9451,9457 ----
>     else
>       TREE_STATIC (eqt) = 0;
>     TREE_PUBLIC (eqt) = 0;
> +   TREE_ADDRESSABLE (eqt) = 1;  /* Ensure non-register allocation */
>     DECL_CONTEXT (eqt) = current_function_decl;
>     if (init)
>       DECL_INITIAL (eqt) = error_mark_node;
> *** gcc/f/Makefile.in.orig      Wed Dec 16 21:16:32 1998
> --- gcc/f/Makefile.in   Sat Jul 15 18:16:29 2000
> ***************
> *** 44,51 ****
>   # BOOT_CFLAGS is the value of CFLAGS to pass
>   # to the stage2 and stage3 compilations
>   # XCFLAGS is used for most compilations but not when using the GCC just built.
> ! XCFLAGS =
> ! CFLAGS = -g
>   BOOT_CFLAGS = -O $(CFLAGS)
>   # These exists to be overridden by the x-* and t-* files, respectively.
>   X_CFLAGS =
> --- 44,51 ----
>   # BOOT_CFLAGS is the value of CFLAGS to pass
>   # to the stage2 and stage3 compilations
>   # XCFLAGS is used for most compilations but not when using the GCC just built.
> ! XCFLAGS = -DSOMEONE_GETS_DEBUG_SUPPORT_WORKING
> ! CFLAGS = -g -DSOMEONE_GETS_DEBUG_SUPPORT_WORKING
>   BOOT_CFLAGS = -O $(CFLAGS)
>   # These exists to be overridden by the x-* and t-* files, respectively.
>   X_CFLAGS =
> *** gcc/f/ChangeLog.orig        Mon Oct 25 07:59:13 1999
> --- gcc/f/ChangeLog     Sat Jul 15 18:28:14 2000
> ***************
> *** 1,3 ****
> --- 1,15 ----
> + Sun Jan  2 19:32:38 GMT 2000 George Helffrich (george@gly.bris.ac.uk)
> +
> +         * com.c: Even if common block is already defined in a program unit,
> +         make ffecom_transform_common_ place the link back to the common block
> +         into the common variable hook so that ffecom_member_phase2_ emits
> +         symbolic debugging information for the variable.  Otherwise this only
> +         gets done for the first definition of the common block in a program
> +         unit.
> +         * Makefile.in: Set -DSOMEONE_GETS_DEBUG_SUPPORT_WORKING so that common
> +         variable debugging symbols are emitted.  This works properly
> +         with gdb 4.16 on i586-unknown-linux.
> +
>   Sun Oct 24 23:54:10 PDT 1999 Jeff Law  (law@cygnus.com)
> 
>         * gcc-2.95.2 Released.
> 
> ------Patch 2
> *** gcc/dbxout.c.orig   Sun Apr 18 14:09:24 1999
> --- gcc/dbxout.c        Sat Jul 15 17:59:27 2000
> ***************
> *** 1236,1242 ****
>           dbxout_type_index (type);
>           fputc (';', asmfile);
>           fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
> !                  int_size_in_bytes (TREE_TYPE (type)));
>           fputs (";0;", asmfile);
>           CHARS (12);           /* The number is probably incorrect here.  */
>         }
> --- 1236,1242 ----
>           dbxout_type_index (type);
>           fputc (';', asmfile);
>           fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
> !                  2*int_size_in_bytes (TREE_TYPE (type)));
>           fputs (";0;", asmfile);
>           CHARS (12);           /* The number is probably incorrect here.  */
>         }
> *** gcc/ChangeLog.orig  Mon Oct 25 07:59:10 1999
> --- gcc/ChangeLog       Sat Jul 15 18:25:22 2000
> ***************
> *** 1,3 ****
> --- 1,7 ----
> + Sat Jul 15 18:23:07 BST 2000 George Helffrich (george@gly.bris.ac.uk)
> +
> +         * dbxout.c: Fix incorrect stabs lengths for native complex types.
> +
>   Sun Oct 24 23:54:10 PDT 1999 Jeff Law  (law@cygnus.com)
> 
>         * gcc-2.95.2 Released.

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
GNU Fortran 95: http://g95.sourceforge.net/ (under construction)


More information about the Gcc-bugs mailing list