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 for .debug_frame


Hi,

Please, comment on the following patch (against 3.0).

What it does:

I. In dwarf2out_frame_finish enables the output of the .debug_frame
   section.

II. Makes sure that the CFA offset is output with
    DWARF_CIE_DATA_ALIGNMENT factored out as specified by DWARF2:
   
    " ... A signed LEB128 constant that is factored out of all offset
    instructions ..."

The patch doesn't change the values of DW_CFA_GNU_window_size and
DW_CFA_GNU_args_size (I hope).  The patch keeps the invariants that
dw_cfi_offset hold factored offset and dw_cfa_location.offset a full
one.

There remains the question about the sign of the CFA offset. I have
made the compiler output positive CFA offsets when data alignment is
negative, because (1) it takes less space in the file and (2) it
matches two other compilers, whose developers might have had better
idea of DWARF2 than me. Anyway, it doesn't matter for DWARF2 readers
(including me) since they can always flip the sign of the CFA offset
to make it different from the data alignment.

III. Puts offset check in a separate function and calls it all over the place.  

I'll, of course, provide change logs, when/if we resolve the above
question and you decide the patch is worth including.

Regards,
-velco

Oh, and, by the way, how about inline keyword? Is it allowed in the
GCC source?

Index: gcc/dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.242.2.2
diff -c -3 -p -r1.242.2.2 dwarf2out.c
*** dwarf2out.c	2001/02/21 14:56:06	1.242.2.2
--- dwarf2out.c	2001/03/12 15:07:59
*************** static void get_cfa_from_loc_descr 	PARA
*** 253,258 ****
--- 253,259 ----
  static struct dw_loc_descr_struct *build_cfa_loc
  					PARAMS ((dw_cfa_location *));
  static void def_cfa_1		 	PARAMS ((const char *, dw_cfa_location *));
+ static void check_offset		PARAMS ((long int));
  
  /* Definitions of defaults for assembler-dependent names of various
     pseudo-ops and section names.
*************** lookup_cfa_1 (cfi, loc)
*** 801,814 ****
    switch (cfi->dw_cfi_opc)
      {
      case DW_CFA_def_cfa_offset:
!       loc->offset = cfi->dw_cfi_oprnd1.dw_cfi_offset;
        break;
      case DW_CFA_def_cfa_register:
        loc->reg = cfi->dw_cfi_oprnd1.dw_cfi_reg_num;
        break;
      case DW_CFA_def_cfa:
        loc->reg = cfi->dw_cfi_oprnd1.dw_cfi_reg_num;
!       loc->offset = cfi->dw_cfi_oprnd2.dw_cfi_offset;
        break;
      case DW_CFA_def_cfa_expression:
        get_cfa_from_loc_descr (loc, cfi->dw_cfi_oprnd1.dw_cfi_loc);
--- 802,815 ----
    switch (cfi->dw_cfi_opc)
      {
      case DW_CFA_def_cfa_offset:
!       loc->offset = - cfi->dw_cfi_oprnd1.dw_cfi_offset * DWARF_CIE_DATA_ALIGNMENT;
        break;
      case DW_CFA_def_cfa_register:
        loc->reg = cfi->dw_cfi_oprnd1.dw_cfi_reg_num;
        break;
      case DW_CFA_def_cfa:
        loc->reg = cfi->dw_cfi_oprnd1.dw_cfi_reg_num;
!       loc->offset = - cfi->dw_cfi_oprnd2.dw_cfi_offset * DWARF_CIE_DATA_ALIGNMENT;
        break;
      case DW_CFA_def_cfa_expression:
        get_cfa_from_loc_descr (loc, cfi->dw_cfi_oprnd1.dw_cfi_loc);
*************** dwarf2out_def_cfa (label, reg, offset)
*** 873,878 ****
--- 874,896 ----
    def_cfa_1 (label, &loc);
  }
  
+ static void
+ check_offset (offset)
+      long int offset ATTRIBUTE_UNUSED;
+ {
+ #ifdef ENABLE_CHECKING
+   if (ENABLE_CHECKING)
+     {
+       /* If we get an offset that is not a multiple of
+          DWARF_CIE_DATA_ALIGNMENT, there is either a bug in the
+          definition of DWARF_CIE_DATA_ALIGNMENT, or a bug in the
+          machine description.  */
+       if (offset % DWARF_CIE_DATA_ALIGMENT)
+ 	abort ();
+     }
+ #endif
+ }
+ 
  /* This routine does the actual work.  The CFA is now calculated from
     the dw_cfa_location structure.  */
  static void
*************** def_cfa_1 (label, loc_p)
*** 909,916 ****
        /* Construct a "DW_CFA_def_cfa_offset <offset>" instruction,
  	 indicating the CFA register did not change but the offset
  	 did.  */
        cfi->dw_cfi_opc = DW_CFA_def_cfa_offset;
!       cfi->dw_cfi_oprnd1.dw_cfi_offset = loc.offset;
      }
  
  #ifndef MIPS_DEBUGGING_INFO  /* SGI dbx thinks this means no offset.  */
--- 927,935 ----
        /* Construct a "DW_CFA_def_cfa_offset <offset>" instruction,
  	 indicating the CFA register did not change but the offset
  	 did.  */
+       check_offset (loc.offset);
        cfi->dw_cfi_opc = DW_CFA_def_cfa_offset;
!       cfi->dw_cfi_oprnd1.dw_cfi_offset = - loc.offset / DWARF_CIE_DATA_ALIGNMENT;
      }
  
  #ifndef MIPS_DEBUGGING_INFO  /* SGI dbx thinks this means no offset.  */
*************** def_cfa_1 (label, loc_p)
*** 930,938 ****
        /* Construct a "DW_CFA_def_cfa <register> <offset>" instruction,
  	 indicating the CFA register has changed to <register> with
  	 the specified offset.  */
        cfi->dw_cfi_opc = DW_CFA_def_cfa;
        cfi->dw_cfi_oprnd1.dw_cfi_reg_num = loc.reg;
!       cfi->dw_cfi_oprnd2.dw_cfi_offset = loc.offset;
      }
    else
      {
--- 949,958 ----
        /* Construct a "DW_CFA_def_cfa <register> <offset>" instruction,
  	 indicating the CFA register has changed to <register> with
  	 the specified offset.  */
+       check_offset (loc.offset);
        cfi->dw_cfi_opc = DW_CFA_def_cfa;
        cfi->dw_cfi_oprnd1.dw_cfi_reg_num = loc.reg;
!       cfi->dw_cfi_oprnd2.dw_cfi_offset = - loc.offset / DWARF_CIE_DATA_ALIGNMENT;
      }
    else
      {
*************** reg_save (label, reg, sreg, offset)
*** 975,992 ****
        else
  	cfi->dw_cfi_opc = DW_CFA_offset;
  
! #ifdef ENABLE_CHECKING
!       {
! 	/* If we get an offset that is not a multiple of
! 	   DWARF_CIE_DATA_ALIGNMENT, there is either a bug in the
! 	   definition of DWARF_CIE_DATA_ALIGNMENT, or a bug in the machine
! 	   description.  */
! 	long check_offset = offset / DWARF_CIE_DATA_ALIGNMENT;
  
- 	if (check_offset * DWARF_CIE_DATA_ALIGNMENT != offset)
- 	  abort ();
-       }
- #endif
        offset /= DWARF_CIE_DATA_ALIGNMENT;
        if (offset < 0)
  	{
--- 995,1002 ----
        else
  	cfi->dw_cfi_opc = DW_CFA_offset;
  
!       check_offset (offset);
  
        offset /= DWARF_CIE_DATA_ALIGNMENT;
        if (offset < 0)
  	{
*************** void
*** 2313,2328 ****
  dwarf2out_frame_finish ()
  {
    /* Output call frame information.  */
- #ifdef MIPS_DEBUGGING_INFO
    if (write_symbols == DWARF2_DEBUG)
      output_call_frame_info (0);
    if (flag_unwind_tables || (flag_exceptions && ! exceptions_via_longjmp))
      output_call_frame_info (1);
- #else
-   if (write_symbols == DWARF2_DEBUG
-       || flag_unwind_tables || (flag_exceptions && ! exceptions_via_longjmp))
-     output_call_frame_info (1);
- #endif
  }
  
  /* And now, the subset of the debugging information support code necessary
--- 2323,2332 ----


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