Bug 559291

Summary: breakpoints on routine names don't work in Fortran in gdb 6.8-37
Product: Red Hat Enterprise Linux 5 Reporter: Need Real Name <david.moore>
Component: gdbAssignee: Jan Kratochvil <jan.kratochvil>
Status: CLOSED ERRATA QA Contact: qe-baseos-tools-bugs
Severity: urgent Docs Contact:
Priority: low    
Version: 5.4CC: cagney, ebachalo, pmuller, syeghiay
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gdb-7.0.1-21.el5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-03-30 08:52:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 466118    
Bug Blocks:    

Description Need Real Name 2010-01-27 16:58:22 UTC
A new search routine has been added to be used when "set language fortran" is on. 

The new code fails to fall through to the default searches when the new search lists are empty. Note that this bug was introduced between gdb 6.8 and 6.8-37.

As a result the following fails (notice though that is I reset the language to C it succeeds):

--------
        program array2a
        integer, dimension(3,5) :: arr
        integer i,j

        do i=1,3
           do j=1,5
              arr(i,j) = i*10+j;
           enddo
        enddo
  
        print *, arr
        end
-----------
...
gdb array2a
gdb array2a.exe
GNU gdb Fedora (6.8-37.el5)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "ia64-redhat-linux-gnu"...
(gdb) set language fortran
(gdb) b array2a
Function "array2a" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) set language c
(gdb) b array2a
Breakpoint 1 at 0x4000000000002b71: file array2a.f, line 5.
(gdb) 

Here is a diff to fix the problem. It just puts the test around the new search rather than returning prematurely. Note that this routine is new to 6.8-39. In 6.8 the language config is simply bound to basic_lookup_symbol_nonlocal.

*** f-lang.c    2010-01-27 11:45:30.000000000 -0500
--- f-lang.c.new        2010-01-27 11:24:46.000000000 -0500
***************
*** 320,351 ****
  {
    struct fortran_using *use;
  
!   if (!block)
!     return NULL;
! 
!   for (use = BLOCK_FORTRAN_USE (block); use; use = use->next)
!     {
!       struct symbol *sym;
!       struct type *type;
!       struct symbol *retval;
! 
!       sym = lookup_symbol_global (use->module_name, NULL, block, MODULE_DOMAIN,
!                                 symtab);
! 
!       /* Module name lookup should not fail with correct debug info.  */
!       if (sym == NULL)
!       continue;
! 
!       type = SYMBOL_TYPE (sym);
!       gdb_assert (TYPE_CODE (type) == TYPE_CODE_MODULE);
!       gdb_assert (TYPE_MODULE_BLOCK (type) != NULL);
! 
!       retval = lookup_block_symbol (TYPE_MODULE_BLOCK (type), name,
!                                   linkage_name, domain);
!       if (retval)
!       return retval;
      }
- 
    return basic_lookup_symbol_nonlocal (name, linkage_name, block, domain,
                                       symtab);
  }
--- 320,349 ----
  {
    struct fortran_using *use;
  
!   if (block) {
!     for (use = BLOCK_FORTRAN_USE (block); use; use = use->next)
!       {
!         struct symbol *sym;
!         struct type *type;
!         struct symbol *retval;
!   
!         sym = lookup_symbol_global (use->module_name, NULL, block, MODULE_DOMAIN,
!                                 symtab);
!   
!         /* Module name lookup should not fail with correct debug info.  */
!         if (sym == NULL)
!       continue;
!   
!         type = SYMBOL_TYPE (sym);
!         gdb_assert (TYPE_CODE (type) == TYPE_CODE_MODULE);
!         gdb_assert (TYPE_MODULE_BLOCK (type) != NULL);
!   
!         retval = lookup_block_symbol (TYPE_MODULE_BLOCK (type), name,
!                                   linkage_name, domain);
!         if (retval)
!       return retval;
!       }
      }
    return basic_lookup_symbol_nonlocal (name, linkage_name, block, domain,
                                       symtab);
  }

Comment 1 Jan Kratochvil 2010-02-03 00:13:54 UTC
Thanks, checked-in archer-jankratochvil-fortran-module and going to be pushed for RHEL:
http://sourceware.org/ml/archer/2010-q1/msg00047.html

Comment 3 Fedora Update System 2010-02-03 15:01:43 UTC
gdb-6.8.50.20090302-40.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/gdb-6.8.50.20090302-40.fc11

Comment 4 Fedora Update System 2010-02-03 15:02:31 UTC
gdb-7.0.1-31.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/gdb-7.0.1-31.fc12

Comment 6 Fedora Update System 2010-02-05 01:29:28 UTC
gdb-6.8.50.20090302-40.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 7 Fedora Update System 2010-02-05 01:33:51 UTC
gdb-7.0.1-31.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 8 Jan Kratochvil 2010-02-08 13:03:47 UTC
* Mon Feb  8 2010 Jan Kratochvil <jan.kratochvil> - 7.0.1-21.el5
- Fortran: Fix regression on setting breakpoint at toplevel symbols (BZ 559291;
  David Moore, Intel).
- Resolves: rhbz#559291

Comment 12 errata-xmlrpc 2010-03-30 08:52:46 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2010-0285.html