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]

defer dwarf2 debug_line construction to the assembler


This patch adds support to gcc to defer generation of dwarf2 line number info
to the assembler.  Dwarf2 line number support was added to GNU as about two
months ago (gas/dwarf2dbg.c).

Since gas has exact info on instruction sizes, gas is able to create a much
smaller debug_line section than gcc can, thus reducing the size of the debug
info.

For VLIW targets, this also avoids emitting labels for line numbers.  These
extra labels interfere with instruction packing, as we can't pack insns
together if they cross a label.

This code will be used with the ia64 port, which can't be disclosed yet
so I can't show actual examples of how to use this.  This will be beneficial
for many targets once it is working reliably though.  Meanwhile, I am willing
to answer questions if someone wants to try to get this working for another
target.

Unless someone offers constructive criticism, I plan to check this in as is.

Wed Aug 25 20:51:31 1999  Jim Wilson  <wilson@cygnus.com>

	* dwarf2out.c (debug_dwarf): Add DWARF2_ASM_LINE_DEBUG_INFO support.
	(dwarf2out_line, dwarf2out_finish): Likewise.
	* tm.texi (DWARF2_ASM_LINE_DEBUG_INFO): Add documetation.

Index: dwarf2out.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/dwarf2out.c,v
retrieving revision 1.112
diff -p -r1.112 dwarf2out.c
*** dwarf2out.c	1999/07/08 03:16:09	1.112
--- dwarf2out.c	1999/08/26 03:50:48
*************** debug_dwarf ()
*** 4442,4448 ****
  {
    print_indent = 0;
    print_die (comp_unit_die, stderr);
!   print_dwarf_line_table (stderr);
  }
  
  /* Traverse the DIE, and add a sibling attribute if it may have the
--- 4442,4449 ----
  {
    print_indent = 0;
    print_die (comp_unit_die, stderr);
!   if (! DWARF2_ASM_LINE_DEBUG_INFO)
!     print_dwarf_line_table (stderr);
  }
  
  /* Traverse the DIE, and add a sibling attribute if it may have the
*************** dwarf2out_line (filename, line)
*** 9839,9846 ****
      {
        function_section (current_function_decl);
  
!       if (DECL_SECTION_NAME (current_function_decl))
  	{
  	  register dw_separate_line_info_ref line_info;
  	  ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, SEPARATE_LINE_CODE_LABEL,
  				     separate_line_info_table_in_use);
--- 9840,9867 ----
      {
        function_section (current_function_decl);
  
!       if (DWARF2_ASM_LINE_DEBUG_INFO)
  	{
+ 	  static char *lastfile;
+ 
+ 	  /* Emit the .file and .loc directives understood by GNU as.  */
+ 	  if (lastfile == 0 || strcmp (filename, lastfile))
+ 	    {
+ 	      fprintf (asm_out_file, "\t.file 0 \"%s\"\n", filename);
+ 	      lastfile = filename;
+ 	    }
+ 
+ 	  fprintf (asm_out_file, "\t.loc 0 %d 0\n", line);
+ 
+ 	  /* Indicate that line number info exists.  */
+ 	  ++line_info_table_in_use;
+ 
+ 	  /* Indicate that multiple line number tables exist.  */
+ 	  if (DECL_SECTION_NAME (current_function_decl))
+ 	    ++separate_line_info_table_in_use;
+ 	}
+       else if (DECL_SECTION_NAME (current_function_decl))
+ 	{
  	  register dw_separate_line_info_ref line_info;
  	  ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, SEPARATE_LINE_CODE_LABEL,
  				     separate_line_info_table_in_use);
*************** dwarf2out_finish ()
*** 10078,10086 ****
    /* Output the source line correspondence table.  */
    if (line_info_table_in_use > 1 || separate_line_info_table_in_use)
      {
!       fputc ('\n', asm_out_file);
!       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.  */
--- 10099,10110 ----
    /* 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)
! 	{
! 	  fputc ('\n', asm_out_file);
! 	  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.  */
Index: tm.texi
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/tm.texi,v
retrieving revision 1.155
diff -p -r1.155 tm.texi
*** tm.texi	1999/07/28 03:04:40	1.155
--- tm.texi	1999/08/26 03:57:02
*************** Normally, if the user specifies only @sa
*** 6947,6952 ****
--- 6947,6958 ----
  version 2 if available; this macro disables this.  See the description
  of the @code{PREFERRED_DEBUGGING_TYPE} macro for more details.
  
+ @findex DWARF2_ASM_LINE_DEBUG_INFO
+ @item DWARF2_ASM_LINE_DEBUG_INFO
+ Define this macro to be a nonzero value if the assembler can generate Dwarf 2
+ line debug info sections.  This will result in much more compact line number
+ tables, and hence is desirable if it works.
+ 
  @findex PUT_SDB_@dots{}
  @item PUT_SDB_@dots{}
  Define these macros to override the assembler syntax for the special


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