mcontext_t *mctx = &((ucontext_t *) ctx)->uc_mcontext;
unsigned int from = (unsigned int) mctx->gregs[REG_EIP];
- mateTrapHandler(nSignal, info, ctx, from);
+ //mateTrapHandler(nSignal, info, ctx, from);
printf("from: 0x%08x\n", from);
exit(0);
}
-void registerSignalHandlers(void)
-{
- printf("registering\n");
- struct sigaction illaction;
- illaction.sa_sigaction = trap;
- sigemptyset(&illaction.sa_mask);
- illaction.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER;
- sigaction(SIGILL, &illaction, NULL);
-
-
-/*
- struct sigaction segvaction;
- segvaction.sa_sigaction = trap;
- sigemptyset(&segvaction.sa_mask);
- segvaction.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER;
- sigaction(SIGSEGV, &segvaction, NULL);
-*/
-}
-
void registerSignalHandlers2(void (*f)(int, siginfo_t*,void*))
{
-extern void registerSignalHandlers(void);
-extern void mateTrapHandler(unsigned int signal,
+//extern void registerSignalHandlers(void);
+/*extern void mateTrapHandler(unsigned int signal,
siginfo_t *sigInfo,
void *ctx,
unsigned int eip);
-
+*/
extern void registerSignalHandlers2(void (*f)(int, siginfo_t*,void*));
foreign import ccall "static stdlib.h"
memalign :: CUInt -> CUInt -> IO (Ptr a)
-foreign import ccall safe "prototypes.h"
- registerSignalHandlers :: IO ()
foreign import ccall "wrapper"
wrap :: (CUInt -> Ptr SigInfo -> Ptr Context -> IO ()) -> IO (FunPtr (CUInt -> Ptr SigInfo -> Ptr Context -> IO ()))
foreign import ccall "prototypes.h"
registerSignalHandlers2 :: FunPtr (CUInt -> Ptr SigInfo -> Ptr Context -> IO ()) -> IO ()
-foreign export ccall
- mateTrapHandler :: CUInt -> Ptr SigInfo -> Ptr Context -> CUInt -> IO ()
-
type SigInfo = ()
type Context = ()
runMateKernel _ = do
compileAndRun
+
-- use FFI to unpack sigInfo and ctx....
handler mateCtx signal sigInfo ctx = do
putStr "handler got me."
senseless :: IO Int
senseless = getStdRandom (randomR (1,100))
-
-
-mateTrapHandler :: CUInt -> Ptr SigInfo -> Ptr Context -> CUInt -> IO ()
-mateTrapHandler signal sigInfo ctx eip = do
- putStr "mateTrapHandler says: "
- let eip' = (fromIntegral eip) :: Int
- printf "source, eip: 0x%08x" eip'
- print eip'
-
-