Bug 35154 - Unable to reference symbols in Fortran COMMON due to .stabs format
Summary: Unable to reference symbols in Fortran COMMON due to .stabs format
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: George Helffrich
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-10 11:34 UTC by ghlixo
Modified: 2011-08-25 07:08 UTC (History)
2 users (show)

See Also:
Host: powerpc-apple-darwin8.8.0 (and others)
Target: powerpc-apple-darwin8.8.0
Build: powerpc-apple-darwin8.8.0
Known to work:
Known to fail:
Last reconfirmed: 2008-02-14 09:09:32


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ghlixo 2008-02-10 11:34:48 UTC
Problem is fixed with approved (but uncommitted) patch at

http://gcc.gnu.org/ml/gcc-patches/2008-02/msg00286.html

Arises on different systems lacking either: 1) loader ability to process external (i.e. non-.TEXT) SYMBOL+offset in .stabs; or 2) gdb ability to process same.  Darwin is one; FX Coudert's gfortran
testing system is another (unknown type).

To replicate, see below.
----------------
#cat simtest.f
      common i,j
      common /label/l,m
      i = 1
      j = 2
      k = 3
      l = 4
      m = 5
      call sub
      end
      subroutine sub
      common /label/l,m
      logical first
      save n
      data first /.true./
      if (first) then
         n = 0
         first = .false.
      endif
      n = n + 1
      l = l + 1
      end
#
#gfortran -v -g -o simtest simtest.f
Driving: gfortran -mmacosx-version-min=10.4 -v -g -o simtest simtest.f -lgfortranbegin -lgfortran -shared-libgcc
Using built-in specs.
Target: powerpc-apple-darwin8.8.0
Configured with: ../gcc-trunk/gcc/configure --enable-languages=c,fortran
Thread model: posix
gcc version 4.3.0 20080204 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.4' '-v' '-g' '-o' 'simtest' '-shared-libgcc'
 /usr/local/libexec/gcc/powerpc-apple-darwin8.8.0/4.3.0/f951 simtest.f -ffixed-form -feliminate-unused-debug-symbols -fPIC -quiet -dumpbase simtest.f -mmacosx-version-min=10.4 -auxbase simtest -g -version -fintrinsic-modules-path /usr/local/lib/gcc/powerpc-apple-darwin8.8.0/4.3.0/finclude -o /var/tmp//cc6Ld1Df.s
GNU F95 (GCC) version 4.3.0 20080204 (experimental) (powerpc-apple-darwin8.8.0)
        compiled by GNU C version 4.3.0 20080204 (experimental), GMP version 4.2.2, MPFR version 2.3.0-p3.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.4' '-v' '-g' '-o' 'simtest' '-shared-libgcc'
 as -arch ppc -o /var/tmp//ccILL0ce.o /var/tmp//cc6Ld1Df.s
COMPILER_PATH=/usr/local/libexec/gcc/powerpc-apple-darwin8.8.0/4.3.0/:/usr/local/libexec/gcc/powerpc-apple-darwin8.8.0/4.3.0/:/usr/local/libexec/gcc/powerpc-apple-darwin8.8.0/:/usr/local/lib/gcc/powerpc-apple-darwin8.8.0/4.3.0/:/usr/local/lib/gcc/powerpc-apple-darwin8.8.0/
LIBRARY_PATH=/usr/local/lib/gcc/powerpc-apple-darwin8.8.0/4.3.0/:/usr/local/lib/gcc/powerpc-apple-darwin8.8.0/4.3.0/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.4' '-v' '-g' '-o' 'simtest' '-shared-libgcc'
 /usr/local/libexec/gcc/powerpc-apple-darwin8.8.0/4.3.0/collect2 -dynamic -arch ppc -macosx_version_min 10.4 -multiply_defined suppress -weak_reference_mismatches non-weak -o simtest -lcrt1.o /usr/local/lib/gcc/powerpc-apple-darwin8.8.0/4.3.0/crt3.o -L/usr/local/lib/gcc/powerpc-apple-darwin8.8.0/4.3.0 -L/usr/local/lib/gcc/powerpc-apple-darwin8.8.0/4.3.0/../../.. /var/tmp//ccILL0ce.o -lgfortranbegin -lgfortran -lgcc_s.10.4 -lgcc -lSystemStubs -lSystem
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.4' '-v' '-g' '-o' 'simtest' '-shared-libgcc'

#gdb simtest
GNU gdb 6.3.50-20050815 (Apple version gdb-573) (Fri Oct 20 15:54:33 GMT 2006)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-apple-darwin"...Reading symbols for shared libraries .... done

(gdb) l MAIN__ 
1             common i,j
2             common /label/l,m
3             i = 1
4             j = 2
5             k = 3
6             l = 4
7             m = 5
8             call sub
9             end
10            subroutine sub
(gdb) break 8
Breakpoint 1 at 0x2c28: file simtest.f, line 8.
(gdb) run
Starting program: /Users/george/f77/simtest 
Reading symbols for shared libraries ..+. done

Breakpoint 1, MAIN__ () at simtest.f:8
8             call sub
(gdb) p i
Address of symbol "i" is unknown.
(gdb) p j
No symbol "j" in current context.
(gdb) p k
$1 = 3
Current language:  auto; currently fortran
(gdb) p l
Address of symbol "l" is unknown.
(gdb) p m
No symbol "m" in current context.
(gdb) quit
The program is running.  Exit anyway? (y or n) y
#
-------------------
Comment 1 George Helffrich 2008-04-02 08:01:06 UTC
Fixed in rev 133800 1 April 2008
Comment 2 Jerry DeLisle 2008-04-19 06:49:40 UTC
Reopening this PR after reverting the patch until the problem can be sorted out.

See PR35892 which caused by the patch to this one.
Comment 3 George Helffrich 2008-04-26 09:46:53 UTC
Subject: Bug 35154

Author: george
Date: Sat Apr 26 09:46:01 2008
New Revision: 134696

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134696
Log:
2008-04-26  George Helffrich <george@gcc.gnu.org>

	PR fortran/35892
	PR fortran/35154
	* fortran/trans-common.c (create_common):  Add decl to function
	chain (if inside one) to preserve identifier scope in debug output.

        * testsuite/gfortran.dg/debug/pr35154-stabs.f:  New test case for
        .stabs functionality.
        * testsuite/gfortran.dg/debug/pr35154-dwarf2.f:  New test case for
        DWARF functionality.


Added:
    trunk/gcc/testsuite/gfortran.dg/debug/pr35154-dwarf2.f
    trunk/gcc/testsuite/gfortran.dg/debug/pr35154-stabs.f
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-common.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 George Helffrich 2008-04-26 10:14:16 UTC
Reworked patch committed as rev. 134696.
Comment 5 Dominique d'Humieres 2008-09-01 09:37:56 UTC
On i686-apple-darwin9, I have the following failures in both 32 and 64 bit modes:

FAIL: gfortran.dg/debug/pr35154-dwarf2.f -gdwarf-2 scan-assembler DW_AT_name: "__BLNK__"
FAIL: gfortran.dg/debug/pr35154-dwarf2.f -gdwarf-2 scan-assembler DW_AT_name: "label"

Looking at the assembly code I see:

...
	.ascii "__BLNK__\0"	# DW_AT_name
	.ascii "i\0"	# DW_AT_name
	.ascii "j\0"	# DW_AT_name
	.ascii "label\0"	# DW_AT_name
...

I thing that changing

C { dg-final { scan-assembler "DW_AT_name: \"__BLNK__\"" } }
C { dg-final { scan-assembler "DW_AT_name: \"label\"" } }

with

C { dg-final { scan-assembler "DW_AT_name: \"__BLNK__.*\"" } }
C { dg-final { scan-assembler "DW_AT_name: \"label.*\"" } }

will fix the failures.