/*
 * Return the time, in milliseconds, since the last debugger activity.
 *
 * Returns -1 if no debugger is attached, or 0 if we're in the middle of
 * processing a debugger request.
 */
s8 dvmJdwpLastDebuggerActivity(JdwpState* state)
{
    long lastSec, lastMsec;
    long nowSec, nowMsec;

    /* these are volatile; lastSec becomes 0 during update */
    lastSec = state->lastActivitySec;
    lastMsec = state->lastActivityMsec;

    /* initializing or in the middle of something? */
    if (lastSec == 0 || state->lastActivitySec != lastSec) {
        //LOGI("+++ last=busy\n");
        return 0;
    }

    /* get the current time *after* latching the "last" time */
    dvmJdwpGetNowMsec(&nowSec, &nowMsec);

    s8 last = (s8)lastSec * 1000 + lastMsec;
    s8 now = (s8)nowSec * 1000 + nowMsec;

    //LOGI("last is %ld.%ld --> %lld\n", lastSec, lastMsec, last);
    //LOGI("now is  %ld.%ld --> %lld\n", nowSec, nowMsec, now);


    //LOGI("+++ interval=%lld\n", now - last);
    return now - last;
}
Exemplo n.º 2
0
/*
 * Return the time, in milliseconds, since the last debugger activity.
 *
 * Returns -1 if no debugger is attached, or 0 if we're in the middle of
 * processing a debugger request.
 */
s8 dvmJdwpLastDebuggerActivity(JdwpState* state)
{
    if (!gDvm.debuggerActive) {
        LOGD("dvmJdwpLastDebuggerActivity: no active debugger\n");
        return -1;
    }

    s8 last = dvmQuasiAtomicRead64(&state->lastActivityWhen);

    /* initializing or in the middle of something? */
    if (last == 0) {
        LOGV("+++ last=busy\n");
        return 0;
    }

    /* now get the current time */
    s8 now = dvmJdwpGetNowMsec();
    assert(now > last);

    LOGV("+++ debugger interval=%lld\n", now - last);
    return now - last;
}