blob: 3bb00726f11bb426f9e95b67c63df61508da2d72 [file] [log] [blame]
Adrian McCarthy18a9135d2015-10-28 18:21:45 +00001//===-- LocalDebugDelegate.cpp ----------------------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Adrian McCarthy18a9135d2015-10-28 18:21:45 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "LocalDebugDelegate.h"
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000010#include "ProcessWindows.h"
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000011
12using namespace lldb;
13using namespace lldb_private;
14
15LocalDebugDelegate::LocalDebugDelegate(ProcessWP process)
Kate Stoneb9c1b512016-09-06 20:57:50 +000016 : m_process(process) {}
17
18void LocalDebugDelegate::OnExitProcess(uint32_t exit_code) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000019 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000020 process->OnExitProcess(exit_code);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000021}
22
Kate Stoneb9c1b512016-09-06 20:57:50 +000023void LocalDebugDelegate::OnDebuggerConnected(lldb::addr_t image_base) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000024 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000025 process->OnDebuggerConnected(image_base);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000026}
27
28ExceptionResult
Kate Stoneb9c1b512016-09-06 20:57:50 +000029LocalDebugDelegate::OnDebugException(bool first_chance,
30 const ExceptionRecord &record) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000031 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000032 return process->OnDebugException(first_chance, record);
33 else
34 return ExceptionResult::MaskException;
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000035}
36
Kate Stoneb9c1b512016-09-06 20:57:50 +000037void LocalDebugDelegate::OnCreateThread(const HostThread &thread) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000038 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000039 process->OnCreateThread(thread);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000040}
41
Kate Stoneb9c1b512016-09-06 20:57:50 +000042void LocalDebugDelegate::OnExitThread(lldb::tid_t thread_id,
43 uint32_t exit_code) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000044 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000045 process->OnExitThread(thread_id, exit_code);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000046}
47
Kate Stoneb9c1b512016-09-06 20:57:50 +000048void LocalDebugDelegate::OnLoadDll(const lldb_private::ModuleSpec &module_spec,
49 lldb::addr_t module_addr) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000050 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000051 process->OnLoadDll(module_spec, module_addr);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000052}
53
Kate Stoneb9c1b512016-09-06 20:57:50 +000054void LocalDebugDelegate::OnUnloadDll(lldb::addr_t module_addr) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000055 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000056 process->OnUnloadDll(module_addr);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000057}
58
Kate Stoneb9c1b512016-09-06 20:57:50 +000059void LocalDebugDelegate::OnDebugString(const std::string &string) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000060 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000061 process->OnDebugString(string);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000062}
63
Zachary Turner97206d52017-05-12 04:51:55 +000064void LocalDebugDelegate::OnDebuggerError(const Status &error, uint32_t type) {
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000065 if (ProcessWindowsSP process = GetProcessPointer())
Kate Stoneb9c1b512016-09-06 20:57:50 +000066 process->OnDebuggerError(error, type);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000067}
68
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000069ProcessWindowsSP LocalDebugDelegate::GetProcessPointer() {
Kate Stoneb9c1b512016-09-06 20:57:50 +000070 ProcessSP process = m_process.lock();
Adrian McCarthy4ad5def2016-11-23 16:26:37 +000071 return std::static_pointer_cast<ProcessWindows>(process);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000072}