diff options
Diffstat (limited to 'src/ToolBox/superpmi/mcs')
31 files changed, 1219 insertions, 821 deletions
diff --git a/src/ToolBox/superpmi/mcs/commandline.cpp b/src/ToolBox/superpmi/mcs/commandline.cpp index ea6a4a3e72..cc2244d870 100644 --- a/src/ToolBox/superpmi/mcs/commandline.cpp +++ b/src/ToolBox/superpmi/mcs/commandline.cpp @@ -134,25 +134,26 @@ void CommandLine::DumpHelp(const char* program) printf("Note: Inputs are case insensitive.\n"); } -//Assumption: All inputs are initialized to default or real value. we'll just set the stuff in what we see on the command line. -//Assumption: Single byte names are passed in.. mb stuff doesnt cause an obvious problem... but it might have issues... -//Assumption: Values larger than 2^31 aren't expressible from the commandline.... (atoi) Unless you pass in negatives.. :-| +// Assumption: All inputs are initialized to default or real value. we'll just set the stuff in what we see on the +// command line. Assumption: Single byte names are passed in.. mb stuff doesnt cause an obvious problem... but it might +// have issues... Assumption: Values larger than 2^31 aren't expressible from the commandline.... (atoi) Unless you pass +// in negatives.. :-| bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) { - size_t argLen = 0; + size_t argLen = 0; size_t tempLen = 0; - bool foundVerb = false; + bool foundVerb = false; bool foundFile1 = false; bool foundFile2 = false; - if (argc == 1) //Print help when no args are passed + if (argc == 1) // Print help when no args are passed { DumpHelp(argv[0]); return false; } - for (int i = 1; i<argc; i++) + for (int i = 1; i < argc; i++) { bool isASwitch = (argv[i][0] == '-'); #ifndef FEATURE_PAL @@ -162,98 +163,97 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) } #endif // !FEATURE_PAL - //Process a switch + // Process a switch if (isASwitch) { argLen = strlen(argv[i]); - if (argLen >1) - argLen--; //adjust for leading switch + if (argLen > 1) + argLen--; // adjust for leading switch else { DumpHelp(argv[0]); return false; } - if ((_strnicmp(&argv[i][1], "help", argLen) == 0) || - (_strnicmp(&argv[i][1], "?", argLen) == 0)) + if ((_strnicmp(&argv[i][1], "help", argLen) == 0) || (_strnicmp(&argv[i][1], "?", argLen) == 0)) { DumpHelp(argv[0]); return false; } else if ((_strnicmp(&argv[i][1], "ASMDump", argLen) == 0)) { - tempLen = strlen(argv[i]); - foundVerb = true; + tempLen = strlen(argv[i]); + foundVerb = true; o->actionASMDump = true; - if (i + 1 < argc) //Peek to see if we have an mcl file or an integer next + if (i + 1 < argc) // Peek to see if we have an mcl file or an integer next goto processMCL; } else if ((_strnicmp(&argv[i][1], "concat", argLen) == 0)) { - tempLen = strlen(argv[i]); - foundVerb = true; + tempLen = strlen(argv[i]); + foundVerb = true; o->actionConcat = true; } else if ((_strnicmp(&argv[i][1], "copy", argLen) == 0)) { - tempLen = strlen(argv[i]); - foundVerb = true; + tempLen = strlen(argv[i]); + foundVerb = true; o->actionCopy = true; - if (i + 1 < argc) //Peek to see if we have an mcl file or an integer next + if (i + 1 < argc) // Peek to see if we have an mcl file or an integer next goto processMCL; } else if ((_strnicmp(&argv[i][1], "dump", argLen) == 0)) { - tempLen = strlen(argv[i]); - foundVerb = true; + tempLen = strlen(argv[i]); + foundVerb = true; o->actionDump = true; - if (i + 1 < argc) //Peek to see if we have an mcl file or an integer next + if (i + 1 < argc) // Peek to see if we have an mcl file or an integer next goto processMCL; } else if ((_strnicmp(&argv[i][1], "fracture", argLen) == 0)) { - tempLen = strlen(argv[i]); - foundVerb = true; + tempLen = strlen(argv[i]); + foundVerb = true; o->actionFracture = true; - if (i + 1 < argc) //Peek to see if we have an mcl file or an integer next + if (i + 1 < argc) // Peek to see if we have an mcl file or an integer next goto processMCL; } else if ((_strnicmp(&argv[i][1], "dumpmap", argLen) == 0)) { - tempLen = strlen(argv[i]); - foundVerb = true; + tempLen = strlen(argv[i]); + foundVerb = true; o->actionDumpMap = true; } else if ((_strnicmp(&argv[i][1], "dumptoc", argLen) == 0)) { - tempLen = strlen(argv[i]); - foundVerb = true; + tempLen = strlen(argv[i]); + foundVerb = true; o->actionDumpToc = true; } else if ((_strnicmp(&argv[i][1], "ildump", argLen) == 0)) { - tempLen = strlen(argv[i]); - foundVerb = true; + tempLen = strlen(argv[i]); + foundVerb = true; o->actionILDump = true; - if (i + 1 < argc) //Peek to see if we have an mcl file or an integer next + if (i + 1 < argc) // Peek to see if we have an mcl file or an integer next goto processMCL; } else if ((_strnicmp(&argv[i][1], "merge", argLen) == 0)) { - tempLen = strlen(argv[i]); - foundVerb = true; + tempLen = strlen(argv[i]); + foundVerb = true; o->actionMerge = true; } else if ((_strnicmp(&argv[i][1], "recursive", argLen) == 0)) { - tempLen = strlen(argv[i]); + tempLen = strlen(argv[i]); o->recursive = true; } else if ((_strnicmp(&argv[i][1], "toc", argLen) == 0)) { - tempLen = strlen(argv[i]); - foundVerb = true; + tempLen = strlen(argv[i]); + foundVerb = true; o->actionTOC = true; } else if ((_strnicmp(&argv[i][1], "input", argLen) == 0)) @@ -294,8 +294,8 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) } else if ((_strnicmp(&argv[i][1], "integ", argLen) == 0)) { - tempLen = strlen(argv[i]); - foundVerb = true; + tempLen = strlen(argv[i]); + foundVerb = true; o->actionInteg = true; } else if ((_strnicmp(&argv[i][1], "mcl", argLen) == 0)) @@ -316,24 +316,24 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) } else if ((_strnicmp(&argv[i][1], "removeDup", argLen) == 0)) { - tempLen = strlen(argv[i]); - foundVerb = true; + tempLen = strlen(argv[i]); + foundVerb = true; o->actionRemoveDup = true; } else if ((_strnicmp(&argv[i][1], "stat", argLen) == 0)) { - tempLen = strlen(argv[i]); - foundVerb = true; + tempLen = strlen(argv[i]); + foundVerb = true; o->actionStat = true; - if (i + 1 < argc) //Peek to see if we have an mcl file or an integer next + if (i + 1 < argc) // Peek to see if we have an mcl file or an integer next goto processMCL; } else if ((_strnicmp(&argv[i][1], "strip", argLen) == 0)) { - tempLen = strlen(argv[i]); - foundVerb = true; + tempLen = strlen(argv[i]); + foundVerb = true; o->actionStrip = true; - if (i + 1 < argc) //Peek to see if we have an mcl file or an integer next + if (i + 1 < argc) // Peek to see if we have an mcl file or an integer next goto processMCL; } else if ((_strnicmp(&argv[i][1], "thin", argLen) == 0)) @@ -346,10 +346,10 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) } else if ((_strnicmp(&argv[i][1], "smarty", argLen) == 0)) { - tempLen = strlen(argv[i]); + tempLen = strlen(argv[i]); o->actionSmarty = true; - foundVerb = true; - if (i + 1 < argc) //Peek to see if we have an mcl file or an integer next + foundVerb = true; + if (i + 1 < argc) // Peek to see if we have an mcl file or an integer next goto processMCL; } else if ((_strnicmp(&argv[i][1], "verbosity", argLen) == 0)) @@ -378,12 +378,11 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) DumpHelp(argv[0]); return false; } - } - //Process an input filename + // Process an input filename else { - char *lastdot = strrchr(argv[i], '.'); + char* lastdot = strrchr(argv[i], '.'); if (lastdot != nullptr) { if (_stricmp(lastdot, ".mcl") == 0) diff --git a/src/ToolBox/superpmi/mcs/commandline.h b/src/ToolBox/superpmi/mcs/commandline.h index a04969696b..442f2a4098 100644 --- a/src/ToolBox/superpmi/mcs/commandline.h +++ b/src/ToolBox/superpmi/mcs/commandline.h @@ -12,60 +12,59 @@ class CommandLine { public: - class Options { public: - Options() : - actionASMDump(false), - actionConcat(false), - actionCopy(false), - actionDump(false), - actionDumpMap(false), - actionDumpToc(false), - actionFracture(false), - actionILDump(false), - actionInteg(false), - actionMerge(false), - actionRemoveDup(false), - actionSmarty(false), - actionStat(false), - actionStrip(false), - actionTOC(false), - legacyCompare(false), - recursive(false), - stripCR(false), - nameOfFile1(nullptr), - nameOfFile2(nullptr), - nameOfFile3(nullptr), - indexCount(-1), - indexes(nullptr) + Options() + : actionASMDump(false) + , actionConcat(false) + , actionCopy(false) + , actionDump(false) + , actionDumpMap(false) + , actionDumpToc(false) + , actionFracture(false) + , actionILDump(false) + , actionInteg(false) + , actionMerge(false) + , actionRemoveDup(false) + , actionSmarty(false) + , actionStat(false) + , actionStrip(false) + , actionTOC(false) + , legacyCompare(false) + , recursive(false) + , stripCR(false) + , nameOfFile1(nullptr) + , nameOfFile2(nullptr) + , nameOfFile3(nullptr) + , indexCount(-1) + , indexes(nullptr) { } - bool actionASMDump; - bool actionConcat; - bool actionCopy; - bool actionDump; - bool actionDumpMap; - bool actionDumpToc; - bool actionFracture; - bool actionILDump; - bool actionInteg; - bool actionMerge; - bool actionRemoveDup; - bool actionSmarty; - bool actionStat; - bool actionStrip; - bool actionTOC; - bool legacyCompare; - bool recursive; - bool stripCR; + bool actionASMDump; + bool actionConcat; + bool actionCopy; + bool actionDump; + bool actionDumpMap; + bool actionDumpToc; + bool actionFracture; + bool actionILDump; + bool actionInteg; + bool actionMerge; + bool actionRemoveDup; + bool actionSmarty; + bool actionStat; + bool actionStrip; + bool actionTOC; + bool legacyCompare; + bool recursive; + bool stripCR; char* nameOfFile1; char* nameOfFile2; char* nameOfFile3; - int indexCount; - int* indexes; + int indexCount; + int* indexes; }; static bool Parse(int argc, char* argv[], /* OUT */ Options* o); diff --git a/src/ToolBox/superpmi/mcs/mcs.cpp b/src/ToolBox/superpmi/mcs/mcs.cpp index d2debdd90f..7026ff55a3 100644 --- a/src/ToolBox/superpmi/mcs/mcs.cpp +++ b/src/ToolBox/superpmi/mcs/mcs.cpp @@ -35,12 +35,12 @@ int __cdecl main(int argc, char* argv[]) Logger::Initialize(); CommandLine::Options o; - if(!CommandLine::Parse(argc, argv, &o)) + if (!CommandLine::Parse(argc, argv, &o)) { return -1; } - //execute the chosen command. + // execute the chosen command. int exitCode = 0; if (o.actionASMDump) { diff --git a/src/ToolBox/superpmi/mcs/verbasmdump.cpp b/src/ToolBox/superpmi/mcs/verbasmdump.cpp index 3f018b3a45..ffefd55d99 100644 --- a/src/ToolBox/superpmi/mcs/verbasmdump.cpp +++ b/src/ToolBox/superpmi/mcs/verbasmdump.cpp @@ -13,7 +13,7 @@ #define BUFFER_SIZE 0xFFFFFF -int verbASMDump::DoWork(const char *nameOfInput, const char *nameOfOutput, int indexCount, const int *indexes) +int verbASMDump::DoWork(const char* nameOfInput, const char* nameOfOutput, int indexCount, const int* indexes) { LogVerbose("Loading from '%s' and writing ASM output into '%s-MC#.asm'", nameOfInput, nameOfOutput); @@ -30,7 +30,8 @@ int verbASMDump::DoWork(const char *nameOfInput, const char *nameOfOutput, int i char buff[500]; sprintf_s(buff, 500, "%s-%d.asm", nameOfOutput, mci.MethodContextNumber()); - HANDLE hFileOut = CreateFileA(buff, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN, NULL); + HANDLE hFileOut = CreateFileA(buff, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (hFileOut == INVALID_HANDLE_VALUE) { LogError("Failed to open output '%s'. GetLastError()=%u", buff, GetLastError()); @@ -40,8 +41,8 @@ int verbASMDump::DoWork(const char *nameOfInput, const char *nameOfOutput, int i if (mc->cr->IsEmpty()) { const size_t bufflen = 4096; - DWORD bytesWritten; - char buff[bufflen]; + DWORD bytesWritten; + char buff[bufflen]; ZeroMemory(buff, bufflen * sizeof(char)); int buff_offset = sprintf_s(buff, bufflen, ";;Method context has no compile result"); WriteFile(hFileOut, buff, buff_offset * sizeof(char), &bytesWritten, nullptr); diff --git a/src/ToolBox/superpmi/mcs/verbasmdump.h b/src/ToolBox/superpmi/mcs/verbasmdump.h index 693366ef91..b3873b24e7 100644 --- a/src/ToolBox/superpmi/mcs/verbasmdump.h +++ b/src/ToolBox/superpmi/mcs/verbasmdump.h @@ -12,8 +12,6 @@ class verbASMDump { public: - static int DoWork(const char *nameOfInput1, const char *nameOfOutput, int indexCount, const int *indexes); + static int DoWork(const char* nameOfInput1, const char* nameOfOutput, int indexCount, const int* indexes); }; #endif - - diff --git a/src/ToolBox/superpmi/mcs/verbconcat.cpp b/src/ToolBox/superpmi/mcs/verbconcat.cpp index 36620f11b2..a41e55d00b 100644 --- a/src/ToolBox/superpmi/mcs/verbconcat.cpp +++ b/src/ToolBox/superpmi/mcs/verbconcat.cpp @@ -10,7 +10,7 @@ #define BUFFER_SIZE 0xFFFFFF -int verbConcat::DoWork(const char *nameOfFile1, const char *nameOfFile2) +int verbConcat::DoWork(const char* nameOfFile1, const char* nameOfFile2) { SimpleTimer st1; @@ -19,33 +19,35 @@ int verbConcat::DoWork(const char *nameOfFile1, const char *nameOfFile2) LARGE_INTEGER DataTemp1; LARGE_INTEGER DataTemp2; - HANDLE hFileIn1 = CreateFileA(nameOfFile1, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN, NULL); - if(hFileIn1 == INVALID_HANDLE_VALUE) + HANDLE hFileIn1 = CreateFileA(nameOfFile1, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + if (hFileIn1 == INVALID_HANDLE_VALUE) { LogError("Failed to open input 1 '%s'. GetLastError()=%u", nameOfFile1, GetLastError()); return -1; } - if(GetFileSizeEx(hFileIn1, &DataTemp1)==0) + if (GetFileSizeEx(hFileIn1, &DataTemp1) == 0) { LogError("GetFileSizeEx failed. GetLastError()=%u", GetLastError()); return -1; } - LONG highDWORD = 0; - DWORD dwPtr = SetFilePointer(hFileIn1, 0, &highDWORD, FILE_END); + LONG highDWORD = 0; + DWORD dwPtr = SetFilePointer(hFileIn1, 0, &highDWORD, FILE_END); if (dwPtr == INVALID_SET_FILE_POINTER) { LogError("Failed to SetFilePointer on input 1 '%s'. GetLastError()=%u", nameOfFile1, GetLastError()); return -1; } - HANDLE hFileIn2 = CreateFileA(nameOfFile2, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN, NULL); - if(hFileIn2 == INVALID_HANDLE_VALUE) + HANDLE hFileIn2 = CreateFileA(nameOfFile2, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + if (hFileIn2 == INVALID_HANDLE_VALUE) { LogError("Failed to open input 2 '%s'. GetLastError()=%u", nameOfFile2, GetLastError()); return -1; } - if(GetFileSizeEx(hFileIn2, &DataTemp2)==0) + if (GetFileSizeEx(hFileIn2, &DataTemp2) == 0) { LogError("2nd GetFileSizeEx failed. GetLastError()=%u", GetLastError()); return -1; @@ -54,23 +56,23 @@ int verbConcat::DoWork(const char *nameOfFile1, const char *nameOfFile2) unsigned char* buffer = new unsigned char[BUFFER_SIZE]; st1.Start(); - for(LONGLONG offset = 0; offset < DataTemp2.QuadPart; offset += BUFFER_SIZE) + for (LONGLONG offset = 0; offset < DataTemp2.QuadPart; offset += BUFFER_SIZE) { DWORD bytesRead = -1; - BOOL res = ReadFile(hFileIn2, buffer, BUFFER_SIZE, &bytesRead, nullptr); - if(res == 0) + BOOL res = ReadFile(hFileIn2, buffer, BUFFER_SIZE, &bytesRead, nullptr); + if (res == 0) { LogError("Failed to read '%s' from offset %lld. GetLastError()=%u", nameOfFile2, offset, GetLastError()); return -1; } DWORD bytesWritten = -1; - BOOL res2 = WriteFile(hFileIn1, buffer, bytesRead, &bytesWritten, nullptr); - if(res2 == 0) + BOOL res2 = WriteFile(hFileIn1, buffer, bytesRead, &bytesWritten, nullptr); + if (res2 == 0) { LogError("Failed to write '%s' at offset %lld. GetLastError()=%u", nameOfFile1, offset, GetLastError()); return -1; } - if(bytesRead!=bytesWritten) + if (bytesRead != bytesWritten) { LogError("Failed to read/write matching bytes %u!=%u", bytesRead, bytesWritten); return -1; @@ -80,20 +82,20 @@ int verbConcat::DoWork(const char *nameOfFile1, const char *nameOfFile2) delete[] buffer; - if(CloseHandle(hFileIn1)==0) + if (CloseHandle(hFileIn1) == 0) { LogError("CloseHandle failed. GetLastError()=%u", GetLastError()); return -1; } - if(CloseHandle(hFileIn2)==0) + if (CloseHandle(hFileIn2) == 0) { LogError("2nd CloseHandle failed. GetLastError()=%u", GetLastError()); return -1; } - LogInfo("Read/Wrote %lld MB @ %4.2f MB/s.\n", - DataTemp2.QuadPart/(1000*1000), - (((double)DataTemp2.QuadPart)/(1000*1000))/st1.GetSeconds()); //yes yes.. http://en.wikipedia.org/wiki/Megabyte_per_second#Megabyte_per_second + LogInfo("Read/Wrote %lld MB @ %4.2f MB/s.\n", DataTemp2.QuadPart / (1000 * 1000), + (((double)DataTemp2.QuadPart) / (1000 * 1000)) / + st1.GetSeconds()); // yes yes.. http://en.wikipedia.org/wiki/Megabyte_per_second#Megabyte_per_second return 0; } diff --git a/src/ToolBox/superpmi/mcs/verbconcat.h b/src/ToolBox/superpmi/mcs/verbconcat.h index 26e55857bd..85674ff7d9 100644 --- a/src/ToolBox/superpmi/mcs/verbconcat.h +++ b/src/ToolBox/superpmi/mcs/verbconcat.h @@ -12,6 +12,6 @@ class verbConcat { public: - static int DoWork(const char *nameOfFile1, const char *nameOfFile2); + static int DoWork(const char* nameOfFile1, const char* nameOfFile2); }; #endif diff --git a/src/ToolBox/superpmi/mcs/verbdump.cpp b/src/ToolBox/superpmi/mcs/verbdump.cpp index 290cbdbac5..7a04abced6 100644 --- a/src/ToolBox/superpmi/mcs/verbdump.cpp +++ b/src/ToolBox/superpmi/mcs/verbdump.cpp @@ -10,7 +10,7 @@ #include "methodcontextiterator.h" #include "errorhandling.h" -int verbDump::DoWork(const char *nameOfInput, int indexCount, const int *indexes) +int verbDump::DoWork(const char* nameOfInput, int indexCount, const int* indexes) { LogVerbose("Dumping '%s' to console", nameOfInput); diff --git a/src/ToolBox/superpmi/mcs/verbdump.h b/src/ToolBox/superpmi/mcs/verbdump.h index 32f4b0d661..4c0f295276 100644 --- a/src/ToolBox/superpmi/mcs/verbdump.h +++ b/src/ToolBox/superpmi/mcs/verbdump.h @@ -12,6 +12,6 @@ class verbDump { public: - static int DoWork(const char *nameofInput, int indexCount, const int *indexes); + static int DoWork(const char* nameofInput, int indexCount, const int* indexes); }; #endif diff --git a/src/ToolBox/superpmi/mcs/verbdumpmap.cpp b/src/ToolBox/superpmi/mcs/verbdumpmap.cpp index 3fc8268f5f..2acd2b636d 100644 --- a/src/ToolBox/superpmi/mcs/verbdumpmap.cpp +++ b/src/ToolBox/superpmi/mcs/verbdumpmap.cpp @@ -19,16 +19,16 @@ void DumpMapHeader() printf("full signature\n"); } -void DumpMap(int index, MethodContext *mc) +void DumpMap(int index, MethodContext* mc) { CORINFO_METHOD_INFO cmi; - unsigned int flags = 0; + unsigned int flags = 0; mc->repCompileMethod(&cmi, &flags); - const char *moduleName = nullptr; - const char *methodName = mc->repGetMethodName(cmi.ftn, &moduleName); - const char *className = mc->repGetClassName(mc->repGetMethodClass(cmi.ftn)); + const char* moduleName = nullptr; + const char* methodName = mc->repGetMethodName(cmi.ftn, &moduleName); + const char* className = mc->repGetClassName(mc->repGetMethodClass(cmi.ftn)); printf("%d,", index); // printf("\"%s\",", mc->cr->repProcessName()); @@ -43,7 +43,7 @@ void DumpMap(int index, MethodContext *mc) printf(")\"\n"); } -int verbDumpMap::DoWork(const char *nameOfInput) +int verbDumpMap::DoWork(const char* nameOfInput) { MethodContextIterator mci; if (!mci.Initialize(nameOfInput)) diff --git a/src/ToolBox/superpmi/mcs/verbdumpmap.h b/src/ToolBox/superpmi/mcs/verbdumpmap.h index 129b8d8440..93e0854cdf 100644 --- a/src/ToolBox/superpmi/mcs/verbdumpmap.h +++ b/src/ToolBox/superpmi/mcs/verbdumpmap.h @@ -12,6 +12,6 @@ class verbDumpMap { public: - static int DoWork(const char *nameofInput); + static int DoWork(const char* nameofInput); }; #endif diff --git a/src/ToolBox/superpmi/mcs/verbdumptoc.cpp b/src/ToolBox/superpmi/mcs/verbdumptoc.cpp index 2837f0bf3e..f9cc69effa 100644 --- a/src/ToolBox/superpmi/mcs/verbdumptoc.cpp +++ b/src/ToolBox/superpmi/mcs/verbdumptoc.cpp @@ -9,7 +9,7 @@ #include "tocfile.h" #include "runtimedetails.h" -int verbDumpToc::DoWork(const char *nameOfInput) +int verbDumpToc::DoWork(const char* nameOfInput) { TOCFile tf; diff --git a/src/ToolBox/superpmi/mcs/verbdumptoc.h b/src/ToolBox/superpmi/mcs/verbdumptoc.h index c2ea880b52..dffb4b4373 100644 --- a/src/ToolBox/superpmi/mcs/verbdumptoc.h +++ b/src/ToolBox/superpmi/mcs/verbdumptoc.h @@ -12,6 +12,6 @@ class verbDumpToc { public: - static int DoWork(const char *nameOfInput1); + static int DoWork(const char* nameOfInput1); }; #endif diff --git a/src/ToolBox/superpmi/mcs/verbfracture.cpp b/src/ToolBox/superpmi/mcs/verbfracture.cpp index bcc6d04e1d..68cc7affbf 100644 --- a/src/ToolBox/superpmi/mcs/verbfracture.cpp +++ b/src/ToolBox/superpmi/mcs/verbfracture.cpp @@ -11,17 +11,19 @@ #include "errorhandling.h" #include "logging.h" -int verbFracture::DoWork(const char *nameOfInput, const char *nameOfOutput, int indexCount, const int *indexes, bool stripCR) +int verbFracture::DoWork( + const char* nameOfInput, const char* nameOfOutput, int indexCount, const int* indexes, bool stripCR) { int rangeSize = indexes[0]; - LogVerbose("Reading from '%s' copying %d MethodContexts files into each output file of '%s'", nameOfInput, rangeSize, nameOfOutput); + LogVerbose("Reading from '%s' copying %d MethodContexts files into each output file of '%s'", nameOfInput, + rangeSize, nameOfOutput); MethodContextIterator mci(true); if (!mci.Initialize(nameOfInput)) return -1; - int fileCount = 0; + int fileCount = 0; char fileName[512]; HANDLE hFileOut = INVALID_HANDLE_VALUE; @@ -41,7 +43,8 @@ int verbFracture::DoWork(const char *nameOfInput, const char *nameOfOutput, int hFileOut = INVALID_HANDLE_VALUE; } sprintf_s(fileName, 512, "%s-%0*d.mch", nameOfOutput, 5, fileCount++); - hFileOut = CreateFileA(fileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN, NULL); + hFileOut = CreateFileA(fileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (hFileOut == INVALID_HANDLE_VALUE) { LogError("Failed to open output file '%s'. GetLastError()=%u", fileName, GetLastError()); diff --git a/src/ToolBox/superpmi/mcs/verbfracture.h b/src/ToolBox/superpmi/mcs/verbfracture.h index feddbe1908..f156be198d 100644 --- a/src/ToolBox/superpmi/mcs/verbfracture.h +++ b/src/ToolBox/superpmi/mcs/verbfracture.h @@ -12,6 +12,7 @@ class verbFracture { public: - static int DoWork(const char *nameOfInput1, const char *nameOfOutput, int indexCount, const int *indexes, bool stripCR); + static int DoWork( + const char* nameOfInput1, const char* nameOfOutput, int indexCount, const int* indexes, bool stripCR); }; #endif diff --git a/src/ToolBox/superpmi/mcs/verbildump.cpp b/src/ToolBox/superpmi/mcs/verbildump.cpp index 23b68da003..d46ad2b20b 100644 --- a/src/ToolBox/superpmi/mcs/verbildump.cpp +++ b/src/ToolBox/superpmi/mcs/verbildump.cpp @@ -9,48 +9,90 @@ #include "methodcontextiterator.h" #include "verbildump.h" -void DumpPrimToConsoleBare(MethodContext *mc, CorInfoType prim, DWORDLONG classHandle) +void DumpPrimToConsoleBare(MethodContext* mc, CorInfoType prim, DWORDLONG classHandle) { - switch(prim) + switch (prim) { - case CORINFO_TYPE_VOID: printf("void"); return; - case CORINFO_TYPE_BOOL: printf("bool"); return; - case CORINFO_TYPE_CHAR: printf("char"); return; - case CORINFO_TYPE_BYTE: printf("int8"); return; - case CORINFO_TYPE_UBYTE: printf("unsigned int8"); return; - case CORINFO_TYPE_SHORT: printf("int16"); return; - case CORINFO_TYPE_USHORT: printf("unsigned int16"); return; - case CORINFO_TYPE_INT: printf("int32"); return; - case CORINFO_TYPE_UINT: printf("unsigned int32"); return; - case CORINFO_TYPE_LONG: printf("int64"); return; - case CORINFO_TYPE_ULONG: printf("unsigned int64"); return; - case CORINFO_TYPE_NATIVEINT: printf("native int"); return; - case CORINFO_TYPE_NATIVEUINT: printf("native unsigned int"); return; - case CORINFO_TYPE_FLOAT: printf("float32"); return; - case CORINFO_TYPE_DOUBLE: printf("float64"); return; -// case CORINFO_TYPE_STRING: printf("string"); return; - case CORINFO_TYPE_PTR: printf("ptr"); return; - case CORINFO_TYPE_BYREF: printf("byref"); return; - case CORINFO_TYPE_VALUECLASS: printf("valueclass %s", mc->repGetClassName((CORINFO_CLASS_HANDLE)classHandle)); return; - case CORINFO_TYPE_CLASS: printf("class %s", mc->repGetClassName((CORINFO_CLASS_HANDLE)classHandle)); return; - case CORINFO_TYPE_REFANY: printf("refany"); return; - case CORINFO_TYPE_VAR: printf("var"); return; - default: - LogWarning("unknown type in PrimToString(0x%x)",prim); - __debugbreak(); - return; - } + case CORINFO_TYPE_VOID: + printf("void"); + return; + case CORINFO_TYPE_BOOL: + printf("bool"); + return; + case CORINFO_TYPE_CHAR: + printf("char"); + return; + case CORINFO_TYPE_BYTE: + printf("int8"); + return; + case CORINFO_TYPE_UBYTE: + printf("unsigned int8"); + return; + case CORINFO_TYPE_SHORT: + printf("int16"); + return; + case CORINFO_TYPE_USHORT: + printf("unsigned int16"); + return; + case CORINFO_TYPE_INT: + printf("int32"); + return; + case CORINFO_TYPE_UINT: + printf("unsigned int32"); + return; + case CORINFO_TYPE_LONG: + printf("int64"); + return; + case CORINFO_TYPE_ULONG: + printf("unsigned int64"); + return; + case CORINFO_TYPE_NATIVEINT: + printf("native int"); + return; + case CORINFO_TYPE_NATIVEUINT: + printf("native unsigned int"); + return; + case CORINFO_TYPE_FLOAT: + printf("float32"); + return; + case CORINFO_TYPE_DOUBLE: + printf("float64"); + return; + // case CORINFO_TYPE_STRING: printf("string"); return; + case CORINFO_TYPE_PTR: + printf("ptr"); + return; + case CORINFO_TYPE_BYREF: + printf("byref"); + return; + case CORINFO_TYPE_VALUECLASS: + printf("valueclass %s", mc->repGetClassName((CORINFO_CLASS_HANDLE)classHandle)); + return; + case CORINFO_TYPE_CLASS: + printf("class %s", mc->repGetClassName((CORINFO_CLASS_HANDLE)classHandle)); + return; + case CORINFO_TYPE_REFANY: + printf("refany"); + return; + case CORINFO_TYPE_VAR: + printf("var"); + return; + default: + LogWarning("unknown type in PrimToString(0x%x)", prim); + __debugbreak(); + return; + } } -void DumpSigToConsoleBare(MethodContext *mc, CORINFO_SIG_INFO *pSig) +void DumpSigToConsoleBare(MethodContext* mc, CORINFO_SIG_INFO* pSig) { CORINFO_ARG_LIST_HANDLE currentItem = pSig->args; - DWORD exceptionCode; + DWORD exceptionCode; - for(int i=0; i < (int)pSig->numArgs; i++) + for (int i = 0; i < (int)pSig->numArgs; i++) { - DWORDLONG dl; - CorInfoTypeWithMod type = mc->repGetArgType(pSig, currentItem, (CORINFO_CLASS_HANDLE *)&dl, &exceptionCode); - CorInfoType cit = strip(type); + DWORDLONG dl; + CorInfoTypeWithMod type = mc->repGetArgType(pSig, currentItem, (CORINFO_CLASS_HANDLE*)&dl, &exceptionCode); + CorInfoType cit = strip(type); if (cit == CORINFO_TYPE_CLASS) dl = (DWORDLONG)mc->repGetArgClass(pSig, currentItem, &exceptionCode); if ((type & CORINFO_TYPE_MOD_PINNED) == CORINFO_TYPE_MOD_PINNED) @@ -62,521 +104,839 @@ void DumpSigToConsoleBare(MethodContext *mc, CORINFO_SIG_INFO *pSig) } } - -void DumpILToConsoleBare(unsigned char *ilCode, int len) +void DumpILToConsoleBare(unsigned char* ilCode, int len) { - int i,j,k; - for(i=0;i<len;i++) + int i, j, k; + for (i = 0; i < len; i++) { - printf("IL_%04x: ",i); - switch(ilCode[i]) + printf("IL_%04x: ", i); + switch (ilCode[i]) { - case 0x00:printf("nop");continue; - case 0x01:printf("break");continue; - case 0x02:printf("ldarg.0");continue; - case 0x03:printf("ldarg.1");continue; - case 0x04:printf("ldarg.2");continue; - case 0x05:printf("ldarg.3");continue; - case 0x06:printf("ldloc.0");continue; - case 0x07:printf("ldloc.1");continue; - case 0x08:printf("ldloc.2");continue; - case 0x09:printf("ldloc.3");continue; - case 0x0a:printf("stloc.0");continue; - case 0x0b:printf("stloc.1");continue; - case 0x0c:printf("stloc.2");continue; - case 0x0d:printf("stloc.3");continue; - case 0x0e: //ldarg.s X - printf("ldarg.s 0x%02x", ilCode[i+1]); - i+=1; - continue; - case 0x0f: //ldarga.s X - printf("ldarga.s 0x%02x", ilCode[i+1]); - i+=1; - continue; - case 0x10: //starg.s X - printf("starg.s 0x%02x", ilCode[i+1]); - i+=1; - continue; - case 0x11: //ldloc.s X - printf("ldloc.s 0x%02x", ilCode[i+1]); - i+=1; - continue; - case 0x12: //ldloca.s X - printf("ldloca.s 0x%02x", ilCode[i+1]); - i+=1; - continue; - case 0x13: //stloc.s X - printf("stloc.s 0x%02x", ilCode[i+1]); - i+=1; - continue; - case 0x14:printf("ldnull");continue; - case 0x15:printf("ldc.i4.m1");continue; - case 0x16:printf("ldc.i4.0");continue; - case 0x17:printf("ldc.i4.1");continue; - case 0x18:printf("ldc.i4.2");continue; - case 0x19:printf("ldc.i4.3");continue; - case 0x1a:printf("ldc.i4.4");continue; - case 0x1b:printf("ldc.i4.5");continue; - case 0x1c:printf("ldc.i4.6");continue; - case 0x1d:printf("ldc.i4.7");continue; - case 0x1e:printf("ldc.i4.8");continue; - case 0x1f: //ldc.i4.s X - printf("ldc.i4.s 0x%02x", ilCode[i+1]); - i+=1; - continue; - case 0x20: //ldc.i4 XXXX - printf("ldc.i4 0x%02x%02x%02x%02x", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x21: //ldc.i8 XXXXXXXX - printf("ldc.i8 0x%02x%02x%02x%02x%02x%02x%02x%02x", ilCode[i+8], ilCode[i+7], ilCode[i+6], ilCode[i+5], ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=8; - continue; - case 0x22: //ldc.r4 XXXX - printf("ldc.r4 float32(0x%02x%02x%02x%02x)", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x23: //ldc.r8 XXXXXXXX - printf("ldc.r8 float64(0x%02x%02x%02x%02x%02x%02x%02x%02x)", ilCode[i+8], ilCode[i+7], ilCode[i+6], ilCode[i+5], ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=8; - continue; - case 0x25:printf("dup");continue; - case 0x26:printf("pop");continue; - case 0x27: //JMP <T> - printf("jmp <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x28: //call <T> - printf("call <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x29: //calli <T> - printf("calli <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x2a:printf("ret");continue; - case 0x2b: //br.s X - printf("br.s IL_%04x", i+2+ilCode[i+1]);; - i+=1; - continue; - case 0x2c: //brfalse.s X - printf("brfalse.s IL_%04x", i+2+ilCode[i+1]);; - i+=1; - continue; - case 0x2d: //brtrue.s X - printf("brtrue.s IL_%04x", i+2+ilCode[i+1]);; - i+=1; - continue; - case 0x2e: //beq.s X - printf("beq.s IL_%04x", i+2+ilCode[i+1]);; - i+=1; - continue; - case 0x2f: //bgt.s X - printf("bgt.s IL_%04x", i+2+ilCode[i+1]);; - i+=1; - continue; - case 0x30: //bgt.s X - printf("bgt.s IL_%04x", i+2+ilCode[i+1]);; - i+=1; - continue; - case 0x31: //ble.s X - printf("ble.s IL_%04x", i+2+ilCode[i+1]);; - i+=1; - continue; - case 0x32: //blt.s X - printf("blt.s IL_%04x", i+2+ilCode[i+1]);; - i+=1; - continue; - case 0x33: //bne.un.s X - printf("bne.un.s IL_%04x", i+2+ilCode[i+1]);; - i+=1; - continue; - case 0x34: //bge.un.s X - printf("bge.un.s IL_%04x", i+2+ilCode[i+1]);; - i+=1; - continue; - case 0x35: //bgt.un.s X - printf("bgt.un.s IL_%04x", i+2+ilCode[i+1]);; - i+=1; - continue; - case 0x36: //ble.un.s X - printf("ble.un.s IL_%04x", i+2+ilCode[i+1]);; - i+=1; - continue; - case 0x37: //blt.un.s X - printf("blt.un.s IL_%04x", i+2+ilCode[i+1]);; - i+=1; - continue; - case 0x38: //br XXXX - printf("br IL_%04x", i+5+(ilCode[i+4]<<24|ilCode[i+3]<<16|ilCode[i+2]<<8|ilCode[i+1])); - i+=4; - continue; - case 0x39: //brfalse XXXX - printf("brfalse IL_%04x", i+5+(ilCode[i+4]<<24|ilCode[i+3]<<16|ilCode[i+2]<<8|ilCode[i+1])); - i+=4; - continue; - case 0x3a: //brtrue XXXX - printf("brtrue IL_%04x", i+5+(ilCode[i+4]<<24|ilCode[i+3]<<16|ilCode[i+2]<<8|ilCode[i+1])); - i+=4; - continue; - case 0x3b: //beq XXXX - printf("beq IL_%04x", i+5+(ilCode[i+4]<<24|ilCode[i+3]<<16|ilCode[i+2]<<8|ilCode[i+1])); - i+=4; - continue; - case 0x3c: //bgt XXXX - printf("bgt IL_%04x", i+5+(ilCode[i+4]<<24|ilCode[i+3]<<16|ilCode[i+2]<<8|ilCode[i+1])); - i+=4; - continue; - case 0x3d: //bgt XXXX - printf("bgt IL_%04x", i+5+(ilCode[i+4]<<24|ilCode[i+3]<<16|ilCode[i+2]<<8|ilCode[i+1])); - i+=4; - continue; - case 0x3e: //ble XXXX - printf("ble IL_%04x", i+5+(ilCode[i+4]<<24|ilCode[i+3]<<16|ilCode[i+2]<<8|ilCode[i+1])); - i+=4; - continue; - case 0x3f: //blt XXXX - printf("blt IL_%04x", i+5+(ilCode[i+4]<<24|ilCode[i+3]<<16|ilCode[i+2]<<8|ilCode[i+1])); - i+=4; - continue; - case 0x40: //bne.un XXXX - printf("bne.un IL_%04x", i+5+(ilCode[i+4]<<24|ilCode[i+3]<<16|ilCode[i+2]<<8|ilCode[i+1])); - i+=4; - continue; - case 0x41: //bge.un XXXX - printf("bge.un IL_%04x", i+5+(ilCode[i+4]<<24|ilCode[i+3]<<16|ilCode[i+2]<<8|ilCode[i+1])); - i+=4; - continue; - case 0x42: //bgt.un XXXX - printf("bgt.un IL_%04x", i+5+(ilCode[i+4]<<24|ilCode[i+3]<<16|ilCode[i+2]<<8|ilCode[i+1])); - i+=4; - continue; - case 0x43: //ble.un XXXX - printf("ble.un IL_%04x", i+5+(ilCode[i+4]<<24|ilCode[i+3]<<16|ilCode[i+2]<<8|ilCode[i+1])); - i+=4; - continue; - case 0x44: //blt.un XXXX - printf("blt.un IL_%04x", i+5+(ilCode[i+4]<<24|ilCode[i+3]<<16|ilCode[i+2]<<8|ilCode[i+1])); - i+=4; - continue; - case 0x45: //switch NNNN NNNN*XXXX - printf("switch (0x%02x%02x%02x%02x)", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - k = (ilCode[i+4]<<24)|(ilCode[i+3]<<16)|(ilCode[i+2]<<8)|(ilCode[i+1]<<0); - i+=4; - for(j=0;j<k;j++) - { - printf(" <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - } - continue; - case 0x46:printf("ldind.i1");continue; - case 0x47:printf("ldind.u1");continue; - case 0x48:printf("ldind.i2");continue; - case 0x49:printf("ldind.u2");continue; - case 0x4a:printf("ldind.i4");continue; - case 0x4b:printf("ldind.u4");continue; - case 0x4c:printf("ldind.i8");continue; - case 0x4d:printf("ldind.u8");continue; - case 0x4e:printf("ldind.r4");continue; - case 0x4f:printf("ldind.r8");continue; - case 0x50:printf("ldind.ref");continue; - case 0x51:printf("stind.ref");continue; - case 0x52:printf("stind.i1");continue; - case 0x53:printf("stind.i2");continue; - case 0x54:printf("stind.i4");continue; - case 0x55:printf("stind.i8");continue; - case 0x56:printf("stind.r4");continue; - case 0x57:printf("stind.r8");continue; - case 0x58:printf("add");continue; - case 0x59:printf("sub");continue; - case 0x5a:printf("mul");continue; - case 0x5b:printf("div");continue; - case 0x5c:printf("div.un");continue; - case 0x5d:printf("rem");continue; - case 0x5e:printf("rem.un");continue; - case 0x5f:printf("and");continue; - case 0x60:printf("or");continue; - case 0x61:printf("xor");continue; - case 0x62:printf("shl");continue; - case 0x63:printf("shr");continue; - case 0x64:printf("shr.un");continue; - case 0x65:printf("neg");continue; - case 0x66:printf("not");continue; - case 0x67:printf("conv.i1");continue; - case 0x68:printf("conv.i2");continue; - case 0x69:printf("conv.i4");continue; - case 0x6a:printf("conv.i8");continue; - case 0x6b:printf("conv.r4");continue; - case 0x6c:printf("conv.r8");continue; - case 0x6d:printf("conv.u4");continue; - case 0x6e:printf("conv.u8");continue; - case 0x6f: //callvirt <T> - printf("callvirt <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x70: //cpobj <T> - printf("cpobj <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x71: //ldobj <T> - printf("ldobj <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x72: //ldstr <T> - printf("ldstr <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x73: //newobj <T> - printf("newobj <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x74: //castclass <T> - printf("castclass <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x75: //isinst <T> - printf("isinst <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x76:printf("conv.r.un");continue; - case 0x79: //unbox <T> - printf("unbox <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x7a:printf("throw");continue; - case 0x7b: //ldfld <T> - printf("ldfld <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x7c: //ldflda <T> - printf("ldflda <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x7d: //stfld <T> - printf("stfld <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x7e: //ldsfld <T> - printf("ldsfld <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x7f: //ldsflda <T> - printf("ldsflda <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x80: //stsfld <T> - printf("stsfld <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x81: //stobj <T> - printf("stobj <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x82:printf("conv.ovf.i1.un");continue; - case 0x83:printf("conv.ovf.i2.un");continue; - case 0x84:printf("conv.ovf.i4.un");continue; - case 0x85:printf("conv.ovf.i8.un");continue; - case 0x86:printf("conv.ovf.u1.un");continue; - case 0x87:printf("conv.ovf.u2.un");continue; - case 0x88:printf("conv.ovf.u4.un");continue; - case 0x89:printf("conv.ovf.u8.un");continue; - case 0x8a:printf("conv.ovf.i.un");continue; - case 0x8b:printf("conv.ovf.u.un");continue; - case 0x8c: //box <T> - printf("box <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x8d: //newarr <T> - printf("newarr <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x8e:printf("ldlen");continue; - case 0x8f:printf("ldelema <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x90:printf("ldelem.i1");continue; - case 0x91:printf("ldelem.u1");continue; - case 0x92:printf("ldelem.i2");continue; - case 0x93:printf("ldelem.u2");continue; - case 0x94:printf("ldelem.i4");continue; - case 0x95:printf("ldelem.u4");continue; - case 0x96:printf("ldelem.i8");continue; - case 0x97:printf("ldelem.i");continue; - case 0x98:printf("ldelem.r4");continue; - case 0x99:printf("ldelem.r8");continue; - case 0x9a:printf("ldelem.ref");continue; - case 0x9b:printf("stelem.i");continue; - case 0x9c:printf("stelem.i1");continue; - case 0x9d:printf("stelem.i2");continue; - case 0x9e:printf("stelem.i4");continue; - case 0x9f:printf("stelem.i8");continue; - case 0xa0:printf("stelem.r4");continue; - case 0xa1:printf("stelem.r8");continue; - case 0xa2:printf("stelem.ref");continue; - case 0xa3:printf("stelem <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0xa4:printf("stelem <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0xa5:printf("unbox.any <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0xb3:printf("conv.ovf.i1");continue; - case 0xb4:printf("conv.ovf.u1");continue; - case 0xb5:printf("conv.ovf.i2");continue; - case 0xb6:printf("conv.ovf.u2");continue; - case 0xb7:printf("conv.ovf.i4");continue; - case 0xb8:printf("conv.ovf.u4");continue; - case 0xb9:printf("conv.ovf.i8");continue; - case 0xba:printf("conv.ovf.u8");continue; - case 0xc2: //refanyval <T> - printf("refanyval <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0xc3:printf("ckfinite");continue; - case 0xc6: //mkrefany <T> - printf("mkrefany <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0xd0: //ldtoken <T> - printf("ldtoken <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0xd1:printf("conv.u2");continue; - case 0xd2:printf("conv.u1");continue; - case 0xd3:printf("conv.i");continue; - case 0xd4:printf("conv.ovf.i");continue; - case 0xd5:printf("conv.ovf.u");continue; - case 0xd6:printf("add.ovf");continue; - case 0xd7:printf("add.ovf.un");continue; - case 0xd8:printf("mul.ovf");continue; - case 0xd9:printf("mul.ovf.un");continue; - case 0xda:printf("sub.ovf");continue; - case 0xdb:printf("sub.ovf.un");continue; - case 0xdc:printf("endfinally");continue; - case 0xdd: //leave XXXX - printf("leave 0x%02x%02x%02x%02x", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0xde: //leave.s X - printf("leave 0x%02x", ilCode[i+1]); - i+=1; - continue; - case 0xdf:printf("stind.i");continue; - case 0xe0:printf("conv.u");continue; - case 0xfe: - i++; - switch(ilCode[i]) - { - case 0x00:printf("arglist");continue; - case 0x01:printf("ceq");continue; - case 0x02:printf("cgt");continue; - case 0x03:printf("cgt.un");continue; - case 0x04:printf("clt");continue; - case 0x05:printf("clt.un");continue; - case 0x06: //ldftn <T> - printf("ldftn <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x07: //ldvirtftn <T> - printf("ldvirtftn <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x09: //ldarg XX - printf("ldarg 0x%02x%02x", ilCode[i+2], ilCode[i+1]); - i+=2; - continue; - case 0x0a: //ldarga XX - printf("ldarga 0x%02x%02x", ilCode[i+2], ilCode[i+1]); - i+=2; - continue; - case 0x0b: //starg XX - printf("starg 0x%02x%02x", ilCode[i+2], ilCode[i+1]); - i+=2; - continue; - case 0x0c: //ldloc XX - printf("ldloc 0x%02x%02x", ilCode[i+2], ilCode[i+1]); - i+=2; - continue; - case 0x0d: //ldloca XX - printf("ldloca 0x%02x%02x", ilCode[i+2], ilCode[i+1]); - i+=2; - continue; - case 0x0e: //stloc XX - printf("stloc 0x%02x%02x", ilCode[i+2], ilCode[i+1]); - i+=2; - continue; - case 0x0f:printf("localloc");continue; - case 0x11:printf("endfilter");continue; - case 0x12: //unaligned X - printf("unaligned. 0x%02x", ilCode[i+1]); - i+=1; - continue; - case 0x13:printf("volatile.");continue; - case 0x14:printf("tail.");continue; - case 0x15: //initobj <T> - printf("initobj <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x16://incomplete? - printf("constrained. <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x17:printf("cpblk");continue; - case 0x18:printf("initblk");continue; - case 0x19:printf("no.");continue; //incomplete? - case 0x1a:printf("rethrow");continue; - case 0x1c: //sizeof <T> - printf("sizeof <0x%02x%02x%02x%02x>", ilCode[i+4], ilCode[i+3], ilCode[i+2], ilCode[i+1]); - i+=4; - continue; - case 0x1d:printf("refanytype");continue; - default: - LogError("unknown ilCode 0xfe%2x at offset %d in MethodGen::PrettyPrint", ilCode[i], i); + case 0x00: + printf("nop"); + continue; + case 0x01: + printf("break"); + continue; + case 0x02: + printf("ldarg.0"); + continue; + case 0x03: + printf("ldarg.1"); + continue; + case 0x04: + printf("ldarg.2"); + continue; + case 0x05: + printf("ldarg.3"); + continue; + case 0x06: + printf("ldloc.0"); + continue; + case 0x07: + printf("ldloc.1"); + continue; + case 0x08: + printf("ldloc.2"); + continue; + case 0x09: + printf("ldloc.3"); + continue; + case 0x0a: + printf("stloc.0"); + continue; + case 0x0b: + printf("stloc.1"); + continue; + case 0x0c: + printf("stloc.2"); + continue; + case 0x0d: + printf("stloc.3"); + continue; + case 0x0e: // ldarg.s X + printf("ldarg.s 0x%02x", ilCode[i + 1]); + i += 1; + continue; + case 0x0f: // ldarga.s X + printf("ldarga.s 0x%02x", ilCode[i + 1]); + i += 1; + continue; + case 0x10: // starg.s X + printf("starg.s 0x%02x", ilCode[i + 1]); + i += 1; + continue; + case 0x11: // ldloc.s X + printf("ldloc.s 0x%02x", ilCode[i + 1]); + i += 1; + continue; + case 0x12: // ldloca.s X + printf("ldloca.s 0x%02x", ilCode[i + 1]); + i += 1; + continue; + case 0x13: // stloc.s X + printf("stloc.s 0x%02x", ilCode[i + 1]); + i += 1; + continue; + case 0x14: + printf("ldnull"); + continue; + case 0x15: + printf("ldc.i4.m1"); + continue; + case 0x16: + printf("ldc.i4.0"); + continue; + case 0x17: + printf("ldc.i4.1"); + continue; + case 0x18: + printf("ldc.i4.2"); + continue; + case 0x19: + printf("ldc.i4.3"); + continue; + case 0x1a: + printf("ldc.i4.4"); + continue; + case 0x1b: + printf("ldc.i4.5"); + continue; + case 0x1c: + printf("ldc.i4.6"); + continue; + case 0x1d: + printf("ldc.i4.7"); + continue; + case 0x1e: + printf("ldc.i4.8"); + continue; + case 0x1f: // ldc.i4.s X + printf("ldc.i4.s 0x%02x", ilCode[i + 1]); + i += 1; + continue; + case 0x20: // ldc.i4 XXXX + printf("ldc.i4 0x%02x%02x%02x%02x", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x21: // ldc.i8 XXXXXXXX + printf("ldc.i8 0x%02x%02x%02x%02x%02x%02x%02x%02x", ilCode[i + 8], ilCode[i + 7], ilCode[i + 6], + ilCode[i + 5], ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 8; + continue; + case 0x22: // ldc.r4 XXXX + printf("ldc.r4 float32(0x%02x%02x%02x%02x)", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], + ilCode[i + 1]); + i += 4; + continue; + case 0x23: // ldc.r8 XXXXXXXX + printf("ldc.r8 float64(0x%02x%02x%02x%02x%02x%02x%02x%02x)", ilCode[i + 8], ilCode[i + 7], + ilCode[i + 6], ilCode[i + 5], ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 8; + continue; + case 0x25: + printf("dup"); + continue; + case 0x26: + printf("pop"); + continue; + case 0x27: // JMP <T> + printf("jmp <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x28: // call <T> + printf("call <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x29: // calli <T> + printf("calli <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x2a: + printf("ret"); + continue; + case 0x2b: // br.s X + printf("br.s IL_%04x", i + 2 + ilCode[i + 1]); + ; + i += 1; + continue; + case 0x2c: // brfalse.s X + printf("brfalse.s IL_%04x", i + 2 + ilCode[i + 1]); + ; + i += 1; + continue; + case 0x2d: // brtrue.s X + printf("brtrue.s IL_%04x", i + 2 + ilCode[i + 1]); + ; + i += 1; + continue; + case 0x2e: // beq.s X + printf("beq.s IL_%04x", i + 2 + ilCode[i + 1]); + ; + i += 1; + continue; + case 0x2f: // bgt.s X + printf("bgt.s IL_%04x", i + 2 + ilCode[i + 1]); + ; + i += 1; + continue; + case 0x30: // bgt.s X + printf("bgt.s IL_%04x", i + 2 + ilCode[i + 1]); + ; + i += 1; + continue; + case 0x31: // ble.s X + printf("ble.s IL_%04x", i + 2 + ilCode[i + 1]); + ; + i += 1; + continue; + case 0x32: // blt.s X + printf("blt.s IL_%04x", i + 2 + ilCode[i + 1]); + ; + i += 1; + continue; + case 0x33: // bne.un.s X + printf("bne.un.s IL_%04x", i + 2 + ilCode[i + 1]); + ; + i += 1; + continue; + case 0x34: // bge.un.s X + printf("bge.un.s IL_%04x", i + 2 + ilCode[i + 1]); + ; + i += 1; + continue; + case 0x35: // bgt.un.s X + printf("bgt.un.s IL_%04x", i + 2 + ilCode[i + 1]); + ; + i += 1; + continue; + case 0x36: // ble.un.s X + printf("ble.un.s IL_%04x", i + 2 + ilCode[i + 1]); + ; + i += 1; + continue; + case 0x37: // blt.un.s X + printf("blt.un.s IL_%04x", i + 2 + ilCode[i + 1]); + ; + i += 1; + continue; + case 0x38: // br XXXX + printf("br IL_%04x", + i + 5 + (ilCode[i + 4] << 24 | ilCode[i + 3] << 16 | ilCode[i + 2] << 8 | ilCode[i + 1])); + i += 4; + continue; + case 0x39: // brfalse XXXX + printf("brfalse IL_%04x", + i + 5 + (ilCode[i + 4] << 24 | ilCode[i + 3] << 16 | ilCode[i + 2] << 8 | ilCode[i + 1])); + i += 4; + continue; + case 0x3a: // brtrue XXXX + printf("brtrue IL_%04x", + i + 5 + (ilCode[i + 4] << 24 | ilCode[i + 3] << 16 | ilCode[i + 2] << 8 | ilCode[i + 1])); + i += 4; + continue; + case 0x3b: // beq XXXX + printf("beq IL_%04x", + i + 5 + (ilCode[i + 4] << 24 | ilCode[i + 3] << 16 | ilCode[i + 2] << 8 | ilCode[i + 1])); + i += 4; + continue; + case 0x3c: // bgt XXXX + printf("bgt IL_%04x", + i + 5 + (ilCode[i + 4] << 24 | ilCode[i + 3] << 16 | ilCode[i + 2] << 8 | ilCode[i + 1])); + i += 4; + continue; + case 0x3d: // bgt XXXX + printf("bgt IL_%04x", + i + 5 + (ilCode[i + 4] << 24 | ilCode[i + 3] << 16 | ilCode[i + 2] << 8 | ilCode[i + 1])); + i += 4; + continue; + case 0x3e: // ble XXXX + printf("ble IL_%04x", + i + 5 + (ilCode[i + 4] << 24 | ilCode[i + 3] << 16 | ilCode[i + 2] << 8 | ilCode[i + 1])); + i += 4; + continue; + case 0x3f: // blt XXXX + printf("blt IL_%04x", + i + 5 + (ilCode[i + 4] << 24 | ilCode[i + 3] << 16 | ilCode[i + 2] << 8 | ilCode[i + 1])); + i += 4; + continue; + case 0x40: // bne.un XXXX + printf("bne.un IL_%04x", + i + 5 + (ilCode[i + 4] << 24 | ilCode[i + 3] << 16 | ilCode[i + 2] << 8 | ilCode[i + 1])); + i += 4; + continue; + case 0x41: // bge.un XXXX + printf("bge.un IL_%04x", + i + 5 + (ilCode[i + 4] << 24 | ilCode[i + 3] << 16 | ilCode[i + 2] << 8 | ilCode[i + 1])); + i += 4; + continue; + case 0x42: // bgt.un XXXX + printf("bgt.un IL_%04x", + i + 5 + (ilCode[i + 4] << 24 | ilCode[i + 3] << 16 | ilCode[i + 2] << 8 | ilCode[i + 1])); + i += 4; + continue; + case 0x43: // ble.un XXXX + printf("ble.un IL_%04x", + i + 5 + (ilCode[i + 4] << 24 | ilCode[i + 3] << 16 | ilCode[i + 2] << 8 | ilCode[i + 1])); + i += 4; + continue; + case 0x44: // blt.un XXXX + printf("blt.un IL_%04x", + i + 5 + (ilCode[i + 4] << 24 | ilCode[i + 3] << 16 | ilCode[i + 2] << 8 | ilCode[i + 1])); + i += 4; + continue; + case 0x45: // switch NNNN NNNN*XXXX + printf("switch (0x%02x%02x%02x%02x)", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + k = (ilCode[i + 4] << 24) | (ilCode[i + 3] << 16) | (ilCode[i + 2] << 8) | (ilCode[i + 1] << 0); + i += 4; + for (j = 0; j < k; j++) + { + printf(" <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + } + continue; + case 0x46: + printf("ldind.i1"); + continue; + case 0x47: + printf("ldind.u1"); + continue; + case 0x48: + printf("ldind.i2"); + continue; + case 0x49: + printf("ldind.u2"); + continue; + case 0x4a: + printf("ldind.i4"); + continue; + case 0x4b: + printf("ldind.u4"); + continue; + case 0x4c: + printf("ldind.i8"); + continue; + case 0x4d: + printf("ldind.u8"); + continue; + case 0x4e: + printf("ldind.r4"); + continue; + case 0x4f: + printf("ldind.r8"); + continue; + case 0x50: + printf("ldind.ref"); + continue; + case 0x51: + printf("stind.ref"); + continue; + case 0x52: + printf("stind.i1"); + continue; + case 0x53: + printf("stind.i2"); + continue; + case 0x54: + printf("stind.i4"); + continue; + case 0x55: + printf("stind.i8"); + continue; + case 0x56: + printf("stind.r4"); + continue; + case 0x57: + printf("stind.r8"); + continue; + case 0x58: + printf("add"); + continue; + case 0x59: + printf("sub"); + continue; + case 0x5a: + printf("mul"); + continue; + case 0x5b: + printf("div"); + continue; + case 0x5c: + printf("div.un"); + continue; + case 0x5d: + printf("rem"); + continue; + case 0x5e: + printf("rem.un"); + continue; + case 0x5f: + printf("and"); + continue; + case 0x60: + printf("or"); + continue; + case 0x61: + printf("xor"); + continue; + case 0x62: + printf("shl"); + continue; + case 0x63: + printf("shr"); + continue; + case 0x64: + printf("shr.un"); + continue; + case 0x65: + printf("neg"); + continue; + case 0x66: + printf("not"); + continue; + case 0x67: + printf("conv.i1"); + continue; + case 0x68: + printf("conv.i2"); + continue; + case 0x69: + printf("conv.i4"); + continue; + case 0x6a: + printf("conv.i8"); + continue; + case 0x6b: + printf("conv.r4"); + continue; + case 0x6c: + printf("conv.r8"); + continue; + case 0x6d: + printf("conv.u4"); + continue; + case 0x6e: + printf("conv.u8"); + continue; + case 0x6f: // callvirt <T> + printf("callvirt <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x70: // cpobj <T> + printf("cpobj <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x71: // ldobj <T> + printf("ldobj <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x72: // ldstr <T> + printf("ldstr <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x73: // newobj <T> + printf("newobj <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x74: // castclass <T> + printf("castclass <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x75: // isinst <T> + printf("isinst <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x76: + printf("conv.r.un"); + continue; + case 0x79: // unbox <T> + printf("unbox <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x7a: + printf("throw"); + continue; + case 0x7b: // ldfld <T> + printf("ldfld <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x7c: // ldflda <T> + printf("ldflda <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x7d: // stfld <T> + printf("stfld <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x7e: // ldsfld <T> + printf("ldsfld <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x7f: // ldsflda <T> + printf("ldsflda <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x80: // stsfld <T> + printf("stsfld <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x81: // stobj <T> + printf("stobj <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x82: + printf("conv.ovf.i1.un"); + continue; + case 0x83: + printf("conv.ovf.i2.un"); + continue; + case 0x84: + printf("conv.ovf.i4.un"); + continue; + case 0x85: + printf("conv.ovf.i8.un"); + continue; + case 0x86: + printf("conv.ovf.u1.un"); + continue; + case 0x87: + printf("conv.ovf.u2.un"); + continue; + case 0x88: + printf("conv.ovf.u4.un"); + continue; + case 0x89: + printf("conv.ovf.u8.un"); + continue; + case 0x8a: + printf("conv.ovf.i.un"); + continue; + case 0x8b: + printf("conv.ovf.u.un"); + continue; + case 0x8c: // box <T> + printf("box <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x8d: // newarr <T> + printf("newarr <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x8e: + printf("ldlen"); + continue; + case 0x8f: + printf("ldelema <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0x90: + printf("ldelem.i1"); + continue; + case 0x91: + printf("ldelem.u1"); + continue; + case 0x92: + printf("ldelem.i2"); + continue; + case 0x93: + printf("ldelem.u2"); + continue; + case 0x94: + printf("ldelem.i4"); + continue; + case 0x95: + printf("ldelem.u4"); + continue; + case 0x96: + printf("ldelem.i8"); + continue; + case 0x97: + printf("ldelem.i"); + continue; + case 0x98: + printf("ldelem.r4"); + continue; + case 0x99: + printf("ldelem.r8"); + continue; + case 0x9a: + printf("ldelem.ref"); + continue; + case 0x9b: + printf("stelem.i"); + continue; + case 0x9c: + printf("stelem.i1"); + continue; + case 0x9d: + printf("stelem.i2"); + continue; + case 0x9e: + printf("stelem.i4"); + continue; + case 0x9f: + printf("stelem.i8"); + continue; + case 0xa0: + printf("stelem.r4"); + continue; + case 0xa1: + printf("stelem.r8"); + continue; + case 0xa2: + printf("stelem.ref"); + continue; + case 0xa3: + printf("stelem <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0xa4: + printf("stelem <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0xa5: + printf("unbox.any <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0xb3: + printf("conv.ovf.i1"); + continue; + case 0xb4: + printf("conv.ovf.u1"); + continue; + case 0xb5: + printf("conv.ovf.i2"); + continue; + case 0xb6: + printf("conv.ovf.u2"); + continue; + case 0xb7: + printf("conv.ovf.i4"); + continue; + case 0xb8: + printf("conv.ovf.u4"); + continue; + case 0xb9: + printf("conv.ovf.i8"); + continue; + case 0xba: + printf("conv.ovf.u8"); + continue; + case 0xc2: // refanyval <T> + printf("refanyval <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0xc3: + printf("ckfinite"); + continue; + case 0xc6: // mkrefany <T> + printf("mkrefany <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0xd0: // ldtoken <T> + printf("ldtoken <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0xd1: + printf("conv.u2"); + continue; + case 0xd2: + printf("conv.u1"); + continue; + case 0xd3: + printf("conv.i"); + continue; + case 0xd4: + printf("conv.ovf.i"); + continue; + case 0xd5: + printf("conv.ovf.u"); + continue; + case 0xd6: + printf("add.ovf"); + continue; + case 0xd7: + printf("add.ovf.un"); + continue; + case 0xd8: + printf("mul.ovf"); + continue; + case 0xd9: + printf("mul.ovf.un"); + continue; + case 0xda: + printf("sub.ovf"); + continue; + case 0xdb: + printf("sub.ovf.un"); + continue; + case 0xdc: + printf("endfinally"); + continue; + case 0xdd: // leave XXXX + printf("leave 0x%02x%02x%02x%02x", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], ilCode[i + 1]); + i += 4; + continue; + case 0xde: // leave.s X + printf("leave 0x%02x", ilCode[i + 1]); + i += 1; + continue; + case 0xdf: + printf("stind.i"); + continue; + case 0xe0: + printf("conv.u"); + continue; + case 0xfe: + i++; + switch (ilCode[i]) + { + case 0x00: + printf("arglist"); + continue; + case 0x01: + printf("ceq"); + continue; + case 0x02: + printf("cgt"); + continue; + case 0x03: + printf("cgt.un"); + continue; + case 0x04: + printf("clt"); + continue; + case 0x05: + printf("clt.un"); + continue; + case 0x06: // ldftn <T> + printf("ldftn <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], + ilCode[i + 1]); + i += 4; + continue; + case 0x07: // ldvirtftn <T> + printf("ldvirtftn <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], + ilCode[i + 1]); + i += 4; + continue; + case 0x09: // ldarg XX + printf("ldarg 0x%02x%02x", ilCode[i + 2], ilCode[i + 1]); + i += 2; + continue; + case 0x0a: // ldarga XX + printf("ldarga 0x%02x%02x", ilCode[i + 2], ilCode[i + 1]); + i += 2; + continue; + case 0x0b: // starg XX + printf("starg 0x%02x%02x", ilCode[i + 2], ilCode[i + 1]); + i += 2; + continue; + case 0x0c: // ldloc XX + printf("ldloc 0x%02x%02x", ilCode[i + 2], ilCode[i + 1]); + i += 2; + continue; + case 0x0d: // ldloca XX + printf("ldloca 0x%02x%02x", ilCode[i + 2], ilCode[i + 1]); + i += 2; + continue; + case 0x0e: // stloc XX + printf("stloc 0x%02x%02x", ilCode[i + 2], ilCode[i + 1]); + i += 2; + continue; + case 0x0f: + printf("localloc"); + continue; + case 0x11: + printf("endfilter"); + continue; + case 0x12: // unaligned X + printf("unaligned. 0x%02x", ilCode[i + 1]); + i += 1; + continue; + case 0x13: + printf("volatile."); + continue; + case 0x14: + printf("tail."); + continue; + case 0x15: // initobj <T> + printf("initobj <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], + ilCode[i + 1]); + i += 4; + continue; + case 0x16: // incomplete? + printf("constrained. <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], + ilCode[i + 1]); + i += 4; + continue; + case 0x17: + printf("cpblk"); + continue; + case 0x18: + printf("initblk"); + continue; + case 0x19: + printf("no."); + continue; // incomplete? + case 0x1a: + printf("rethrow"); + continue; + case 0x1c: // sizeof <T> + printf("sizeof <0x%02x%02x%02x%02x>", ilCode[i + 4], ilCode[i + 3], ilCode[i + 2], + ilCode[i + 1]); + i += 4; + continue; + case 0x1d: + printf("refanytype"); + continue; + default: + LogError("unknown ilCode 0xfe%2x at offset %d in MethodGen::PrettyPrint", ilCode[i], i); + break; + } + default: + LogError("unknown ilCode 0x%02x at offset %d in MethodGen::PrettyPrint", ilCode[i], i); break; - } - default: - LogError("unknown ilCode 0x%02x at offset %d in MethodGen::PrettyPrint", ilCode[i], i); - break; } printf("\n"); } } -char * DumpAttributeToConsoleBare(DWORD attribute) +char* DumpAttributeToConsoleBare(DWORD attribute) { - const char *s_static = "static"; - const char *s_dontInline = "$dontInline "; - const char *s_constructor = "$constructor"; - const char *s_cfnw = "$noSecurityWrap"; + const char* s_static = "static"; + const char* s_dontInline = "$dontInline "; + const char* s_constructor = "$constructor"; + const char* s_cfnw = "$noSecurityWrap"; -#define ifPrint(s,t) else if((s&attribute)==s) {printf(t); printf(" ");} +#define ifPrint(s, t) \ + else if ((s & attribute) == s) \ + { \ + printf(t); \ + printf(" "); \ + } - if(0); - ifPrint(CORINFO_FLG_STATIC, s_static) - ifPrint(CORINFO_FLG_DONT_INLINE, s_dontInline) - ifPrint(CORINFO_FLG_CONSTRUCTOR, s_constructor) - ifPrint(CORINFO_FLG_NOSECURITYWRAP, s_cfnw) - else + if (0) + ; + ifPrint(CORINFO_FLG_STATIC, s_static) ifPrint(CORINFO_FLG_DONT_INLINE, s_dontInline) + ifPrint(CORINFO_FLG_CONSTRUCTOR, s_constructor) ifPrint(CORINFO_FLG_NOSECURITYWRAP, s_cfnw) else { LogError("unknown attribute %x", attribute); - __debugbreak(); + __debugbreak(); } return nullptr; #undef ifPrint } -void DumpIL(MethodContext *mc) +void DumpIL(MethodContext* mc) { CORINFO_METHOD_INFO cmi; - unsigned int flags = 0; + unsigned int flags = 0; mc->repCompileMethod(&cmi, &flags); - const char *moduleName = nullptr; - const char *methodName = mc->repGetMethodName(cmi.ftn, &moduleName); - const char *className = mc->repGetClassName(mc->repGetMethodClass(cmi.ftn)); + const char* moduleName = nullptr; + const char* methodName = mc->repGetMethodName(cmi.ftn, &moduleName); + const char* className = mc->repGetClassName(mc->repGetMethodClass(cmi.ftn)); printf("// ProcessName - '%s'\n", mc->cr->repProcessName()); printf(".assembly extern mscorlib{}\n"); @@ -591,7 +951,7 @@ void DumpIL(MethodContext *mc) printf(")\n"); printf(" {\n"); printf(" .maxstack %u\n", cmi.maxStack); - printf(" .locals%s(", (((cmi.options&CORINFO_OPT_INIT_LOCALS)==CORINFO_OPT_INIT_LOCALS)?" init ":" ")); + printf(" .locals%s(", (((cmi.options & CORINFO_OPT_INIT_LOCALS) == CORINFO_OPT_INIT_LOCALS) ? " init " : " ")); DumpSigToConsoleBare(mc, &cmi.locals); printf(")\n"); DumpILToConsoleBare(cmi.ILCode, cmi.ILCodeSize); @@ -599,7 +959,7 @@ void DumpIL(MethodContext *mc) printf("}\n"); } -int verbILDump::DoWork(const char *nameOfInput, int indexCount, const int *indexes) +int verbILDump::DoWork(const char* nameOfInput, int indexCount, const int* indexes) { LogVerbose("// Reading from '%s' dumping raw IL for MC Indexes to console", nameOfInput); diff --git a/src/ToolBox/superpmi/mcs/verbildump.h b/src/ToolBox/superpmi/mcs/verbildump.h index e947fcf40c..d93b9ac1a5 100644 --- a/src/ToolBox/superpmi/mcs/verbildump.h +++ b/src/ToolBox/superpmi/mcs/verbildump.h @@ -14,11 +14,11 @@ class verbILDump { public: - static int DoWork(const char *nameOfInput1, int indexCount, const int *indexes); + static int DoWork(const char* nameOfInput1, int indexCount, const int* indexes); }; -void DumpPrimToConsoleBare(MethodContext *mc, CorInfoType prim, DWORDLONG classHandle); -void DumpSigToConsoleBare(MethodContext *mc, CORINFO_SIG_INFO *pSig); -char * DumpAttributeToConsoleBare(DWORD attribute); +void DumpPrimToConsoleBare(MethodContext* mc, CorInfoType prim, DWORDLONG classHandle); +void DumpSigToConsoleBare(MethodContext* mc, CORINFO_SIG_INFO* pSig); +char* DumpAttributeToConsoleBare(DWORD attribute); #endif diff --git a/src/ToolBox/superpmi/mcs/verbinteg.cpp b/src/ToolBox/superpmi/mcs/verbinteg.cpp index 9b1057769a..851ed9ce3e 100644 --- a/src/ToolBox/superpmi/mcs/verbinteg.cpp +++ b/src/ToolBox/superpmi/mcs/verbinteg.cpp @@ -9,7 +9,7 @@ #include "methodcontext.h" #include "methodcontextiterator.h" -int verbInteg::DoWork(const char *nameOfInput) +int verbInteg::DoWork(const char* nameOfInput) { LogVerbose("Checking the integrity of '%s'", nameOfInput); @@ -27,8 +27,8 @@ int verbInteg::DoWork(const char *nameOfInput) } st2.Stop(); - LogInfo("Checked the integrity of %d methodContexts at %d per second", - mci.MethodContextNumber(), (int)((double)mci.MethodContextNumber() / st2.GetSeconds())); + LogInfo("Checked the integrity of %d methodContexts at %d per second", mci.MethodContextNumber(), + (int)((double)mci.MethodContextNumber() / st2.GetSeconds())); if (!mci.Destroy()) return -1; diff --git a/src/ToolBox/superpmi/mcs/verbinteg.h b/src/ToolBox/superpmi/mcs/verbinteg.h index d45ea15307..3dfded4fd8 100644 --- a/src/ToolBox/superpmi/mcs/verbinteg.h +++ b/src/ToolBox/superpmi/mcs/verbinteg.h @@ -12,6 +12,6 @@ class verbInteg { public: - static int DoWork(const char *nameofInput); + static int DoWork(const char* nameofInput); }; #endif diff --git a/src/ToolBox/superpmi/mcs/verbmerge.cpp b/src/ToolBox/superpmi/mcs/verbmerge.cpp index c4acfd8769..c074fdd1f6 100644 --- a/src/ToolBox/superpmi/mcs/verbmerge.cpp +++ b/src/ToolBox/superpmi/mcs/verbmerge.cpp @@ -17,10 +17,10 @@ // static char* verbMerge::MergePathStrings(const char* dir, const char* file) { - size_t dirlen = strlen(dir); + size_t dirlen = strlen(dir); size_t filelen = strlen(file); - size_t newlen = dirlen + 1 /* slash */ + filelen + 1 /* null */; - char* newpath = new char[newlen]; + size_t newlen = dirlen + 1 /* slash */ + filelen + 1 /* null */; + char* newpath = new char[newlen]; strcpy(newpath, dir); strcat(newpath, DIRECTORY_SEPARATOR_STR_A); strcat(newpath, file); @@ -39,7 +39,8 @@ int verbMerge::AppendFile(HANDLE hFileOut, const char* fileName, unsigned char* LogInfo("Appending file '%s'", fileName); - HANDLE hFileIn = CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN, NULL); + HANDLE hFileIn = CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (hFileIn == INVALID_HANDLE_VALUE) { LogError("Failed to open input file '%s'. GetLastError()=%u", fileName, GetLastError()); @@ -57,7 +58,7 @@ int verbMerge::AppendFile(HANDLE hFileOut, const char* fileName, unsigned char* for (LONGLONG offset = 0; offset < fileSize.QuadPart; offset += bufferSize) { DWORD bytesRead = -1; - BOOL res = ReadFile(hFileIn, buffer, (DWORD)bufferSize, &bytesRead, nullptr); + BOOL res = ReadFile(hFileIn, buffer, (DWORD)bufferSize, &bytesRead, nullptr); if (!res) { LogError("Failed to read '%s' from offset %lld. GetLastError()=%u", fileName, offset, GetLastError()); @@ -65,7 +66,7 @@ int verbMerge::AppendFile(HANDLE hFileOut, const char* fileName, unsigned char* goto CLEAN_UP; } DWORD bytesWritten = -1; - BOOL res2 = WriteFile(hFileOut, buffer, bytesRead, &bytesWritten, nullptr); + BOOL res2 = WriteFile(hFileOut, buffer, bytesRead, &bytesWritten, nullptr); if (!res2) { LogError("Failed to write output file at offset %lld. GetLastError()=%u", offset, GetLastError()); @@ -98,11 +99,11 @@ bool verbMerge::DirectoryFilterDirectories(WIN32_FIND_DATAA* findData) { if ((findData->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { - // It's a directory. See if we want to exclude it because of other reasons, such as: - // 1. reparse points: avoid the possibility of loops - // 2. system directories - // 3. hidden directories - // 4. "." or ".." +// It's a directory. See if we want to exclude it because of other reasons, such as: +// 1. reparse points: avoid the possibility of loops +// 2. system directories +// 3. hidden directories +// 4. "." or ".." #ifndef FEATURE_PAL // FILE_ATTRIBUTE_REPARSE_POINT is not defined in the PAL if ((findData->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) @@ -154,52 +155,52 @@ int __cdecl verbMerge::WIN32_FIND_DATAA_qsort_helper(const void* p1, const void* // If success, fileArray and elemCount are set. // // static -int verbMerge::FilterDirectory(const char* searchPattern, DirectoryFilterFunction_t filter, /* out */ WIN32_FIND_DATAA** ppFileArray, int* pElemCount) +int verbMerge::FilterDirectory(const char* searchPattern, + DirectoryFilterFunction_t filter, + /* out */ WIN32_FIND_DATAA** ppFileArray, + int* pElemCount) { // First, build up a list, then create an array and sort it after we know how many elements there are. struct findDataList { - findDataList(WIN32_FIND_DATAA* newFindData, findDataList* newNext) - : findData(*newFindData) - , next(newNext) + findDataList(WIN32_FIND_DATAA* newFindData, findDataList* newNext) : findData(*newFindData), next(newNext) { } static void DeleteList(findDataList* root) { - for (findDataList* loop = root; loop != nullptr; ) + for (findDataList* loop = root; loop != nullptr;) { - findDataList* tmp = loop; - loop = loop->next; - delete tmp; + findDataList* tmp = loop; + loop = loop->next; + delete tmp; } } WIN32_FIND_DATAA findData; - findDataList* next; + findDataList* next; }; WIN32_FIND_DATAA* retArray = nullptr; - findDataList* first = nullptr; + findDataList* first = nullptr; - int result = 0; // default to zero == success + int result = 0; // default to zero == success int elemCount = 0; // NOTE: this function only works on Windows 7 and later. WIN32_FIND_DATAA findData; - HANDLE hSearch; + HANDLE hSearch; #ifdef FEATURE_PAL // PAL doesn't have FindFirstFileEx(). So just use FindFirstFile(). The only reason we use // the Ex version is potentially better performance (don't populate short name; use large fetch), // not functionality. hSearch = FindFirstFileA(searchPattern, &findData); -#else // !FEATURE_PAL +#else // !FEATURE_PAL hSearch = FindFirstFileExA(searchPattern, FindExInfoBasic, // We don't care about the short names &findData, FindExSearchNameMatch, // standard name matching - NULL, - FIND_FIRST_EX_LARGE_FETCH); + NULL, FIND_FIRST_EX_LARGE_FETCH); #endif // !FEATURE_PAL if (hSearch == INVALID_HANDLE_VALUE) @@ -246,7 +247,7 @@ int verbMerge::FilterDirectory(const char* searchPattern, DirectoryFilterFunctio int i; retArray = new WIN32_FIND_DATAA[elemCount]; - i = 0; + i = 0; for (findDataList* tmp = first; tmp != nullptr; tmp = tmp->next) { retArray[i++] = tmp->findData; @@ -266,23 +267,29 @@ CLEAN_UP: } *ppFileArray = retArray; - *pElemCount = elemCount; + *pElemCount = elemCount; return result; } // Append all files in the given directory matching the file pattern. // // static -int verbMerge::AppendAllInDir(HANDLE hFileOut, const char* dir, const char* file, unsigned char* buffer, size_t bufferSize, bool recursive, /* out */ LONGLONG* size) +int verbMerge::AppendAllInDir(HANDLE hFileOut, + const char* dir, + const char* file, + unsigned char* buffer, + size_t bufferSize, + bool recursive, + /* out */ LONGLONG* size) { - int result = 0; // default to zero == success + int result = 0; // default to zero == success LONGLONG totalSize = 0; char* searchPattern = MergePathStrings(dir, file); WIN32_FIND_DATAA* fileArray = nullptr; - int elemCount = 0; - result = FilterDirectory(searchPattern, DirectoryFilterFile, &fileArray, &elemCount); + int elemCount = 0; + result = FilterDirectory(searchPattern, DirectoryFilterFile, &fileArray, &elemCount); if (result != 0) { goto CLEAN_UP; @@ -290,8 +297,8 @@ int verbMerge::AppendAllInDir(HANDLE hFileOut, const char* dir, const char* file for (int i = 0; i < elemCount; i++) { - const WIN32_FIND_DATAA& findData = fileArray[i]; - char* fileFullPath = MergePathStrings(dir, findData.cFileName); + const WIN32_FIND_DATAA& findData = fileArray[i]; + char* fileFullPath = MergePathStrings(dir, findData.cFileName); // Is it zero length? If so, skip it. if ((findData.nFileSizeLow == 0) && (findData.nFileSizeHigh == 0)) @@ -320,9 +327,9 @@ int verbMerge::AppendAllInDir(HANDLE hFileOut, const char* dir, const char* file delete[] fileArray; searchPattern = MergePathStrings(dir, "*"); - fileArray = nullptr; - elemCount = 0; - result = FilterDirectory(searchPattern, DirectoryFilterDirectories, &fileArray, &elemCount); + fileArray = nullptr; + elemCount = 0; + result = FilterDirectory(searchPattern, DirectoryFilterDirectories, &fileArray, &elemCount); if (result != 0) { goto CLEAN_UP; @@ -334,7 +341,7 @@ int verbMerge::AppendAllInDir(HANDLE hFileOut, const char* dir, const char* file const WIN32_FIND_DATAA& findData = fileArray[i]; char* fileFullPath = MergePathStrings(dir, findData.cFileName); - result = AppendAllInDir(hFileOut, fileFullPath, file, buffer, bufferSize, recursive, &dirSize); + result = AppendAllInDir(hFileOut, fileFullPath, file, buffer, bufferSize, recursive, &dirSize); delete[] fileFullPath; if (result != 0) { @@ -363,20 +370,22 @@ CLEAN_UP: // 1. *.mc -- simple pattern. Assumes current directory. // 2. foo\bar\*.mc -- simple pattern with relative directory. // 3. c:\foo\bar\baz\*.mc -- simple pattern with full path. -// If no pattern is given, then the last component of the path is expected to be a directory name, and the pattern is assumed to be "*" (that is, all files). +// If no pattern is given, then the last component of the path is expected to be a directory name, and the pattern is +// assumed to be "*" (that is, all files). // -// If "recursive" is true, then the pattern is searched for in the specified directory (or implicit current directory) and -// all sub-directories, recursively. +// If "recursive" is true, then the pattern is searched for in the specified directory (or implicit current directory) +// and all sub-directories, recursively. // // static int verbMerge::DoWork(const char* nameOfOutputFile, const char* pattern, bool recursive) { - int result = 0; // default to zero == success + int result = 0; // default to zero == success SimpleTimer st1; LogInfo("Merging files matching '%s' into '%s'", pattern, nameOfOutputFile); - HANDLE hFileOut = CreateFileA(nameOfOutputFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN, NULL); + HANDLE hFileOut = CreateFileA(nameOfOutputFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (hFileOut == INVALID_HANDLE_VALUE) { LogError("Failed to open output file '%s'. GetLastError()=%u", nameOfOutputFile, GetLastError()); @@ -385,16 +394,16 @@ int verbMerge::DoWork(const char* nameOfOutputFile, const char* pattern, bool re // Create a buffer we can use for all the copies. unsigned char* buffer = new unsigned char[BUFFER_SIZE]; - char* dir = nullptr; - const char* file = nullptr; + char* dir = nullptr; + const char* file = nullptr; - dir = _strdup(pattern); + dir = _strdup(pattern); char* lastSlash = strrchr(dir, DIRECTORY_SEPARATOR_CHAR_A); if (lastSlash == NULL) { // The user may have passed a relative path without a slash, or the current directory. - // If there is a wildcard, we use it as the file pattern. If there isn't, we assume it's a relative directory name - // and use it as a directory, with "*" as the file pattern. + // If there is a wildcard, we use it as the file pattern. If there isn't, we assume it's a relative directory + // name and use it as a directory, with "*" as the file pattern. const char* wildcard = strchr(dir, '*'); if (wildcard == NULL) { @@ -403,7 +412,7 @@ int verbMerge::DoWork(const char* nameOfOutputFile, const char* pattern, bool re else { file = dir; - dir = _strdup("."); + dir = _strdup("."); } } else @@ -413,7 +422,8 @@ int verbMerge::DoWork(const char* nameOfOutputFile, const char* pattern, bool re { file = "*"; - // Minor canonicalization: if there is a trailing last slash, strip it (probably should do this in a loop...) + // Minor canonicalization: if there is a trailing last slash, strip it (probably should do this in a + // loop...) if (*(lastSlash + 1) == '\0') { *lastSlash = '\0'; @@ -423,12 +433,12 @@ int verbMerge::DoWork(const char* nameOfOutputFile, const char* pattern, bool re { // ok, we found a wildcard after the last slash, so assume there is a pattern. Strip it at the last slash. *lastSlash = '\0'; - file = lastSlash + 1; + file = lastSlash + 1; } } LONGLONG totalSize = 0; - LONGLONG dirSize = 0; + LONGLONG dirSize = 0; st1.Start(); @@ -441,9 +451,9 @@ int verbMerge::DoWork(const char* nameOfOutputFile, const char* pattern, bool re st1.Stop(); - LogInfo("Read/Wrote %lld MB @ %4.2f MB/s.", - totalSize/(1000*1000), - (((double)totalSize)/(1000*1000))/st1.GetSeconds()); //yes yes.. http://en.wikipedia.org/wiki/Megabyte_per_second#Megabyte_per_second + LogInfo("Read/Wrote %lld MB @ %4.2f MB/s.", totalSize / (1000 * 1000), + (((double)totalSize) / (1000 * 1000)) / + st1.GetSeconds()); // yes yes.. http://en.wikipedia.org/wiki/Megabyte_per_second#Megabyte_per_second CLEAN_UP: diff --git a/src/ToolBox/superpmi/mcs/verbmerge.h b/src/ToolBox/superpmi/mcs/verbmerge.h index 1d612426f3..222669dac0 100644 --- a/src/ToolBox/superpmi/mcs/verbmerge.h +++ b/src/ToolBox/superpmi/mcs/verbmerge.h @@ -19,11 +19,20 @@ private: static bool DirectoryFilterDirectories(WIN32_FIND_DATAA* findData); static bool DirectoryFilterFile(WIN32_FIND_DATAA* findData); static int __cdecl WIN32_FIND_DATAA_qsort_helper(const void* p1, const void* p2); - static int FilterDirectory(const char* searchPattern, DirectoryFilterFunction_t filter, /* out */ WIN32_FIND_DATAA** ppFileArray, int* pElemCount); + static int FilterDirectory(const char* searchPattern, + DirectoryFilterFunction_t filter, + /* out */ WIN32_FIND_DATAA** ppFileArray, + int* pElemCount); static char* MergePathStrings(const char* dir, const char* file); static int AppendFile(HANDLE hFileOut, const char* fileName, unsigned char* buffer, size_t bufferSize); - static int AppendAllInDir(HANDLE hFileOut, const char* dir, const char* file, unsigned char* buffer, size_t bufferSize, bool recursive, /* out */ LONGLONG* size); + static int AppendAllInDir(HANDLE hFileOut, + const char* dir, + const char* file, + unsigned char* buffer, + size_t bufferSize, + bool recursive, + /* out */ LONGLONG* size); }; #endif diff --git a/src/ToolBox/superpmi/mcs/verbremovedup.cpp b/src/ToolBox/superpmi/mcs/verbremovedup.cpp index eca5dc1b09..cd2ead0632 100644 --- a/src/ToolBox/superpmi/mcs/verbremovedup.cpp +++ b/src/ToolBox/superpmi/mcs/verbremovedup.cpp @@ -10,32 +10,32 @@ #include "methodcontext.h" #include "methodcontextiterator.h" -//We use a hash to limit the number of comparisons we need to do. -//The first level key to our hash map is ILCodeSize and the second -//level map key is just an index and the value is an existing MC Hash. +// We use a hash to limit the number of comparisons we need to do. + //The first level key to our hash map is ILCodeSize and the second + //level map key is just an index and the value is an existing MC Hash. -LightWeightMap<int, DenseLightWeightMap<char *> *> *inFile = nullptr; +LightWeightMap<int, DenseLightWeightMap<char*>*>* inFile = nullptr; -bool unique(MethodContext *mc) +bool unique(MethodContext* mc) { if (inFile == nullptr) - inFile = new LightWeightMap<int, DenseLightWeightMap<char *> *>(); + inFile = new LightWeightMap<int, DenseLightWeightMap<char*>*>(); CORINFO_METHOD_INFO newInfo; - unsigned newFlags = 0; + unsigned newFlags = 0; mc->repCompileMethod(&newInfo, &newFlags); - char *md5Buff = new char[MD5_HASH_BUFFER_SIZE]; + char* md5Buff = new char[MD5_HASH_BUFFER_SIZE]; mc->dumpMethodMD5HashToBuffer(md5Buff, MD5_HASH_BUFFER_SIZE); if (inFile->GetIndex(newInfo.ILCodeSize) == -1) - inFile->Add(newInfo.ILCodeSize, new DenseLightWeightMap<char *>()); + inFile->Add(newInfo.ILCodeSize, new DenseLightWeightMap<char*>()); - DenseLightWeightMap<char *> *ourRank = inFile->Get(newInfo.ILCodeSize); + DenseLightWeightMap<char*>* ourRank = inFile->Get(newInfo.ILCodeSize); for (int i = 0; i < (int)ourRank->GetCount(); i++) { - char *md5Buff2 = ourRank->Get(i); + char* md5Buff2 = ourRank->Get(i); if (strncmp(md5Buff, md5Buff2, MD5_HASH_BUFFER_SIZE) == 0) { @@ -48,25 +48,25 @@ bool unique(MethodContext *mc) return true; } -LightWeightMap<int, DenseLightWeightMap<MethodContext *> *> *inFileLegacy = nullptr; +LightWeightMap<int, DenseLightWeightMap<MethodContext*>*>* inFileLegacy = nullptr; -bool uniqueLegacy(MethodContext *mc) +bool uniqueLegacy(MethodContext* mc) { if (inFileLegacy == nullptr) - inFileLegacy = new LightWeightMap<int, DenseLightWeightMap<MethodContext *> *>(); + inFileLegacy = new LightWeightMap<int, DenseLightWeightMap<MethodContext*>*>(); CORINFO_METHOD_INFO newInfo; - unsigned newFlags = 0; + unsigned newFlags = 0; mc->repCompileMethod(&newInfo, &newFlags); if (inFileLegacy->GetIndex(newInfo.ILCodeSize) == -1) - inFileLegacy->Add(newInfo.ILCodeSize, new DenseLightWeightMap<MethodContext *>()); + inFileLegacy->Add(newInfo.ILCodeSize, new DenseLightWeightMap<MethodContext*>()); - DenseLightWeightMap<MethodContext *> *ourRank = inFileLegacy->Get(newInfo.ILCodeSize); + DenseLightWeightMap<MethodContext*>* ourRank = inFileLegacy->Get(newInfo.ILCodeSize); for (int i = 0; i < (int)ourRank->GetCount(); i++) { - MethodContext *scratch = ourRank->Get(i); + MethodContext* scratch = ourRank->Get(i); if (mc->Equal(scratch)) { return false; @@ -78,7 +78,7 @@ bool uniqueLegacy(MethodContext *mc) return true; } -int verbRemoveDup::DoWork(const char *nameOfInput, const char *nameOfOutput, bool stripCR, bool legacyCompare) +int verbRemoveDup::DoWork(const char* nameOfInput, const char* nameOfOutput, bool stripCR, bool legacyCompare) { LogVerbose("Removing duplicates from '%s', writing to '%s'", nameOfInput, nameOfOutput); @@ -88,7 +88,8 @@ int verbRemoveDup::DoWork(const char *nameOfInput, const char *nameOfOutput, boo int savedCount = 0; - HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (hFileOut == INVALID_HANDLE_VALUE) { LogError("Failed to open output '%s'. GetLastError()=%u", nameOfOutput, GetLastError()); @@ -110,7 +111,8 @@ int verbRemoveDup::DoWork(const char *nameOfInput, const char *nameOfOutput, boo mc->saveToFile(hFileOut); savedCount++; - // In this case, for the legacy comparer, it has placed the 'mc' in the 'inFileLegacy' table, so we can't delete it. + // In this case, for the legacy comparer, it has placed the 'mc' in the 'inFileLegacy' table, so we + // can't delete it. } else { diff --git a/src/ToolBox/superpmi/mcs/verbremovedup.h b/src/ToolBox/superpmi/mcs/verbremovedup.h index ab0cb98692..e4cbad841a 100644 --- a/src/ToolBox/superpmi/mcs/verbremovedup.h +++ b/src/ToolBox/superpmi/mcs/verbremovedup.h @@ -12,6 +12,6 @@ class verbRemoveDup { public: - static int DoWork(const char *nameOfInput1, const char *nameOfOutput, bool stripCR, bool legacyCompare); + static int DoWork(const char* nameOfInput1, const char* nameOfOutput, bool stripCR, bool legacyCompare); }; #endif diff --git a/src/ToolBox/superpmi/mcs/verbsmarty.cpp b/src/ToolBox/superpmi/mcs/verbsmarty.cpp index 9b881cdcbf..a9425bd11c 100644 --- a/src/ToolBox/superpmi/mcs/verbsmarty.cpp +++ b/src/ToolBox/superpmi/mcs/verbsmarty.cpp @@ -20,7 +20,7 @@ // verbSmarty::verbSmarty(HANDLE hFile) { - m_hFile=hFile; + m_hFile = hFile; } // @@ -31,21 +31,21 @@ verbSmarty::verbSmarty(HANDLE hFile) // void verbSmarty::DumpTestInfo(int testID) { - #define bufflen 4096 +#define bufflen 4096 DWORD bytesWritten; char buff[bufflen]; - int buff_offset = 0; + int buff_offset = 0; ZeroMemory(buff, bufflen * sizeof(char)); - buff_offset+=sprintf_s(&buff[buff_offset], bufflen-buff_offset, "%i\r\n", testID); + buff_offset += sprintf_s(&buff[buff_offset], bufflen - buff_offset, "%i\r\n", testID); WriteFile(m_hFile, buff, buff_offset * sizeof(char), &bytesWritten, nullptr); } - -int verbSmarty::DoWork(const char *nameOfInput, const char *nameOfOutput, int indexCount, const int *indexes) +int verbSmarty::DoWork(const char* nameOfInput, const char* nameOfOutput, int indexCount, const int* indexes) { - LogVerbose("Reading from '%s' reading Smarty ID for the Mc Indexes and writing into '%s'", nameOfInput, nameOfOutput); + LogVerbose("Reading from '%s' reading Smarty ID for the Mc Indexes and writing into '%s'", nameOfInput, + nameOfOutput); MethodContextIterator mci(indexCount, indexes); if (!mci.Initialize(nameOfInput)) @@ -53,16 +53,17 @@ int verbSmarty::DoWork(const char *nameOfInput, const char *nameOfOutput, int in int savedCount = 0; - HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN, NULL); - if(hFileOut == INVALID_HANDLE_VALUE) + HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + if (hFileOut == INVALID_HANDLE_VALUE) { LogError("Failed to open input 1 '%s'. GetLastError()=%u", nameOfOutput, GetLastError()); return -1; } - verbSmarty *verbList = new verbSmarty(hFileOut); + verbSmarty* verbList = new verbSmarty(hFileOut); - //TODO-Cleanup: look to use toc for this + // TODO-Cleanup: look to use toc for this while (mci.MoveNext()) { MethodContext* mc = mci.Current(); @@ -70,7 +71,7 @@ int verbSmarty::DoWork(const char *nameOfInput, const char *nameOfOutput, int in int testID = mc->repGetTestID(); if (testID != -1) { - //write to the file + // write to the file verbList->DumpTestInfo(testID); } else diff --git a/src/ToolBox/superpmi/mcs/verbsmarty.h b/src/ToolBox/superpmi/mcs/verbsmarty.h index 994695da79..c595ecbf4e 100644 --- a/src/ToolBox/superpmi/mcs/verbsmarty.h +++ b/src/ToolBox/superpmi/mcs/verbsmarty.h @@ -14,7 +14,7 @@ class verbSmarty public: verbSmarty(HANDLE hFile); void DumpTestInfo(int testID); - static int DoWork(const char *nameOfInput, const char *nameofOutput, int indexCount, const int *indexes); + static int DoWork(const char* nameOfInput, const char* nameofOutput, int indexCount, const int* indexes); private: HANDLE m_hFile; diff --git a/src/ToolBox/superpmi/mcs/verbstat.cpp b/src/ToolBox/superpmi/mcs/verbstat.cpp index 473f452f96..137451944d 100644 --- a/src/ToolBox/superpmi/mcs/verbstat.cpp +++ b/src/ToolBox/superpmi/mcs/verbstat.cpp @@ -10,7 +10,7 @@ #include "methodcontextiterator.h" #include "errorhandling.h" -int verbStat::DoWork(const char *nameOfInput, const char *nameOfOutput, int indexCount, const int *indexes) +int verbStat::DoWork(const char* nameOfInput, const char* nameOfOutput, int indexCount, const int* indexes) { LogVerbose("Stat'ing from '%s' and writing output into '%s'", nameOfInput, nameOfOutput); @@ -20,17 +20,18 @@ int verbStat::DoWork(const char *nameOfInput, const char *nameOfOutput, int inde int savedCount = 0; - HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN, NULL); - if(hFileOut == INVALID_HANDLE_VALUE) + HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + if (hFileOut == INVALID_HANDLE_VALUE) { LogError("Failed to open input 1 '%s'. GetLastError()=%u", nameOfOutput, GetLastError()); return -1; } - #define bufflen 50000 +#define bufflen 50000 DWORD bytesWritten; - char buff[bufflen]; - int offset = 0; + char buff[bufflen]; + int offset = 0; ZeroMemory(&buff[0], bufflen); offset += sprintf_s(buff, bufflen, "Title,MC#,"); offset += MethodContext::dumpStatTitleToBuffer(&buff[offset], bufflen - offset); @@ -46,7 +47,7 @@ int verbStat::DoWork(const char *nameOfInput, const char *nameOfOutput, int inde ZeroMemory(&buff[0], bufflen); if ((mc->cr->ProcessName != nullptr) && (mc->cr->ProcessName->GetCount() > 0)) { - const char *procname = mc->cr->repProcessName(); + const char* procname = mc->cr->repProcessName(); strcpy_s(&buff[offset], bufflen, procname); offset += (int)strlen(procname); } diff --git a/src/ToolBox/superpmi/mcs/verbstat.h b/src/ToolBox/superpmi/mcs/verbstat.h index 53a3a78d6f..8e74c257e6 100644 --- a/src/ToolBox/superpmi/mcs/verbstat.h +++ b/src/ToolBox/superpmi/mcs/verbstat.h @@ -12,6 +12,6 @@ class verbStat { public: - static int DoWork(const char *nameOfInput1, const char *nameOfOutput, int indexCount, const int *indexes); + static int DoWork(const char* nameOfInput1, const char* nameOfOutput, int indexCount, const int* indexes); }; #endif diff --git a/src/ToolBox/superpmi/mcs/verbstrip.cpp b/src/ToolBox/superpmi/mcs/verbstrip.cpp index 8783b1a767..352ef04e93 100644 --- a/src/ToolBox/superpmi/mcs/verbstrip.cpp +++ b/src/ToolBox/superpmi/mcs/verbstrip.cpp @@ -13,37 +13,39 @@ // verbStrip::DoWork handles both "-copy" and "-strip". These both copy from input file to output file, // but treat the passed-in indexes in opposite ways. -int verbStrip::DoWork(const char *nameOfInput, const char *nameOfOutput, int indexCount, const int *indexes, bool strip, bool stripCR) +int verbStrip::DoWork( + const char* nameOfInput, const char* nameOfOutput, int indexCount, const int* indexes, bool strip, bool stripCR) { if (strip) return DoWorkTheOldWay(nameOfInput, nameOfOutput, indexCount, indexes, stripCR); - SimpleTimer *st1 = new SimpleTimer(); + SimpleTimer* st1 = new SimpleTimer(); LogVerbose("Reading from '%s' removing Mc Indexes and writing into '%s'", nameOfInput, nameOfOutput); - int loadedCount = 0; - MethodContext *mc = nullptr; - int savedCount = 0; - int index = 0; + int loadedCount = 0; + MethodContext* mc = nullptr; + int savedCount = 0; + int index = 0; // The method context reader handles skipping any unrequested method contexts // Used in conjunction with an MCI file, it does a lot less work... - MethodContextReader *reader = new MethodContextReader(nameOfInput, indexes, indexCount); + MethodContextReader* reader = new MethodContextReader(nameOfInput, indexes, indexCount); if (!reader->isValid()) { return -1; } - HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN, NULL); - if(hFileOut == INVALID_HANDLE_VALUE) + HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + if (hFileOut == INVALID_HANDLE_VALUE) { LogError("Failed to open input 1 '%s'. GetLastError()=%u", nameOfOutput, GetLastError()); return -1; } - if(indexCount == -1) - strip = true; //Copy command with no indexes listed should copy all the inputs... - while(true) + if (indexCount == -1) + strip = true; // Copy command with no indexes listed should copy all the inputs... + while (true) { MethodContextBuffer mcb = reader->GetNextMethodContext(); if (mcb.Error()) @@ -56,17 +58,18 @@ int verbStrip::DoWork(const char *nameOfInput, const char *nameOfOutput, int ind } loadedCount++; - if((loadedCount%500==0)&&(loadedCount>0)) + if ((loadedCount % 500 == 0) && (loadedCount > 0)) { st1->Stop(); - LogVerbose("%2.1f%% - Loaded %d at %d per second", reader->PercentComplete(), loadedCount, (int)((double)500 / st1->GetSeconds())); + LogVerbose("%2.1f%% - Loaded %d at %d per second", reader->PercentComplete(), loadedCount, + (int)((double)500 / st1->GetSeconds())); st1->Start(); } if (!MethodContext::Initialize(loadedCount, mcb.buff, mcb.size, &mc)) return -1; - if(stripCR) + if (stripCR) { delete mc->cr; mc->cr = new CompileResult(); @@ -75,7 +78,7 @@ int verbStrip::DoWork(const char *nameOfInput, const char *nameOfOutput, int ind savedCount++; delete mc; } - if(CloseHandle(hFileOut)==0) + if (CloseHandle(hFileOut) == 0) { LogError("2nd CloseHandle failed. GetLastError()=%u", GetLastError()); return -1; @@ -85,9 +88,9 @@ int verbStrip::DoWork(const char *nameOfInput, const char *nameOfOutput, int ind return 0; } - // This is only used for "-strip". -int verbStrip::DoWorkTheOldWay(const char *nameOfInput, const char *nameOfOutput, int indexCount, const int *indexes, bool stripCR) +int verbStrip::DoWorkTheOldWay( + const char* nameOfInput, const char* nameOfOutput, int indexCount, const int* indexes, bool stripCR) { LogVerbose("Reading from '%s' removing MC Indexes and writing into '%s'", nameOfInput, nameOfOutput); @@ -95,11 +98,12 @@ int verbStrip::DoWorkTheOldWay(const char *nameOfInput, const char *nameOfOutput if (!mci.Initialize(nameOfInput)) return -1; - int savedCount = 0; + int savedCount = 0; bool write; - int index = 0; // Can't use MethodContextIterator indexing, since we want the opposite of that. + int index = 0; // Can't use MethodContextIterator indexing, since we want the opposite of that. - HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (hFileOut == INVALID_HANDLE_VALUE) { LogError("Failed to open input 1 '%s'. GetLastError()=%u", nameOfOutput, GetLastError()); @@ -139,7 +143,8 @@ int verbStrip::DoWorkTheOldWay(const char *nameOfInput, const char *nameOfOutput } if (index < indexCount) - LogWarning("Didn't use all of index count input %d < %d (i.e. didn't see MC #%d)", index, indexCount, indexes[index]); + LogWarning("Didn't use all of index count input %d < %d (i.e. didn't see MC #%d)", index, indexCount, + indexes[index]); LogInfo("Loaded %d, Saved %d", mci.MethodContextNumber(), savedCount); diff --git a/src/ToolBox/superpmi/mcs/verbstrip.h b/src/ToolBox/superpmi/mcs/verbstrip.h index 9db77736a8..c7b62553ad 100644 --- a/src/ToolBox/superpmi/mcs/verbstrip.h +++ b/src/ToolBox/superpmi/mcs/verbstrip.h @@ -12,7 +12,13 @@ class verbStrip { public: - static int DoWork(const char *nameOfInput1, const char *nameOfOutput, int indexCount, const int *indexes, bool strip, bool stripCR); - static int DoWorkTheOldWay(const char *nameOfInput, const char *nameOfOutput, int indexCount, const int *indexes, bool stripCR); + static int DoWork(const char* nameOfInput1, + const char* nameOfOutput, + int indexCount, + const int* indexes, + bool strip, + bool stripCR); + static int DoWorkTheOldWay( + const char* nameOfInput, const char* nameOfOutput, int indexCount, const int* indexes, bool stripCR); }; #endif diff --git a/src/ToolBox/superpmi/mcs/verbtoc.cpp b/src/ToolBox/superpmi/mcs/verbtoc.cpp index a99fbf0183..5fcf4ce6f5 100644 --- a/src/ToolBox/superpmi/mcs/verbtoc.cpp +++ b/src/ToolBox/superpmi/mcs/verbtoc.cpp @@ -13,17 +13,15 @@ class TOCElementNode { public: - TOCElementNode *Next; - TOCElement tocElement; + TOCElementNode* Next; + TOCElement tocElement; - TOCElementNode(int number, __int64 offset) - : Next(nullptr) - , tocElement(number, offset) + TOCElementNode(int number, __int64 offset) : Next(nullptr), tocElement(number, offset) { } }; -int verbTOC::DoWork(const char *nameOfInput) +int verbTOC::DoWork(const char* nameOfInput) { LogVerbose("Indexing from '%s' into '%s.mct'", nameOfInput, nameOfInput); @@ -33,14 +31,14 @@ int verbTOC::DoWork(const char *nameOfInput) int savedCount = 0; - TOCElementNode *head = nullptr; - TOCElementNode *curElem = nullptr; + TOCElementNode* head = nullptr; + TOCElementNode* curElem = nullptr; while (mci.MoveNext()) { MethodContext* mc = mci.Current(); - TOCElementNode *nxt = new TOCElementNode(mci.MethodContextNumber(), mci.CurrentPos()); + TOCElementNode* nxt = new TOCElementNode(mci.MethodContextNumber(), mci.CurrentPos()); mc->dumpMethodMD5HashToBuffer(nxt->tocElement.Hash, MD5_HASH_BUFFER_SIZE); if (curElem != nullptr) @@ -55,11 +53,12 @@ int verbTOC::DoWork(const char *nameOfInput) savedCount++; } - size_t maxLen = strlen(nameOfInput) + 5; - char *nameOfOutput = (char*)_alloca(maxLen); + size_t maxLen = strlen(nameOfInput) + 5; + char* nameOfOutput = (char*)_alloca(maxLen); strcpy_s(nameOfOutput, maxLen, nameOfInput); strcat_s(nameOfOutput, maxLen, ".mct"); - HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFileOut = + CreateFileA(nameOfOutput, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFileOut == INVALID_HANDLE_VALUE) { LogError("Failed to open input 1 '%s'. GetLastError()=%u", nameOfOutput, GetLastError()); @@ -69,7 +68,7 @@ int verbTOC::DoWork(const char *nameOfInput) DWORD written; // Write out the signature "INDX" and then the element count LARGE_INTEGER token; - token.u.LowPart = *(const int*)"INDX"; // cuz Type Safety is for languages that have good IO facilities + token.u.LowPart = *(const int*)"INDX"; // cuz Type Safety is for languages that have good IO facilities token.u.HighPart = savedCount; if (!WriteFile(hFileOut, &token, sizeof(token), &written, nullptr) || written != sizeof(token)) { @@ -83,12 +82,14 @@ int verbTOC::DoWork(const char *nameOfInput) { if (!WriteFile(hFileOut, &curElem->tocElement, chunkSize, &written, nullptr) || written != chunkSize) { - LogError("Failed to write index element '%d'. GetLastError()=%u", curElem->tocElement.Number, GetLastError()); + LogError("Failed to write index element '%d'. GetLastError()=%u", curElem->tocElement.Number, + GetLastError()); return -1; } } // Now write out a final "INDX" to flag the end of the file... - if (!WriteFile(hFileOut, &token.u.LowPart, sizeof(token.u.LowPart), &written, nullptr) || (written != sizeof(token.u.LowPart))) + if (!WriteFile(hFileOut, &token.u.LowPart, sizeof(token.u.LowPart), &written, nullptr) || + (written != sizeof(token.u.LowPart))) { LogError("Failed to write index terminal. GetLastError()=%u", GetLastError()); } diff --git a/src/ToolBox/superpmi/mcs/verbtoc.h b/src/ToolBox/superpmi/mcs/verbtoc.h index 7eea371191..aa4f48158a 100644 --- a/src/ToolBox/superpmi/mcs/verbtoc.h +++ b/src/ToolBox/superpmi/mcs/verbtoc.h @@ -12,6 +12,6 @@ class verbTOC { public: - static int DoWork(const char *nameOfInput1); + static int DoWork(const char* nameOfInput1); }; #endif |