aboutsummaryrefslogtreecommitdiffstats
path: root/utils/KillTheDoctor/KillTheDoctor.cpp
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-07-21 00:45:20 -0700
committerStephen Hines <srhines@google.com>2014-07-21 00:45:20 -0700
commitc6a4f5e819217e1e12c458aed8e7b122e23a3a58 (patch)
tree81b7dd2bb4370a392f31d332a566c903b5744764 /utils/KillTheDoctor/KillTheDoctor.cpp
parent19c6fbb3e8aaf74093afa08013134b61fa08f245 (diff)
downloadexternal_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.zip
external_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.tar.gz
external_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.tar.bz2
Update LLVM for rebase to r212749.
Includes a cherry-pick of: r212948 - fixes a small issue with atomic calls Change-Id: Ib97bd980b59f18142a69506400911a6009d9df18
Diffstat (limited to 'utils/KillTheDoctor/KillTheDoctor.cpp')
-rw-r--r--utils/KillTheDoctor/KillTheDoctor.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/utils/KillTheDoctor/KillTheDoctor.cpp b/utils/KillTheDoctor/KillTheDoctor.cpp
index feba2e5..111bad2 100644
--- a/utils/KillTheDoctor/KillTheDoctor.cpp
+++ b/utils/KillTheDoctor/KillTheDoctor.cpp
@@ -40,14 +40,15 @@
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Signals.h"
+#include "llvm/Support/WindowsError.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/system_error.h"
#include "llvm/Support/type_traits.h"
#include <algorithm>
#include <cerrno>
#include <cstdlib>
#include <map>
#include <string>
+#include <system_error>
// These includes must be last.
#include <Windows.h>
@@ -169,8 +170,10 @@ namespace {
typedef ScopedHandle<FileHandle> FileScopedHandle;
}
-static error_code GetFileNameFromHandle(HANDLE FileHandle,
- std::string& Name) {
+static std::error_code windows_error(DWORD E) { return mapWindowsError(E); }
+
+static std::error_code GetFileNameFromHandle(HANDLE FileHandle,
+ std::string &Name) {
char Filename[MAX_PATH+1];
bool Success = false;
Name.clear();
@@ -210,7 +213,7 @@ static error_code GetFileNameFromHandle(HANDLE FileHandle,
return windows_error(::GetLastError());
else {
Name = Filename;
- return windows_error::success;
+ return std::error_code();
}
}
@@ -220,7 +223,8 @@ static error_code GetFileNameFromHandle(HANDLE FileHandle,
/// extension is present, try all extensions in PATHEXT.
/// @return If ec == errc::success, The absolute path to the program. Otherwise
/// the return value is undefined.
-static std::string FindProgram(const std::string &Program, error_code &ec) {
+static std::string FindProgram(const std::string &Program,
+ std::error_code &ec) {
char PathName[MAX_PATH + 1];
typedef SmallVector<StringRef, 12> pathext_t;
pathext_t pathext;
@@ -245,11 +249,11 @@ static std::string FindProgram(const std::string &Program, error_code &ec) {
ec = windows_error(::GetLastError());
else if (length > array_lengthof(PathName)) {
// This may have been the file, return with error.
- ec = windows_error::buffer_overflow;
+ ec = windows_error(ERROR_BUFFER_OVERFLOW);
break;
} else {
// We found the path! Return it.
- ec = windows_error::success;
+ ec = std::error_code();
break;
}
}
@@ -312,7 +316,7 @@ int main(int argc, char **argv) {
std::string CommandLine(ProgramToRun);
- error_code ec;
+ std::error_code ec;
ProgramToRun = FindProgram(ProgramToRun, ec);
if (ec) {
errs() << ToolName << ": Failed to find program: '" << CommandLine
@@ -356,8 +360,8 @@ int main(int argc, char **argv) {
&StartupInfo,
&ProcessInfo);
if (!success) {
- errs() << ToolName << ": Failed to run program: '" << ProgramToRun
- << "': " << error_code(windows_error(::GetLastError())).message()
+ errs() << ToolName << ": Failed to run program: '" << ProgramToRun << "': "
+ << std::error_code(windows_error(::GetLastError())).message()
<< '\n';
return -1;
}
@@ -420,9 +424,10 @@ int main(int argc, char **argv) {
success = WaitForDebugEvent(&DebugEvent, TimeLeft);
if (!success) {
- ec = windows_error(::GetLastError());
+ DWORD LastError = ::GetLastError();
+ ec = windows_error(LastError);
- if (ec == errc::timed_out) {
+ if (LastError == ERROR_SEM_TIMEOUT || LastError == WSAETIMEDOUT) {
errs() << ToolName << ": Process timed out.\n";
::TerminateProcess(ProcessInfo.hProcess, -1);
// Otherwise other stuff starts failing...