X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=utils%2FKillTheDoctor%2FKillTheDoctor.cpp;h=feba2e54f6a5fb20f8c7367e07e06eb137a80593;hb=1ce47acc1cdb585bd033135a598e0f82e67e0e22;hp=7a89dd379b70f5cd9c7e42a51845013d9f04ec79;hpb=738550910156b5cefdc0c12923ec8cc6982fb26f;p=oota-llvm.git diff --git a/utils/KillTheDoctor/KillTheDoctor.cpp b/utils/KillTheDoctor/KillTheDoctor.cpp index 7a89dd379b7..feba2e54f6a 100644 --- a/utils/KillTheDoctor/KillTheDoctor.cpp +++ b/utils/KillTheDoctor/KillTheDoctor.cpp @@ -39,19 +39,22 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/PrettyStackTrace.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/Support/type_traits.h" #include "llvm/Support/Signals.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Support/system_error.h" +#include "llvm/Support/type_traits.h" #include #include #include #include #include + +// These includes must be last. #include #include #include #include + using namespace llvm; #undef max @@ -169,14 +172,14 @@ namespace { static error_code GetFileNameFromHandle(HANDLE FileHandle, std::string& Name) { char Filename[MAX_PATH+1]; - bool Sucess = false; + bool Success = false; Name.clear(); // Get the file size. LARGE_INTEGER FileSize; - Sucess = ::GetFileSizeEx(FileHandle, &FileSize); + Success = ::GetFileSizeEx(FileHandle, &FileSize); - if (!Sucess) + if (!Success) return windows_error(::GetLastError()); // Create a file mapping object. @@ -198,12 +201,12 @@ static error_code GetFileNameFromHandle(HANDLE FileHandle, if (!MappedFile) return windows_error(::GetLastError()); - Sucess = ::GetMappedFileNameA(::GetCurrentProcess(), + Success = ::GetMappedFileNameA(::GetCurrentProcess(), MappedFile, Filename, array_lengthof(Filename) - 1); - if (!Sucess) + if (!Success) return windows_error(::GetLastError()); else { Name = Filename; @@ -211,19 +214,6 @@ static error_code GetFileNameFromHandle(HANDLE FileHandle, } } -static std::string QuoteProgramPathIfNeeded(StringRef Command) { - if (Command.find_first_of(' ') == StringRef::npos) - return Command; - else { - std::string ret; - ret.reserve(Command.size() + 3); - ret.push_back('"'); - ret.append(Command.begin(), Command.end()); - ret.push_back('"'); - return ret; - } -} - /// @brief Find program using shell lookup rules. /// @param Program This is either an absolute path, relative path, or simple a /// program name. Look in PATH for any programs that match. If no @@ -269,39 +259,6 @@ static std::string FindProgram(const std::string &Program, error_code &ec) { return PathName; } -static error_code EnableDebugPrivileges() { - HANDLE TokenHandle; - BOOL success = ::OpenProcessToken(::GetCurrentProcess(), - TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, - &TokenHandle); - if (!success) - return windows_error(::GetLastError()); - - TokenScopedHandle Token(TokenHandle); - TOKEN_PRIVILEGES TokenPrivileges; - LUID LocallyUniqueID; - - success = ::LookupPrivilegeValueA(NULL, - SE_DEBUG_NAME, - &LocallyUniqueID); - if (!success) - return windows_error(::GetLastError()); - - TokenPrivileges.PrivilegeCount = 1; - TokenPrivileges.Privileges[0].Luid = LocallyUniqueID; - TokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - - success = ::AdjustTokenPrivileges(Token, - FALSE, - &TokenPrivileges, - sizeof(TOKEN_PRIVILEGES), - NULL, - NULL); - // The value of success is basically useless. Either way we are just returning - // the value of ::GetLastError(). - return windows_error(::GetLastError()); -} - static StringRef ExceptionCodeToString(DWORD ExceptionCode) { switch(ExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: return "EXCEPTION_ACCESS_VIOLATION";