[comp.sys.amiga] SetExcept

scott@applix.UUCP (Scott Evernden) (07/13/87)

Can anyone help me?

I am trying to use SetExcept() to capture some keyboard signals.  I
would like to know what, if any, are the problems associated with
longjmp()'ing out of the exception handling code.  Is this legal?
Should it work?

Don't groan too loudly.  Not feeling real cool messing in gross ways
with my stack, I normally try to avoid set/longjmp().  I myself wouldn't
try to do this sort of thing.  But the CM/LSRHS LOGO recently posted to
comp.sources.unix, which I've ported to the Amiga, does.

I have tried doing this longjmp() trick, and things actually seem to
proceed OK - for a while.  DOS calls even seem to work.  I'm having some
difficulty locating the exact point of failure (the machine completely
locks up), but it looks like somewhere in the kernel Read() routine (for
next user input).

I've noticed, however, while using the MANX DB debugger, that the
IDNestCnt of my task seems to go up and never come down.  Is this a
characteristic of the debugger, or what I am attempting to do?  Should
I be concerned about this?

If I can longjmp(), can I call SetExcept() again?  Or should/can I adjust
the Task's tc_SigExcept directly?

Are there other things about SetExcept() or the associated Task structure
fields I should know?  For example, I've discovered that it's quite
important to record and restore the original contents of the
tc_ExceptCode/Data fields (now it seems obvious), as well as the
original tc_SigExcept mask.

thanks
-scott

ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) (07/15/87)

In article <545@applix.UUCP> scott@applix.UUCP (Scott Evernden) writes:
>I am trying to use SetExcept() to capture some keyboard signals.  I
>would like to know what, if any, are the problems associated with
>longjmp()'ing out of the exception handling code.  Is this legal?
>Should it work?
>
	Unlikely.  When the exception vector gets called, *all processor
registers* are pushed on the stack, and the exception handler is called.
This means that, eventually, the stack may exhaust itself back to the
register list on the stack.  Also, if the exception routine itself ever
manages to return back to the exception dispatcher, the dispatcher will
attempt to reload the CPU registers with garbage.

	I tried using an exception handler to trap a ^C interrupt, and then
clean up and exit.  Part of exiting is flushing the stack.  So all the
cleanup code worked great, but when exit() got called, the stack got
flushed, destroying the register list, and then tried to return to the DOS.
Somewhere, a guru happened, and I didn't feel like massaging the stack to
make it happen neatly.  Sigh.

	I guess the moral is that exceptions should always return invisibly,
and not try to do anything cute.  I'll study this in more detail when the
mood strikes me....

P.S:	This is off the top of my head, and I'm not thinking too hard at
	the moment.  Please forgive any inaccuracies...
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Leo L. Schwab -- The Guy in The Cape	ihnp4!ptsfa -\
 \_ -_	 Bike shrunk by popular demand,	      dual ---> !{well,unicom}!ewhac
O----^o	 But it's still the only way to fly.  hplabs / (pronounced "AE-wack")
"Work FOR?  I don't work FOR anybody!  I'm just having fun."  -- The Doctor

phillip@cbmvax.UUCP (Phillip Lindsay GUEST) (07/17/87)

in article <545@applix.UUCP>, scott@applix.UUCP (Scott Evernden) says:
> 
> Can anyone help me?
...
> I've noticed, however, while using the MANX DB debugger, that the
> IDNestCnt of my task seems to go up and never come down.  Is this a
> characteristic of the debugger, or what I am attempting to do?  Should
> I be concerned about this?
Yes you should be concerned... Unfortunately there is no protection in
things like the graphics.library for exec/exceptions....so while some
routine in the graphics.library has you Disable()'d an exception grabs
you throws someplace while in that state. ( IDNestCnt == Interrupt 
diabled next count ) This being my best guess of what is going on...
-phil
==============================================================================
Phillip (Flip) Lindsay - Wake up and watch CNN at: Heather Ridge Apts. #G-115
UUCP: {ihnp4|seismo|caip}!cbmvax!phillip           Mantua, NJ 08051
No warranty is implied or otherwise given in the 
form of suggestion or example. Any opinions found here are of my making.