diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2017-04-27 16:54:50 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2017-04-27 16:54:50 +0900 |
commit | 5b975f8233e8c8d17b215372f89ca713b45d6a0b (patch) | |
tree | 0267bcc331458a01f4c26fafd28110a72273beb3 /src/ToolBox/superpmi/mcs/verbstrip.cpp | |
parent | a56e30c8d33048216567753d9d3fefc2152af8ac (diff) | |
download | coreclr-5b975f8233e8c8d17b215372f89ca713b45d6a0b.tar.gz coreclr-5b975f8233e8c8d17b215372f89ca713b45d6a0b.tar.bz2 coreclr-5b975f8233e8c8d17b215372f89ca713b45d6a0b.zip |
Imported Upstream version 2.0.0.11599upstream/2.0.0.11599
Diffstat (limited to 'src/ToolBox/superpmi/mcs/verbstrip.cpp')
-rw-r--r-- | src/ToolBox/superpmi/mcs/verbstrip.cpp | 49 |
1 files changed, 27 insertions, 22 deletions
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); |