Home | History | Annotate | Download | only in vm

Lines Matching full:state

365     MethodTraceState* state = &gDvm.methodTrace;
369 dvmLockMutex(&state->startStopLock);
370 while (state->traceEnabled != 0) {
372 dvmUnlockMutex(&state->startStopLock);
374 dvmLockMutex(&state->startStopLock);
390 state->buf = (u1*) malloc(bufferSize);
391 if (state->buf == NULL) {
397 state->traceFile = fopen(traceFileName, "w");
399 state->traceFile = fdopen(traceFd, "w");
401 if (state->traceFile == NULL) {
412 memset(state->buf, (char)FILL_PATTERN, bufferSize);
414 state->directToDdms = directToDdms;
415 state->bufferSize = bufferSize;
416 state->overflow = false;
421 state->flags = flags;
428 state->startWhen = getWallTimeInUsec();
431 state->traceVersion = 3;
432 state->recordSize = TRACE_REC_SIZE_DUAL_CLOCK;
434 state->traceVersion = 2;
435 state->recordSize = TRACE_REC_SIZE_SINGLE_CLOCK;
441 memset(state->buf, 0, TRACE_HEADER_LEN);
442 storeIntLE(state->buf + 0, TRACE_MAGIC);
443 storeShortLE(state->buf + 4, state->traceVersion);
444 storeShortLE(state->buf + 6, TRACE_HEADER_LEN);
445 storeLongLE(state->buf + 8, state->startWhen);
446 if (state->traceVersion >= 3) {
447 storeShortLE(state->buf + 16, state->recordSize);
449 state->curOffset = TRACE_HEADER_LEN;
455 android_atomic_release_store(true, &state->traceEnabled);
456 dvmUnlockMutex(&state->startStopLock);
461 if (state->traceFile != NULL) {
462 fclose(state->traceFile);
463 state->traceFile = NULL;
465 if (state->buf != NULL) {
466 free(state->buf);
467 state->buf = NULL;
471 dvmUnlockMutex(&state->startStopLock);
543 const MethodTraceState* state = &gDvm.methodTrace;
544 return state->traceEnabled;
553 MethodTraceState* state = &gDvm.methodTrace;
560 dvmLockMutex(&state->startStopLock);
562 if (!state->traceEnabled) {
565 dvmUnlockMutex(&state->startStopLock);
572 elapsed = getWallTimeInUsec() - state->startWhen;
581 state->traceEnabled = false;
586 if ((state->flags & TRACE_ALLOC_COUNTS) != 0)
595 * To avoid seeing partially-written data, we grab state->curOffset here,
609 int finalCurOffset = state->curOffset;
611 size_t recordSize = state->recordSize;
614 u1* scanPtr = state->buf + TRACE_HEADER_LEN;
616 while (scanPtr < state->buf + finalCurOffset) {
620 u1* scanBase = state->buf + TRACE_HEADER_LEN;
624 finalCurOffset = scanPtr - state->buf;
633 state->overflow ? " (NOTE: overflowed buffer)" : "",
649 if (state->directToDdms) {
650 assert(state->traceFile == NULL);
651 state->traceFile = open_memstream(&memStreamPtr, &memStreamSize);
652 if (state->traceFile == NULL) {
658 assert(state->traceFile != NULL);
660 fprintf(state->traceFile, "%cversion\n", TOKEN_CHAR);
661 fprintf(state->traceFile, "%d\n", state->traceVersion);
662 fprintf(state->traceFile, "data-file-overflow=%s\n",
663 state->overflow ? "true" : "false");
666 fprintf(state->traceFile, "clock=dual\n");
668 fprintf(state->traceFile, "clock=thread-cpu\n");
671 fprintf(state->traceFile, "clock=wall\n");
673 fprintf(state->traceFile, "elapsed-time-usec=%llu\n", elapsed);
674 fprintf(state->traceFile, "num-method-calls=%d\n",
675 (finalCurOffset - TRACE_HEADER_LEN) / state->recordSize);
676 fprintf(state->traceFile, "clock-call-overhead-nsec=%d\n", clockNsec);
677 fprintf(state->traceFile, "vm=dalvik\n");
678 if ((state->flags & TRACE_ALLOC_COUNTS) != 0) {
679 fprintf(state->traceFile, "alloc-count=%d\n",
681 fprintf(state->traceFile, "alloc-size=%d\n",
683 fprintf(state->traceFile, "gc-count=%d\n",
686 fprintf(state->traceFile, "%cthreads\n", TOKEN_CHAR);
687 dumpThreadList(state->traceFile);
688 fprintf(state->traceFile, "%cmethods\n", TOKEN_CHAR);
689 dumpMethodList(state->traceFile);
690 fprintf(state->traceFile, "%cend\n", TOKEN_CHAR);
692 if (state->directToDdms) {
694 * Data is in two places: memStreamPtr and state->buf. Send
697 fflush(state->traceFile);
702 iov[1].iov_base = state->buf;
707 if (fwrite(state->buf, finalCurOffset, 1, state->traceFile) != 1) {
717 free(state->buf);
718 state->buf = NULL;
719 fclose(state->traceFile);
720 state->traceFile = NULL;
723 dvmBroadcastCond(&state->threadExitCond);
724 dvmUnlockMutex(&state->startStopLock);
735 MethodTraceState* state = &gDvm.methodTrace;
761 oldOffset = state->curOffset;
762 newOffset = oldOffset + state->recordSize;
763 if (newOffset > state->bufferSize) {
764 state->overflow = true;
768 &state->curOffset) != 0);
777 ptr = state->buf + oldOffset;
796 u4 wallClockDiff = (u4) (getWallTimeInUsec() - state->startWhen);