From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6465 invoked by alias); 21 Jul 2005 06:47:21 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 6451 invoked by uid 22791); 21 Jul 2005 06:47:17 -0000 Received: from ausmtp01.au.ibm.com (HELO ausmtp01.au.ibm.com) (202.81.18.186) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 21 Jul 2005 06:47:17 +0000 Received: from sd0112e0.au.ibm.com (d23rh903.au.ibm.com [202.81.18.201]) by ausmtp01.au.ibm.com (8.12.10/8.12.10) with ESMTP id j6L6n7ne103304 for ; Thu, 21 Jul 2005 16:49:21 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.250.243]) by sd0112e0.au.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id j6L6mu4q175818 for ; Thu, 21 Jul 2005 16:49:00 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.12.11/8.13.3) with ESMTP id j6L6jlQc027463 for ; Thu, 21 Jul 2005 16:45:47 +1000 Received: from [9.181.134.203] ([9.181.134.203]) by d23av02.au.ibm.com (8.12.11/8.12.11) with ESMTP id j6L6jhpM027395; Thu, 21 Jul 2005 16:45:45 +1000 Date: Thu, 21 Jul 2005 06:47:00 -0000 From: Wu Zhou To: gdb@sources.redhat.com, fortran@gcc.gnu.org Subject: [GDB & Fortran]: common block's DWARF representation and "info common" output Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2005-07/txt/msg00216.txt.bz2 Hello all, I am investigating how GDB work with Fortran and found an odd question: GDB's "info common" command won't work with either G77 (I tested with 3.3.3 and 3.4.3) or Gfortran (I tested with gfortran-4.0). In section 12.4.3 of GDB manual, it says that info common [common-name] This command prints the values contained in the Fortran COMMON block whose name is common-name. With no argument, the names of all COMMON blocks visible at current program location are printed. So I use a short fortran program (source code is attached below)to verify whether it works or not. I found: whenever I issue "info common" command, it always reports empty like this: (gdb) info common All COMMON blocks visible at this level: (gdb) source code of common.f: =========================== program info_common implicit none integer :: a,b common /group1/ a,b a=1 b=2 call ShowCommon() stop end subroutine ShowCommon() implicit none integer :: num1, num2 common /group1/ num1, num2 write(*,*) num1, num2 return end Did anybody ever have success experience with this? Maybe this works well with an ancient g77, such as 2.95? I try using "readelf -wi common" to see the DWARF information the compilers generated. It seems that g77 treats common block group1 as an 8-bytes string and gfortran treats it as a two-members structure. Neither conform to DWARF standard, which use DW_TAG_common_block to represent a common block. So the error might due to the fact g77 and gfortran generate error debuginfo for common block. Any objection on this? Maybe I can open a PR for this. Please comment. Thanks in advance! P.S: I attach the debuginfo the compilers generated and the relative section of DWARF standards below for your reference. The DWARF information generated by g77: ======================================= <1><12b>: Abbrev Number: 6 (DW_TAG_base_type) DW_AT_name : (indirect string, offset: 0x3b): char DW_AT_byte_size : 1 DW_AT_encoding : 8 (unsigned char) <1><132>: Abbrev Number: 15 (DW_TAG_array_type) DW_AT_sibling : <143> DW_AT_type : <12b> <2><13b>: Abbrev Number: 16 (DW_TAG_subrange_type) DW_AT_type : <70> DW_AT_lower_bound : 0 DW_AT_upper_bound : 7 <1><143>: Abbrev Number: 17 (DW_TAG_variable) DW_AT_name : (indirect string, offset: 0xbb): group1_ DW_AT_decl_file : 1 DW_AT_decl_line : 3 DW_AT_type : <132> DW_AT_external : 1 DW_AT_location : 5 byte block: 3 a0 99 4 8 (DW_OP_addr: 80499a0) The DWARF information generated by gfortran: ============================================= <2><9e>: Abbrev Number: 3 (DW_TAG_variable) DW_AT_name : group1 DW_AT_decl_file : 1 DW_AT_decl_line : 4 DW_AT_MIPS_linkage_name: group1_ DW_AT_type : DW_AT_external : 1 DW_AT_location : 5 byte block: 3 d0 99 4 8 (DW_OP_addr: 80499d0) <1>: Abbrev Number: 5 (DW_TAG_structure_type) DW_AT_sibling : <100> DW_AT_byte_size : 8 <2>: Abbrev Number: 6 (DW_TAG_member) DW_AT_name : a DW_AT_decl_file : 1 DW_AT_decl_line : 3 DW_AT_type : <100> DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0) <2>: Abbrev Number: 6 (DW_TAG_member) DW_AT_name : b DW_AT_decl_file : 1 DW_AT_decl_line : 3 DW_AT_type : <100> DW_AT_data_member_location: 2 byte block: 23 4 (DW_OP_plus_uconst: 4) What DWARF standard said about common block: ============================================= A Fortran common block may be described by a debugging information entry with the tag DW_TAG_common_block. The common block entry has a DW_AT_name attribute whose value is a null-terminated string containing the common block name as it appears in the source program. It also has a DW_AT_location attribute whose value describes the location of the beginning of the common block. The common block entry owns debugging information entries describing the variables contained within the common block. Regards - Wu Zhou