blob: 600aef372505ff37057b2ce498d624f4988cd21a [file] [log] [blame]
Adrian McCarthy18a9135d2015-10-28 18:21:45 +00001//===-- LocalDebugDelegate.cpp ----------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "LocalDebugDelegate.h"
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000011#include "ProcessWindows.h"
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000012
13using namespace lldb;
14using namespace lldb_private;
15
16LocalDebugDelegate::LocalDebugDelegate(ProcessWP process)
Kate Stoneb9c1b512016-09-06 20:57:50 +000017 : m_process(process) {}
18
19void LocalDebugDelegate::OnExitProcess(uint32_t exit_code) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000020 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000021 process->OnExitProcess(exit_code);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000022}
23
Kate Stoneb9c1b512016-09-06 20:57:50 +000024void LocalDebugDelegate::OnDebuggerConnected(lldb::addr_t image_base) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000025 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000026 process->OnDebuggerConnected(image_base);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000027}
28
29ExceptionResult
Kate Stoneb9c1b512016-09-06 20:57:50 +000030LocalDebugDelegate::OnDebugException(bool first_chance,
31 const ExceptionRecord &record) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000032 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000033 return process->OnDebugException(first_chance, record);
34 else
35 return ExceptionResult::MaskException;
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000036}
37
Kate Stoneb9c1b512016-09-06 20:57:50 +000038void LocalDebugDelegate::OnCreateThread(const HostThread &thread) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000039 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000040 process->OnCreateThread(thread);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000041}
42
Kate Stoneb9c1b512016-09-06 20:57:50 +000043void LocalDebugDelegate::OnExitThread(lldb::tid_t thread_id,
44 uint32_t exit_code) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000045 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000046 process->OnExitThread(thread_id, exit_code);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000047}
48
Kate Stoneb9c1b512016-09-06 20:57:50 +000049void LocalDebugDelegate::OnLoadDll(const lldb_private::ModuleSpec &module_spec,
50 lldb::addr_t module_addr) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000051 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000052 process->OnLoadDll(module_spec, module_addr);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000053}
54
Kate Stoneb9c1b512016-09-06 20:57:50 +000055void LocalDebugDelegate::OnUnloadDll(lldb::addr_t module_addr) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000056 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000057 process->OnUnloadDll(module_addr);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000058}
59
Kate Stoneb9c1b512016-09-06 20:57:50 +000060void LocalDebugDelegate::OnDebugString(const std::string &string) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000061 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000062 process->OnDebugString(string);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000063}
64
Kate Stoneb9c1b512016-09-06 20:57:50 +000065void LocalDebugDelegate::OnDebuggerError(const Error &error, uint32_t type) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000066 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000067 process->OnDebuggerError(error, type);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000068}
69
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000070ProcessWindowsSP LocalDebugDelegate::GetProcessPointer() {
Kate Stoneb9c1b512016-09-06 20:57:50 +000071 ProcessSP process = m_process.lock();
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000072 return std::static_pointer_cast<ProcessWindows>(process);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000073}