X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=ffi%2Ftrap.c;h=301f2060ce47f5252bb4d2dfd73112efa069d9a7;hb=13cf9f65321881050edb99776f29eea8580ec457;hp=e0878b2bb0a296989934bf48b9314c355fb0d0df;hpb=7f54316f216f6508e8d6d5b37bed49350fc0d14e;p=mate.git diff --git a/ffi/trap.c b/ffi/trap.c index e0878b2..301f206 100644 --- a/ffi/trap.c +++ b/ffi/trap.c @@ -1,5 +1,6 @@ #include #include +#include #include "../debug.h" @@ -21,8 +22,7 @@ #include -unsigned int mallocObject(int); -unsigned int mateHandler(unsigned int, unsigned int, unsigned int, unsigned int); +ptrdiff_t mateHandler(ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t); #ifdef DBG_TRAP #define dprintf(args...) do { printf (args); } while (0); @@ -30,19 +30,17 @@ unsigned int mateHandler(unsigned int, unsigned int, unsigned int, unsigned int) #define dprintf(args...) #endif -void mainresult(unsigned int a) -{ - dprintf("mainresult: 0x%08x\n", a); -} - void chandler(int nSignal, siginfo_t *info, void *ctx) { mcontext_t *mctx = &((ucontext_t *) ctx)->uc_mcontext; - unsigned int eip = (unsigned int) mctx->gregs[REG_EIP]; - unsigned int eax = (unsigned int) mctx->gregs[REG_EAX]; - unsigned int ebx = (unsigned int) mctx->gregs[REG_EBX]; - unsigned int esp = (unsigned int) mctx->gregs[REG_ESP]; + ptrdiff_t eip = (ptrdiff_t) mctx->gregs[REG_EIP]; + ptrdiff_t eax = (ptrdiff_t) mctx->gregs[REG_EAX]; + ptrdiff_t ebx = (ptrdiff_t) mctx->gregs[REG_EBX]; + ptrdiff_t esp = (ptrdiff_t) mctx->gregs[REG_ESP]; + dprintf("trap: type %d, eip 0x%08x, eax 0x%08x, ebx 0x%08x, " + "esp 0x%08x, *esp 0x%08x\n", nSignal, eip, + eax, ebx, esp, *(ptrdiff_t*) esp); mctx->gregs[REG_EIP] = mateHandler(eip, eax, ebx, esp); } @@ -61,13 +59,3 @@ void register_signal(void) segvaction.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER; sigaction(SIGSEGV, &segvaction, NULL); } - -unsigned int getaddr(void) -{ - return (unsigned int) mainresult; -} - -unsigned int getMallocObjectAddr(void) -{ - return (unsigned int) mallocObject; -}