• Home
  • Raw
  • Download

Lines Matching refs:state

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