[Lldb-commits] [lldb] 6ae657b - [lldb] Adapt Plugins/Process/Windows to new Status API
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 27 17:03:06 PDT 2024
Author: Adrian Prantl
Date: 2024-08-27T17:02:49-07:00
New Revision: 6ae657b08d624f9634fa6ebbf5d6fd7a22dc3b4d
URL: https://github.com/llvm/llvm-project/commit/6ae657b08d624f9634fa6ebbf5d6fd7a22dc3b4d
DIFF: https://github.com/llvm/llvm-project/commit/6ae657b08d624f9634fa6ebbf5d6fd7a22dc3b4d.diff
LOG: [lldb] Adapt Plugins/Process/Windows to new Status API
Added:
Modified:
lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm.cpp
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp b/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
index e7fee41239da7c..6f2f6633021d34 100644
--- a/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
@@ -187,7 +187,7 @@ Status DebuggerThread::StopDebugging(bool terminate) {
// thread.
if (!::DebugBreakProcess(
GetProcess().GetNativeProcess().GetSystemHandle())) {
- error.SetError(::GetLastError(), eErrorTypeWin32);
+ error = Status(::GetLastError(), eErrorTypeWin32);
}
}
@@ -195,7 +195,7 @@ Status DebuggerThread::StopDebugging(bool terminate) {
DWORD wait_result = WaitForSingleObject(m_debugging_ended_event, 5000);
if (wait_result != WAIT_OBJECT_0) {
- error.SetError(GetLastError(), eErrorTypeWin32);
+ error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "error: WaitForSingleObject({0}, 5000) returned {1}",
m_debugging_ended_event, wait_result);
} else
diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
index c62c9e2dd434ef..24c9aa6b32659d 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -120,7 +120,7 @@ Status NativeProcessWindows::Resume(const ResumeActionList &resume_actions) {
break;
default:
- return Status(
+ return Status::FromErrorStringWithFormat(
"NativeProcessWindows::%s (): unexpected state %s specified "
"for pid %" PRIu64 ", tid %" PRIu64,
__FUNCTION__, StateAsCString(action->state), GetID(),
@@ -361,7 +361,7 @@ Status NativeProcessWindows::CacheLoadedModules() {
return Status();
}
- error.SetError(::GetLastError(), lldb::ErrorType::eErrorTypeWin32);
+ error = Status(::GetLastError(), lldb::ErrorType::eErrorTypeWin32);
return error;
}
diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp
index 5c9611f35d8619..a9642d1c5e48da 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp
@@ -65,7 +65,7 @@ GetWoW64ThreadContextHelper(lldb::thread_t thread_handle,
memset(context_ptr, 0, sizeof(::WOW64_CONTEXT));
context_ptr->ContextFlags = control_flag;
if (!::Wow64GetThreadContext(thread_handle, context_ptr)) {
- error.SetError(GetLastError(), eErrorTypeWin32);
+ error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "{0} Wow64GetThreadContext failed with error {1}",
__FUNCTION__, error);
return error;
@@ -78,7 +78,7 @@ static Status SetWoW64ThreadContextHelper(lldb::thread_t thread_handle,
Log *log = GetLog(WindowsLog::Registers);
Status error;
if (!::Wow64SetThreadContext(thread_handle, context_ptr)) {
- error.SetError(GetLastError(), eErrorTypeWin32);
+ error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "{0} Wow64SetThreadContext failed with error {1}",
__FUNCTION__, error);
return error;
diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm.cpp
index 2c6b0e2a58d45d..4209fdf3c7109a 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm.cpp
@@ -94,7 +94,7 @@ static Status GetThreadContextHelper(lldb::thread_t thread_handle,
memset(context_ptr, 0, sizeof(::CONTEXT));
context_ptr->ContextFlags = control_flag;
if (!::GetThreadContext(thread_handle, context_ptr)) {
- error.SetError(GetLastError(), eErrorTypeWin32);
+ error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "{0} GetThreadContext failed with error {1}", __FUNCTION__,
error);
return error;
@@ -108,7 +108,7 @@ static Status SetThreadContextHelper(lldb::thread_t thread_handle,
Status error;
// It's assumed that the thread has stopped.
if (!::SetThreadContext(thread_handle, context_ptr)) {
- error.SetError(GetLastError(), eErrorTypeWin32);
+ error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "{0} SetThreadContext failed with error {1}", __FUNCTION__,
error);
return error;
diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
index e1746a74922072..080a9140e36a64 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
@@ -111,7 +111,7 @@ static Status GetThreadContextHelper(lldb::thread_t thread_handle,
memset(context_ptr, 0, sizeof(::CONTEXT));
context_ptr->ContextFlags = control_flag;
if (!::GetThreadContext(thread_handle, context_ptr)) {
- error.SetError(GetLastError(), eErrorTypeWin32);
+ error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "{0} GetThreadContext failed with error {1}", __FUNCTION__,
error);
return error;
@@ -125,7 +125,7 @@ static Status SetThreadContextHelper(lldb::thread_t thread_handle,
Status error;
// It's assumed that the thread has stopped.
if (!::SetThreadContext(thread_handle, context_ptr)) {
- error.SetError(GetLastError(), eErrorTypeWin32);
+ error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "{0} SetThreadContext failed with error {1}", __FUNCTION__,
error);
return error;
diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp
index 0856a3e87ba5de..53df9866793946 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp
@@ -61,7 +61,7 @@ static Status GetThreadContextHelper(lldb::thread_t thread_handle,
memset(context_ptr, 0, sizeof(::CONTEXT));
context_ptr->ContextFlags = control_flag;
if (!::GetThreadContext(thread_handle, context_ptr)) {
- error.SetError(GetLastError(), eErrorTypeWin32);
+ error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "{0} GetThreadContext failed with error {1}", __FUNCTION__,
error);
return error;
@@ -75,7 +75,7 @@ static Status SetThreadContextHelper(lldb::thread_t thread_handle,
Status error;
if (!::SetThreadContext(thread_handle, context_ptr)) {
- error.SetError(GetLastError(), eErrorTypeWin32);
+ error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "{0} SetThreadContext failed with error {1}", __FUNCTION__,
error);
return error;
diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
index fb6fbe27718cee..4c59273b845aaa 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp
@@ -73,7 +73,7 @@ static Status GetThreadContextHelper(lldb::thread_t thread_handle,
memset(context_ptr, 0, sizeof(::CONTEXT));
context_ptr->ContextFlags = control_flag;
if (!::GetThreadContext(thread_handle, context_ptr)) {
- error.SetError(GetLastError(), eErrorTypeWin32);
+ error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "{0} GetThreadContext failed with error {1}", __FUNCTION__,
error);
return error;
@@ -87,7 +87,7 @@ static Status SetThreadContextHelper(lldb::thread_t thread_handle,
Status error;
// It's assumed that the thread has stopped.
if (!::SetThreadContext(thread_handle, context_ptr)) {
- error.SetError(GetLastError(), eErrorTypeWin32);
+ error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "{0} SetThreadContext failed with error {1}", __FUNCTION__,
error);
return error;
diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
index 8e070c5ba02ee2..04c7c0f826039d 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
@@ -252,7 +252,7 @@ Status ProcessDebugger::HaltProcess(bool &caused_stop) {
.GetNativeProcess()
.GetSystemHandle());
if (!caused_stop) {
- error.SetError(::GetLastError(), eErrorTypeWin32);
+ error = Status(::GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "DebugBreakProcess failed with error {0}", error);
}
@@ -281,7 +281,7 @@ Status ProcessDebugger::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
SIZE_T num_of_bytes_read = 0;
if (!::ReadProcessMemory(process.GetNativeProcess().GetSystemHandle(), addr,
buf, size, &num_of_bytes_read)) {
- error.SetError(GetLastError(), eErrorTypeWin32);
+ error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "reading failed with error: {0}", error);
} else {
bytes_read = num_of_bytes_read;
@@ -313,7 +313,7 @@ Status ProcessDebugger::WriteMemory(lldb::addr_t vm_addr, const void *buf,
FlushInstructionCache(handle, addr, num_of_bytes_written);
bytes_written = num_of_bytes_written;
} else {
- error.SetError(GetLastError(), eErrorTypeWin32);
+ error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "writing failed with error: {0}", error);
}
return error;
@@ -340,7 +340,7 @@ Status ProcessDebugger::AllocateMemory(size_t size, uint32_t permissions,
auto protect = ConvertLldbToWinApiProtect(permissions);
auto result = ::VirtualAllocEx(handle, nullptr, size, MEM_COMMIT, protect);
if (!result) {
- error.SetError(GetLastError(), eErrorTypeWin32);
+ error = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "allocating failed with error: {0}", error);
} else {
addr = reinterpret_cast<addr_t>(result);
@@ -366,7 +366,7 @@ Status ProcessDebugger::DeallocateMemory(lldb::addr_t vm_addr) {
lldb::process_t handle = process.GetNativeProcess().GetSystemHandle();
if (!::VirtualFreeEx(handle, reinterpret_cast<LPVOID>(vm_addr), 0,
MEM_RELEASE)) {
- result.SetError(GetLastError(), eErrorTypeWin32);
+ result = Status(GetLastError(), eErrorTypeWin32);
LLDB_LOG(log, "deallocating failed with error: {0}", result);
}
@@ -414,7 +414,7 @@ Status ProcessDebugger::GetMemoryRegionInfo(lldb::addr_t vm_addr,
info.SetMapped(MemoryRegionInfo::eNo);
return error;
} else {
- error.SetError(last_error, eErrorTypeWin32);
+ error = Status(last_error, eErrorTypeWin32);
LLDB_LOG(log,
"VirtualQueryEx returned error {0} while getting memory "
"region info for address {1:x}",
More information about the lldb-commits
mailing list