LLDB mainline
NativeProcessWindows.cpp
Go to the documentation of this file.
1//===-- NativeProcessWindows.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
10#include <psapi.h>
11
13#include "NativeThreadWindows.h"
23#include "lldb/Target/Process.h"
24#include "lldb/Utility/State.h"
25#include "llvm/Support/ConvertUTF.h"
26#include "llvm/Support/Errc.h"
27#include "llvm/Support/Error.h"
28#include "llvm/Support/Format.h"
29#include "llvm/Support/Threading.h"
30#include "llvm/Support/raw_ostream.h"
31
32#include "DebuggerThread.h"
33#include "ExceptionRecord.h"
34#include "ProcessWindowsLog.h"
35
36#include <tlhelp32.h>
37
38#pragma warning(disable : 4005)
39#include "winternl.h"
40#include <ntstatus.h>
41
42using namespace lldb;
43using namespace lldb_private;
44using namespace llvm;
45
46namespace lldb_private {
47
49 NativeDelegate &delegate,
50 llvm::Error &E)
53 PseudoTerminal::invalid_fd, // TODO: Implement on Windows
54 delegate),
55 ProcessDebugger(), m_arch(launch_info.GetArchitecture()) {
56 ErrorAsOutParameter EOut(&E);
57 DebugDelegateSP delegate_sp(new NativeDebugDelegate(*this));
58 E = LaunchProcess(launch_info, delegate_sp).ToError();
59 if (E)
60 return;
61
63}
64
66 NativeDelegate &delegate,
67 llvm::Error &E)
68 : NativeProcessProtocol(pid, terminal_fd, delegate), ProcessDebugger() {
69 ErrorAsOutParameter EOut(&E);
70 DebugDelegateSP delegate_sp(new NativeDebugDelegate(*this));
71 ProcessAttachInfo attach_info;
72 attach_info.SetProcessID(pid);
73 E = AttachProcess(pid, attach_info, delegate_sp).ToError();
74 if (E)
75 return;
76
78
80 if (!Host::GetProcessInfo(pid, info)) {
81 E = createStringError(inconvertibleErrorCode(),
82 "Cannot get process information");
83 return;
84 }
85 m_arch = info.GetArchitecture();
86}
87
91 llvm::sys::ScopedLock lock(m_mutex);
92
93 StateType state = GetState();
94 if (state == eStateStopped || state == eStateCrashed) {
95 LLDB_LOG(log, "process {0} is in state {1}. Resuming...",
96 GetDebuggedProcessId(), state);
97 LLDB_LOG(log, "resuming {0} threads.", m_threads.size());
98
99 bool failed = false;
100 for (uint32_t i = 0; i < m_threads.size(); ++i) {
101 auto thread = static_cast<NativeThreadWindows *>(m_threads[i].get());
102 const ResumeAction *const action =
103 resume_actions.GetActionForThread(thread->GetID(), true);
104 if (action == nullptr)
105 continue;
106
107 switch (action->state) {
108 case eStateRunning:
109 case eStateStepping: {
110 Status result = thread->DoResume(action->state);
111 if (result.Fail()) {
112 failed = true;
113 LLDB_LOG(log,
114 "Trying to resume thread at index {0}, but failed with "
115 "error {1}.",
116 i, result);
117 }
118 break;
119 }
120 case eStateSuspended:
121 case eStateStopped:
122 break;
123
124 default:
126 "NativeProcessWindows::%s (): unexpected state %s specified "
127 "for pid %" PRIu64 ", tid %" PRIu64,
128 __FUNCTION__, StateAsCString(action->state), GetID(),
129 thread->GetID());
130 }
131 }
132
133 if (failed) {
134 error = Status::FromErrorString("NativeProcessWindows::DoResume failed");
135 } else {
137 }
138
139 // Resume the debug loop.
140 ExceptionRecordSP active_exception =
141 m_session_data->m_debugger->GetActiveException().lock();
142 if (active_exception) {
143 // Resume the process and continue processing debug events. Mask the
144 // exception so that from the process's view, there is no indication that
145 // anything happened.
146 m_session_data->m_debugger->ContinueAsyncException(
148 }
149 } else {
150 LLDB_LOG(log, "error: process {0} is in state {1}. Returning...",
152 }
153
154 return error;
155}
156
162
164 bool caused_stop = false;
165 StateType state = GetState();
166 if (state != eStateStopped)
167 return HaltProcess(caused_stop);
168 return Status();
169}
170
174 StateType state = GetState();
175 if (state != eStateExited && state != eStateDetached) {
177 if (error.Success())
179 else
180 LLDB_LOG(log, "Detaching process error: {0}", error);
181 } else {
183 "error: process {0} in state = {1}, but "
184 "cannot detach it in this state.",
185 GetID(), state);
186 LLDB_LOG(log, "error: {0}", error);
187 }
188 return error;
189}
190
194 "Windows does not support sending signals to processes");
195 return error;
196}
197
199
201 StateType state = GetState();
202 return DestroyProcess(state);
203}
204
205Status NativeProcessWindows::IgnoreSignals(llvm::ArrayRef<int> signals) {
206 return Status();
207}
208
213
215 size_t size, size_t &bytes_read) {
216 return ProcessDebugger::ReadMemory(addr, buf, size, bytes_read);
217}
218
220 size_t size, size_t &bytes_written) {
221 return ProcessDebugger::WriteMemory(addr, buf, size, bytes_written);
222}
223
224llvm::Expected<lldb::addr_t>
225NativeProcessWindows::AllocateMemory(size_t size, uint32_t permissions) {
226 lldb::addr_t addr;
227 Status ST = ProcessDebugger::AllocateMemory(size, permissions, addr);
228 if (ST.Success())
229 return addr;
230 return ST.ToError();
231}
232
236
238
240 StateType state = GetState();
241 switch (state) {
242 case eStateCrashed:
243 case eStateDetached:
244 case eStateExited:
245 case eStateInvalid:
246 case eStateUnloaded:
247 return false;
248 default:
249 return true;
250 }
251}
252
254 lldb::StopReason reason,
255 std::string description) {
256 SetCurrentThreadID(thread.GetID());
257
258 ThreadStopInfo stop_info;
259 stop_info.reason = reason;
260 // No signal support on Windows but required to provide a 'valid' signum.
261 stop_info.signo = SIGTRAP;
262
263 if (reason == StopReason::eStopReasonException) {
264 stop_info.details.exception.type = 0;
265 stop_info.details.exception.data_count = 0;
266 }
267
268 thread.SetStopReason(stop_info, description);
269}
270
272 lldb::StopReason reason,
273 std::string description) {
274 NativeThreadWindows *thread = GetThreadByID(thread_id);
275 if (!thread)
276 return;
277
278 for (uint32_t i = 0; i < m_threads.size(); ++i) {
279 auto t = static_cast<NativeThreadWindows *>(m_threads[i].get());
280 Status error = t->DoStop();
281 if (error.Fail())
282 exit(1);
283 }
284 SetStopReasonForThread(*thread, reason, description);
285}
286
288
289llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
291 // Not available on this target.
292 return llvm::errc::not_supported;
293}
294
295llvm::Expected<llvm::ArrayRef<uint8_t>>
297 static const uint8_t g_aarch64_opcode[] = {0x00, 0x00, 0x3e,
298 0xd4}; // brk #0xf000
299 static const uint8_t g_thumb_opcode[] = {0xfe, 0xde}; // udf #0xfe
300
301 switch (GetArchitecture().GetMachine()) {
302 case llvm::Triple::aarch64:
303 return llvm::ArrayRef(g_aarch64_opcode);
304
305 case llvm::Triple::arm:
306 case llvm::Triple::thumb:
307 return llvm::ArrayRef(g_thumb_opcode);
308
309 default:
311 }
312}
313
315 // Windows always reports an incremented PC after a breakpoint is hit,
316 // even on ARM.
317 return cantFail(GetSoftwareBreakpointTrapOpcode(0)).size();
318}
319
321 auto it = m_software_breakpoints.find(addr);
322 if (it == m_software_breakpoints.end())
323 return false;
324 return true;
325}
326
328 bool hardware) {
329 if (hardware)
330 return SetHardwareBreakpoint(addr, size);
331 return SetSoftwareBreakpoint(addr, size);
332}
333
335 bool hardware) {
336 if (hardware)
337 return RemoveHardwareBreakpoint(addr);
338 return RemoveSoftwareBreakpoint(addr);
339}
340
343 if (!m_loaded_modules.empty())
344 return Status();
345
346 // Retrieve loaded modules by a Target/Module free implemenation.
347 AutoHandle snapshot(CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetID()));
348 if (snapshot.IsValid()) {
349 MODULEENTRY32W me;
350 me.dwSize = sizeof(MODULEENTRY32W);
351 if (Module32FirstW(snapshot.get(), &me)) {
352 do {
353 std::string path;
354 if (!llvm::convertWideToUTF8(me.szExePath, path))
355 continue;
356
357 FileSpec file_spec(path);
358 FileSystem::Instance().Resolve(file_spec);
359 m_loaded_modules[file_spec] = (addr_t)me.modBaseAddr;
360 } while (Module32Next(snapshot.get(), &me));
361 }
362
363 if (!m_loaded_modules.empty())
364 return Status();
365 }
366
367 error = Status(::GetLastError(), lldb::ErrorType::eErrorTypeWin32);
368 return error;
369}
370
372 FileSpec &file_spec) {
374 if (error.Fail())
375 return error;
376
377 FileSpec module_file_spec(module_path);
378 FileSystem::Instance().Resolve(module_file_spec);
379 for (auto &it : m_loaded_modules) {
380 if (it.first == module_file_spec) {
381 file_spec = it.first;
382 return Status();
383 }
384 }
386 "Module (%s) not found in process %" PRIu64 "!",
387 module_file_spec.GetPath().c_str(), GetID());
388}
389
390Status
391NativeProcessWindows::GetFileLoadAddress(const llvm::StringRef &file_name,
392 lldb::addr_t &load_addr) {
394 if (error.Fail())
395 return error;
396
397 load_addr = LLDB_INVALID_ADDRESS;
398 FileSpec file_spec(file_name);
399 FileSystem::Instance().Resolve(file_spec);
400 for (auto &it : m_loaded_modules) {
401 if (it.first == file_spec) {
402 load_addr = it.second;
403 return Status();
404 }
405 }
407 "Can't get loaded address of file (%s) in process %" PRIu64 "!",
408 file_spec.GetPath().c_str(), GetID());
409}
410
411void NativeProcessWindows::OnExitProcess(uint32_t exit_code) {
413 LLDB_LOG(log, "Process {0} exited with code {1}", GetID(), exit_code);
414
416
417 // No signal involved. It is just an exit event.
418 WaitStatus wait_status(WaitStatus::Exit, exit_code);
419 SetExitStatus(wait_status, true);
420
421 // Notify the native delegate.
422 SetState(eStateExited, true);
423}
424
427 LLDB_LOG(log, "Debugger connected to process {0}. Image base = {1:x}",
428 GetDebuggedProcessId(), image_base);
429
430 // This is the earliest chance we can resolve the process ID and
431 // architecture if we don't know them yet.
434
435 if (GetArchitecture().GetMachine() == llvm::Triple::UnknownArch) {
436 ProcessInstanceInfo process_info;
437 if (!Host::GetProcessInfo(GetDebuggedProcessId(), process_info)) {
438 LLDB_LOG(log, "Cannot get process information during debugger connecting "
439 "to process");
440 return;
441 }
442 SetArchitecture(process_info.GetArchitecture());
443 }
444
445 // The very first one shall always be the main thread.
446 assert(m_threads.empty());
447 m_threads.push_back(std::make_unique<NativeThreadWindows>(
448 *this, m_session_data->m_debugger->GetMainThread()));
449}
450
453 const ExceptionRecord &record) {
455 llvm::sys::ScopedLock lock(m_mutex);
456
457 // Let the debugger establish the internal status.
458 ProcessDebugger::OnDebugException(first_chance, record);
459
460 static bool initial_stop = false;
461 if (!first_chance) {
462 SetState(eStateStopped, false);
463 }
464
466 switch (record.GetExceptionCode()) {
467 case DWORD(STATUS_SINGLE_STEP):
468 case STATUS_WX86_SINGLE_STEP: {
469#ifndef __aarch64__
470 uint32_t wp_id = LLDB_INVALID_INDEX32;
471 if (NativeThreadWindows *thread = GetThreadByID(record.GetThreadID())) {
472 NativeRegisterContextWindows &reg_ctx = thread->GetRegisterContext();
473 Status error =
474 reg_ctx.GetWatchpointHitIndex(wp_id, record.GetExceptionAddress());
475 if (error.Fail())
476 LLDB_LOG(log,
477 "received error while checking for watchpoint hits, pid = "
478 "{0}, error = {1}",
479 thread->GetID(), error);
480 if (wp_id != LLDB_INVALID_INDEX32) {
481 addr_t wp_addr = reg_ctx.GetWatchpointAddress(wp_id);
482 addr_t wp_hit_addr = reg_ctx.GetWatchpointHitAddress(wp_id);
483 std::string desc =
484 formatv("{0} {1} {2}", wp_addr, wp_id, wp_hit_addr).str();
486 desc);
487 }
488 }
489 if (wp_id == LLDB_INVALID_INDEX32)
490#endif
492
493 SetState(eStateStopped, true);
494
495 // Continue the debugger.
497 }
498 case DWORD(STATUS_BREAKPOINT):
500
501 if (NativeThreadWindows *stop_thread =
502 GetThreadByID(record.GetThreadID())) {
503 auto &reg_ctx = stop_thread->GetRegisterContext();
504 const auto exception_addr = record.GetExceptionAddress();
505 const auto thread_id = record.GetThreadID();
506
507 if (FindSoftwareBreakpoint(exception_addr)) {
508 LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
509 exception_addr);
510 // The current PC is AFTER the BP opcode, on all architectures.
511 reg_ctx.SetPC(reg_ctx.GetPC() - GetSoftwareBreakpointPCOffset());
513 SetState(eStateStopped, true);
515 } else {
516 // This block of code will only be entered in case of a hardware
517 // watchpoint or breakpoint hit on AArch64. However, we only handle
518 // hardware watchpoints below as breakpoints are not yet supported.
519 const std::vector<ULONG_PTR> &args = record.GetExceptionArguments();
520 // Check that the ExceptionInformation array of EXCEPTION_RECORD
521 // contains at least two elements: the first is a read-write flag
522 // indicating the type of data access operation (read or write) while
523 // the second contains the virtual address of the accessed data.
524 if (args.size() >= 2) {
525 uint32_t hw_id = LLDB_INVALID_INDEX32;
526 Status error = reg_ctx.GetWatchpointHitIndex(hw_id, args[1]);
527 if (error.Fail())
528 LLDB_LOG(log,
529 "received error while checking for watchpoint hits, pid = "
530 "{0}, error = {1}",
531 thread_id, error);
532
533 if (hw_id != LLDB_INVALID_INDEX32) {
534 std::string desc =
535 formatv("{0} {1} {2}", reg_ctx.GetWatchpointAddress(hw_id),
536 hw_id, exception_addr)
537 .str();
539 SetState(eStateStopped, true);
541 }
542 }
543 }
544 }
545
546 if (!initial_stop) {
547 initial_stop = true;
548 LLDB_LOG(log,
549 "Hit loader breakpoint at address {0:x}, setting initial stop "
550 "event.",
551 record.GetExceptionAddress());
552
553 // We are required to report the reason for the first stop after
554 // launching or being attached.
555 if (NativeThreadWindows *thread = GetThreadByID(record.GetThreadID()))
557
558 // Do not notify the native delegate (e.g. llgs) since at this moment
559 // the program hasn't returned from Manager::Launch() and the delegate
560 // might not have an valid native process to operate on.
561 SetState(eStateStopped, false);
562
563 // Hit the initial stop. Continue the application.
565 }
566
567 [[fallthrough]];
568 default:
569 LLDB_LOG(log,
570 "Debugger thread reported exception {0:x} at address {1:x} "
571 "(first_chance={2})",
572 record.GetExceptionCode(), record.GetExceptionAddress(),
573 first_chance);
574
575 {
576 std::string desc;
577 llvm::raw_string_ostream desc_stream(desc);
578 desc_stream << "Exception "
579 << llvm::format_hex(record.GetExceptionCode(), 8)
580 << " encountered at address "
581 << llvm::format_hex(record.GetExceptionAddress(), 8);
583 desc.c_str());
584
585 SetState(eStateStopped, true);
586 }
587
588 // For non-breakpoints, give the application a chance to handle the
589 // exception first.
590 if (first_chance)
592 else
594 }
595
596 return result;
597}
598
600 llvm::sys::ScopedLock lock(m_mutex);
601
602 auto thread = std::make_unique<NativeThreadWindows>(*this, new_thread);
603 thread->GetRegisterContext().ClearAllHardwareWatchpoints();
604 for (const auto &pair : GetWatchpointMap()) {
605 const NativeWatchpoint &wp = pair.second;
606 thread->SetWatchpoint(wp.m_addr, wp.m_size, wp.m_watch_flags,
607 wp.m_hardware);
608 }
609
610 m_threads.push_back(std::move(thread));
611}
612
614 uint32_t exit_code) {
615 llvm::sys::ScopedLock lock(m_mutex);
616 NativeThreadWindows *thread = GetThreadByID(thread_id);
617 if (!thread)
618 return;
619
620 for (auto t = m_threads.begin(); t != m_threads.end();) {
621 if ((*t)->GetID() == thread_id) {
622 t = m_threads.erase(t);
623 } else {
624 ++t;
625 }
626 }
627}
628
630 lldb::addr_t module_addr) {
631 // Simply invalidate the cached loaded modules.
632 if (!m_loaded_modules.empty())
633 m_loaded_modules.clear();
634}
635
637 if (!m_loaded_modules.empty())
638 m_loaded_modules.clear();
639}
640
641llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
643 ProcessLaunchInfo &launch_info,
644 NativeProcessProtocol::NativeDelegate &native_delegate) {
645 Error E = Error::success();
646 auto process_up = std::unique_ptr<NativeProcessWindows>(
647 new NativeProcessWindows(launch_info, native_delegate, E));
648 if (E)
649 return std::move(E);
650 return std::move(process_up);
651}
652
653llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
656 Error E = Error::success();
657 // Set pty primary fd invalid since it is not available.
658 auto process_up = std::unique_ptr<NativeProcessWindows>(
659 new NativeProcessWindows(pid, -1, native_delegate, E));
660 if (E)
661 return std::move(E);
662 return std::move(process_up);
663}
664} // namespace lldb_private
static llvm::raw_ostream & error(Stream &strm)
#define STATUS_WX86_BREAKPOINT
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition Log.h:369
static llvm::Error createStringError(const char *format, Args &&...args)
Definition Resource.cpp:59
lldb::tid_t GetThreadID() const
const std::vector< ULONG_PTR > & GetExceptionArguments() const
lldb::addr_t GetExceptionAddress() const
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
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
static FileSystem & Instance()
static bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info)
Definition aix/Host.cpp:177
NativeProcessProtocol(lldb::pid_t pid, int terminal_fd, NativeDelegate &delegate)
Status SetSoftwareBreakpoint(lldb::addr_t addr, uint32_t size_hint)
virtual const NativeWatchpointList::WatchpointMap & GetWatchpointMap() const
void SetState(lldb::StateType state, bool notify_delegates=true)
NativeThreadProtocol * GetThreadByID(lldb::tid_t tid)
std::vector< std::unique_ptr< NativeThreadProtocol > > m_threads
virtual bool SetExitStatus(WaitStatus status, bool bNotifyStateChange)
Status RemoveSoftwareBreakpoint(lldb::addr_t addr)
virtual Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size)
virtual llvm::Expected< llvm::ArrayRef< uint8_t > > GetSoftwareBreakpointTrapOpcode(size_t size_hint)
virtual Status RemoveHardwareBreakpoint(lldb::addr_t addr)
std::unordered_map< lldb::addr_t, SoftwareBreakpoint > m_software_breakpoints
llvm::Expected< std::unique_ptr< NativeProcessProtocol > > Launch(ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate) override
Launch a process for debugging.
llvm::Expected< std::unique_ptr< NativeProcessProtocol > > Attach(lldb::pid_t pid, NativeDelegate &native_delegate) override
Attach to an existing process.
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) override
llvm::Error DeallocateMemory(lldb::addr_t addr) override
Status Resume(const ResumeActionList &resume_actions) override
void OnCreateThread(const HostThread &thread) override
void OnExitProcess(uint32_t exit_code) override
Status GetLoadedModuleFileSpec(const char *module_path, FileSpec &file_spec) override
llvm::Expected< llvm::ArrayRef< uint8_t > > GetSoftwareBreakpointTrapOpcode(size_t size_hint) override
void OnDebuggerConnected(lldb::addr_t image_base) override
Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override
NativeProcessWindows(ProcessLaunchInfo &launch_info, NativeDelegate &delegate, llvm::Error &E)
Status SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware) override
void SetArchitecture(const ArchSpec &arch_spec)
ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record) override
size_t GetSoftwareBreakpointPCOffset() override
Return the offset of the PC relative to the software breakpoint that was hit.
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > GetAuxvData() const override
void OnUnloadDll(lldb::addr_t module_addr) override
Status GetFileLoadAddress(const llvm::StringRef &file_name, lldb::addr_t &load_addr) override
NativeThreadWindows * GetThreadByID(lldb::tid_t thread_id)
Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) override
void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override
llvm::Expected< lldb::addr_t > AllocateMemory(size_t size, uint32_t permissions) override
Status Signal(int signo) override
Sends a process a UNIX signal signal.
Status RemoveBreakpoint(lldb::addr_t addr, bool hardware=false) override
const ArchSpec & GetArchitecture() const override
void SetStopReasonForThread(NativeThreadWindows &thread, lldb::StopReason reason, std::string description="")
Status Interrupt() override
Tells a process to interrupt all operations as if by a Ctrl-C.
void OnLoadDll(const ModuleSpec &module_spec, lldb::addr_t module_addr) override
void StopThread(lldb::tid_t thread_id, lldb::StopReason reason, std::string description="")
lldb::addr_t GetSharedLibraryInfoAddress() override
Status IgnoreSignals(llvm::ArrayRef< int > signals) override
std::map< lldb_private::FileSpec, lldb::addr_t > m_loaded_modules
virtual Status GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr)
virtual lldb::addr_t GetWatchpointAddress(uint32_t wp_index)
virtual lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index)
Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written)
Status DestroyProcess(lldb::StateType process_state)
Status LaunchProcess(ProcessLaunchInfo &launch_info, DebugDelegateSP delegate)
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info)
std::unique_ptr< ProcessWindowsData > m_session_data
Status AllocateMemory(size_t size, uint32_t permissions, lldb::addr_t &addr)
virtual ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record)
Status AttachProcess(lldb::pid_t pid, const ProcessAttachInfo &attach_info, DebugDelegateSP delegate)
lldb::pid_t GetDebuggedProcessId() const
Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read)
virtual void OnExitProcess(uint32_t exit_code)
Status HaltProcess(bool &caused_stop)
Status DeallocateMemory(lldb::addr_t addr)
void SetProcessID(lldb::pid_t pid)
Definition ProcessInfo.h:70
ArchSpec & GetArchitecture()
Definition ProcessInfo.h:62
A pseudo terminal helper class.
const ResumeAction * GetActionForThread(lldb::tid_t tid, bool default_ok) const
Definition Debug.h:74
An error handling class.
Definition Status.h:118
llvm::Error ToError() const
FIXME: Replace all uses with takeError() instead.
Definition Status.cpp:139
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition Status.cpp:106
static Status FromErrorString(const char *str)
Definition Status.h:141
bool Fail() const
Test for error condition.
Definition Status.cpp:294
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
Definition Status.h:151
bool Success() const
Test for success condition.
Definition Status.cpp:304
#define LLDB_INVALID_INDEX32
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_PROCESS_ID
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:332
std::shared_ptr< ExceptionRecord > ExceptionRecordSP
Definition ForwardDecl.h:37
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
Definition State.cpp:14
std::shared_ptr< IDebugDelegate > DebugDelegateSP
Definition ForwardDecl.h:35
StateType
Process and Thread States.
@ eStateUnloaded
Process is object is valid, but not currently loaded.
@ eStateDetached
Process has been detached and can't be examined.
@ eStateStopped
Process or thread is stopped and can be examined.
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
@ eStateRunning
Process or thread is running and can't be examined.
@ eStateExited
Process has exited and can't be examined.
@ eStateStepping
Process or thread is in the process of stepping and can not be examined.
@ eStateCrashed
Process or thread has crashed and can be examined.
@ eErrorTypeWin32
Standard Win32 error codes.
uint64_t pid_t
Definition lldb-types.h:83
uint64_t addr_t
Definition lldb-types.h:80
StopReason
Thread stop reasons.
@ eStopReasonBreakpoint
@ eStopReasonException
@ eStopReasonWatchpoint
uint64_t tid_t
Definition lldb-types.h:84
lldb::StateType state
Definition Debug.h:23
struct lldb_private::ThreadStopInfo::@116236113001137253323017204263037302160273237376::@034237007264067231263360140073224264215170222231 exception
lldb::StopReason reason
Definition Debug.h:132
union lldb_private::ThreadStopInfo::@116236113001137253323017204263037302160273237376 details
#define SIGTRAP