blob: e47b26e58f8c7134d8fa037bc9b72d7291102604 [file] [log] [blame]
Adrian McCarthy27785dd2015-08-24 16:00:51 +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"
11#include "ProcessWindows.h"
12
13using namespace lldb;
14using namespace lldb_private;
15
Zachary Turner1d397bf2015-09-01 20:02:44 +000016LocalDebugDelegate::LocalDebugDelegate(ProcessWP process)
Adrian McCarthy27785dd2015-08-24 16:00:51 +000017 : m_process(process)
18{
19}
20
21void
22LocalDebugDelegate::OnExitProcess(uint32_t exit_code)
23{
Zachary Turner1d397bf2015-09-01 20:02:44 +000024 if (ProcessWindowsSP process = GetProcessPointer())
25 process->OnExitProcess(exit_code);
Adrian McCarthy27785dd2015-08-24 16:00:51 +000026}
27
28void
29LocalDebugDelegate::OnDebuggerConnected(lldb::addr_t image_base)
30{
Zachary Turner1d397bf2015-09-01 20:02:44 +000031 if (ProcessWindowsSP process = GetProcessPointer())
32 process->OnDebuggerConnected(image_base);
Adrian McCarthy27785dd2015-08-24 16:00:51 +000033}
34
35ExceptionResult
36LocalDebugDelegate::OnDebugException(bool first_chance, const ExceptionRecord &record)
37{
Zachary Turner1d397bf2015-09-01 20:02:44 +000038 if (ProcessWindowsSP process = GetProcessPointer())
39 return process->OnDebugException(first_chance, record);
40 else
41 return ExceptionResult::MaskException;
Adrian McCarthy27785dd2015-08-24 16:00:51 +000042}
43
44void
45LocalDebugDelegate::OnCreateThread(const HostThread &thread)
46{
Zachary Turner1d397bf2015-09-01 20:02:44 +000047 if (ProcessWindowsSP process = GetProcessPointer())
48 process->OnCreateThread(thread);
Adrian McCarthy27785dd2015-08-24 16:00:51 +000049}
50
51void
52LocalDebugDelegate::OnExitThread(lldb::tid_t thread_id, uint32_t exit_code)
53{
Zachary Turner1d397bf2015-09-01 20:02:44 +000054 if (ProcessWindowsSP process = GetProcessPointer())
55 process->OnExitThread(thread_id, exit_code);
Adrian McCarthy27785dd2015-08-24 16:00:51 +000056}
57
58void
59LocalDebugDelegate::OnLoadDll(const lldb_private::ModuleSpec &module_spec, lldb::addr_t module_addr)
60{
Zachary Turner1d397bf2015-09-01 20:02:44 +000061 if (ProcessWindowsSP process = GetProcessPointer())
62 process->OnLoadDll(module_spec, module_addr);
Adrian McCarthy27785dd2015-08-24 16:00:51 +000063}
64
65void
66LocalDebugDelegate::OnUnloadDll(lldb::addr_t module_addr)
67{
Zachary Turner1d397bf2015-09-01 20:02:44 +000068 if (ProcessWindowsSP process = GetProcessPointer())
69 process->OnUnloadDll(module_addr);
Adrian McCarthy27785dd2015-08-24 16:00:51 +000070}
71
72void
73LocalDebugDelegate::OnDebugString(const std::string &string)
74{
Zachary Turner1d397bf2015-09-01 20:02:44 +000075 if (ProcessWindowsSP process = GetProcessPointer())
76 process->OnDebugString(string);
Adrian McCarthy27785dd2015-08-24 16:00:51 +000077}
78
79void
80LocalDebugDelegate::OnDebuggerError(const Error &error, uint32_t type)
81{
Zachary Turner1d397bf2015-09-01 20:02:44 +000082 if (ProcessWindowsSP process = GetProcessPointer())
83 process->OnDebuggerError(error, type);
84}
85
86ProcessWindowsSP
87LocalDebugDelegate::GetProcessPointer()
88{
89 ProcessSP process = m_process.lock();
90 return std::static_pointer_cast<ProcessWindows>(process);
Adrian McCarthy27785dd2015-08-24 16:00:51 +000091}