コード例 #1
0
ファイル: decode.c プロジェクト: djmott/dynamorio
static void
signal_handler(int sig)
{
    if (sig == SIGILL) {
        count++;
        print("Bad instruction, instance %d\n", count);
        SIGLONGJMP(mark, count);
    } else if (sig == SIGSEGV) {
        count++;
        if (print_access_vio)
            print("Access violation, instance %d\n", count);
        SIGLONGJMP(mark, count);
    }
    exit(-1);
}
コード例 #2
0
void
throw_exception (struct gdb_exception exception)
{
  prepare_to_throw_exception ();

  do_cleanups (all_cleanups ());

#if GDB_XCPT == GDB_XCPT_SJMP
  /* Jump to the containing catch_errors() call, communicating REASON
     to that call via setjmp's return value.  Note that REASON can't
     be zero, by definition in defs.h.  */
  exceptions_state_mc (CATCH_THROWING);
  current_catcher->exception = exception;
  SIGLONGJMP (current_catcher->buf, exception.reason);
#else
  if (exception.reason == RETURN_QUIT)
    {
      gdb_exception_RETURN_MASK_QUIT ex;

      gdb_exception_sliced_copy (&ex, &exception);
      throw ex;
    }
  else if (exception.reason == RETURN_ERROR)
    {
      gdb_exception_RETURN_MASK_ERROR ex;

      gdb_exception_sliced_copy (&ex, &exception);
      throw ex;
    }
  else
    gdb_assert_not_reached ("invalid return reason");
#endif
}
コード例 #3
0
ファイル: ptsig.c プロジェクト: djmott/dynamorio
static void
signal_handler(int sig, siginfo_t *siginfo, ucontext_t *ucxt)
{
#if VERBOSE
    print("thread %d signal_handler: sig=%d, retaddr=" PFX ", fpregs=" PFX "\n", getpid(),
          sig, *(&sig - 1), ucxt->uc_mcontext.fpregs);
#endif

    switch (sig) {
    case SIGUSR1: {
        sigcontext_t *sc = SIGCXT_FROM_UCXT(ucxt);
        void *pc = (void *)sc->SC_XIP;
#if VERBOSE
        print("thread %d got SIGUSR1 @ " PFX "\n", getpid(), pc);
#endif
        break;
    }
    case SIGSEGV:
#if VERBOSE
        print("thread %d got SIGSEGV @ " PFX "\n", getpid(), pc);
#endif
        SIGLONGJMP(mark, 1);
        break;
    default: assert(0);
    }
}
コード例 #4
0
ファイル: drreg-test.c プロジェクト: pb2bee/dynamorio
static LONG WINAPI
handle_exception(struct _EXCEPTION_POINTERS *ep)
{
    if (ep->ExceptionRecord->ExceptionCode == EXCEPTION_ILLEGAL_INSTRUCTION) {
        if (ep->ContextRecord->TEST_REG_CXT != DRREG_TEST_3_C)
            print("ERROR: spilled register value was not preserved!\n");
    }
    SIGLONGJMP(mark, 1);
}
コード例 #5
0
ファイル: drreg-test.c プロジェクト: pb2bee/dynamorio
static void
handle_signal(int signal, siginfo_t *siginfo, ucontext_t *ucxt)
{
    if (signal == SIGILL) {
        struct sigcontext *sc = (struct sigcontext *) &(ucxt->uc_mcontext);
        if (sc->TEST_REG_SIG != DRREG_TEST_3_C)
            print("ERROR: spilled register value was not preserved!\n");
    }
    SIGLONGJMP(mark, 1);
}
コード例 #6
0
ファイル: retnonexisting.c プロジェクト: djmott/dynamorio
static void
signal_handler(int sig)
{
    if (sig == SIGSEGV) {
#    if VERY_VERBOSE
        print("Got seg fault\n");
#    endif
        SIGLONGJMP(mark, 1);
    }
    exit(-1);
}
コード例 #7
0
ファイル: decode-bad.c プロジェクト: AVGirl/dynamorio
/* top-level exception handler */
static LONG
our_top_handler(struct _EXCEPTION_POINTERS * pExceptionInfo)
{
    if (pExceptionInfo->ExceptionRecord->ExceptionCode ==
        /* Windows doesn't have an EXCEPTION_ constant to equal the invalid lock code */
        0xc000001e/*STATUS_INVALID_LOCK_SEQUENCE*/
        /* FIXME: DR doesn't generate the invalid lock exception */
        || (invalid_lock && pExceptionInfo->ExceptionRecord->ExceptionCode ==
            STATUS_ILLEGAL_INSTRUCTION)) {
        CONTEXT *cxt = pExceptionInfo->ContextRecord;
        count++;
        print("Invalid lock sequence, instance %d\n", count);
        /* FIXME : add CXT_XFLAGS (currently comes back incorrect), eip, esp? */
        print("eax="SZFMT" ebx="SZFMT" ecx="SZFMT" edx="SZFMT" "
              "edi="SZFMT" esi="SZFMT" ebp="SZFMT"\n",
              cxt->CXT_XAX, cxt->CXT_XBX, cxt->CXT_XCX, cxt->CXT_XDX,
              cxt->CXT_XDI, cxt->CXT_XSI, cxt->CXT_XBP);
        SIGLONGJMP(mark, count);
    }
    if (pExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ILLEGAL_INSTRUCTION) {
        count++;
        print("Bad instruction, instance %d\n", count);
        SIGLONGJMP(mark, count);
    }
    if (pExceptionInfo->ExceptionRecord->ExceptionCode ==
        STATUS_PRIVILEGED_INSTRUCTION) {
        count++;
        print("Privileged instruction, instance %d\n", count);
        SIGLONGJMP(mark, count);
    }
    /* Shouldn't get here in normal operation so this isn't #if VERBOSE */
    print("Exception 0x"PFMT" occurred, process about to die silently\n",
          pExceptionInfo->ExceptionRecord->ExceptionCode);
    if (pExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) {
        print("\tPC "PFX" tried to %s address "PFX"\n",
            pExceptionInfo->ExceptionRecord->ExceptionAddress,
            (pExceptionInfo->ExceptionRecord->ExceptionInformation[0]==0)?"read":"write",
            pExceptionInfo->ExceptionRecord->ExceptionInformation[1]);
    }
    return EXCEPTION_EXECUTE_HANDLER; /* => global unwind and silent death */
}
コード例 #8
0
ファイル: protect-dstack.c プロジェクト: AVGirl/dynamorio
/* the goal is to get DR to jmp to here by clobbering the fcache_return ret addr
 * on the dstack
 */
static void
evil()
{
    /* popf of DR's eflags (in old DR design) w/ our clobbered value could
     * set some funny flags -- clear them all here
     */
    clear_eflags();
    /* don't trusk stack -- hopefully enough there to call SIGLONGJMP
     * certainly can't return from this function since not called
     */
    SIGLONGJMP(mark, 2);
}
コード例 #9
0
ファイル: selfmod.c プロジェクト: AVGirl/dynamorio
static void
signal_handler(int sig, siginfo_t *siginfo, ucontext_t *ucxt)
{
    if (sig == SIGSEGV || sig == SIGILL) {
        sigcontext_t *sc = SIGCXT_FROM_UCXT(ucxt);
        if (sig == SIGILL)
            print("Illegal instruction\n");
        print_fault_code((unsigned char *)sc->SC_XIP);
        SIGLONGJMP(mark, count++);
    }
    exit(-1);
}
コード例 #10
0
ファイル: decode-bad.c プロジェクト: AVGirl/dynamorio
static void
signal_handler(int sig)
{
    if (sig == SIGILL) {
        count++;
        if (invalid_lock) {
            print("Invalid lock sequence, instance %d\n", count);
            /* add this so output matches test on windows, FIXME : would like to test
             * this on linux too, but won't work now (bug 651, 832) */
            print("eax=1 ebx=2 ecx=3 edx=4 edi=5 esi=6 ebp=7\n");
        } else
            print("Bad instruction, instance %d\n", count);
        SIGLONGJMP(mark, count);
    }
    if (sig == SIGSEGV) {
        count++;
        /* We can't distinguish but this is the only segv we expect */
        print("Privileged instruction, instance %d\n", count);
        SIGLONGJMP(mark, count);
    }
    exit(-1);
}
コード例 #11
0
ファイル: drreg-test.c プロジェクト: illera88/dynamorio
static void
handle_signal(int signal, siginfo_t *siginfo, ucontext_t *ucxt)
{
    if (signal == SIGILL) {
        sigcontext_t *sc = SIGCXT_FROM_UCXT(ucxt);
        if (sc->TEST_REG_SIG != DRREG_TEST_3_C)
            print("ERROR: spilled register value was not preserved!\n");
    } else if (signal == SIGSEGV) {
        sigcontext_t *sc = SIGCXT_FROM_UCXT(ucxt);
        if (((sc->TEST_FLAGS_SIG) & DRREG_TEST_AFLAGS_C) != DRREG_TEST_AFLAGS_C)
            print("ERROR: spilled flags value was not preserved!\n");
    }
    SIGLONGJMP(mark, 1);
}
コード例 #12
0
ファイル: retnonexisting.c プロジェクト: djmott/dynamorio
/* top-level exception handler */
static LONG
custom_top_handler(struct _EXCEPTION_POINTERS *pExceptionInfo)
{
    if (pExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) {
#    if VERY_VERBOSE
        print("Got segfault\n");
#    endif
        SIGLONGJMP(mark, 1);
    }
#    if VERBOSE
    print("Exception occurred, process about to die silently\n");
#    endif
    return EXCEPTION_EXECUTE_HANDLER; /* => global unwind and silent death */
}
コード例 #13
0
ファイル: selfmod.c プロジェクト: AVGirl/dynamorio
/* top-level exception handler */
static LONG
our_top_handler(struct _EXCEPTION_POINTERS * pExceptionInfo)
{
    if (pExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
        pExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ILLEGAL_INSTRUCTION) {
        if (pExceptionInfo->ExceptionRecord->ExceptionCode ==
            EXCEPTION_ILLEGAL_INSTRUCTION)
            print("Illegal instruction\n");
        print_fault_code((unsigned char *)
                         pExceptionInfo->ExceptionRecord->ExceptionAddress);
        SIGLONGJMP(mark, count++);
    }
    return EXCEPTION_EXECUTE_HANDLER; /* => global unwind and silent death */
}
コード例 #14
0
ファイル: protect-dstack.c プロジェクト: AVGirl/dynamorio
/* top-level exception handler */
static LONG
our_top_handler(struct _EXCEPTION_POINTERS * pExceptionInfo)
{
    if (pExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) {
# if VERBOSE
        /* DR gets the target addr wrong for far call/jmp so we don't print it */
        print("\tPC "PFX" tried to %s address "PFX"\n",
            pExceptionInfo->ExceptionRecord->ExceptionAddress,
            (pExceptionInfo->ExceptionRecord->ExceptionInformation[0]==0)?"read":"write",
            pExceptionInfo->ExceptionRecord->ExceptionInformation[1]);
# endif
        SIGLONGJMP(mark, 1);
    }
# if VERBOSE
    print("Exception occurred, process about to die silently\n");
# endif
    return EXCEPTION_EXECUTE_HANDLER; /* => global unwind and silent death */
}
コード例 #15
0
ファイル: fvwmsignal.c プロジェクト: ThomasAdam/fvwm-cvs
/*
 * fvwmSetTerminate - set the "end-of-execution" flag.
 * This function should ONLY be called at the end of a
 * signal handler. It is an integral part of the mechanism
 * to stop system calls from blocking once the process is
 * finished.
 *
 * NOTE: This is NOT a signal handler function in its own right!
 */
void
fvwmSetTerminate(int sig)
{
	BSD_BLOCK_SIGNALS;

	isTerminated = true;

	if (canJump)
	{
		canJump = false;

		/*
		 * This non-local jump is safe ONLY because we haven't called
		 * any non-reentrant functions in the short period where the
		 * "canJump" variable is true.
		 *
		 * NOTE: No need to restore the signal mask, since siglongjmp
		 *       is designed to do that for us.
		 */
		SIGLONGJMP(deadJump, SIG_DONE);
	}

	BSD_UNBLOCK_SIGNALS;
}
コード例 #16
0
ファイル: drx_buf-test.c プロジェクト: KRVPerera/dynamorio
static void
handle_signal(int signal, siginfo_t *siginfo, ucontext_t *ucxt)
{
    print("drx_buf signal test PASS\n");
    SIGLONGJMP(mark, 1);
}
コード例 #17
0
ファイル: drx_buf-test.c プロジェクト: KRVPerera/dynamorio
static LONG WINAPI
handle_exception(struct _EXCEPTION_POINTERS *ep)
{
    print("drx_buf signal test PASS\n");
    SIGLONGJMP(mark, 1);
}
コード例 #18
0
ファイル: sys-std.c プロジェクト: lovmoy/r-source
static RETSIGTYPE handleSelectInterrupt(int dummy)
{
    signal(SIGINT, oldSigintHandler);
    SIGLONGJMP(seljmpbuf, 1);
}