https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96158

            Bug ID: 96158
           Summary: Symbols not emitted for module common variables
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amelvill at umich dot edu
  Target Milestone: ---

Created attachment 48859
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48859&action=edit
A tarball archive demonstrating the problem

I am trying to debug a Fortran program that uses common statements like this:

module somemodule

    integer*8    moduleVar

    !Comment out the line below to make "call moduleVar" start working again
    common /othermodule/  moduleVar

end module

... but it seems like gfortran does not emit debugging symbols that GDB can
use.

See this github repo for a minimal example: 
https://github.com/amelvill-umich/Fortran_GDB_Common

I have also attached a zip file with the sources (and a README that goes into
more detail, with GDB commands and output), if you prefer.
- With the common statement, I can access the variable in Fortran code, but GDB
is not able to read its value.
- Manually inspecting somemodule.o with a hex editor, I notice that the
.debug_str section seems to have information that might identify the common
variable, but it doesn't appear to be used

I almost filed a bug report with GDB about this, until I noticed that gfortran
emits only othermodule_ as a symbol for the othermodule common variable, which
didn't seem right. It doesn't seem like GDB would be able to provide very
useful information with only that as a symbol.

But, if this is the expected behavior let me know if you have any suggestions
for debugging variables like this (or if you think this is a bug/limitation in
GDB)

Additional information:

$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-10ubuntu2'
--with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-9
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-offload-targets=nvptx-none,hsa
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2) 

The Makefile in the tarball/repository did not have -Wall -Wextra, but adding
these did not produce any additional information (no errors / warnings at all
from gfortran)
$ make
gfortran -c somemodule.f90 -g -Wall -Wextra
gfortran -c main.f90 -g -Wall -Wextra
gfortran -o main main.o somemodule.o -g -Wall -Wextra

I'm not aware of a way to reproduce this bug with a single file.

I mentioned this on the gfortran mailing list and somebody recommended that I
post this here.

Thanks,

- ajm

Reply via email to