This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

PATCH: Fix DWARF2 regression on IRIX 6.5



On IRIX 6.5, we had regression from GCC 2.95 in that you could no
longer run `nm' on an empty translation unit.  IRIX nm gave an error,
saying that the length of .debug_info and .debug_line were zero.
Apparently, if we're going to create the sections we need to put
something in there.

We can't decide whether they're empty or not because we now create
them at the beginning of the translation unit.  (This is different
from GCC 2.95.)  There are no comments on the code that does that.

Anyhow, it's sort-of silly to try to optimize this case.  If most of
the space in your program is taken up by empty source files, you have
worse problems.

Here's the patch.  Bootstrapped and tested on mips-sgi-irix6.5.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

Index: gcc/dwarf2out.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/dwarf2out.c,v
retrieving revision 1.242.2.15
diff -c -p -r1.242.2.15 dwarf2out.c
*** dwarf2out.c	2001/05/16 19:29:54	1.242.2.15
--- dwarf2out.c	2001/05/18 06:26:20
*************** output_comp_unit (die)
*** 5929,5938 ****
  {
    const char *secname;
  
!   if (die->die_child == 0)
!     return;
! 
!   /* Mark all the DIEs in this CU so we know which get local refs.  */
    mark_dies (die);
  
    build_abbrev_table (die);
--- 5929,5941 ----
  {
    const char *secname;
  
!   /* Even if there are no children of this DIE, we must output the
!      information about the compilation unit.  Otherwise, on an empty
!      translation unit, we will generate a present, but empty,
!      .debug_info section.  IRIX 6.5 `nm' will then complain when
!      examining the file.
!      
!      Mark all the DIEs in this CU so we know which get local refs.  */
    mark_dies (die);
  
    build_abbrev_table (die);
*************** dwarf2out_finish ()
*** 11266,11291 ****
    ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, BSS_END_LABEL, 0);
  #endif
  
!   /* Output the source line correspondence table.  */
!   if (line_info_table_in_use > 1 || separate_line_info_table_in_use)
      {
!       if (! DWARF2_ASM_LINE_DEBUG_INFO)
! 	{
! 	  ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LINE_SECTION);
! 	  output_line_info ();
! 	}
! 
!       /* We can only use the low/high_pc attributes if all of the code
! 	 was in .text.  */
!       if (separate_line_info_table_in_use == 0)
! 	{
! 	  add_AT_lbl_id (comp_unit_die, DW_AT_low_pc, text_section_label);
! 	  add_AT_lbl_id (comp_unit_die, DW_AT_high_pc, text_end_label);
! 	}
  
!       add_AT_lbl_offset (comp_unit_die, DW_AT_stmt_list,
! 			 debug_line_section_label);
      }
  
  #if 0 /* unimplemented */
    if (debug_info_level >= DINFO_LEVEL_VERBOSE && primary)
--- 11269,11295 ----
    ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, BSS_END_LABEL, 0);
  #endif
  
!   /* Output the source line correspondence table.  We must do this
!      even if there is no line information.  Otherwise, on an empty
!      translation unit, we will generate a present, but empty,
!      .debug_info section.  IRIX 6.5 `nm' will then complain when
!      examining the file.  */
!   if (! DWARF2_ASM_LINE_DEBUG_INFO)
      {
!       ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LINE_SECTION);
!       output_line_info ();
!     }
  
!   /* We can only use the low/high_pc attributes if all of the code was
!      in .text.  */
!   if (separate_line_info_table_in_use == 0)
!     {
!       add_AT_lbl_id (comp_unit_die, DW_AT_low_pc, text_section_label);
!       add_AT_lbl_id (comp_unit_die, DW_AT_high_pc, text_end_label);
      }
+ 
+   add_AT_lbl_offset (comp_unit_die, DW_AT_stmt_list,
+ 		     debug_line_section_label);
  
  #if 0 /* unimplemented */
    if (debug_info_level >= DINFO_LEVEL_VERBOSE && primary)


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