summaryrefslogtreecommitdiff
path: root/src/ToolBox
diff options
context:
space:
mode:
authorSergey Andreenko <seandree@microsoft.com>2018-05-23 10:23:18 -0700
committerGitHub <noreply@github.com>2018-05-23 10:23:18 -0700
commitd7be1d0f72a1b5367a4cb504ea7234f7b49e08c9 (patch)
treefa6c26984176a1ba96fac4755c7205c020556c51 /src/ToolBox
parent7e517ed6b6a210c820a7336f199008f31c19d52f (diff)
downloadcoreclr-d7be1d0f72a1b5367a4cb504ea7234f7b49e08c9.tar.gz
coreclr-d7be1d0f72a1b5367a4cb504ea7234f7b49e08c9.tar.bz2
coreclr-d7be1d0f72a1b5367a4cb504ea7234f7b49e08c9.zip
Fix parallel spmi return code. (#18093)
Diffstat (limited to 'src/ToolBox')
-rw-r--r--src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp34
-rw-r--r--src/ToolBox/superpmi/superpmi/superpmi.cpp38
-rw-r--r--src/ToolBox/superpmi/superpmi/superpmi.h10
3 files changed, 52 insertions, 30 deletions
diff --git a/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp b/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp
index a773344eb8..70afb5ce20 100644
--- a/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp
+++ b/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp
@@ -566,19 +566,39 @@ int doParallelSuperPMI(CommandLine::Options& o)
CloseHandle(hStdError[i]);
}
- DWORD exitCode = 0; // 0 == assume success
+ SpmiResult result = SpmiResult::Success;
if (!closeRequested)
{
- // Figure out the error code to use. We use the largest magnitude error code of the children.
+ // Figure out the error code to use.
// Mainly, if any child returns non-zero, we want to return non-zero, to indicate failure.
for (int i = 0; i < o.workerCount; i++)
{
- DWORD exitCodeTmp;
- BOOL ok = GetExitCodeProcess(hProcesses[i], &exitCodeTmp);
- if (ok && (exitCodeTmp > exitCode))
+ DWORD exitCodeTmp;
+ BOOL ok = GetExitCodeProcess(hProcesses[i], &exitCodeTmp);
+ SpmiResult childResult = (SpmiResult)exitCodeTmp;
+ if (ok && (childResult != result))
{
- exitCode = exitCodeTmp;
+ if (result == SpmiResult::Error || childResult == SpmiResult::Error)
+ {
+ result = SpmiResult::Error;
+ }
+ else if (result == SpmiResult::Diffs || childResult == SpmiResult::Diffs)
+ {
+ result = SpmiResult::Diffs;
+ }
+ else if (result == SpmiResult::Misses || childResult == SpmiResult::Misses)
+ {
+ result = SpmiResult::Misses;
+ }
+ else if (result == SpmiResult::JitFailedToInit || childResult == SpmiResult::JitFailedToInit)
+ {
+ result = SpmiResult::JitFailedToInit;
+ }
+ else
+ {
+ result = SpmiResult::GeneralFailure;
+ }
}
}
@@ -642,5 +662,5 @@ int doParallelSuperPMI(CommandLine::Options& o)
}
}
- return (int)exitCode;
+ return (int)result;
}
diff --git a/src/ToolBox/superpmi/superpmi/superpmi.cpp b/src/ToolBox/superpmi/superpmi/superpmi.cpp
index b36966e804..be5476e8c3 100644
--- a/src/ToolBox/superpmi/superpmi/superpmi.cpp
+++ b/src/ToolBox/superpmi/superpmi/superpmi.cpp
@@ -129,7 +129,7 @@ int __cdecl main(int argc, char* argv[])
if (0 != PAL_Initialize(argc, argv))
{
fprintf(stderr, "Error: Fail to PAL_Initialize\n");
- return -1;
+ return (int)SpmiResult::GeneralFailure;
}
#endif // FEATURE_PAL
@@ -165,7 +165,7 @@ int __cdecl main(int argc, char* argv[])
CommandLine::Options o;
if (!CommandLine::Parse(argc, argv, &o))
{
- return -1;
+ return (int)SpmiResult::GeneralFailure;
}
if (o.parallel)
@@ -228,7 +228,7 @@ int __cdecl main(int argc, char* argv[])
new MethodContextReader(o.nameOfInputMethodContextFile, o.indexes, o.indexCount, o.hash, o.offset, o.increment);
if (!reader->isValid())
{
- return -1;
+ return (int)SpmiResult::GeneralFailure;
}
int loadedCount = 0;
@@ -246,7 +246,7 @@ int __cdecl main(int argc, char* argv[])
{
if (!nearDiffer.InitAsmDiff())
{
- return -1;
+ return (int)SpmiResult::GeneralFailure;
}
}
@@ -255,7 +255,7 @@ int __cdecl main(int argc, char* argv[])
MethodContextBuffer mcb = reader->GetNextMethodContext();
if (mcb.Error())
{
- return -1;
+ return (int)SpmiResult::GeneralFailure;
}
else if (mcb.allDone())
{
@@ -284,7 +284,7 @@ int __cdecl main(int argc, char* argv[])
loadedCount++;
if (!MethodContext::Initialize(loadedCount, mcb.buff, mcb.size, &mc))
- return -1;
+ return (int)SpmiResult::GeneralFailure;
if (jit == nullptr)
{
@@ -294,7 +294,7 @@ int __cdecl main(int argc, char* argv[])
if (jit == nullptr)
{
// InitJit already printed a failure message
- return -2;
+ return (int)SpmiResult::JitFailedToInit;
}
if (o.nameOfJit2 != nullptr)
@@ -304,7 +304,7 @@ int __cdecl main(int argc, char* argv[])
if (jit2 == nullptr)
{
// InitJit already printed a failure message
- return -2;
+ return (int)SpmiResult::JitFailedToInit;
}
}
}
@@ -520,13 +520,13 @@ int __cdecl main(int argc, char* argv[])
if (hFileOut == INVALID_HANDLE_VALUE)
{
LogError("Failed to open output '%s'. GetLastError()=%u", buff, GetLastError());
- return -1;
+ return (int)SpmiResult::GeneralFailure;
}
mc->saveToFile(hFileOut);
if (CloseHandle(hFileOut) == 0)
{
LogError("CloseHandle for output file failed. GetLastError()=%u", GetLastError());
- return -1;
+ return (int)SpmiResult::GeneralFailure;
}
LogInfo("Wrote out repro to '%s'", buff);
}
@@ -578,28 +578,20 @@ int __cdecl main(int argc, char* argv[])
}
Logger::Shutdown();
- enum Result
- {
- Success,
- Error,
- Diffs,
- Misses
- };
-
- Result result = Success;
+ SpmiResult result = SpmiResult::Success;
if (errorCount > 0)
{
- result = Error;
+ result = SpmiResult::Error;
}
else if (o.applyDiff && matchCount != jittedCount)
{
- result = Diffs;
+ result = SpmiResult::Diffs;
}
else if (missingCount > 0)
{
- result = Misses;
+ result = SpmiResult::Misses;
}
- return result;
+ return (int)result;
}
diff --git a/src/ToolBox/superpmi/superpmi/superpmi.h b/src/ToolBox/superpmi/superpmi/superpmi.h
index ce535994a0..6332383b69 100644
--- a/src/ToolBox/superpmi/superpmi/superpmi.h
+++ b/src/ToolBox/superpmi/superpmi/superpmi.h
@@ -25,4 +25,14 @@ extern const char* const g_AllFormatStringFixedPrefix;
extern const char* const g_SummaryFormatString;
extern const char* const g_AsmDiffsSummaryFormatString;
+enum class SpmiResult
+{
+ JitFailedToInit = -2,
+ GeneralFailure = -1,
+ Success = 0,
+ Error = 1,
+ Diffs = 2,
+ Misses = 3
+};
+
#endif