This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


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

C++ exceptions on m68k-wrs-vxworks, gcc 2.95


I have built gcc 2.95 for a cross compiler from Solaris to a 68k on 
VxWorks.   My main interest is C++ and I have got most of it working.  
The big exception is "c++ exceptions".  


As far as I can tell, most of the basic exception functionality is 
working and when a "throw" occurs, the routine __throw from libgcc2.c 
is invoked.   This is at the bottom of the note, for reference.

__throw() function is calling __terminate() after the call to 
__frame_state_for(&&label, my_udate_);


This suggests to me that it is not finding the exception frame 
information.  

The except.c module seems to suggest that this information is available 
in a static array named __EXCEPTION_TABLE__ in each module.  I checked 
and this symbol is available, but the function "__register_exceptions" 
does not exist in libgcc2.a, suggesting I have DWARF 2 frame unwind 
information (since __register_exceptions is only needed if not using 
DWARF 2).  

All this is suggesting to me that I have to call something to register 
exception tables/frame information, something like "__register_frame" 
from frame.c.  But I have not been able to confirm the.  I have tried 
doing it, using code like this

    asm("pea ___FRAME_BEGIN__");
    asm("jbsr ___register_frame");

Which does compile and link ok.  I call this as part of initialization 
(the program is in only one module at the moment).  But this changes 
nothing.


Am I calling the wrong thing?


Or is my argument wrong?


Or am I totally off the track


Or does it simply not work?


Thanks
Tony.
-------------------------------------------------------
Tony Farrell                  Phone +61 2 9372 4826
Software Group Leader         Fax   +61 2 9372 4880
Anglo-Australian Observatory  Email tjf@aaoepp.aao.gov.au



__throw() as extracted from libgcc2.c.

/* We first search for an exception handler, and if we don't find
   it, we call __terminate on the current stack frame so that we may
   use the debugger to walk the stack and understand why no handler
   was found.

   If we find one, then we unwind the frames down to the one that
   has the handler and transfer control into the handler.  */

/*extern void __throw(void) __attribute__ ((__noreturn__));*/

void
__throw ()
{
  struct eh_context *eh = (*get_eh_context) ();
  void *pc, *handler;
  long offset;

  /* XXX maybe make my_ustruct static so we don't have to look it up for
     each throw.  */
  frame_state my_ustruct, *my_udata = &my_ustruct;

  /* This is required for C++ semantics.  We must call terminate if we
     try and rethrow an exception, when there is no exception currently
     active.  */
  if (! eh->info)
    __terminate ();
    
  /* Start at our stack frame.  */
label:
  my_udata = __frame_state_for (&&label, my_udata);
  if (! my_udata)
    __terminate ();

  /* We need to get the value from the CFA register. */
  my_udata->cfa = __builtin_dwarf_cfa ();

  /* Do any necessary initialization to access arbitrary stack frames.
     On the SPARC, this means flushing the register windows.  */
  __builtin_unwind_init ();

  /* Now reset pc to the right throw point.  */
  pc = __builtin_extract_return_addr (__builtin_return_address (0)) - 1;

  handler = throw_helper (eh, pc, my_udata, &offset);

  /* Now go!  */

  __builtin_eh_return ((void *)eh, offset, handler);

  /* Epilogue:  restore the handler frame's register values and return
     to the stub.  */
}




------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


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