This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

breakpoints/1310: GDB has problem with internal subroutines (variable visibility)


>Number:         1310
>Category:       breakpoints
>Synopsis:       GDB has problem with internal subroutines (variable visibility)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 04 07:58:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     sana@stl.sarov.ru
>Release:        unknown-1.0
>Organization:
>Environment:
IA32 Linux.
>Description:
Fragment of code from regression test is:

subroutine external_subr(par1)
     integer par1
     integer res1
     data res1/10/     
     print *, 'external subr'
     call internal_subr(par1)
     res1 = internal_func(par1)
     
     contains

        subroutine internal_subr(par2)
           integer par2
           integer arg2
        
           print *, 'internal internal_subr'
           arg2 = par2
           arg2 = internal_func(arg2)
        
        end subroutine internal_subr

   end

Variable 'res1' should be visible inside internal subroutine 'internal_subr'. Debug info looks like correct:

 <1><77>: Abbrev Number: 3 (DW_TAG_subprogram)
     DW_AT_decl_line   : 1      
     DW_AT_decl_column : 16     
     DW_AT_decl_file   : 1      
     DW_AT_sibling     : <194>  
     DW_AT_accessibility: 1     (public)
     DW_AT_name        : external_subr  
     DW_AT_type        : <6f>   
     DW_AT_prototyped  : 0      
     DW_AT_frame_base  : 2 byte block: 75 58    (DW_OP_breg5: -40)
     DW_AT_high_pc     : 0x80495a4 134518180    
     DW_AT_low_pc      : 0x8049528 134518056    
     DW_AT_external    : 1      
 <2><9f>: Abbrev Number: 4 (DW_TAG_formal_parameter)
     DW_AT_decl_line   : 1      
     DW_AT_decl_column : 30     
     DW_AT_decl_file   : 1      
     DW_AT_type        : <194>  
     DW_AT_variable_parameter: 1        
     DW_AT_name        : par1   
     DW_AT_location    : 3 byte block: 91 30 6  (DW_OP_fbreg: 48DW_OP_deref)
 <2><b1>: Abbrev Number: 5 (DW_TAG_variable)
     DW_AT_decl_line   : 3      
     DW_AT_decl_column : 13     
     DW_AT_decl_file   : 1      
     DW_AT_accessibility: 1     (public)
     DW_AT_name        : res1   
     DW_AT_type        : <194>  
     DW_AT_location    : 5 byte block: 3 30 84 9 8      (DW_OP_addr: 8098430)
     DW_AT_external    : 0      
     DW_AT_start_scope : 0x804952e 134518062    
 <2><ca>: Abbrev Number: 6 (DW_TAG_subprogram)
     DW_AT_decl_line   : 11     
     DW_AT_decl_column : 19     
     DW_AT_decl_file   : 1      
     DW_AT_sibling     : <11f>  
     DW_AT_accessibility: 1     (public)
     DW_AT_name        : internal_subr  
     DW_AT_type        : <6f>   
     DW_AT_prototyped  : 0      
     DW_AT_static_link : 3 byte block: 75 0 6   
     DW_AT_high_pc     : 0x804961e 134518302    
     DW_AT_low_pc      : 0x80495a4 134518180    
     DW_AT_external    : 0      
 <3><f3>: Abbrev Number: 4 (DW_TAG_formal_parameter)
     DW_AT_decl_line   : 11     
     DW_AT_decl_column : 33     
     DW_AT_decl_file   : 1      
     DW_AT_type        : <194>  
     DW_AT_variable_parameter: 1        
     DW_AT_name        : par2   
     DW_AT_location    : 3 byte block: 75 8 6   (DW_OP_breg5: 8DW_OP_deref)
 <3><105>: Abbrev Number: 5 (DW_TAG_variable)
     DW_AT_decl_line   : 13     
     DW_AT_decl_column : 12     
     DW_AT_decl_file   : 1      
     DW_AT_accessibility: 1     (public)
     DW_AT_name        : arg2   
     DW_AT_type        : <194>  
     DW_AT_location    : 5 byte block: 3 b8 3c a 8      (DW_OP_addr: 80a3cb8)
     DW_AT_external    : 0      
     DW_AT_start_scope : 0x80495aa 134518186    

But GDB output is:

This GDB was configured as "i386-redhat-linux"...
(gdb) b 17
Breakpoint 1 at 0x804941e: file contains_01.f90, line 17.
(gdb) r
Starting program: /home1/sana/trackers/opyt/contains_01.exe 
 general program
 external internal_subr
 external internal_func
 external internal_subr
 external subr
 internal internal_subr

Breakpoint 1, external_subr_.internal_subr_ () at contains_01.f90:17
17                 arg2 = internal_func(arg2)
Current language:  auto; currently fortran
(gdb) whatis res1
No symbol "res1" in current context.
(gdb) 


IDB (Intel debugger) works correctly with it:

object file name: contains_01.exe 
Reading symbolic information ...done
(idb) stop 17
[#1: stop at "contains_01.f90":17 ]
(idb) r
 general program
 external internal_subr
 external internal_func
 external internal_subr
 external subr
 internal internal_subr
[1] stopped at [subroutine external_subr`internal_subr(integer*4):17 0x804941e]
     17            arg2 = internal_func(arg2)
(idb) whatis res1
integer*4 res1
(idb) p res1
10
(idb) 

It looks like as GDB's problem.
>How-To-Repeat:
Regression test is:
     subroutine external_subr(par1)
     integer par1
     integer res1
     data res1/10/     
     print *, 'external subr'
     call internal_subr(par1)
     res1 = internal_func(par1)
     
     contains

        subroutine internal_subr(par2)
           integer par2
           integer arg2
        
           print *, 'internal internal_subr'
           arg2 = par2
           arg2 = internal_func(arg2)
        
        end subroutine internal_subr

        integer function internal_func(par3)
           integer par3
          integer arg3
        
           print *, 'internal internal_func'
           arg3 = par3
           par3 = res1 + par3
           internal_func = par3
        end function internal_func
     end subroutine external_subr

     subroutine internal_subr(par2)
        integer par2
        integer arg2
        
        print *, 'external internal_subr'
        arg2 = par2
        par2 = par2 + par2
     end subroutine internal_subr

     integer function internal_func(par3)
        integer par3
        integer arg3
        
        print *, 'external internal_func'
        arg3 = par3
        call internal_subr(arg3)
        internal_func = arg3
     end function internal_func
     
     program contains1
     integer arg1, arg2, arg3
     
     print *, 'general program'
     call internal_subr(arg1)
     arg2 = internal_func(arg3)
     
     call external_subr(arg1)
     
     end program contains1

Intel compiler is necessary to reproduce situation.
Command line should be 'ifc -g test.f90'.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]