This is the mail archive of the gcc@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]

trying to glue Modula-3 onto egcs table based exception handling support


Hi,

I succeeded to glue the SRC Modula-3 front-end onto gcc 2.95.2 table
based excetion handling support. Or so I thought, as it blew up in my
face when I turned on -O optimizations.  My lack of integration with the
gcc backend caused the optimizations to nuke my exception handlers.

Just to get things working I built a special __m3throw() handler that
would find the correct exception handler.  Further, I did not use the
expand_eh_region_start(), expand_eh_region_end(), etc. calls.  I suppose
at this point all of you will tell me: "what a big mistake, Marc!".  Ok,
I see my wrong doings and would now like to do it properly. 

I've read the comments at the beginning of except.c as well as the
Exception Handling text from
http://gcc.gnu.org/onlinedocs/gxxint_1.html#SEC13.  Unfortunately, I
have not succeeded to get things to work according to that
documentation.  I am hoping that someone on this list could help me.

Here is what I am doing for Modula-3 exception handling:

The syntax of a simple M3 try-catch block is:

TRY
  stmts
EXCEPT
| ExceptionName =>
  stmts
END;

When I see the "TRY" I do the following:
  expand_eh_region_start();
The subsequent statements are then part of the try-block.

When I see the EXCEPT I do:
  expand_start_all_catch();
  start_catch_handler(NULL_TREE); /* ignore the exact arg for now */
The subsequent statements are then part of the catch-block.

When I see the END I do:
  end_catch_handler();
  expand_end_all_catch();

At the end of the procedure I check if the global variable
"catch_clauses" and emit its instructions: 
  if (catch_clauses) {
	rtx funcend = gen_label_rtx();
	emit_jump (funcend);
	emit_insn (catch_clauses);
	catch_clauses = NULL_RTX;
	expand_leftover_cleanups ();
	emit_label (funcend);
  }

When I do all of this I run into one of two problems:

1) if compiling without optimizations I get an internal error 
SanityTest.m3:18: internal error--unrecognizable insn:
(insn 80 79 81 (note 48 0 49 11 NOTE_INSN_EH_REGION_BEG) -1 (nil)
    (nil))
from the gcc/recog.c:extract_insn().

2) if compiling with optimizations I get segmentation fault.  Well, for
the moment I'd be happy if I could figure out how to get (1) above to
work and then worry about this later.

Is there anyone out there that could help me understand what I am doing
wrong?!

Comments/Feedback/Help much appreciated!

Thanks,
Marc


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