[Lldb-commits] [lldb] de687ea - [lldb] Update Host/windows to new Status API
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 27 15:43:21 PDT 2024
Author: Adrian Prantl
Date: 2024-08-27T15:43:12-07:00
New Revision: de687eac24a3f4bac8b5ff9975f51ab98775f2d5
URL: https://github.com/llvm/llvm-project/commit/de687eac24a3f4bac8b5ff9975f51ab98775f2d5
DIFF: https://github.com/llvm/llvm-project/commit/de687eac24a3f4bac8b5ff9975f51ab98775f2d5.diff
LOG: [lldb] Update Host/windows to new Status API
Added:
Modified:
lldb/source/Host/common/Socket.cpp
lldb/source/Host/windows/ConnectionGenericFileWindows.cpp
lldb/source/Host/windows/FileSystem.cpp
lldb/source/Host/windows/HostProcessWindows.cpp
lldb/source/Host/windows/HostThreadWindows.cpp
Removed:
################################################################################
diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp
index 80ec68db775d98..1a506aa95b2465 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -109,8 +109,8 @@ Status SharedSocket::CompleteSending(lldb::pid_t child_pid) {
if (error.Fail())
return error;
if (num_bytes != sizeof(protocol_info))
- return Status::FromErrorStringWithFormat(
- "WriteWithTimeout(WSAPROTOCOL_INFO) failed: %d bytes", num_bytes);
+ return Status::FromErrorStringWithFormatv(
+ "WriteWithTimeout(WSAPROTOCOL_INFO) failed: {0} bytes", num_bytes);
#endif
return Status();
}
@@ -129,16 +129,16 @@ Status SharedSocket::GetNativeSocket(shared_fd_t fd, NativeSocket &socket) {
if (error.Fail())
return error;
if (num_bytes != sizeof(protocol_info)) {
- return Status(
- "socket_pipe.ReadWithTimeout(WSAPROTOCOL_INFO) failed: % d bytes",
+ return Status::FromErrorStringWithFormatv(
+ "socket_pipe.ReadWithTimeout(WSAPROTOCOL_INFO) failed: {0} bytes",
num_bytes);
}
}
socket = ::WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO,
FROM_PROTOCOL_INFO, &protocol_info, 0, 0);
if (socket == INVALID_SOCKET) {
- return Status::FromErrorStringWithFormat(
- "WSASocket(FROM_PROTOCOL_INFO) failed: error %d", ::WSAGetLastError());
+ return Status::FromErrorStringWithFormatv(
+ "WSASocket(FROM_PROTOCOL_INFO) failed: error {0}", ::WSAGetLastError());
}
return Status();
#else
@@ -421,7 +421,7 @@ size_t Socket::Send(const void *buf, const size_t num_bytes) {
void Socket::SetLastError(Status &error) {
#if defined(_WIN32)
- error.SetError(::WSAGetLastError(), lldb::eErrorTypeWin32);
+ error = Status(::WSAGetLastError(), lldb::eErrorTypeWin32);
#else
error = Status::FromErrno();
#endif
diff --git a/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp b/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp
index 3ab7d3e7bb7bd1..fd78a625d9cb92 100644
--- a/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp
+++ b/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp
@@ -28,7 +28,7 @@ namespace {
class ReturnInfo {
public:
void Set(size_t bytes, ConnectionStatus status, DWORD error_code) {
- m_error.SetError(error_code, eErrorTypeWin32);
+ m_error = Status(error_code, eErrorTypeWin32);
m_bytes = bytes;
m_status = status;
}
@@ -97,8 +97,8 @@ lldb::ConnectionStatus ConnectionGenericFile::Connect(llvm::StringRef path,
if (!path.consume_front("file://")) {
if (error_ptr)
- error_ptr->SetErrorStringWithFormat("unsupported connection URL: '%s'",
- path.str().c_str());
+ *error_ptr = Status::FromErrorStringWithFormat(
+ "unsupported connection URL: '%s'", path.str().c_str());
return eConnectionStatusError;
}
@@ -115,7 +115,7 @@ lldb::ConnectionStatus ConnectionGenericFile::Connect(llvm::StringRef path,
std::wstring wpath;
if (!llvm::ConvertUTF8toWide(path, wpath)) {
if (error_ptr)
- error_ptr->SetError(1, eErrorTypeGeneric);
+ *error_ptr = Status(1, eErrorTypeGeneric);
return eConnectionStatusError;
}
m_file = ::CreateFileW(wpath.c_str(), GENERIC_READ | GENERIC_WRITE,
@@ -123,7 +123,7 @@ lldb::ConnectionStatus ConnectionGenericFile::Connect(llvm::StringRef path,
FILE_FLAG_OVERLAPPED, NULL);
if (m_file == INVALID_HANDLE_VALUE) {
if (error_ptr)
- error_ptr->SetError(::GetLastError(), eErrorTypeWin32);
+ *error_ptr = Status(::GetLastError(), eErrorTypeWin32);
return eConnectionStatusError;
}
diff --git a/lldb/source/Host/windows/FileSystem.cpp b/lldb/source/Host/windows/FileSystem.cpp
index fb3cdda162e9c5..8d2c3f8db8acca 100644
--- a/lldb/source/Host/windows/FileSystem.cpp
+++ b/lldb/source/Host/windows/FileSystem.cpp
@@ -37,14 +37,14 @@ Status FileSystem::Symlink(const FileSpec &src, const FileSpec &dst) {
return error;
DWORD attrib = ::GetFileAttributesW(wdst.c_str());
if (attrib == INVALID_FILE_ATTRIBUTES) {
- error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
+ error = Status(::GetLastError(), lldb::eErrorTypeWin32);
return error;
}
bool is_directory = !!(attrib & FILE_ATTRIBUTE_DIRECTORY);
DWORD flag = is_directory ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0;
BOOL result = ::CreateSymbolicLinkW(wsrc.c_str(), wdst.c_str(), flag);
if (!result)
- error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
+ error = Status(::GetLastError(), lldb::eErrorTypeWin32);
return error;
}
@@ -60,7 +60,7 @@ Status FileSystem::Readlink(const FileSpec &src, FileSpec &dst) {
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT, NULL);
if (h == INVALID_HANDLE_VALUE) {
- error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
+ error = Status(::GetLastError(), lldb::eErrorTypeWin32);
return error;
}
@@ -71,7 +71,7 @@ Status FileSystem::Readlink(const FileSpec &src, FileSpec &dst) {
h, buf.data(), buf.size() - 1, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
std::string path;
if (result == 0)
- error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
+ error = Status(::GetLastError(), lldb::eErrorTypeWin32);
else if (!llvm::convertWideToUTF8(buf.data(), path))
error = Status::FromErrorString(PATH_CONVERSION_ERROR);
else
diff --git a/lldb/source/Host/windows/HostProcessWindows.cpp b/lldb/source/Host/windows/HostProcessWindows.cpp
index 1955f57bbc383d..44cb333808773b 100644
--- a/lldb/source/Host/windows/HostProcessWindows.cpp
+++ b/lldb/source/Host/windows/HostProcessWindows.cpp
@@ -40,10 +40,10 @@ void HostProcessWindows::SetOwnsHandle(bool owns) { m_owns_handle = owns; }
Status HostProcessWindows::Terminate() {
Status error;
if (m_process == nullptr)
- error.SetError(ERROR_INVALID_HANDLE, lldb::eErrorTypeWin32);
+ error = Status(ERROR_INVALID_HANDLE, lldb::eErrorTypeWin32);
if (!::TerminateProcess(m_process, 0))
- error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
+ error = Status(::GetLastError(), lldb::eErrorTypeWin32);
return error;
}
diff --git a/lldb/source/Host/windows/HostThreadWindows.cpp b/lldb/source/Host/windows/HostThreadWindows.cpp
index 1219c387754533..4a8843ffdd7831 100644
--- a/lldb/source/Host/windows/HostThreadWindows.cpp
+++ b/lldb/source/Host/windows/HostThreadWindows.cpp
@@ -40,9 +40,9 @@ Status HostThreadWindows::Join(lldb::thread_result_t *result) {
*result = 0;
*result = exit_code;
} else if (WAIT_OBJECT_0 != wait_result)
- error.SetError(::GetLastError(), eErrorTypeWin32);
+ error = Status(::GetLastError(), eErrorTypeWin32);
} else
- error.SetError(ERROR_INVALID_HANDLE, eErrorTypeWin32);
+ error = Status(ERROR_INVALID_HANDLE, eErrorTypeWin32);
Reset();
return error;
@@ -52,7 +52,7 @@ Status HostThreadWindows::Cancel() {
Status error;
DWORD result = ::QueueUserAPC(::ExitThreadProxy, m_thread, 0);
- error.SetError(result, eErrorTypeWin32);
+ error = Status(result, eErrorTypeWin32);
return error;
}
More information about the lldb-commits
mailing list