Skip to content

Commit 6ae657b

Browse files
committed
[lldb] Adapt Plugins/Process/Windows to new Status API
1 parent 0b1c8fd commit 6ae657b

8 files changed

+20
-20
lines changed

lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,15 @@ Status DebuggerThread::StopDebugging(bool terminate) {
187187
// thread.
188188
if (!::DebugBreakProcess(
189189
GetProcess().GetNativeProcess().GetSystemHandle())) {
190-
error.SetError(::GetLastError(), eErrorTypeWin32);
190+
error = Status(::GetLastError(), eErrorTypeWin32);
191191
}
192192
}
193193

194194
LLDB_LOG(log, "waiting for detach from process {0} to complete.", pid);
195195

196196
DWORD wait_result = WaitForSingleObject(m_debugging_ended_event, 5000);
197197
if (wait_result != WAIT_OBJECT_0) {
198-
error.SetError(GetLastError(), eErrorTypeWin32);
198+
error = Status(GetLastError(), eErrorTypeWin32);
199199
LLDB_LOG(log, "error: WaitForSingleObject({0}, 5000) returned {1}",
200200
m_debugging_ended_event, wait_result);
201201
} else

lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Status NativeProcessWindows::Resume(const ResumeActionList &resume_actions) {
120120
break;
121121

122122
default:
123-
return Status(
123+
return Status::FromErrorStringWithFormat(
124124
"NativeProcessWindows::%s (): unexpected state %s specified "
125125
"for pid %" PRIu64 ", tid %" PRIu64,
126126
__FUNCTION__, StateAsCString(action->state), GetID(),
@@ -361,7 +361,7 @@ Status NativeProcessWindows::CacheLoadedModules() {
361361
return Status();
362362
}
363363

364-
error.SetError(::GetLastError(), lldb::ErrorType::eErrorTypeWin32);
364+
error = Status(::GetLastError(), lldb::ErrorType::eErrorTypeWin32);
365365
return error;
366366
}
367367

lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ GetWoW64ThreadContextHelper(lldb::thread_t thread_handle,
6565
memset(context_ptr, 0, sizeof(::WOW64_CONTEXT));
6666
context_ptr->ContextFlags = control_flag;
6767
if (!::Wow64GetThreadContext(thread_handle, context_ptr)) {
68-
error.SetError(GetLastError(), eErrorTypeWin32);
68+
error = Status(GetLastError(), eErrorTypeWin32);
6969
LLDB_LOG(log, "{0} Wow64GetThreadContext failed with error {1}",
7070
__FUNCTION__, error);
7171
return error;
@@ -78,7 +78,7 @@ static Status SetWoW64ThreadContextHelper(lldb::thread_t thread_handle,
7878
Log *log = GetLog(WindowsLog::Registers);
7979
Status error;
8080
if (!::Wow64SetThreadContext(thread_handle, context_ptr)) {
81-
error.SetError(GetLastError(), eErrorTypeWin32);
81+
error = Status(GetLastError(), eErrorTypeWin32);
8282
LLDB_LOG(log, "{0} Wow64SetThreadContext failed with error {1}",
8383
__FUNCTION__, error);
8484
return error;

lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static Status GetThreadContextHelper(lldb::thread_t thread_handle,
9494
memset(context_ptr, 0, sizeof(::CONTEXT));
9595
context_ptr->ContextFlags = control_flag;
9696
if (!::GetThreadContext(thread_handle, context_ptr)) {
97-
error.SetError(GetLastError(), eErrorTypeWin32);
97+
error = Status(GetLastError(), eErrorTypeWin32);
9898
LLDB_LOG(log, "{0} GetThreadContext failed with error {1}", __FUNCTION__,
9999
error);
100100
return error;
@@ -108,7 +108,7 @@ static Status SetThreadContextHelper(lldb::thread_t thread_handle,
108108
Status error;
109109
// It's assumed that the thread has stopped.
110110
if (!::SetThreadContext(thread_handle, context_ptr)) {
111-
error.SetError(GetLastError(), eErrorTypeWin32);
111+
error = Status(GetLastError(), eErrorTypeWin32);
112112
LLDB_LOG(log, "{0} SetThreadContext failed with error {1}", __FUNCTION__,
113113
error);
114114
return error;

lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static Status GetThreadContextHelper(lldb::thread_t thread_handle,
111111
memset(context_ptr, 0, sizeof(::CONTEXT));
112112
context_ptr->ContextFlags = control_flag;
113113
if (!::GetThreadContext(thread_handle, context_ptr)) {
114-
error.SetError(GetLastError(), eErrorTypeWin32);
114+
error = Status(GetLastError(), eErrorTypeWin32);
115115
LLDB_LOG(log, "{0} GetThreadContext failed with error {1}", __FUNCTION__,
116116
error);
117117
return error;
@@ -125,7 +125,7 @@ static Status SetThreadContextHelper(lldb::thread_t thread_handle,
125125
Status error;
126126
// It's assumed that the thread has stopped.
127127
if (!::SetThreadContext(thread_handle, context_ptr)) {
128-
error.SetError(GetLastError(), eErrorTypeWin32);
128+
error = Status(GetLastError(), eErrorTypeWin32);
129129
LLDB_LOG(log, "{0} SetThreadContext failed with error {1}", __FUNCTION__,
130130
error);
131131
return error;

lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static Status GetThreadContextHelper(lldb::thread_t thread_handle,
6161
memset(context_ptr, 0, sizeof(::CONTEXT));
6262
context_ptr->ContextFlags = control_flag;
6363
if (!::GetThreadContext(thread_handle, context_ptr)) {
64-
error.SetError(GetLastError(), eErrorTypeWin32);
64+
error = Status(GetLastError(), eErrorTypeWin32);
6565
LLDB_LOG(log, "{0} GetThreadContext failed with error {1}", __FUNCTION__,
6666
error);
6767
return error;
@@ -75,7 +75,7 @@ static Status SetThreadContextHelper(lldb::thread_t thread_handle,
7575
Status error;
7676

7777
if (!::SetThreadContext(thread_handle, context_ptr)) {
78-
error.SetError(GetLastError(), eErrorTypeWin32);
78+
error = Status(GetLastError(), eErrorTypeWin32);
7979
LLDB_LOG(log, "{0} SetThreadContext failed with error {1}", __FUNCTION__,
8080
error);
8181
return error;

lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static Status GetThreadContextHelper(lldb::thread_t thread_handle,
7373
memset(context_ptr, 0, sizeof(::CONTEXT));
7474
context_ptr->ContextFlags = control_flag;
7575
if (!::GetThreadContext(thread_handle, context_ptr)) {
76-
error.SetError(GetLastError(), eErrorTypeWin32);
76+
error = Status(GetLastError(), eErrorTypeWin32);
7777
LLDB_LOG(log, "{0} GetThreadContext failed with error {1}", __FUNCTION__,
7878
error);
7979
return error;
@@ -87,7 +87,7 @@ static Status SetThreadContextHelper(lldb::thread_t thread_handle,
8787
Status error;
8888
// It's assumed that the thread has stopped.
8989
if (!::SetThreadContext(thread_handle, context_ptr)) {
90-
error.SetError(GetLastError(), eErrorTypeWin32);
90+
error = Status(GetLastError(), eErrorTypeWin32);
9191
LLDB_LOG(log, "{0} SetThreadContext failed with error {1}", __FUNCTION__,
9292
error);
9393
return error;

lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Status ProcessDebugger::HaltProcess(bool &caused_stop) {
252252
.GetNativeProcess()
253253
.GetSystemHandle());
254254
if (!caused_stop) {
255-
error.SetError(::GetLastError(), eErrorTypeWin32);
255+
error = Status(::GetLastError(), eErrorTypeWin32);
256256
LLDB_LOG(log, "DebugBreakProcess failed with error {0}", error);
257257
}
258258

@@ -281,7 +281,7 @@ Status ProcessDebugger::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
281281
SIZE_T num_of_bytes_read = 0;
282282
if (!::ReadProcessMemory(process.GetNativeProcess().GetSystemHandle(), addr,
283283
buf, size, &num_of_bytes_read)) {
284-
error.SetError(GetLastError(), eErrorTypeWin32);
284+
error = Status(GetLastError(), eErrorTypeWin32);
285285
LLDB_LOG(log, "reading failed with error: {0}", error);
286286
} else {
287287
bytes_read = num_of_bytes_read;
@@ -313,7 +313,7 @@ Status ProcessDebugger::WriteMemory(lldb::addr_t vm_addr, const void *buf,
313313
FlushInstructionCache(handle, addr, num_of_bytes_written);
314314
bytes_written = num_of_bytes_written;
315315
} else {
316-
error.SetError(GetLastError(), eErrorTypeWin32);
316+
error = Status(GetLastError(), eErrorTypeWin32);
317317
LLDB_LOG(log, "writing failed with error: {0}", error);
318318
}
319319
return error;
@@ -340,7 +340,7 @@ Status ProcessDebugger::AllocateMemory(size_t size, uint32_t permissions,
340340
auto protect = ConvertLldbToWinApiProtect(permissions);
341341
auto result = ::VirtualAllocEx(handle, nullptr, size, MEM_COMMIT, protect);
342342
if (!result) {
343-
error.SetError(GetLastError(), eErrorTypeWin32);
343+
error = Status(GetLastError(), eErrorTypeWin32);
344344
LLDB_LOG(log, "allocating failed with error: {0}", error);
345345
} else {
346346
addr = reinterpret_cast<addr_t>(result);
@@ -366,7 +366,7 @@ Status ProcessDebugger::DeallocateMemory(lldb::addr_t vm_addr) {
366366
lldb::process_t handle = process.GetNativeProcess().GetSystemHandle();
367367
if (!::VirtualFreeEx(handle, reinterpret_cast<LPVOID>(vm_addr), 0,
368368
MEM_RELEASE)) {
369-
result.SetError(GetLastError(), eErrorTypeWin32);
369+
result = Status(GetLastError(), eErrorTypeWin32);
370370
LLDB_LOG(log, "deallocating failed with error: {0}", result);
371371
}
372372

@@ -414,7 +414,7 @@ Status ProcessDebugger::GetMemoryRegionInfo(lldb::addr_t vm_addr,
414414
info.SetMapped(MemoryRegionInfo::eNo);
415415
return error;
416416
} else {
417-
error.SetError(last_error, eErrorTypeWin32);
417+
error = Status(last_error, eErrorTypeWin32);
418418
LLDB_LOG(log,
419419
"VirtualQueryEx returned error {0} while getting memory "
420420
"region info for address {1:x}",

0 commit comments

Comments
 (0)