LLDB mainline
DebuggerThread.cpp
Go to the documentation of this file.
1//===-- DebuggerThread.cpp ------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "DebuggerThread.h"
10#include "ExceptionRecord.h"
11#include "IDebugDelegate.h"
12
20#include "lldb/Target/Process.h"
22#include "lldb/Utility/Log.h"
24#include "lldb/Utility/Status.h"
25
27
29#include "llvm/ADT/STLExtras.h"
30#include "llvm/Support/ConvertUTF.h"
31#include "llvm/Support/Threading.h"
32#include "llvm/Support/raw_ostream.h"
33
34#include <optional>
35#include <psapi.h>
36
37#ifndef STATUS_WX86_BREAKPOINT
38#define STATUS_WX86_BREAKPOINT 0x4000001FL // For WOW64
39#endif
40
41using namespace lldb;
42using namespace lldb_private;
43
44typedef BOOL WINAPI WaitForDebugEventFn(LPDEBUG_EVENT, DWORD);
46
48 HMODULE h_kernel32 = LoadLibraryW(L"kernel32.dll");
49 if (!h_kernel32) {
50 llvm::Error err = llvm::errorCodeToError(
51 std::error_code(GetLastError(), std::system_category()));
52 LLDB_LOG_ERROR(GetLog(LLDBLog::Host), std::move(err),
53 "Could not load kernel32: {0}");
54 return nullptr;
55 }
56
57 return reinterpret_cast<WaitForDebugEventFn *>(
58 GetProcAddress(h_kernel32, "WaitForDebugEventEx"));
59}
60
61/// WaitForDebugEventEx is only available on Windows 10+. This lazily checks if
62/// the function is available and falls back to WaitForDebugEvent if
63/// unavailable. The -Ex version ensures correct forwarding of
64/// OutputDebugStringW events.
67 return;
68
73 "WaitForDebugEventEx unavailable, using WaitForDebugEvent instead. "
74 "Unicode strings from OutputDebugStringW might show incorrectly.");
75 g_wait_for_debug_event = &WaitForDebugEvent;
76 }
77}
78
80 : m_debug_delegate(debug_delegate), m_pid_to_detach(0),
81 m_is_shutting_down(false) {
83 m_debugging_ended_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr);
84}
85
87
90 LLDB_LOG(log, "launching '{0}'", launch_info.GetExecutableFile().GetPath());
91
92 Status result;
93 llvm::Expected<HostThread> secondary_thread = ThreadLauncher::LaunchThread(
94 "lldb.plugin.process-windows.secondary[?]",
95 [this, launch_info] { return DebuggerThreadLaunchRoutine(launch_info); });
96 if (!secondary_thread) {
97 result = Status::FromError(secondary_thread.takeError());
98 LLDB_LOG(log, "couldn't launch debugger thread. {0}", result);
99 }
100
101 return result;
102}
103
105 const ProcessAttachInfo &attach_info) {
107 LLDB_LOG(log, "attaching to '{0}'", pid);
108
109 Status result;
110 llvm::Expected<HostThread> secondary_thread = ThreadLauncher::LaunchThread(
111 "lldb.plugin.process-windows.secondary[?]", [this, pid, attach_info] {
112 return DebuggerThreadAttachRoutine(pid, attach_info);
113 });
114 if (!secondary_thread) {
115 result = Status::FromError(secondary_thread.takeError());
116 LLDB_LOG(log, "couldn't attach to process '{0}'. {1}", pid, result);
117 }
118
119 return result;
120}
121
123 const ProcessLaunchInfo &launch_info) {
124 // Grab a shared_ptr reference to this so that we know it won't get deleted
125 // until after the thread routine has exited.
126 std::shared_ptr<DebuggerThread> this_ref(shared_from_this());
127
129 LLDB_LOG(log, "preparing to launch '{0}' on background thread.",
130 launch_info.GetExecutableFile().GetPath());
131
133 ProcessLauncherWindows launcher;
134 HostProcess process(launcher.LaunchProcess(launch_info, error));
135 // If we couldn't create the process, notify waiters immediately. Otherwise
136 // enter the debug loop and wait until we get the create process debug
137 // notification. Note that if the process was created successfully, we can
138 // throw away the process handle we got from CreateProcess because Windows
139 // will give us another (potentially more useful?) handle when it sends us
140 // the CREATE_PROCESS_DEBUG_EVENT.
141 if (error.Success())
142 DebugLoop();
143 else
144 m_debug_delegate->OnDebuggerError(error, 0);
145
146 return {};
147}
148
150 lldb::pid_t pid, const ProcessAttachInfo &attach_info) {
151 // Grab a shared_ptr reference to this so that we know it won't get deleted
152 // until after the thread routine has exited.
153 std::shared_ptr<DebuggerThread> this_ref(shared_from_this());
154
156 LLDB_LOG(log, "preparing to attach to process '{0}' on background thread.",
157 pid);
158
159 if (!DebugActiveProcess((DWORD)pid)) {
160 Status error(::GetLastError(), eErrorTypeWin32);
161 m_debug_delegate->OnDebuggerError(error, 0);
162 return {};
163 }
164
165 // The attach was successful, enter the debug loop. From here on out, this
166 // is no different than a create process operation, so all the same comments
167 // in DebugLaunch should apply from this point out.
168 DebugLoop();
169
170 return {};
171}
172
175
176 lldb::pid_t pid = m_process.GetProcessId();
177
179 LLDB_LOG(log, "terminate = {0}, inferior={1}.", terminate, pid);
180
181 // Set m_is_shutting_down to true if it was false. Return if it was already
182 // true.
183 bool expected = false;
184 if (!m_is_shutting_down.compare_exchange_strong(expected, true))
185 return error;
186
187 // Make a copy of the process, since the termination sequence will reset
188 // DebuggerThread's internal copy and it needs to remain open for the Wait
189 // operation.
190 HostProcess process_copy = m_process;
191 lldb::process_t handle = m_process.GetNativeProcess().GetSystemHandle();
192
193 if (terminate) {
194 if (handle != nullptr && handle != LLDB_INVALID_PROCESS) {
195 // Initiate the termination before continuing the exception, so that the
196 // next debug event we get is the exit process event, and not some other
197 // event.
198 BOOL terminate_suceeded = TerminateProcess(handle, 0);
199 LLDB_LOG(log,
200 "calling TerminateProcess({0}, 0) (inferior={1}), success={2}",
201 handle, pid, terminate_suceeded);
202 } else {
203 LLDB_LOG(log,
204 "NOT calling TerminateProcess because the inferior is not valid "
205 "({0}, 0) (inferior={1})",
206 handle, pid);
207 }
208 }
209
210 // If we're stuck waiting for an exception to continue (e.g. the user is at a
211 // breakpoint messing around in the debugger), continue it now. But only
212 // AFTER calling TerminateProcess to make sure that the very next call to
213 // WaitForDebugEvent is an exit process event.
214 if (m_active_exception.get()) {
215 LLDB_LOG(log, "masking active exception");
217 }
218
219 if (!terminate) {
220 // Indicate that we want to detach.
222
223 // Force a fresh break so that the detach can happen from the debugger
224 // thread.
225 if (!::DebugBreakProcess(
226 GetProcess().GetNativeProcess().GetSystemHandle())) {
227 error = Status(::GetLastError(), eErrorTypeWin32);
228 }
229 }
230
231 LLDB_LOG(log, "waiting for detach from process {0} to complete.", pid);
232
233 DWORD wait_result = WaitForSingleObject(m_debugging_ended_event, 5000);
234 if (wait_result != WAIT_OBJECT_0) {
235 error = Status(GetLastError(), eErrorTypeWin32);
236 LLDB_LOG(log, "error: WaitForSingleObject({0}, 5000) returned {1}",
237 m_debugging_ended_event, wait_result);
238 } else
239 LLDB_LOG(log, "detach from process {0} completed successfully.", pid);
240
241 if (!error.Success()) {
242 LLDB_LOG(log, "encountered an error while trying to stop process {0}. {1}",
243 pid, error);
244 }
245 return error;
246}
247
249 if (!m_active_exception.get())
250 return;
251
253 LLDB_LOG(log, "broadcasting for inferior process {0}.",
254 m_process.GetProcessId());
255
256 m_active_exception.reset();
257 m_exception_pred.SetValue(result, eBroadcastAlways);
258}
259
263 if (m_image_file) {
264 ::CloseHandle(m_image_file);
265 m_image_file = nullptr;
266 }
267}
268
271 DEBUG_EVENT dbe = {};
272 bool should_debug = true;
273 LLDB_LOG_VERBOSE(log, "Entering WaitForDebugEvent loop");
274 while (should_debug) {
275 LLDB_LOG_VERBOSE(log, "Calling WaitForDebugEvent");
276 BOOL wait_result = g_wait_for_debug_event(&dbe, INFINITE);
277 if (wait_result) {
278 DWORD continue_status = DBG_CONTINUE;
279 bool shutting_down = m_is_shutting_down;
280 switch (dbe.dwDebugEventCode) {
281 default:
282 llvm_unreachable("Unhandle debug event code!");
283 case EXCEPTION_DEBUG_EVENT: {
285 dbe.u.Exception, dbe.dwThreadId, shutting_down);
286
287 if (status == ExceptionResult::MaskException)
288 continue_status = DBG_CONTINUE;
289 else if (status == ExceptionResult::SendToApplication)
290 continue_status = DBG_EXCEPTION_NOT_HANDLED;
291
292 break;
293 }
294 case CREATE_THREAD_DEBUG_EVENT:
295 continue_status =
296 HandleCreateThreadEvent(dbe.u.CreateThread, dbe.dwThreadId);
297 break;
298 case CREATE_PROCESS_DEBUG_EVENT:
299 continue_status =
300 HandleCreateProcessEvent(dbe.u.CreateProcessInfo, dbe.dwThreadId);
301 break;
302 case EXIT_THREAD_DEBUG_EVENT:
303 continue_status =
304 HandleExitThreadEvent(dbe.u.ExitThread, dbe.dwThreadId);
305 break;
306 case EXIT_PROCESS_DEBUG_EVENT:
307 continue_status =
308 HandleExitProcessEvent(dbe.u.ExitProcess, dbe.dwThreadId);
309 should_debug = false;
310 break;
311 case LOAD_DLL_DEBUG_EVENT:
312 continue_status = HandleLoadDllEvent(dbe.u.LoadDll, dbe.dwThreadId);
313 break;
314 case UNLOAD_DLL_DEBUG_EVENT:
315 continue_status = HandleUnloadDllEvent(dbe.u.UnloadDll, dbe.dwThreadId);
316 break;
317 case OUTPUT_DEBUG_STRING_EVENT:
318 continue_status = HandleODSEvent(dbe.u.DebugString, dbe.dwThreadId);
319 break;
320 case RIP_EVENT:
321 continue_status = HandleRipEvent(dbe.u.RipInfo, dbe.dwThreadId);
322 if (dbe.u.RipInfo.dwType == SLE_ERROR)
323 should_debug = false;
324 break;
325 }
326
328 log, "calling ContinueDebugEvent({0}, {1}, {2}) on thread {3}.",
329 dbe.dwProcessId, dbe.dwThreadId, continue_status,
330 ::GetCurrentThreadId());
331
332 ::ContinueDebugEvent(dbe.dwProcessId, dbe.dwThreadId, continue_status);
333
334 // We have to DebugActiveProcessStop after ContinueDebugEvent, otherwise
335 // the target process will crash
336 if (shutting_down) {
337 // A breakpoint that occurs while `m_pid_to_detach` is non-zero is a
338 // magic exception that we use simply to wake up the DebuggerThread so
339 // that we can close out the debug loop.
340 if (m_pid_to_detach != 0 &&
341 (dbe.u.Exception.ExceptionRecord.ExceptionCode ==
342 EXCEPTION_BREAKPOINT ||
343 dbe.u.Exception.ExceptionRecord.ExceptionCode ==
345 LLDB_LOG(log,
346 "Breakpoint exception is cue to detach from process {0:x}",
347 m_pid_to_detach.load());
348
349 // detaching with leaving breakpoint exception event on the queue may
350 // cause target process to crash so process events as possible since
351 // target threads are running at this time, there is possibility to
352 // have some breakpoint exception between last WaitForDebugEvent and
353 // DebugActiveProcessStop but ignore for now.
354 while (g_wait_for_debug_event(&dbe, 0)) {
355 continue_status = DBG_CONTINUE;
356 if (dbe.dwDebugEventCode == EXCEPTION_DEBUG_EVENT &&
357 !(dbe.u.Exception.ExceptionRecord.ExceptionCode ==
358 EXCEPTION_BREAKPOINT ||
359 dbe.u.Exception.ExceptionRecord.ExceptionCode ==
361 dbe.u.Exception.ExceptionRecord.ExceptionCode ==
362 EXCEPTION_SINGLE_STEP))
363 continue_status = DBG_EXCEPTION_NOT_HANDLED;
364 ::ContinueDebugEvent(dbe.dwProcessId, dbe.dwThreadId,
365 continue_status);
366 }
367
368 ::DebugActiveProcessStop(m_pid_to_detach);
369 m_detached = true;
370 }
371 }
372
373 if (m_detached) {
374 should_debug = false;
375 }
376 } else {
377 LLDB_LOG(log, "returned FALSE from WaitForDebugEvent. Error = {0}",
378 ::GetLastError());
379
380 should_debug = false;
381 }
382 }
384
385 LLDB_LOG(log, "WaitForDebugEvent loop completed, exiting.");
386 ::SetEvent(m_debugging_ended_event);
387}
388
390DebuggerThread::HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info,
391 DWORD thread_id, bool shutting_down) {
393 if (shutting_down) {
394 bool is_breakpoint =
395 (info.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT ||
396 info.ExceptionRecord.ExceptionCode == STATUS_WX86_BREAKPOINT);
397
398 // Don't perform any blocking operations while we're shutting down. That
399 // will cause TerminateProcess -> WaitForSingleObject to time out.
400 // We should not send breakpoint exceptions to the application.
401 return is_breakpoint ? ExceptionResult::MaskException
403 }
404
405 bool first_chance = (info.dwFirstChance != 0);
406
407 m_active_exception.reset(
408 new ExceptionRecord(info.ExceptionRecord, thread_id));
409 LLDB_LOG(log, "encountered {0} chance exception {1:x} on thread {2:x}",
410 first_chance ? "first" : "second",
411 info.ExceptionRecord.ExceptionCode, thread_id);
412
413 ExceptionResult result =
414 m_debug_delegate->OnDebugException(first_chance, *m_active_exception);
415 m_exception_pred.SetValue(result, eBroadcastNever);
416
417 LLDB_LOG(log, "waiting for ExceptionPred != BreakInDebugger");
418 result = *m_exception_pred.WaitForValueNotEqualTo(
420
421 LLDB_LOG(log, "got ExceptionPred = {0}", (int)m_exception_pred.GetValue());
422 return result;
423}
424
425DWORD
426DebuggerThread::HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info,
427 DWORD thread_id) {
429 LLDB_LOG(log, "Thread {0} spawned in process {1}", thread_id,
430 m_process.GetProcessId());
431 HostThread thread(info.hThread);
432 thread.GetNativeThread().SetOwnsHandle(false);
433 m_debug_delegate->OnCreateThread(thread);
434 return DBG_CONTINUE;
435}
436
437DWORD
438DebuggerThread::HandleCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO &info,
439 DWORD thread_id) {
441 uint32_t process_id = ::GetProcessId(info.hProcess);
442
443 LLDB_LOG(log, "process {0} spawned", process_id);
444
445 std::string thread_name;
446 llvm::raw_string_ostream name_stream(thread_name);
447 name_stream << "lldb.plugin.process-windows.secondary[" << process_id << "]";
448 llvm::set_thread_name(thread_name);
449
450 // info.hProcess and info.hThread are closed automatically by Windows when
451 // EXIT_PROCESS_DEBUG_EVENT is received.
452 m_process = HostProcess(info.hProcess);
453 ((HostProcessWindows &)m_process.GetNativeProcess()).SetOwnsHandle(false);
454 m_main_thread = HostThread(info.hThread);
455 m_main_thread.GetNativeThread().SetOwnsHandle(false);
456 m_image_file = info.hFile;
457
458 lldb::addr_t load_addr = reinterpret_cast<lldb::addr_t>(info.lpBaseOfImage);
459 m_debug_delegate->OnDebuggerConnected(load_addr);
460
461 return DBG_CONTINUE;
462}
463
464DWORD
465DebuggerThread::HandleExitThreadEvent(const EXIT_THREAD_DEBUG_INFO &info,
466 DWORD thread_id) {
468 LLDB_LOG(log, "Thread {0} exited with code {1} in process {2}", thread_id,
469 info.dwExitCode, m_process.GetProcessId());
470 m_debug_delegate->OnExitThread(thread_id, info.dwExitCode);
471 return DBG_CONTINUE;
472}
473
474DWORD
475DebuggerThread::HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info,
476 DWORD thread_id) {
478 LLDB_LOG(log, "process {0} exited with code {1}", m_process.GetProcessId(),
479 info.dwExitCode);
480
481 m_debug_delegate->OnExitProcess(info.dwExitCode);
482
483 return DBG_CONTINUE;
484}
485
486static std::optional<std::string> GetFileNameFromHandleFallback(HANDLE hFile) {
487 // Check that file is not empty as we cannot map a file with zero length.
488 DWORD dwFileSizeHi = 0;
489 DWORD dwFileSizeLo = ::GetFileSize(hFile, &dwFileSizeHi);
490 if (dwFileSizeLo == 0 && dwFileSizeHi == 0)
491 return std::nullopt;
492
493 AutoHandle filemap(
494 ::CreateFileMappingW(hFile, nullptr, PAGE_READONLY, 0, 1, NULL), nullptr);
495 if (!filemap.IsValid())
496 return std::nullopt;
497
498 auto view_deleter = [](void *pMem) { ::UnmapViewOfFile(pMem); };
499 std::unique_ptr<void, decltype(view_deleter)> pMem(
500 ::MapViewOfFile(filemap.get(), FILE_MAP_READ, 0, 0, 1), view_deleter);
501 if (!pMem)
502 return std::nullopt;
503
504 std::array<wchar_t, MAX_PATH + 1> mapped_filename;
505 if (!::GetMappedFileNameW(::GetCurrentProcess(), pMem.get(),
506 mapped_filename.data(), mapped_filename.size()))
507 return std::nullopt;
508
509 // A series of null-terminated strings, plus an additional null character
510 std::array<wchar_t, 512> drive_strings;
511 drive_strings[0] = L'\0';
512 if (!::GetLogicalDriveStringsW(drive_strings.size(), drive_strings.data()))
513 return std::nullopt;
514
515 std::array<wchar_t, 3> drive = {L"_:"};
516 for (const wchar_t *it = drive_strings.data(); *it != L'\0';
517 it += wcslen(it) + 1) {
518 // Copy the drive letter to the template string
519 drive[0] = it[0];
520 std::array<wchar_t, MAX_PATH> device_name;
521 if (::QueryDosDeviceW(drive.data(), device_name.data(),
522 device_name.size())) {
523 size_t device_name_len = wcslen(device_name.data());
524 if (device_name_len < mapped_filename.size()) {
525 bool match = _wcsnicmp(mapped_filename.data(), device_name.data(),
526 device_name_len) == 0;
527 if (match && mapped_filename[device_name_len] == L'\\') {
528 // Replace device path with its drive letter
529 std::wstring rebuilt_path(drive.data());
530 rebuilt_path.append(&mapped_filename[device_name_len]);
531 std::string path_utf8;
532 llvm::convertWideToUTF8(rebuilt_path, path_utf8);
533 return path_utf8;
534 }
535 }
536 }
537 }
538 return std::nullopt;
539}
540
541DWORD
542DebuggerThread::HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info,
543 DWORD thread_id) {
545 if (info.hFile == nullptr) {
546 // Not sure what this is, so just ignore it.
547 LLDB_LOG(log, "Warning: Inferior {0} has a NULL file handle, returning...",
548 m_process.GetProcessId());
549 return DBG_CONTINUE;
550 }
551
552 auto on_load_dll = [&](llvm::StringRef path) {
553 FileSpec file_spec(path);
554 ModuleSpec module_spec(file_spec);
555 lldb::addr_t load_addr = reinterpret_cast<lldb::addr_t>(info.lpBaseOfDll);
556
557 LLDB_LOG(log, "Inferior {0} - DLL '{1}' loaded at address {2:x}...",
558 m_process.GetProcessId(), path, info.lpBaseOfDll);
559
560 m_debug_delegate->OnLoadDll(module_spec, load_addr);
561 };
562
563 std::vector<wchar_t> buffer(1);
564 DWORD required_size =
565 GetFinalPathNameByHandleW(info.hFile, &buffer[0], 0, VOLUME_NAME_DOS);
566 if (required_size > 0) {
567 buffer.resize(required_size + 1);
568 required_size = GetFinalPathNameByHandleW(info.hFile, &buffer[0],
569 required_size, VOLUME_NAME_DOS);
570 std::string path_str_utf8;
571 llvm::convertWideToUTF8(buffer.data(), path_str_utf8);
572 llvm::StringRef path_str = path_str_utf8;
573 const char *path = path_str.data();
574 if (path_str.starts_with("\\\\?\\"))
575 path += 4;
576
577 on_load_dll(path);
578 } else if (std::optional<std::string> path =
579 GetFileNameFromHandleFallback(info.hFile)) {
580 on_load_dll(*path);
581 } else {
582 LLDB_LOG(
583 log,
584 "Inferior {0} - Error {1} occurred calling GetFinalPathNameByHandle",
585 m_process.GetProcessId(), ::GetLastError());
586 }
587 // Windows does not automatically close info.hFile, so we need to do it.
588 ::CloseHandle(info.hFile);
589 return DBG_CONTINUE;
590}
591
592DWORD
593DebuggerThread::HandleUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO &info,
594 DWORD thread_id) {
596 LLDB_LOG(log, "process {0} unloading DLL at addr {1:x}.",
597 m_process.GetProcessId(), info.lpBaseOfDll);
598
599 m_debug_delegate->OnUnloadDll(
600 reinterpret_cast<lldb::addr_t>(info.lpBaseOfDll));
601 return DBG_CONTINUE;
602}
603
604DWORD
605DebuggerThread::HandleODSEvent(const OUTPUT_DEBUG_STRING_INFO &info,
606 DWORD thread_id) {
607 return DBG_CONTINUE;
608}
609
610DWORD
611DebuggerThread::HandleRipEvent(const RIP_INFO &info, DWORD thread_id) {
613 LLDB_LOG(log, "encountered error {0} (type={1}) in process {2} thread {3}",
614 info.dwError, info.dwType, m_process.GetProcessId(), thread_id);
615
616 Status error(info.dwError, eErrorTypeWin32);
617 m_debug_delegate->OnDebuggerError(error, info.dwType);
618
619 return DBG_CONTINUE;
620}
static llvm::raw_ostream & error(Stream &strm)
static WaitForDebugEventFn * g_wait_for_debug_event
static std::optional< std::string > GetFileNameFromHandleFallback(HANDLE hFile)
#define STATUS_WX86_BREAKPOINT
BOOL WINAPI WaitForDebugEventFn(LPDEBUG_EVENT, DWORD)
static WaitForDebugEventFn * GetWaitForDebugEventEx()
static void InitializeWaitForDebugEvent()
WaitForDebugEventEx is only available on Windows 10+.
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition Log.h:364
#define LLDB_LOG_ERROR(log, error,...)
Definition Log.h:394
#define LLDB_LOG_VERBOSE(log,...)
Definition Log.h:371
void * HANDLE
std::atomic< bool > m_is_shutting_down
std::atomic< DWORD > m_pid_to_detach
DWORD HandleExitThreadEvent(const EXIT_THREAD_DEBUG_INFO &info, DWORD thread_id)
DWORD HandleODSEvent(const OUTPUT_DEBUG_STRING_INFO &info, DWORD thread_id)
DWORD HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info, DWORD thread_id)
DWORD HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info, DWORD thread_id)
Status StopDebugging(bool terminate)
DWORD HandleRipEvent(const RIP_INFO &info, DWORD thread_id)
void ContinueAsyncException(ExceptionResult result)
HostProcess GetProcess() const
lldb::thread_result_t DebuggerThreadAttachRoutine(lldb::pid_t pid, const ProcessAttachInfo &launch_info)
DebuggerThread(DebugDelegateSP debug_delegate)
DWORD HandleCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO &info, DWORD thread_id)
ExceptionResult HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info, DWORD thread_id, bool shutting_down)
Status DebugAttach(lldb::pid_t pid, const ProcessAttachInfo &attach_info)
lldb::thread_result_t DebuggerThreadLaunchRoutine(const ProcessLaunchInfo &launch_info)
ExceptionRecordSP m_active_exception
Predicate< ExceptionResult > m_exception_pred
Status DebugLaunch(const ProcessLaunchInfo &launch_info)
DWORD HandleUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO &info, DWORD thread_id)
DWORD HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info, DWORD thread_id)
A file utility class.
Definition FileSpec.h:57
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition FileSpec.cpp:374
lldb::pid_t GetProcessId() const
FileSpec & GetExecutableFile()
Definition ProcessInfo.h:43
HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Status &error) override
An error handling class.
Definition Status.h:118
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
Definition Status.cpp:136
static llvm::Expected< HostThread > LaunchThread(llvm::StringRef name, std::function< lldb::thread_result_t()> thread_function, size_t min_stack_byte_size=0)
#define LLDB_INVALID_PROCESS
Definition lldb-types.h:68
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:327
@ eBroadcastNever
No broadcast will be sent when the value is modified.
Definition Predicate.h:28
@ eBroadcastAlways
Always send a broadcast when the value is modified.
Definition Predicate.h:29
std::shared_ptr< IDebugDelegate > DebugDelegateSP
Definition ForwardDecl.h:35
void * thread_result_t
Definition lldb-types.h:62
@ eErrorTypeWin32
Standard Win32 error codes.
uint64_t pid_t
Definition lldb-types.h:83
uint64_t addr_t
Definition lldb-types.h:80
uint64_t process_t
Definition lldb-types.h:57