Beispiel #1
0
int
backtrace(void **buffer, int size)
{
  USHORT frames;

  HANDLE hProcess;
  if (size <= 0)
    return 0;
  hProcess = GetCurrentProcess();
  frames = rec_backtrace(buffer, (DWORD) size);

  return (int) frames;
}
Beispiel #2
0
// The handler function, called whenever the profiling timer elapses
static void profile_bt(int signal, siginfo_t *si, void *uc)
{
    if (running && si->si_value.sival_ptr == &timerprof && bt_size_cur < bt_size_max) {
        // Get backtrace data
        bt_size_cur += rec_backtrace((ptrint_t*)bt_data_prof+bt_size_cur, bt_size_max-bt_size_cur-1);
        // Mark the end of this block with 0
        bt_data_prof[bt_size_cur] = 0;
        bt_size_cur++;
    }
    if (bt_size_cur >= bt_size_max) {
        // Buffer full: Delete the  timer
        jl_profile_stop_timer();
    }
}
Beispiel #3
0
// The handler function, called whenever the profiling timer elapses
static void profile_bt(int sig)
{
    if (running && bt_size_cur < bt_size_max) {
        // Get backtrace data
        bt_size_cur += rec_backtrace((ptrint_t*)bt_data_prof+bt_size_cur, bt_size_max-bt_size_cur-1);
        // Mark the end of this block with 0
        bt_data_prof[bt_size_cur] = 0;
        bt_size_cur++;
    }
    if (bt_size_cur >= bt_size_max) {
        // Buffer full: Delete the  timer
        jl_profile_stop_timer();
    }
}
Beispiel #4
0
// The handler function, called whenever the profiling timer elapses
static void profile_bt(int dummy)
{
    // Get backtrace data
    bt_size_cur += rec_backtrace((ptrint_t*)bt_data_prof+bt_size_cur, bt_size_max-bt_size_cur-1);
    // Mark the end of this block with 0
    bt_data_prof[bt_size_cur] = 0;
    bt_size_cur++;
    // Re-arm the  timer
    if (running && bt_size_cur < bt_size_max) {
        timerprof.it_value.tv_usec = nsecprof/1000;
        setitimer(ITIMER_REAL, &timerprof, 0);
        signal(SIGALRM, profile_bt);
    }
}
Beispiel #5
0
// The handler function, called whenever the profiling timer elapses
static void profile_bt(int signal, siginfo_t *si, void *uc)
{
    if (si->si_value.sival_ptr == &timerprof && bt_size_cur < bt_size_max) {
        // Get backtrace data
        bt_size_cur += rec_backtrace((ptrint_t*)bt_data_prof+bt_size_cur, bt_size_max-bt_size_cur-1);
        // Mark the end of this block with 0
        bt_data_prof[bt_size_cur] = 0;
        bt_size_cur++;
        // Re-arm the  timer
        if (bt_size_cur < bt_size_max) {
            itsprof.it_value.tv_nsec = nsecprof;
            timer_settime(timerprof, 0, &itsprof, NULL);
        }
    }
}
Beispiel #6
0
void __cdecl crt_sig_handler(int sig, int num)
{
    switch (sig) {
    case SIGFPE:
        fpreset();
        signal(SIGFPE, (void (__cdecl *)(int))crt_sig_handler);
        switch(num) {
        case _FPE_INVALID:
        case _FPE_OVERFLOW:
        case _FPE_UNDERFLOW:
        default:
            jl_errorf("Unexpected FPE Error 0x%X", num);
            break;
        case _FPE_ZERODIVIDE:
            jl_throw(jl_diverror_exception);
            break;
        }
        break;
    case SIGINT:
        signal(SIGINT, (void (__cdecl *)(int))crt_sig_handler);
        if (exit_on_sigint) jl_exit(0);
        if (jl_defer_signal) {
            jl_signal_pending = sig;
        }
        else {
            jl_signal_pending = 0;
            jl_throw(jl_interrupt_exception);
        }
        break;
    default: // SIGSEGV, (SSIGTERM, IGILL)
        ios_printf(ios_stderr,"\nsignal (%d): %s\n", sig, strsignal(sig));
        bt_size = rec_backtrace(bt_data, MAX_BT_SIZE);
        jlbacktrace();
        raise(sig);
    }
}