DebuggerThread::~DebuggerThread() { ::CloseHandle(m_debugging_ended_event); }
Status DebuggerThread::DebugLaunch(const ProcessLaunchInfo &launch_info) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
LLDB_LOG(log, "launching '{0}'", launch_info.GetExecutableFile().GetPath());
Status result;
Status DebuggerThread::DebugAttach(lldb::pid_t pid,
const ProcessAttachInfo &attach_info) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
LLDB_LOG(log, "attaching to '{0}'", pid);
Status result;
// until after the thread routine has exited.
std::shared_ptr<DebuggerThread> this_ref(shared_from_this());
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
LLDB_LOG(log, "preparing to launch '{0}' on background thread.",
launch_info.GetExecutableFile().GetPath());
// until after the thread routine has exited.
std::shared_ptr<DebuggerThread> this_ref(shared_from_this());
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
LLDB_LOG(log, "preparing to attach to process '{0}' on background thread.",
pid);
lldb::pid_t pid = m_process.GetProcessId();
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
LLDB_LOG(log, "terminate = {0}, inferior={1}.", terminate, pid);
// Set m_is_shutting_down to true if it was false. Return if it was already
if (!m_active_exception.get())
return;
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS |
- WINDOWS_LOG_EXCEPTION);
+ Log *log = GetLog(WindowsLog::Process | WindowsLog::Exception);
LLDB_LOG(log, "broadcasting for inferior process {0}.",
m_process.GetProcessId());
}
void DebuggerThread::DebugLoop() {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT);
+ Log *log = GetLog(WindowsLog::Event);
DEBUG_EVENT dbe = {};
bool should_debug = true;
LLDB_LOGV(log, "Entering WaitForDebugEvent loop");
ExceptionResult
DebuggerThread::HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info,
DWORD thread_id) {
- Log *log =
- ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION);
+ Log *log = GetLog(WindowsLog::Event | WindowsLog::Exception);
if (m_is_shutting_down) {
// A breakpoint that occurs while `m_pid_to_detach` is non-zero is a magic
// exception that
DWORD
DebuggerThread::HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info,
DWORD thread_id) {
- Log *log =
- ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD);
+ Log *log = GetLog(WindowsLog::Event | WindowsLog::Thread);
LLDB_LOG(log, "Thread {0} spawned in process {1}", thread_id,
m_process.GetProcessId());
HostThread thread(info.hThread);
DWORD
DebuggerThread::HandleCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO &info,
DWORD thread_id) {
- Log *log =
- ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Event | WindowsLog::Process);
uint32_t process_id = ::GetProcessId(info.hProcess);
LLDB_LOG(log, "process {0} spawned", process_id);
DWORD
DebuggerThread::HandleExitThreadEvent(const EXIT_THREAD_DEBUG_INFO &info,
DWORD thread_id) {
- Log *log =
- ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD);
+ Log *log = GetLog(WindowsLog::Event | WindowsLog::Thread);
LLDB_LOG(log, "Thread {0} exited with code {1} in process {2}", thread_id,
info.dwExitCode, m_process.GetProcessId());
m_debug_delegate->OnExitThread(thread_id, info.dwExitCode);
DWORD
DebuggerThread::HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info,
DWORD thread_id) {
- Log *log =
- ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD);
+ Log *log = GetLog(WindowsLog::Event | WindowsLog::Thread);
LLDB_LOG(log, "process {0} exited with code {1}", m_process.GetProcessId(),
info.dwExitCode);
DWORD
DebuggerThread::HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info,
DWORD thread_id) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT);
+ Log *log = GetLog(WindowsLog::Event);
if (info.hFile == nullptr) {
// Not sure what this is, so just ignore it.
LLDB_LOG(log, "Warning: Inferior {0} has a NULL file handle, returning...",
DWORD
DebuggerThread::HandleUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO &info,
DWORD thread_id) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT);
+ Log *log = GetLog(WindowsLog::Event);
LLDB_LOG(log, "process {0} unloading DLL at addr {1:x}.",
m_process.GetProcessId(), info.lpBaseOfDll);
DWORD
DebuggerThread::HandleRipEvent(const RIP_INFO &info, DWORD thread_id) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT);
+ Log *log = GetLog(WindowsLog::Event);
LLDB_LOG(log, "encountered error {0} (type={1}) in process {2} thread {3}",
info.dwError, info.dwType, m_process.GetProcessId(), thread_id);
}
Status NativeProcessWindows::Resume(const ResumeActionList &resume_actions) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
Status error;
llvm::sys::ScopedLock lock(m_mutex);
Status NativeProcessWindows::Detach() {
Status error;
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
StateType state = GetState();
if (state != eStateExited && state != eStateDetached) {
error = DetachProcess();
}
void NativeProcessWindows::OnExitProcess(uint32_t exit_code) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
LLDB_LOG(log, "Process {0} exited with code {1}", GetID(), exit_code);
ProcessDebugger::OnExitProcess(exit_code);
}
void NativeProcessWindows::OnDebuggerConnected(lldb::addr_t image_base) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
LLDB_LOG(log, "Debugger connected to process {0}. Image base = {1:x}",
GetDebuggedProcessId(), image_base);
ExceptionResult
NativeProcessWindows::OnDebugException(bool first_chance,
const ExceptionRecord &record) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EXCEPTION);
+ Log *log = GetLog(WindowsLog::Exception);
llvm::sys::ScopedLock lock(m_mutex);
// Let the debugger establish the internal status.
GetWoW64ThreadContextHelper(lldb::thread_t thread_handle,
PWOW64_CONTEXT context_ptr,
const DWORD control_flag = kWoW64ContextFlags) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
Status error;
memset(context_ptr, 0, sizeof(::WOW64_CONTEXT));
context_ptr->ContextFlags = control_flag;
static Status SetWoW64ThreadContextHelper(lldb::thread_t thread_handle,
PWOW64_CONTEXT context_ptr) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
Status error;
if (!::Wow64SetThreadContext(thread_handle, context_ptr)) {
error.SetError(GetLastError(), eErrorTypeWin32);
static Status GetThreadContextHelper(lldb::thread_t thread_handle,
PCONTEXT context_ptr,
const DWORD control_flag) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
Status error;
memset(context_ptr, 0, sizeof(::CONTEXT));
static Status SetThreadContextHelper(lldb::thread_t thread_handle,
PCONTEXT context_ptr) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
Status error;
// It's assumed that the thread has stopped.
if (!::SetThreadContext(thread_handle, context_ptr)) {
static Status GetThreadContextHelper(lldb::thread_t thread_handle,
PCONTEXT context_ptr,
const DWORD control_flag) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
Status error;
memset(context_ptr, 0, sizeof(::CONTEXT));
static Status SetThreadContextHelper(lldb::thread_t thread_handle,
PCONTEXT context_ptr) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
Status error;
// It's assumed that the thread has stopped.
if (!::SetThreadContext(thread_handle, context_ptr)) {
static Status GetThreadContextHelper(lldb::thread_t thread_handle,
PCONTEXT context_ptr,
const DWORD control_flag) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
Status error;
memset(context_ptr, 0, sizeof(::CONTEXT));
static Status SetThreadContextHelper(lldb::thread_t thread_handle,
PCONTEXT context_ptr) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
Status error;
if (!::SetThreadContext(thread_handle, context_ptr)) {
static Status GetThreadContextHelper(lldb::thread_t thread_handle,
PCONTEXT context_ptr,
const DWORD control_flag) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
Status error;
memset(context_ptr, 0, sizeof(::CONTEXT));
static Status SetThreadContextHelper(lldb::thread_t thread_handle,
PCONTEXT context_ptr) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
Status error;
// It's assumed that the thread has stopped.
if (!::SetThreadContext(thread_handle, context_ptr)) {
}
Status ProcessDebugger::DetachProcess() {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
DebuggerThreadSP debugger_thread;
{
// Acquire the lock only long enough to get the DebuggerThread.
// thread has been kicked off. So there's no race conditions, and it
// shouldn't be necessary to acquire the mutex.
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
Status result;
FileSpec working_dir = launch_info.GetWorkingDirectory();
Status ProcessDebugger::AttachProcess(lldb::pid_t pid,
const ProcessAttachInfo &attach_info,
DebugDelegateSP delegate) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
m_session_data.reset(
new ProcessWindowsData(!attach_info.GetContinueOnceAttached()));
DebuggerThreadSP debugger(new DebuggerThread(delegate));
}
Status ProcessDebugger::DestroyProcess(const lldb::StateType state) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
DebuggerThreadSP debugger_thread;
{
// Acquire this lock inside an inner scope, only long enough to get the
}
Status ProcessDebugger::HaltProcess(bool &caused_stop) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
Status error;
llvm::sys::ScopedLock lock(m_mutex);
caused_stop = ::DebugBreakProcess(m_session_data->m_debugger->GetProcess()
size_t &bytes_read) {
Status error;
bytes_read = 0;
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY);
+ Log *log = GetLog(WindowsLog::Memory);
llvm::sys::ScopedLock lock(m_mutex);
if (!m_session_data) {
size_t size, size_t &bytes_written) {
Status error;
bytes_written = 0;
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY);
+ Log *log = GetLog(WindowsLog::Memory);
llvm::sys::ScopedLock lock(m_mutex);
LLDB_LOG(log, "attempting to write {0} bytes into address {1:x}", size,
vm_addr);
lldb::addr_t &addr) {
Status error;
addr = LLDB_INVALID_ADDRESS;
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY);
+ Log *log = GetLog(WindowsLog::Memory);
llvm::sys::ScopedLock lock(m_mutex);
LLDB_LOG(log, "attempting to allocate {0} bytes with permissions {1}", size,
permissions);
Status ProcessDebugger::DeallocateMemory(lldb::addr_t vm_addr) {
Status result;
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY);
+ Log *log = GetLog(WindowsLog::Memory);
llvm::sys::ScopedLock lock(m_mutex);
LLDB_LOG(log, "attempting to deallocate bytes at address {0}", vm_addr);
Status ProcessDebugger::GetMemoryRegionInfo(lldb::addr_t vm_addr,
MemoryRegionInfo &info) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY);
+ Log *log = GetLog(WindowsLog::Memory);
Status error;
llvm::sys::ScopedLock lock(m_mutex);
info.Clear();
ExceptionResult
ProcessDebugger::OnDebugException(bool first_chance,
const ExceptionRecord &record) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EXCEPTION);
+ Log *log = GetLog(WindowsLog::Exception);
llvm::sys::ScopedLock lock(m_mutex);
// FIXME: Without this check, occasionally when running the test suite
// there is an issue where m_session_data can be null. It's not clear how
void ProcessDebugger::OnDebuggerError(const Status &error, uint32_t type) {
llvm::sys::ScopedLock lock(m_mutex);
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
if (m_session_data->m_initial_stop_received) {
// This happened while debugging. Do we shutdown the debugging session,
Status ProcessDebugger::WaitForDebuggerConnection(DebuggerThreadSP debugger,
HostProcess &process) {
Status result;
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS |
- WINDOWS_LOG_BREAKPOINTS);
+ Log *log = GetLog(WindowsLog::Process | WindowsLog::Breakpoints);
LLDB_LOG(log, "Waiting for loader breakpoint.");
// Block this function until we receive the initial stop from the process.
if (bp_site->HardwareRequired())
return Status("Hardware breakpoints are not supported.");
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_BREAKPOINTS);
+ Log *log = GetLog(WindowsLog::Breakpoints);
LLDB_LOG(log, "bp_site = {0:x}, id={1}, addr={2:x}", bp_site,
bp_site->GetID(), bp_site->GetLoadAddress());
}
Status ProcessWindows::DisableBreakpointSite(BreakpointSite *bp_site) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_BREAKPOINTS);
+ Log *log = GetLog(WindowsLog::Breakpoints);
LLDB_LOG(log, "bp_site = {0:x}, id={1}, addr={2:x}", bp_site,
bp_site->GetID(), bp_site->GetLoadAddress());
Status ProcessWindows::DoDetach(bool keep_stopped) {
Status error;
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
StateType private_state = GetPrivateState();
if (private_state != eStateExited && private_state != eStateDetached) {
error = DetachProcess();
}
Status ProcessWindows::DoResume() {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
llvm::sys::ScopedLock lock(m_mutex);
Status error;
}
void ProcessWindows::RefreshStateAfterStop() {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EXCEPTION);
+ Log *log = GetLog(WindowsLog::Exception);
llvm::sys::ScopedLock lock(m_mutex);
if (!m_session_data) {
bool ProcessWindows::DoUpdateThreadList(ThreadList &old_thread_list,
ThreadList &new_thread_list) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_THREAD);
+ Log *log = GetLog(WindowsLog::Thread);
// Add all the threads that were previously running and for which we did not
// detect a thread exited event.
int new_size = 0;
void ProcessWindows::OnExitProcess(uint32_t exit_code) {
// No need to acquire the lock since m_session_data isn't accessed.
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
LLDB_LOG(log, "Process {0} exited with code {1}", GetID(), exit_code);
TargetSP target = CalculateTarget();
void ProcessWindows::OnDebuggerConnected(lldb::addr_t image_base) {
DebuggerThreadSP debugger = m_session_data->m_debugger;
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
LLDB_LOG(log, "Debugger connected to process {0}. Image base = {1:x}",
debugger->GetProcess().GetProcessId(), image_base);
ExceptionResult
ProcessWindows::OnDebugException(bool first_chance,
const ExceptionRecord &record) {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EXCEPTION);
+ Log *log = GetLog(WindowsLog::Exception);
llvm::sys::ScopedLock lock(m_mutex);
// FIXME: Without this check, occasionally when running the test suite there
void ProcessWindows::OnDebuggerError(const Status &error, uint32_t type) {
llvm::sys::ScopedLock lock(m_mutex);
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ Log *log = GetLog(WindowsLog::Process);
if (m_session_data->m_initial_stop_received) {
// This happened while debugging. Do we shutdown the debugging session,
LLVM_MARK_AS_BITMASK_ENUM(Thread)
};
-#define WINDOWS_LOG_PROCESS ::lldb_private::WindowsLog::Process
-#define WINDOWS_LOG_EXCEPTION ::lldb_private::WindowsLog::Exception
-#define WINDOWS_LOG_THREAD ::lldb_private::WindowsLog::Thread
-#define WINDOWS_LOG_MEMORY ::lldb_private::WindowsLog::Memory
-#define WINDOWS_LOG_BREAKPOINTS ::lldb_private::WindowsLog::Breakpoints
-#define WINDOWS_LOG_STEP ::lldb_private::WindowsLog::Step
-#define WINDOWS_LOG_REGISTERS ::lldb_private::WindowsLog::Registers
-#define WINDOWS_LOG_EVENT ::lldb_private::WindowsLog::Event
-
class ProcessWindowsLog {
public:
static void Initialize();
static void Terminate();
-
- static Log *GetLogIfAny(WindowsLog mask) { return GetLog(mask); }
};
template <> Log::Channel &LogChannelFor<WindowsLog>();
return ApplyAllRegisterValues();
#else
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
LLDB_LOG(log, "hardware breakpoints not currently supported on this arch");
return false;
#endif
}
bool RegisterContextWindows::CacheAllRegisterValues() {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
if (!m_context_stale)
return true;
return ReadRegisterHelper(CONTEXT_CONTROL, "EFLAGS", m_context.EFlags,
reg_value);
default:
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
LLDB_LOG(log, "Requested unknown register {0}", reg);
break;
}
if (!CacheAllRegisterValues())
return false;
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
switch (reg) {
case lldb_eax_i386:
bool RegisterContextWindows_x86::ReadRegisterHelper(
DWORD flags_required, const char *reg_name, DWORD value,
RegisterValue ®_value) const {
- Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ Log *log = GetLog(WindowsLog::Registers);
if ((m_context.ContextFlags & flags_required) != flags_required) {
LLDB_LOG(log, "Thread context doesn't have {0}", reg_name);
return false;