Changeset 72649 in vbox for trunk/src/VBox/Runtime/common/fuzz/fuzz-observer.cpp
- Timestamp:
- Jun 22, 2018 7:40:23 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/fuzz/fuzz-observer.cpp
r72571 r72649 125 125 /** Pointer to the array of observer thread states. */ 126 126 PRTFUZZOBSTHRD paObsThreads; 127 /** Timestamp of the last stats query. */ 128 uint64_t tsLastStats; 129 /** Last number of fuzzed inputs per second if we didn't gather enough data in between 130 * statistic queries. */ 131 uint32_t cFuzzedInputsPerSecLast; 132 /** Fuzzing statistics. */ 133 RTFUZZOBSSTATS Stats; 127 134 } RTFUZZOBSINT; 128 135 … … 754 761 RTPROCSTATUS ProcSts; 755 762 rc = rtFuzzObsExecCtxClientRun(pThis, pExecCtx, &ProcSts); 763 ASMAtomicIncU32(&pThis->Stats.cFuzzedInputs); 764 ASMAtomicIncU32(&pThis->Stats.cFuzzedInputsPerSec); 765 756 766 if (RT_SUCCESS(rc)) 757 767 { 758 768 if (ProcSts.enmReason != RTPROCEXITREASON_NORMAL) 769 { 770 ASMAtomicIncU32(&pThis->Stats.cFuzzedInputsCrash); 759 771 rc = rtFuzzObsAddInputToResults(pThis, pObsThrd->hFuzzInput, pExecCtx); 772 } 760 773 } 761 774 else if (rc == VERR_TIMEOUT) 775 { 776 ASMAtomicIncU32(&pThis->Stats.cFuzzedInputsHang); 762 777 rc = rtFuzzObsAddInputToResults(pThis, pObsThrd->hFuzzInput, pExecCtx); 778 } 763 779 else 764 780 AssertFailed(); … … 939 955 pThis->cThreads = 0; 940 956 pThis->paObsThreads = NULL; 957 pThis->tsLastStats = RTTimeMilliTS(); 958 pThis->Stats.cFuzzedInputsPerSec = 0; 959 pThis->Stats.cFuzzedInputs = 0; 960 pThis->Stats.cFuzzedInputsHang = 0; 961 pThis->Stats.cFuzzedInputsCrash = 0; 941 962 rc = RTFuzzCtxCreate(&pThis->hFuzzCtx); 942 963 if (RT_SUCCESS(rc)) … … 995 1016 996 1017 1018 RTDECL(int) RTFuzzObsQueryStats(RTFUZZOBS hFuzzObs, PRTFUZZOBSSTATS pStats) 1019 { 1020 PRTFUZZOBSINT pThis = hFuzzObs; 1021 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 1022 AssertPtrReturn(pStats, VERR_INVALID_POINTER); 1023 1024 uint64_t tsStatsQuery = RTTimeMilliTS(); 1025 uint32_t cFuzzedInputsPerSec = ASMAtomicXchgU32(&pThis->Stats.cFuzzedInputsPerSec, 0); 1026 1027 pStats->cFuzzedInputsCrash = ASMAtomicReadU32(&pThis->Stats.cFuzzedInputsCrash); 1028 pStats->cFuzzedInputsHang = ASMAtomicReadU32(&pThis->Stats.cFuzzedInputsHang); 1029 pStats->cFuzzedInputs = ASMAtomicReadU32(&pThis->Stats.cFuzzedInputs); 1030 uint64_t cPeriodSec = (tsStatsQuery - pThis->tsLastStats) / 1000; 1031 if (cPeriodSec) 1032 { 1033 pStats->cFuzzedInputsPerSec = cFuzzedInputsPerSec / cPeriodSec; 1034 pThis->cFuzzedInputsPerSecLast = pStats->cFuzzedInputsPerSec; 1035 pThis->tsLastStats = tsStatsQuery; 1036 } 1037 else 1038 pStats->cFuzzedInputsPerSec = pThis->cFuzzedInputsPerSecLast; 1039 return VINF_SUCCESS; 1040 } 1041 1042 997 1043 RTDECL(int) RTFuzzObsSetTmpDirectory(RTFUZZOBS hFuzzObs, const char *pszTmp) 998 1044 { … … 1052 1098 char **ppszOwn = pThis->papszArgs; 1053 1099 const char * const *ppsz = papszArgs; 1054 while ( *ppsz != NULL 1055 && RT_SUCCESS(rc)) 1100 for (unsigned i = 0; i < cArgs; i++) 1056 1101 { 1057 *ppszOwn = RTStrDup(*ppsz);1058 if (RT_UNLIKELY(! *ppszOwn))1102 pThis->papszArgs[i] = RTStrDup(papszArgs[i]); 1103 if (RT_UNLIKELY(!pThis->papszArgs[i])) 1059 1104 { 1060 while ( ppszOwn > pThis->papszArgs)1105 while (i > 0) 1061 1106 { 1062 ppszOwn--;1063 RTStrFree( *ppszOwn);1107 i--; 1108 RTStrFree(pThis->papszArgs[i]); 1064 1109 } 1065 1110 break; 1066 1111 } 1067 1068 ppszOwn++;1069 ppsz++;1070 1112 } 1071 1113
Note:
See TracChangeset
for help on using the changeset viewer.