Subject: Re: Emulation pointer wanted
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Todd Whitesel <firstname.lastname@example.org>
Date: 09/16/1999 04:08:28
> I expect this to be significantly harder to do, though it should be
> possible. Not in the first version. :-)
> Eventually, perhaps. Someone pointed out signal delivery, which I was
> going to punt on, but now realize I have to emulate it at least a
> little, because some programs use signals during normal operation (the
> commonest signals thus used are, I suspect, SIGALRM and SIGCHLD).
There are lots of ways to do this, some cheesier than others.
My favorite for all-out grossness is to just declare a huge flock of
signal handlers that all set global variables to 1 and return, and have
the emulator code check after every instruction (or every 100 instructions,
who cares). This works fine for asynchronous signals but for synchronous
ones (SEGV, FPE, EMT, etc.) you have to be prepared to twiddle the program
to deliver the (translated) signal and then longjmp back up to the top of
the emulation loop, so you can clean up your own state and start running
the actual signal handler.
toddpw @ best.com