diff options
Diffstat (limited to 'src/ToolBox/superpmi')
20 files changed, 87 insertions, 45 deletions
diff --git a/src/ToolBox/superpmi/superpmi-shared/compileresult.h b/src/ToolBox/superpmi/superpmi-shared/compileresult.h index 8fc3f7a352..87853f4cd3 100644 --- a/src/ToolBox/superpmi/superpmi-shared/compileresult.h +++ b/src/ToolBox/superpmi/superpmi-shared/compileresult.h @@ -203,7 +203,7 @@ public: void recReportInliningDecision(CORINFO_METHOD_HANDLE inlinerHnd, CORINFO_METHOD_HANDLE inlineeHnd, CorInfoInline inlineResult, const char * reason); void dmpReportInliningDecision(DWORD key, const Agnostic_ReportInliningDecision& value); - CorInfoInline CompileResult::repReportInliningDecision(CORINFO_METHOD_HANDLE inlinerHnd, CORINFO_METHOD_HANDLE inlineeHnd); + CorInfoInline repReportInliningDecision(CORINFO_METHOD_HANDLE inlinerHnd, CORINFO_METHOD_HANDLE inlineeHnd); void recSetEHcount(unsigned cEH); void dmpSetEHcount(DWORD key, DWORD value); diff --git a/src/ToolBox/superpmi/superpmi-shared/icorjitcompilerimpl.h b/src/ToolBox/superpmi/superpmi-shared/icorjitcompilerimpl.h index 671b45b392..e1190d7ab6 100644 --- a/src/ToolBox/superpmi/superpmi-shared/icorjitcompilerimpl.h +++ b/src/ToolBox/superpmi/superpmi-shared/icorjitcompilerimpl.h @@ -57,7 +57,11 @@ public: // When the EE loads the System.Numerics.Vectors assembly, it asks the JIT what length (in bytes) of // SIMD vector it supports as an intrinsic type. Zero means that the JIT does not support SIMD // intrinsics, so the EE should use the default size (i.e. the size of the IL implementation). +#if COR_JIT_EE_VERSION > 460 + unsigned getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags); /* { return 0; } */ +#else unsigned getMaxIntrinsicSIMDVectorLength(DWORD cpuCompileFlags); /* { return 0; } */ +#endif // IL obfuscators sometimes interpose on the EE-JIT interface. This function allows the VM to // tell the JIT to use a particular ICorJitCompiler to implement the methods of this interface, diff --git a/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h b/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h index 6eb862c8b8..b847d9bc50 100644 --- a/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h +++ b/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h @@ -653,7 +653,7 @@ public: // in the code are. The native compiler will ensure that these places // have a corresponding break point in native code. // - // Note that unless CORJIT_FLG_DEBUG_CODE is specified, this function will + // Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will // be used only as a hint and the native compiler should not change its // code generation. void getBoundaries( @@ -683,7 +683,7 @@ public: // under debugging, the JIT needs to keep them live over their // entire scope so that they can be inspected. // - // Note that unless CORJIT_FLG_DEBUG_CODE is specified, this function will + // Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will // be used only as a hint and the native compiler should not change its // code generation. void getVars( diff --git a/src/ToolBox/superpmi/superpmi-shared/logging.cpp b/src/ToolBox/superpmi/superpmi-shared/logging.cpp index 5f7aa48a4f..69c321bb39 100644 --- a/src/ToolBox/superpmi/superpmi-shared/logging.cpp +++ b/src/ToolBox/superpmi/superpmi-shared/logging.cpp @@ -262,9 +262,9 @@ void Logger::LogVprintf(const char *function, const char *file, int line, const char *timeStr = ""; #endif // FEATURE_PAL - const char *logEntryFmtStr = "%s - %s [%s:%d] - %s - %s\r\n"; - size_t logEntryBuffSize = _snprintf(nullptr, 0, logEntryFmtStr, - timeStr, function, file, line, logLevelStr, fullMsg) + 1; + const char logEntryFmtStr[] = "%s - %s [%s:%d] - %s - %s\r\n"; + size_t logEntryBuffSize = sizeof(logEntryFmtStr) + strlen(timeStr) + strlen(function) + + strlen(file) + 10 + strlen(logLevelStr) + strlen(fullMsg); char *logEntry = new char[logEntryBuffSize]; sprintf_s(logEntry, logEntryBuffSize, logEntryFmtStr, diff --git a/src/ToolBox/superpmi/superpmi-shared/lwmlist.h b/src/ToolBox/superpmi/superpmi-shared/lwmlist.h index 774e732620..de0db3a9bb 100644 --- a/src/ToolBox/superpmi/superpmi-shared/lwmlist.h +++ b/src/ToolBox/superpmi/superpmi-shared/lwmlist.h @@ -85,6 +85,7 @@ LWM(GetFunctionFixedEntryPoint, DWORDLONG, Agnostic_CORINFO_CONST_LOOKUP) LWM(GetGSCookie, DWORD, DLDL) LWM(GetHelperFtn, DWORD, DLDL) LWM(GetHelperName, DWORD, DWORD) +LWM(GetHFAType, DWORDLONG, DWORD) LWM(GetInlinedCallFrameVptr, DWORD, DLDL) LWM(GetIntConfigValue, Agnostic_ConfigIntInfo, DWORD) LWM(GetIntrinsicID, DWORDLONG, DD) diff --git a/src/ToolBox/superpmi/superpmi-shared/mclist.cpp b/src/ToolBox/superpmi/superpmi-shared/mclist.cpp index 6a6f8701bf..511893fc96 100644 --- a/src/ToolBox/superpmi/superpmi-shared/mclist.cpp +++ b/src/ToolBox/superpmi/superpmi-shared/mclist.cpp @@ -237,7 +237,7 @@ void MCList::AddMethodToMCL(int methodIndex) DWORD charCount = 0; DWORD bytesWritten = 0; - charCount = sprintf(strMethodIndex, "%d\r\n", methodIndex); + charCount = sprintf_s(strMethodIndex, sizeof(strMethodIndex), "%d\r\n", methodIndex); if (!WriteFile(hMCLFile, strMethodIndex, charCount, &bytesWritten, nullptr) || bytesWritten != charCount) { diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp index 2c46065b48..5768d38569 100644 --- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp @@ -744,7 +744,7 @@ void MethodContext::recCompileMethod(CORINFO_METHOD_INFO *info, unsigned flags) void MethodContext::dmpCompileMethod(DWORD key, const Agnostic_CompileMethod& value) { printf("CompiledMethod key %u, value ftn-%016llX scp-%016llX ilo-%u ils-%u ms-%u ehc-%u opt-%u rk-%u " - "args{cc-%u rc-%016llX rts-%016llX rt-%u(%s) flg-%08X nA-%u cc-%u ci-%u mc-%u mi-%u arg-%016llX cb-%u pSig-%u scp-%016llX tok-%08X} " + "args{cc-%u rc-%016llX rts-%016llX rt-%u(%s) flg-%08X nA-%u cc-%u ci-%u mc-%u mi-%u arg-%016llX cb-%u pSig-%u scp-%016llX tok-%08X} " "locals{cc-%u rc-%016llX rts-%016llX rt-%u(%s) flg-%08X nA-%u cc-%u ci-%u mc-%u mi-%u arg-%016llX cb-%u pSig-%u scp-%016llX tok-%08X} " "flg-%08X", key, @@ -1098,8 +1098,8 @@ void MethodContext::recGetJitFlags(CORJIT_FLAGS *jitFlags, DWORD sizeInBytes, DW } void MethodContext::dmpGetJitFlags(DWORD key, DD value) { - CORJIT_FLAGS *flags = (CORJIT_FLAGS*)GetJitFlags->GetBuffer(value.A); - printf("GetJitFlags key %u sizeInBytes-%u corJitFlags-%08X corJitFlags2-%08X", key, value.B, flags->corJitFlags, flags->corJitFlags2); + CORJIT_FLAGS *jitflags = (CORJIT_FLAGS*)GetJitFlags->GetBuffer(value.A); + printf("GetJitFlags key %u sizeInBytes-%u jitFlags-%016llX", key, value.B, jitflags->GetFlagsRaw()); GetJitFlags->Unlock(); } DWORD MethodContext::repGetJitFlags(CORJIT_FLAGS *jitFlags, DWORD sizeInBytes) @@ -2842,6 +2842,34 @@ CORINFO_CLASS_HANDLE MethodContext::repGetArgClass(CORINFO_SIG_INFO* sig, CORINF return (CORINFO_CLASS_HANDLE)value.result; } +void MethodContext::recGetHFAType(CORINFO_CLASS_HANDLE clsHnd, CorInfoType result) +{ + if (GetHFAType == nullptr) + GetHFAType = new LightWeightMap<DWORDLONG, DWORD>(); + + GetHFAType->Add((DWORDLONG)clsHnd, (DWORD)result); + DEBUG_REC(dmpGetHFAType((DWORDLONG)clsHnd, (DWORD)result)); + return; +} + +void MethodContext::dmpGetHFAType(DWORDLONG key, DWORD value) +{ + printf("GetHFAType key %016llX, value %u ", key, value); + return; +} + +CorInfoType MethodContext::repGetHFAType(CORINFO_CLASS_HANDLE clsHnd) +{ + DWORD value; + + AssertCodeMsg(GetHFAType != nullptr, EXCEPTIONCODE_MC, "Didn't find anything for %016llX", (DWORDLONG)clsHnd); + AssertCodeMsg(GetHFAType->GetIndex((DWORDLONG)clsHnd) != -1, EXCEPTIONCODE_MC, "Didn't find %016llX", (DWORDLONG)clsHnd); + + value = GetHFAType->Get((DWORDLONG)clsHnd); + DEBUG_REP(dmpGetHFAType((DWORDLONG)clsHnd, value)); + return (CorInfoType)value; +} + void MethodContext::recGetMethodInfo(CORINFO_METHOD_HANDLE ftn, CORINFO_METHOD_INFO *info, bool result, DWORD exceptionCode) { if (GetMethodInfo == nullptr) diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.h b/src/ToolBox/superpmi/superpmi-shared/methodcontext.h index 5869c85b45..0d49666e5c 100644 --- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.h +++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.h @@ -513,9 +513,9 @@ public: void dmpGetMethodName(DLD key, DD value); const char *repGetMethodName(CORINFO_METHOD_HANDLE ftn, const char **moduleName); - void MethodContext::recGetJitFlags(CORJIT_FLAGS *jitFlags, DWORD sizeInBytes, DWORD result); - void MethodContext::dmpGetJitFlags(DWORD key, DD value); - DWORD MethodContext::repGetJitFlags(CORJIT_FLAGS *jitFlags, DWORD sizeInBytes); + void recGetJitFlags(CORJIT_FLAGS *jitFlags, DWORD sizeInBytes, DWORD result); + void dmpGetJitFlags(DWORD key, DD value); + DWORD repGetJitFlags(CORJIT_FLAGS *jitFlags, DWORD sizeInBytes); void recGetJitTimeLogFilename(LPCWSTR tempFileName); void dmpGetJitTimeLogFilename(DWORD key, DWORD value); @@ -674,6 +674,10 @@ public: void dmpGetArgClass(const Agnostic_GetArgClass& key, const Agnostic_GetArgClass_Value& value); CORINFO_CLASS_HANDLE repGetArgClass(CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_HANDLE args, DWORD *exceptionCode); + void recGetHFAType(CORINFO_CLASS_HANDLE clsHnd, CorInfoType result); + void dmpGetHFAType(DWORDLONG key, DWORD value); + CorInfoType repGetHFAType(CORINFO_CLASS_HANDLE clsHnd); + void recGetMethodInfo(CORINFO_METHOD_HANDLE ftn, CORINFO_METHOD_INFO *info, bool result, DWORD exceptionCode); void dmpGetMethodInfo(DWORDLONG key, const Agnostic_GetMethodInfo& value); bool repGetMethodInfo(CORINFO_METHOD_HANDLE ftn, CORINFO_METHOD_INFO *info, DWORD *exceptionCode); @@ -1012,7 +1016,7 @@ private: // ********************* Please keep this up-to-date to ease adding more *************** -// Highest packet number: 158 +// Highest packet number: 159 // ************************************************************************************* enum mcPackets { @@ -1055,6 +1059,7 @@ enum mcPackets Packet_GetAddrOfCaptureThreadGlobal = 27, Retired1 = 28, Packet_GetArgClass = 139, //retired as 28 on 2013/07/03 + Packet_GetHFAType = 159, Packet_GetArgNext = 29, Retired2 = 30, Packet_GetArgType = 140, //retired as 30 on 2013/07/03 diff --git a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitcompiler.cpp b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitcompiler.cpp index e3f5ae2764..c5f6d8aac1 100644 --- a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitcompiler.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitcompiler.cpp @@ -109,7 +109,7 @@ void interceptor_ICJC::getVersionIdentifier(GUID* versionIdentifier /* OUT */) original_ICorJitCompiler->getVersionIdentifier(versionIdentifier); } -unsigned interceptor_ICJC::getMaxIntrinsicSIMDVectorLength(DWORD cpuCompileFlags) +unsigned interceptor_ICJC::getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags) { return original_ICorJitCompiler->getMaxIntrinsicSIMDVectorLength(cpuCompileFlags); } diff --git a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp index fb9163629d..1813ed29ff 100644 --- a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -1173,7 +1173,7 @@ bool interceptor_ICJI::isFieldStatic(CORINFO_FIELD_HANDLE fldHnd) // in the code are. The native compiler will ensure that these places // have a corresponding break point in native code. // -// Note that unless CORJIT_FLG_DEBUG_CODE is specified, this function will +// Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will // be used only as a hint and the native compiler should not change its // code generation. void interceptor_ICJI::getBoundaries( @@ -1214,7 +1214,7 @@ void interceptor_ICJI::setBoundaries( // under debugging, the JIT needs to keep them live over their // entire scope so that they can be inspected. // -// Note that unless CORJIT_FLG_DEBUG_CODE is specified, this function will +// Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will // be used only as a hint and the native compiler should not change its // code generation. void interceptor_ICJI::getVars( @@ -1388,7 +1388,9 @@ CorInfoType interceptor_ICJI::getHFAType ( ) { mc->cr->AddCall("getHFAType"); - return original_ICorJitInfo->getHFAType(hClass); + CorInfoType temp = original_ICorJitInfo->getHFAType(hClass); + this->mc->recGetHFAType(hClass, temp); + return temp; } /***************************************************************************** diff --git a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitcompiler.cpp b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitcompiler.cpp index da766cc51d..2e088d438c 100644 --- a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitcompiler.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitcompiler.cpp @@ -55,7 +55,7 @@ void interceptor_ICJC::getVersionIdentifier(GUID* versionIdentifier /* OUT */) original_ICorJitCompiler->getVersionIdentifier(versionIdentifier); } -unsigned interceptor_ICJC::getMaxIntrinsicSIMDVectorLength(DWORD cpuCompileFlags) +unsigned interceptor_ICJC::getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags) { mcs->AddCall("getMaxIntrinsicSIMDVectorLength"); return original_ICorJitCompiler->getMaxIntrinsicSIMDVectorLength(cpuCompileFlags); diff --git a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp index 77519caa84..448fb1f686 100644 --- a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp @@ -961,7 +961,7 @@ bool interceptor_ICJI::isFieldStatic(CORINFO_FIELD_HANDLE fldHnd) // in the code are. The native compiler will ensure that these places // have a corresponding break point in native code. // -// Note that unless CORJIT_FLG_DEBUG_CODE is specified, this function will +// Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will // be used only as a hint and the native compiler should not change its // code generation. void interceptor_ICJI::getBoundaries( @@ -999,7 +999,7 @@ void interceptor_ICJI::setBoundaries( // under debugging, the JIT needs to keep them live over their // entire scope so that they can be inspected. // -// Note that unless CORJIT_FLG_DEBUG_CODE is specified, this function will +// Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will // be used only as a hint and the native compiler should not change its // code generation. void interceptor_ICJI::getVars( diff --git a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitcompiler.cpp b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitcompiler.cpp index f6fceb2029..ec266e164f 100644 --- a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitcompiler.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitcompiler.cpp @@ -48,7 +48,7 @@ void interceptor_ICJC::getVersionIdentifier(GUID* versionIdentifier /* OUT */) original_ICorJitCompiler->getVersionIdentifier(versionIdentifier); } -unsigned interceptor_ICJC::getMaxIntrinsicSIMDVectorLength(DWORD cpuCompileFlags) +unsigned interceptor_ICJC::getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags) { return original_ICorJitCompiler->getMaxIntrinsicSIMDVectorLength(cpuCompileFlags); } diff --git a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp index 89b19d8754..4d145f6a41 100644 --- a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp @@ -876,7 +876,7 @@ bool interceptor_ICJI::isFieldStatic(CORINFO_FIELD_HANDLE fldHnd) // in the code are. The native compiler will ensure that these places // have a corresponding break point in native code. // -// Note that unless CORJIT_FLG_DEBUG_CODE is specified, this function will +// Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will // be used only as a hint and the native compiler should not change its // code generation. void interceptor_ICJI::getBoundaries( @@ -912,7 +912,7 @@ void interceptor_ICJI::setBoundaries( // under debugging, the JIT needs to keep them live over their // entire scope so that they can be inspected. // -// Note that unless CORJIT_FLG_DEBUG_CODE is specified, this function will +// Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will // be used only as a hint and the native compiler should not change its // code generation. void interceptor_ICJI::getVars( diff --git a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp index 41b0195a6d..b746d3f6f7 100644 --- a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp @@ -1018,7 +1018,7 @@ bool MyICJI::isFieldStatic(CORINFO_FIELD_HANDLE fldHnd) // in the code are. The native compiler will ensure that these places // have a corresponding break point in native code. // -// Note that unless CORJIT_FLG_DEBUG_CODE is specified, this function will +// Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will // be used only as a hint and the native compiler should not change its // code generation. void MyICJI::getBoundaries( @@ -1068,7 +1068,7 @@ void MyICJI::setBoundaries( // under debugging, the JIT needs to keep them live over their // entire scope so that they can be inspected. // -// Note that unless CORJIT_FLG_DEBUG_CODE is specified, this function will +// Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will // be used only as a hint and the native compiler should not change its // code generation. void MyICJI::getVars( @@ -1192,9 +1192,8 @@ CorInfoType MyICJI::getHFAType ( ) { jitInstance->mc->cr->AddCall("getHFAType"); - LogError("Hit unimplemented getHFAType"); - DebugBreakorAV(75); - return (CorInfoType)0; + CorInfoType value = jitInstance->mc->repGetHFAType(hClass); + return value; } /***************************************************************************** diff --git a/src/ToolBox/superpmi/superpmi/methodstatsemitter.cpp b/src/ToolBox/superpmi/superpmi/methodstatsemitter.cpp index 0a43f02dd9..5cebc97db4 100644 --- a/src/ToolBox/superpmi/superpmi/methodstatsemitter.cpp +++ b/src/ToolBox/superpmi/superpmi/methodstatsemitter.cpp @@ -50,11 +50,11 @@ void MethodStatsEmitter::Emit(int methodNumber, MethodContext *mc, ULONGLONG fir if (mc->dumpMethodMD5HashToBuffer(md5Hash, MD5_HASH_BUFFER_SIZE) != MD5_HASH_BUFFER_SIZE) md5Hash[0] = 0; - charCount += sprintf(rowData + charCount, "%s,", md5Hash); + charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%s,", md5Hash); } if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'n') != NULL || strchr(statsTypes, 'N') != NULL) { - charCount += sprintf(rowData + charCount, "%d,", methodNumber); + charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%d,", methodNumber); } if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'i') != NULL || strchr(statsTypes, 'I') != NULL) { @@ -63,7 +63,7 @@ void MethodStatsEmitter::Emit(int methodNumber, MethodContext *mc, ULONGLONG fir unsigned flags = 0; mc->repCompileMethod(&info, &flags); - charCount += sprintf(rowData + charCount, "%d,", info.ILCodeSize); + charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%d,", info.ILCodeSize); } if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'a') != NULL || strchr(statsTypes, 'A') != NULL) { @@ -76,11 +76,11 @@ void MethodStatsEmitter::Emit(int methodNumber, MethodContext *mc, ULONGLONG fir else codeSize = 0;//this is likely a thin mc - charCount += sprintf(rowData + charCount, "%d,", codeSize); + charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%d,", codeSize); } if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 't') != NULL || strchr(statsTypes, 'T') != NULL) { - charCount += sprintf(rowData + charCount, "%llu,%llu,", firstTime, secondTime); + charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%llu,%llu,", firstTime, secondTime); } //get rid of the final ',' and replace it with a '\n' @@ -105,15 +105,15 @@ void MethodStatsEmitter::SetStatsTypes(char *types) DWORD bytesWritten = 0; if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'h') != NULL || strchr(statsTypes, 'H') != NULL) - charCount += sprintf(rowHeader + charCount, "HASH,"); + charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "HASH,"); if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'n') != NULL || strchr(statsTypes, 'N') != NULL) - charCount += sprintf(rowHeader + charCount, "METHOD_NUMBER,"); + charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "METHOD_NUMBER,"); if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'i') != NULL || strchr(statsTypes, 'I') != NULL) - charCount += sprintf(rowHeader + charCount, "IL_CODE_SIZE,"); + charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "IL_CODE_SIZE,"); if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'a') != NULL || strchr(statsTypes, 'A') != NULL) - charCount += sprintf(rowHeader + charCount, "ASM_CODE_SIZE,"); + charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "ASM_CODE_SIZE,"); if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 't') != NULL || strchr(statsTypes, 'T') != NULL) - charCount += sprintf(rowHeader + charCount, "Time1,Time2,"); + charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "Time1,Time2,"); //get rid of the final ',' and replace it with a '\n' rowHeader[charCount - 1] = '\n'; @@ -123,4 +123,4 @@ void MethodStatsEmitter::SetStatsTypes(char *types) LogError("Failed to write row header '%s'. GetLastError()=%u", rowHeader, GetLastError()); } } -}
\ No newline at end of file +} diff --git a/src/ToolBox/superpmi/superpmi/neardiffer.cpp b/src/ToolBox/superpmi/superpmi/neardiffer.cpp index 5b2e3b1b57..3f2c4db3b8 100644 --- a/src/ToolBox/superpmi/superpmi/neardiffer.cpp +++ b/src/ToolBox/superpmi/superpmi/neardiffer.cpp @@ -154,7 +154,7 @@ void NearDiffer::DumpCodeBlock(unsigned char *block, ULONG blocksize, void *orig const size_t minInstrBytes = 7; size_t instrBytes = max(instrSize, minInstrBytes); - size_t buffSize = _snprintf(nullptr, 0, "%p %s\n", (void*)((size_t)originalAddr+offset), instrMnemonic) + 3 * instrBytes + 1; + size_t buffSize = sizeof("%p %s\n") + 10 + count + 3 * instrBytes + 1; char *buff = new char[buffSize]; int written = 0; written += sprintf_s(buff, buffSize, "%p ", (void*)((size_t)originalAddr+offset)); diff --git a/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp b/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp index 8c5232315e..301db3cfe9 100644 --- a/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp +++ b/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp @@ -138,7 +138,7 @@ bool WriteArrayToMCL(char *mclFilename, int *arr, int count) DWORD charCount = 0; DWORD bytesWritten = 0; - charCount = sprintf(strMethodIndex, "%d\r\n", arr[i]); + charCount = sprintf_s(strMethodIndex, sizeof(strMethodIndex), "%d\r\n", arr[i]); if (!WriteFile(hMCLFile, strMethodIndex, charCount, &bytesWritten, nullptr) || (bytesWritten != charCount)) { @@ -232,7 +232,7 @@ void ProcessChildStdOut(const CommandLine::Options& o, char *stdoutFilename, int if (o.applyDiff) { int temp1 = 0, temp2 = 0, temp3 = 0, temp4 = 0; - int converted = sscanf(buff, g_AsmDiffsSummaryFormatString, &temp1, &temp2, &temp3, &temp4); + int converted = sscanf_s(buff, g_AsmDiffsSummaryFormatString, &temp1, &temp2, &temp3, &temp4); if (converted != 4) { LogError("Couldn't parse status message: \"%s\"", buff); @@ -248,7 +248,7 @@ void ProcessChildStdOut(const CommandLine::Options& o, char *stdoutFilename, int else { int temp1 = 0, temp2 = 0, temp3 = 0; - int converted = sscanf(buff, g_SummaryFormatString, &temp1, &temp2, &temp3); + int converted = sscanf_s(buff, g_SummaryFormatString, &temp1, &temp2, &temp3); if (converted != 3) { LogError("Couldn't parse status message: \"%s\"", buff); diff --git a/src/ToolBox/superpmi/superpmi/superpmi.cpp b/src/ToolBox/superpmi/superpmi/superpmi.cpp index ce352070f8..980792d4a9 100644 --- a/src/ToolBox/superpmi/superpmi/superpmi.cpp +++ b/src/ToolBox/superpmi/superpmi/superpmi.cpp @@ -45,6 +45,8 @@ void SetSuperPmiTargetArchitecture(const char* targetArchitecture) } #elif defined(_TARGET_X86_) SpmiTargetArchitecture = SPMI_TARGET_ARCHITECTURE_X86; +#elif defined(_TARGET_ARM_) + SpmiTargetArchitecture = SPMI_TARGET_ARCHITECTURE_ARM; #endif } diff --git a/src/ToolBox/superpmi/superpmi/superpmi.h b/src/ToolBox/superpmi/superpmi/superpmi.h index d5b7bdaa2b..ce535994a0 100644 --- a/src/ToolBox/superpmi/superpmi/superpmi.h +++ b/src/ToolBox/superpmi/superpmi/superpmi.h @@ -12,7 +12,8 @@ enum SPMI_TARGET_ARCHITECTURE { SPMI_TARGET_ARCHITECTURE_X86, SPMI_TARGET_ARCHITECTURE_AMD64, - SPMI_TARGET_ARCHITECTURE_ARM64 + SPMI_TARGET_ARCHITECTURE_ARM64, + SPMI_TARGET_ARCHITECTURE_ARM }; extern SPMI_TARGET_ARCHITECTURE SpmiTargetArchitecture; |