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: Address sizes in Dwarf 2 debug info



This patch allows GCC to generate Dwarf 2 debug info on processors
which use word addresses --- byte addresses divided by the word size
--- to refer to code.  Dwarf 2 info always contains byte addresses, so
on such processors, the addresses in Dwarf 2 info need to be larger
than the target pointer size.


gcc/ChangeLog:
2000-04-05  Jim Blandy  <jimb@redhat.com>

	* dwarf2out.c (DWARF2_ADDR_SIZE): New macro.  Use it instead
	of PTR_SIZE, when appropriate.
	* config/generic/generic.h (DWARF2_ADDR_SIZE): Document.

Index: gcc/dwarf2out.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/dwarf2out.c,v
retrieving revision 1.133
diff -c -r1.133 dwarf2out.c
*** gcc/dwarf2out.c	2000/04/03 15:29:28	1.133
--- gcc/dwarf2out.c	2000/04/10 18:46:22
***************
*** 147,159 ****
  #ifndef CHAR_TYPE_SIZE
  #define CHAR_TYPE_SIZE BITS_PER_UNIT
  #endif
  #ifndef PTR_SIZE
  #define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
  #endif
  
  /* The size in bytes of a DWARF field indicating an offset or length
!    relative to a debug info section, specified to be 4 bytes in the DWARF-2
!    specification.  The SGI/MIPS ABI defines it to be the same as PTR_SIZE.  */
  
  #ifndef DWARF_OFFSET_SIZE
  #define DWARF_OFFSET_SIZE 4
--- 147,171 ----
  #ifndef CHAR_TYPE_SIZE
  #define CHAR_TYPE_SIZE BITS_PER_UNIT
  #endif
+ 
+ /* The size of the target's pointer type.  */
  #ifndef PTR_SIZE
  #define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
  #endif
  
+ /* The size of addresses as they appear in the Dwarf 2 data.
+    Some architectures use word addresses to refer to code locations,
+    but Dwarf 2 info always uses byte addresses.  On such machines,
+    Dwarf 2 addresses need to be larger than the architecture's
+    pointers.  */
+ #ifndef DWARF2_ADDR_SIZE
+ #define DWARF2_ADDR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
+ #endif
+ 
  /* The size in bytes of a DWARF field indicating an offset or length
!    relative to a debug info section, specified to be 4 bytes in the
!    DWARF-2 specification.  The SGI/MIPS ABI defines it to be the same
!    as PTR_SIZE.  */
  
  #ifndef DWARF_OFFSET_SIZE
  #define DWARF_OFFSET_SIZE 4
***************
*** 315,322 ****
  #endif
  
  #ifndef UNALIGNED_WORD_ASM_OP
! #define UNALIGNED_WORD_ASM_OP \
!   (PTR_SIZE == 8 ? UNALIGNED_DOUBLE_INT_ASM_OP : UNALIGNED_INT_ASM_OP)
  #endif
  
  #ifndef ASM_OUTPUT_DWARF_DELTA2
--- 327,336 ----
  #endif
  
  #ifndef UNALIGNED_WORD_ASM_OP
! #define UNALIGNED_WORD_ASM_OP			\
!   (DWARF2_ADDR_SIZE == 8 			\
!    ? UNALIGNED_DOUBLE_INT_ASM_OP		\
!    : UNALIGNED_INT_ASM_OP)
  #endif
  
  #ifndef ASM_OUTPUT_DWARF_DELTA2
***************
*** 435,441 ****
     .debug_frame.  */
  
  #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
!   assemble_integer (gen_rtx_SYMBOL_REF (Pmode, LABEL), PTR_SIZE, 1)
  
  #define ASM_OUTPUT_DWARF_OFFSET4(FILE,LABEL) \
    assemble_integer (gen_rtx_SYMBOL_REF (SImode, LABEL), 4, 1)
--- 449,455 ----
     .debug_frame.  */
  
  #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
!   assemble_integer (gen_rtx_SYMBOL_REF (Pmode, LABEL), DWARF2_ADDR_SIZE, 1)
  
  #define ASM_OUTPUT_DWARF_OFFSET4(FILE,LABEL) \
    assemble_integer (gen_rtx_SYMBOL_REF (SImode, LABEL), 4, 1)
***************
*** 459,465 ****
    assemble_integer (gen_rtx_MINUS (Pmode,				\
  				   gen_rtx_SYMBOL_REF (Pmode, LABEL1),	\
  				   gen_rtx_SYMBOL_REF (Pmode, LABEL2)),	\
! 		    PTR_SIZE, 1)
  
  #define ASM_OUTPUT_DWARF_DELTA(FILE,LABEL1,LABEL2) \
    ASM_OUTPUT_DWARF_DELTA4 (FILE,LABEL1,LABEL2)
--- 473,479 ----
    assemble_integer (gen_rtx_MINUS (Pmode,				\
  				   gen_rtx_SYMBOL_REF (Pmode, LABEL1),	\
  				   gen_rtx_SYMBOL_REF (Pmode, LABEL2)),	\
! 		    DWARF2_ADDR_SIZE, 1)
  
  #define ASM_OUTPUT_DWARF_DELTA(FILE,LABEL1,LABEL2) \
    ASM_OUTPUT_DWARF_DELTA4 (FILE,LABEL1,LABEL2)
***************
*** 1649,1655 ****
        tree label = get_file_function_name ('F');
  
        force_data_section ();
!       ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
        ASM_GLOBALIZE_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
        ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
  #endif
--- 1663,1669 ----
        tree label = get_file_function_name ('F');
  
        force_data_section ();
!       ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (DWARF2_ADDR_SIZE));
        ASM_GLOBALIZE_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
        ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
  #endif
***************
*** 1753,1759 ****
      output_cfi (cfi, NULL);
  
    /* Pad the CIE out to an address sized boundary.  */
!   ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
    ASM_OUTPUT_LABEL (asm_out_file, l2);
  #ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
    ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL (asm_out_file, ld, l2, l1);
--- 1767,1773 ----
      output_cfi (cfi, NULL);
  
    /* Pad the CIE out to an address sized boundary.  */
!   ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (DWARF2_ADDR_SIZE));
    ASM_OUTPUT_LABEL (asm_out_file, l2);
  #ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
    ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL (asm_out_file, ld, l2, l1);
***************
*** 1825,1831 ****
  	output_cfi (cfi, fde);
  
        /* Pad the FDE out to an address sized boundary.  */
!       ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
        ASM_OUTPUT_LABEL (asm_out_file, l2);
  #ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
        ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL (asm_out_file, ld, l2, l1);
--- 1839,1845 ----
  	output_cfi (cfi, fde);
  
        /* Pad the FDE out to an address sized boundary.  */
!       ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (DWARF2_ADDR_SIZE));
        ASM_OUTPUT_LABEL (asm_out_file, l2);
  #ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
        ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL (asm_out_file, ld, l2, l1);
***************
*** 2156,2163 ****
  #define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
  
  /* Fixed size portion of the address range info.  */
! #define DWARF_ARANGES_HEADER_SIZE \
!   (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, PTR_SIZE * 2) - DWARF_OFFSET_SIZE)
  
  /* The default is to have gcc emit the line number tables.  */
  #ifndef DWARF2_ASM_LINE_DEBUG_INFO
--- 2170,2178 ----
  #define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
  
  /* Fixed size portion of the address range info.  */
! #define DWARF_ARANGES_HEADER_SIZE					\
!   (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, DWARF2_ADDR_SIZE * 2)	\
!    - DWARF_OFFSET_SIZE)
  
  /* The default is to have gcc emit the line number tables.  */
  #ifndef DWARF2_ASM_LINE_DEBUG_INFO
***************
*** 4586,4592 ****
    switch (loc->dw_loc_opc)
      {
      case DW_OP_addr:
!       size += PTR_SIZE;
        break;
      case DW_OP_const1u:
      case DW_OP_const1s:
--- 4601,4607 ----
    switch (loc->dw_loc_opc)
      {
      case DW_OP_addr:
!       size += DWARF2_ADDR_SIZE;
        break;
      case DW_OP_const1u:
      case DW_OP_const1s:
***************
*** 4727,4733 ****
        switch (AT_class (a))
  	{
  	case dw_val_class_addr:
! 	  size += PTR_SIZE;
  	  break;
  	case dw_val_class_loc:
  	  {
--- 4742,4748 ----
        switch (AT_class (a))
  	{
  	case dw_val_class_addr:
! 	  size += DWARF2_ADDR_SIZE;
  	  break;
  	case dw_val_class_loc:
  	  {
***************
*** 4760,4766 ****
  	  size += DWARF_OFFSET_SIZE;
  	  break;
  	case dw_val_class_lbl_id:
! 	  size += PTR_SIZE;
  	  break;
  	case dw_val_class_lbl_offset:
  	  size += DWARF_OFFSET_SIZE;
--- 4775,4781 ----
  	  size += DWARF_OFFSET_SIZE;
  	  break;
  	case dw_val_class_lbl_id:
! 	  size += DWARF2_ADDR_SIZE;
  	  break;
  	case dw_val_class_lbl_offset:
  	  size += DWARF_OFFSET_SIZE;
***************
*** 4867,4877 ****
    size = DWARF_ARANGES_HEADER_SIZE;
  
    /* Count the address/length pair for this compilation unit.  */
!   size += 2 * PTR_SIZE;
!   size += 2 * PTR_SIZE * arange_table_in_use;
  
    /* Count the two zero words used to terminated the address range table.  */
!   size += 2 * PTR_SIZE;
    return size;
  }
  
--- 4882,4892 ----
    size = DWARF_ARANGES_HEADER_SIZE;
  
    /* Count the address/length pair for this compilation unit.  */
!   size += 2 * DWARF2_ADDR_SIZE;
!   size += 2 * DWARF2_ADDR_SIZE * arange_table_in_use;
  
    /* Count the two zero words used to terminated the address range table.  */
!   size += 2 * DWARF2_ADDR_SIZE;
    return size;
  }
  
***************
*** 5338,5344 ****
  	     ASM_COMMENT_START);
  
    fputc ('\n', asm_out_file);
!   ASM_OUTPUT_DWARF_DATA1 (asm_out_file, PTR_SIZE);
    if (flag_debug_asm)
      fprintf (asm_out_file, "\t%s Pointer Size (in bytes)", ASM_COMMENT_START);
  
--- 5353,5359 ----
  	     ASM_COMMENT_START);
  
    fputc ('\n', asm_out_file);
!   ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DWARF2_ADDR_SIZE);
    if (flag_debug_asm)
      fprintf (asm_out_file, "\t%s Pointer Size (in bytes)", ASM_COMMENT_START);
  
***************
*** 5492,5498 ****
  	     ASM_COMMENT_START);
  
    fputc ('\n', asm_out_file);
!   ASM_OUTPUT_DWARF_DATA1 (asm_out_file, PTR_SIZE);
    if (flag_debug_asm)
      fprintf (asm_out_file, "\t%s Size of Address", ASM_COMMENT_START);
  
--- 5507,5513 ----
  	     ASM_COMMENT_START);
  
    fputc ('\n', asm_out_file);
!   ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DWARF2_ADDR_SIZE);
    if (flag_debug_asm)
      fprintf (asm_out_file, "\t%s Size of Address", ASM_COMMENT_START);
  
***************
*** 5515,5521 ****
  
    if (flag_debug_asm)
      fprintf (asm_out_file, "\t%s Pad to %d byte boundary",
! 	     ASM_COMMENT_START, 2 * PTR_SIZE);
  
    fputc ('\n', asm_out_file);
    ASM_OUTPUT_DWARF_ADDR (asm_out_file, text_section_label);
--- 5530,5536 ----
  
    if (flag_debug_asm)
      fprintf (asm_out_file, "\t%s Pad to %d byte boundary",
! 	     ASM_COMMENT_START, 2 * DWARF2_ADDR_SIZE);
  
    fputc ('\n', asm_out_file);
    ASM_OUTPUT_DWARF_ADDR (asm_out_file, text_section_label);
***************
*** 5757,5769 ****
  	}
        else
  	{
! 	  /* This can handle any delta.  This takes 4+PTR_SIZE bytes.  */
  	  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
  	  if (flag_debug_asm)
  	    fprintf (asm_out_file, "\t%s DW_LNE_set_address",
  		     ASM_COMMENT_START);
  	  fputc ('\n', asm_out_file);
! 	  output_uleb128 (1 + PTR_SIZE);
  	  fputc ('\n', asm_out_file);
  	  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
  	  fputc ('\n', asm_out_file);
--- 5772,5785 ----
  	}
        else
  	{
! 	  /* This can handle any delta.  This takes
!              4+DWARF2_ADDR_SIZE bytes.  */
  	  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
  	  if (flag_debug_asm)
  	    fprintf (asm_out_file, "\t%s DW_LNE_set_address",
  		     ASM_COMMENT_START);
  	  fputc ('\n', asm_out_file);
! 	  output_uleb128 (1 + DWARF2_ADDR_SIZE);
  	  fputc ('\n', asm_out_file);
  	  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
  	  fputc ('\n', asm_out_file);
***************
*** 5855,5861 ****
        if (flag_debug_asm)
  	fprintf (asm_out_file, "\t%s DW_LNE_set_address", ASM_COMMENT_START);
        fputc ('\n', asm_out_file);
!       output_uleb128 (1 + PTR_SIZE);
        fputc ('\n', asm_out_file);
        ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
        fputc ('\n', asm_out_file);
--- 5871,5877 ----
        if (flag_debug_asm)
  	fprintf (asm_out_file, "\t%s DW_LNE_set_address", ASM_COMMENT_START);
        fputc ('\n', asm_out_file);
!       output_uleb128 (1 + DWARF2_ADDR_SIZE);
        fputc ('\n', asm_out_file);
        ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
        fputc ('\n', asm_out_file);
***************
*** 5907,5913 ****
  		     ASM_COMMENT_START);
  
  	  fputc ('\n', asm_out_file);
! 	  output_uleb128 (1 + PTR_SIZE);
  	  fputc ('\n', asm_out_file);
  	  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
  	  fputc ('\n', asm_out_file);
--- 5923,5929 ----
  		     ASM_COMMENT_START);
  
  	  fputc ('\n', asm_out_file);
! 	  output_uleb128 (1 + DWARF2_ADDR_SIZE);
  	  fputc ('\n', asm_out_file);
  	  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
  	  fputc ('\n', asm_out_file);
***************
*** 5936,5942 ****
  		fprintf (asm_out_file, "\t%s DW_LNE_set_address",
  			 ASM_COMMENT_START);
  	      fputc ('\n', asm_out_file);
! 	      output_uleb128 (1 + PTR_SIZE);
  	      fputc ('\n', asm_out_file);
  	      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
  	      fputc ('\n', asm_out_file);
--- 5952,5958 ----
  		fprintf (asm_out_file, "\t%s DW_LNE_set_address",
  			 ASM_COMMENT_START);
  	      fputc ('\n', asm_out_file);
! 	      output_uleb128 (1 + DWARF2_ADDR_SIZE);
  	      fputc ('\n', asm_out_file);
  	      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
  	      fputc ('\n', asm_out_file);
***************
*** 6038,6044 ****
  		fprintf (asm_out_file, "\t%s DW_LNE_set_address",
  			 ASM_COMMENT_START);
  	      fputc ('\n', asm_out_file);
! 	      output_uleb128 (1 + PTR_SIZE);
  	      fputc ('\n', asm_out_file);
  	      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
  	      fputc ('\n', asm_out_file);
--- 6054,6060 ----
  		fprintf (asm_out_file, "\t%s DW_LNE_set_address",
  			 ASM_COMMENT_START);
  	      fputc ('\n', asm_out_file);
! 	      output_uleb128 (1 + DWARF2_ADDR_SIZE);
  	      fputc ('\n', asm_out_file);
  	      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
  	      fputc ('\n', asm_out_file);
Index: gcc/config/generic/generic.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/config/generic/generic.h,v
retrieving revision 1.46
diff -c -r1.46 generic.h
*** gcc/config/generic/generic.h	2000/02/14 15:58:35	1.46
--- gcc/config/generic/generic.h	2000/04/10 18:46:30
***************
*** 4952,4957 ****
--- 4952,4968 ----
     Defined in svr4.h.  */
  /* #define DWARF2_DEBUGGING_INFO */
  
+ /* Define this macro if addresses in Dwarf 2 debugging info should not
+    be the same size as pointers on the target architecture.  The
+    macro's value should be the size, in bytes, to use for addresses in
+    the debugging info.
+ 
+    Some architectures use word addresses to refer to code locations,
+    but Dwarf 2 info always uses byte addresses.  On such machines,
+    Dwarf 2 addresses need to be larger than the architecture's
+    pointers.  */
+ /* #define DWARF2_ADDR_SIZE */
+ 
  /* Define these macros to override the assembler syntax for the special SDB
     assembler directives.  See `sdbout.c' for a list of these macros and their
     arguments.  If the standard syntax is used, you need not define them

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