git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120986
91177308-0d34-0410-b5e6-
96231b3b80d8
typedef ScopedHandle<ThreadHandle> ThreadScopedHandle;
typedef ScopedHandle<TokenHandle> TokenScopedHandle;
typedef ScopedHandle<FileHandle> FileScopedHandle;
typedef ScopedHandle<ThreadHandle> ThreadScopedHandle;
typedef ScopedHandle<TokenHandle> TokenScopedHandle;
typedef ScopedHandle<FileHandle> FileScopedHandle;
-
- error_code get_windows_last_error() {
- return make_error_code(windows_error(::GetLastError()));
- }
}
static error_code GetFileNameFromHandle(HANDLE FileHandle,
}
static error_code GetFileNameFromHandle(HANDLE FileHandle,
Sucess = ::GetFileSizeEx(FileHandle, &FileSize);
if (!Sucess)
Sucess = ::GetFileSizeEx(FileHandle, &FileSize);
if (!Sucess)
- return get_windows_last_error();
+ return windows_error(::GetLastError());
// Create a file mapping object.
FileMappingScopedHandle FileMapping(
// Create a file mapping object.
FileMappingScopedHandle FileMapping(
NULL));
if (!FileMapping)
NULL));
if (!FileMapping)
- return get_windows_last_error();
+ return windows_error(::GetLastError());
// Create a file mapping to get the file name.
MappedViewOfFileScopedHandle MappedFile(
::MapViewOfFile(FileMapping, FILE_MAP_READ, 0, 0, 1));
if (!MappedFile)
// Create a file mapping to get the file name.
MappedViewOfFileScopedHandle MappedFile(
::MapViewOfFile(FileMapping, FILE_MAP_READ, 0, 0, 1));
if (!MappedFile)
- return get_windows_last_error();
+ return windows_error(::GetLastError());
Sucess = ::GetMappedFileNameA(::GetCurrentProcess(),
MappedFile,
Sucess = ::GetMappedFileNameA(::GetCurrentProcess(),
MappedFile,
array_lengthof(Filename) - 1);
if (!Sucess)
array_lengthof(Filename) - 1);
if (!Sucess)
- return get_windows_last_error();
+ return windows_error(::GetLastError());
else {
Name = Filename;
return windows_error::success;
else {
Name = Filename;
return windows_error::success;
PathName,
NULL);
if (length == 0)
PathName,
NULL);
if (length == 0)
- ec = get_windows_last_error();
+ ec = windows_error(::GetLastError());
else if (length > array_lengthof(PathName)) {
// This may have been the file, return with error.
else if (length > array_lengthof(PathName)) {
// This may have been the file, return with error.
- ec = error_code(windows_error::buffer_overflow);
+ ec = windows_error::buffer_overflow;
break;
} else {
// We found the path! Return it.
break;
} else {
// We found the path! Return it.
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
&TokenHandle);
if (!success)
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
&TokenHandle);
if (!success)
- return error_code(::GetLastError(), system_category());
+ return windows_error(::GetLastError());
TokenScopedHandle Token(TokenHandle);
TOKEN_PRIVILEGES TokenPrivileges;
TokenScopedHandle Token(TokenHandle);
TOKEN_PRIVILEGES TokenPrivileges;
SE_DEBUG_NAME,
&LocallyUniqueID);
if (!success)
SE_DEBUG_NAME,
&LocallyUniqueID);
if (!success)
- return error_code(::GetLastError(), system_category());
+ return windows_error(::GetLastError());
TokenPrivileges.PrivilegeCount = 1;
TokenPrivileges.Privileges[0].Luid = LocallyUniqueID;
TokenPrivileges.PrivilegeCount = 1;
TokenPrivileges.Privileges[0].Luid = LocallyUniqueID;
NULL);
// The value of success is basically useless. Either way we are just returning
// the value of ::GetLastError().
NULL);
// The value of success is basically useless. Either way we are just returning
// the value of ::GetLastError().
- return error_code(::GetLastError(), system_category());
+ return windows_error(::GetLastError());
}
static StringRef ExceptionCodeToString(DWORD ExceptionCode) {
}
static StringRef ExceptionCodeToString(DWORD ExceptionCode) {
&ProcessInfo);
if (!success) {
errs() << ToolName << ": Failed to run program: '" << ProgramToRun
&ProcessInfo);
if (!success) {
errs() << ToolName << ": Failed to run program: '" << ProgramToRun
- << "': " << error_code(::GetLastError(), system_category()).message()
+ << "': " << error_code(windows_error(::GetLastError())).message()
&KernelTime,
&UserTime);
if (!success) {
&KernelTime,
&UserTime);
if (!success) {
- ec = error_code(::GetLastError(), system_category());
+ ec = windows_error(::GetLastError());
errs() << ToolName << ": Failed to get process times: "
<< ec.message() << '\n';
errs() << ToolName << ": Failed to get process times: "
<< ec.message() << '\n';
success = WaitForDebugEvent(&DebugEvent, TimeLeft);
if (!success) {
success = WaitForDebugEvent(&DebugEvent, TimeLeft);
if (!success) {
- ec = error_code(::GetLastError(), system_category());
+ ec = windows_error(::GetLastError());
- if (ec == error_condition(errc::timed_out)) {
+ if (ec == errc::timed_out) {
errs() << ToolName << ": Process timed out.\n";
::TerminateProcess(ProcessInfo.hProcess, -1);
// Otherwise other stuff starts failing...
errs() << ToolName << ": Process timed out.\n";
::TerminateProcess(ProcessInfo.hProcess, -1);
// Otherwise other stuff starts failing...
DebugEvent.dwThreadId,
dwContinueStatus);
if (!success) {
DebugEvent.dwThreadId,
dwContinueStatus);
if (!success) {
- ec = error_code(::GetLastError(), system_category());
+ ec = windows_error(::GetLastError());
errs() << ToolName << ": Failed to continue debugging program: '"
<< ProgramToRun << "': " << ec.message() << '\n';
return -1;
errs() << ToolName << ": Failed to continue debugging program: '"
<< ProgramToRun << "': " << ec.message() << '\n';
return -1;