dwarf2 EH unwinding

Andreas Schwab schwab@issan.informatik.uni-dortmund.de
Fri Sep 19 01:51:00 GMT 1997


Jason Merrill <jason@cygnus.com> writes:

|> I just checked in the code to add a third EH mechanism, which uses static
|> data to unwind from exceptions.  This information is written out in the
|> format specified by the DWARF v2 debugging information spec, with some
|> slight modifications necessary for putting it in a loaded section.

|> This code currently works on the x86, SPARC and MIPS.

Here's a patch to add the necessary bits for supporting it on the m68k.


1997-09-19  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* config/m68k/m68k.c (output_function_prologue): Add dwarf2 support.

	* config/m68k/m68k.h (INCOMING_RETURN_ADDR_RTX,
	DWARF_FRAME_RETURN_COLUMN, INCOMING_FRAME_SP_OFFSET): New
	definitions.

*** egcs-970917/gcc/config/m68k/m68k.c.~2~	Wed Jul 23 18:32:34 1997
--- egcs-970917/gcc/config/m68k/m68k.c	Fri Sep 19 00:02:39 1997
*************** output_function_prologue (stream, size)
*** 164,169 ****
--- 164,170 ----
    int num_saved_regs = 0;
    extern char call_used_regs[];
    int fsize = (size + 3) & -4;
+   int cfa_offset = INCOMING_FRAME_SP_OFFSET, cfa_store_offset = cfa_offset;
    
  
    if (frame_pointer_needed)
*************** output_function_prologue (stream, size)
*** 212,217 ****
--- 213,228 ----
  		       reg_names[FRAME_POINTER_REGNUM], -fsize);
  #endif
  	}
+       if (dwarf2out_do_frame ())
+ 	{
+ 	  char *l = (char *) dwarf2out_cfi_label ();
+ 	  cfa_store_offset += 4;
+ 	  cfa_offset = cfa_store_offset;
+ 	  dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, cfa_offset);
+ 	  dwarf2out_reg_save (l, FRAME_POINTER_REGNUM, -cfa_store_offset);
+ 	  dwarf2out_def_cfa ("", FRAME_POINTER_REGNUM, cfa_offset);
+ 	  cfa_store_offset += fsize;
+ 	}
      }
    else if (fsize)
      {
*************** output_function_prologue (stream, size)
*** 282,287 ****
--- 293,304 ----
  	  asm_fprintf (stream, "\taddl %0I%d,%Rsp\n", - (fsize + 4));
  #endif
  	}
+       if (dwarf2out_do_frame ())
+ 	{
+ 	  cfa_store_offset += fsize;
+ 	  cfa_offset = cfa_store_offset;
+ 	  dwarf2out_def_cfa ("", STACK_POINTER_REGNUM, cfa_offset);
+ 	}
      }
  #ifdef SUPPORT_SUN_FPA
    for (regno = 24; regno < 56; regno++)
*************** output_function_prologue (stream, size)
*** 294,306 ****
  	asm_fprintf (stream, "\tfpmoved %s,%Rsp@-\n",
  		     reg_names[regno]);
  #endif
        }
  #endif
    if (TARGET_68881)
      {
        for (regno = 16; regno < 24; regno++)
  	if (regs_ever_live[regno] && ! call_used_regs[regno])
! 	   mask |= 1 << (regno - 16);
        if ((mask & 0xff) != 0)
  	{
  #ifdef MOTOROLA
--- 311,337 ----
  	asm_fprintf (stream, "\tfpmoved %s,%Rsp@-\n",
  		     reg_names[regno]);
  #endif
+ 	if (dwarf2out_do_frame ())
+ 	  {
+ 	    char *l = (char *) dwarf2out_cfi_label ();
+ 	    cfa_store_offset += 8;
+ 	    if (! frame_pointer_needed)
+ 	      {
+ 		cfa_offset = cfa_store_offset;
+ 		dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, cfa_offset);
+ 	      }
+ 	    dwarf2out_reg_save (l, regno, -cfa_store_offset);
+ 	  }
        }
  #endif
    if (TARGET_68881)
      {
        for (regno = 16; regno < 24; regno++)
  	if (regs_ever_live[regno] && ! call_used_regs[regno])
! 	  {
! 	    mask |= 1 << (regno - 16);
! 	    num_saved_regs++;
! 	  }
        if ((mask & 0xff) != 0)
  	{
  #ifdef MOTOROLA
*************** output_function_prologue (stream, size)
*** 308,315 ****
--- 339,362 ----
  #else
  	  asm_fprintf (stream, "\tfmovem %0I0x%x,%Rsp@-\n", mask & 0xff);
  #endif
+ 	  if (dwarf2out_do_frame ())
+ 	    {
+ 	      char *l = (char *) dwarf2out_cfi_label ();
+ 	      int n_regs;
+ 	      cfa_store_offset += num_saved_regs * 12;
+ 	      if (! frame_pointer_needed)
+ 		{
+ 		  cfa_offset = cfa_store_offset;
+ 		  dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, cfa_offset);
+ 		}
+ 	      for (regno = 16, n_regs = 0; regno < 24; regno++)
+ 		if (mask & (1 << (regno - 16)))
+ 		  dwarf2out_reg_save (l, regno,
+ 				      -cfa_store_offset + n_regs++ * 12);
+ 	    }
  	}
        mask = 0;
+       num_saved_regs = 0;
      }
    for (regno = 0; regno < 16; regno++)
      if (regs_ever_live[regno] && ! call_used_regs[regno])
*************** output_function_prologue (stream, size)
*** 347,359 ****
        /* Undo the work from above. */
        for (i = 0; i< 16; i++)
          if (mask & (1 << i))
!           asm_fprintf (stream,
  #ifdef MOTOROLA
! 		       "\t%Omove.l %s,-(%Rsp)\n",
  #else
! 		       "\tmovel %s,%Rsp@-\n",
  #endif
! 		       reg_names[15 - i]);
      }
    else if (mask)
      {
--- 394,419 ----
        /* Undo the work from above. */
        for (i = 0; i< 16; i++)
          if (mask & (1 << i))
! 	  {
! 	    asm_fprintf (stream,
  #ifdef MOTOROLA
! 			 "\t%Omove.l %s,-(%Rsp)\n",
  #else
! 			 "\tmovel %s,%Rsp@-\n",
  #endif
! 			 reg_names[15 - i]);
! 	    if (dwarf2out_do_frame ())
! 	      {
! 		char *l = (char *) dwarf2out_cfi_label ();
! 		cfa_store_offset += 4;
!  		if (! frame_pointer_needed)
!  		  {
!  		    cfa_offset = cfa_store_offset;
!  		    dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, cfa_offset);
!  		  }
!  		dwarf2out_reg_save (l, 15 - i, -cfa_store_offset);
! 	      }
! 	  }
      }
    else if (mask)
      {
*************** output_function_prologue (stream, size)
*** 391,396 ****
--- 451,471 ----
  #else
  	  asm_fprintf (stream, "\tmoveml %0I0x%x,%Rsp@-\n", mask);
  #endif
+ 	}
+       if (dwarf2out_do_frame ())
+ 	{
+ 	  char *l = (char *) dwarf2out_cfi_label ();
+ 	  int n_regs;
+ 	  cfa_store_offset += num_saved_regs * 4;
+ 	  if (! frame_pointer_needed)
+ 	    {
+ 	      cfa_offset = cfa_store_offset;
+ 	      dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, cfa_offset);
+ 	    }
+ 	  for (regno = 0, n_regs = 0; regno < 16; regno++)
+ 	    if (mask & (1 << (15 - regno)))
+ 	      dwarf2out_reg_save (l, regno,
+ 				  -cfa_store_offset + n_regs++ * 4);
  	}
      }
    if (flag_pic && current_function_uses_pic_offset_table)
*** egcs-970917/gcc/config/m68k/m68k.h.~2~	Sat Sep 13 01:41:31 1997
--- egcs-970917/gcc/config/m68k/m68k.h	Fri Sep 19 00:07:01 1997
*************** __transfer_from_trampoline ()					\
*** 1792,1797 ****
--- 1792,1807 ----
  
  #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2)
  
+ /* Before the prologue, RA is at 0(%sp).  */
+ #define INCOMING_RETURN_ADDR_RTX \
+   gen_rtx (MEM, VOIDmode, gen_rtx (REG, VOIDmode, STACK_POINTER_REGNUM))
+ 
+ /* PC is dbx register 17; let's use that column for RA. */
+ #define DWARF_FRAME_RETURN_COLUMN 17
+ 
+ /* Before the prologue, the top of the frame is at 4(%sp).  */
+ #define INCOMING_FRAME_SP_OFFSET 4
+ 
  /* This is how to output the definition of a user-level label named NAME,
     such as the label on a static function or variable NAME.  */
  



More information about the Gcc mailing list