In section 4.2 of DWARF STD, it says that: A Fortran common block may be described by a debugging information entry with the tag DW_TAG_common_block.
But it seems that both gfortran and g77 didn't conform to this. This makes trouble for debugging common block. Here is a testcase to verify this: 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 group1 is a named common block. After using gfortran to build this case, I use "readelf -wi" to get the debuginfo of the executable: <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 : <e1> =====> This point to the type of group1 DW_AT_external : 1 DW_AT_location : 5 byte block: 3 d0 99 4 8 (DW_OP_addr: 80499d0) <1><e1>: Abbrev Number: 5 (DW_TAG_structure_type) DW_AT_sibling : <100> DW_AT_byte_size : 8 <2><e7>: 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><f3>: 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) It tells us that group1 is treated as a two-members structure. g77 handles this in another way, it treats group1 as an eight-character array. And eight is exactly the size of common block group1. Here is the debuginfo for g77-generated executable: <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> =====> This point to the type of group1 DW_AT_external : 1 DW_AT_location : 5 byte block: 3 a0 99 4 8 (DW_OP_addr: 80499a0) P.S: I reported this problem some days before. But there is no response ever since. Here is the link: http://gcc.gnu.org/ml/fortran/2005-07/msg00310.html Thanks. -- Summary: Wrong DWARF output for Fortran common block Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: woodzltc at sources dot redhat dot com CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23057