diff options
author | Zachary Turner <zturner@google.com> | 2015-09-01 20:02:44 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2015-09-01 20:02:44 +0000 |
commit | 1d397bfe40295cdb9c124f942a11d5d7926c5db7 (patch) | |
tree | fe661cdf0e2502b444b594cbf78b169ffe458f42 | |
parent | 7529df9abd3a4d98b9c145aae7a0d5e1cc594378 (diff) | |
download | bcm5719-llvm-1d397bfe40295cdb9c124f942a11d5d7926c5db7.tar.gz bcm5719-llvm-1d397bfe40295cdb9c124f942a11d5d7926c5db7.zip |
Make ProcessWindows not create a strong reference to itself.
llvm-svn: 246579
4 files changed, 55 insertions, 12 deletions
diff --git a/lldb/source/Plugins/Process/Windows/Live/LocalDebugDelegate.cpp b/lldb/source/Plugins/Process/Windows/Live/LocalDebugDelegate.cpp index 07f2969d5a9..e47b26e58f8 100644 --- a/lldb/source/Plugins/Process/Windows/Live/LocalDebugDelegate.cpp +++ b/lldb/source/Plugins/Process/Windows/Live/LocalDebugDelegate.cpp @@ -13,7 +13,7 @@ using namespace lldb;
using namespace lldb_private;
-LocalDebugDelegate::LocalDebugDelegate(ProcessSP process)
+LocalDebugDelegate::LocalDebugDelegate(ProcessWP process)
: m_process(process)
{
}
@@ -21,53 +21,71 @@ LocalDebugDelegate::LocalDebugDelegate(ProcessSP process) void
LocalDebugDelegate::OnExitProcess(uint32_t exit_code)
{
- ((ProcessWindows &)*m_process).OnExitProcess(exit_code);
+ if (ProcessWindowsSP process = GetProcessPointer())
+ process->OnExitProcess(exit_code);
}
void
LocalDebugDelegate::OnDebuggerConnected(lldb::addr_t image_base)
{
- ((ProcessWindows &)*m_process).OnDebuggerConnected(image_base);
+ if (ProcessWindowsSP process = GetProcessPointer())
+ process->OnDebuggerConnected(image_base);
}
ExceptionResult
LocalDebugDelegate::OnDebugException(bool first_chance, const ExceptionRecord &record)
{
- return ((ProcessWindows &)*m_process).OnDebugException(first_chance, record);
+ if (ProcessWindowsSP process = GetProcessPointer())
+ return process->OnDebugException(first_chance, record);
+ else
+ return ExceptionResult::MaskException;
}
void
LocalDebugDelegate::OnCreateThread(const HostThread &thread)
{
- ((ProcessWindows &)*m_process).OnCreateThread(thread);
+ if (ProcessWindowsSP process = GetProcessPointer())
+ process->OnCreateThread(thread);
}
void
LocalDebugDelegate::OnExitThread(lldb::tid_t thread_id, uint32_t exit_code)
{
- ((ProcessWindows &)*m_process).OnExitThread(thread_id, exit_code);
+ if (ProcessWindowsSP process = GetProcessPointer())
+ process->OnExitThread(thread_id, exit_code);
}
void
LocalDebugDelegate::OnLoadDll(const lldb_private::ModuleSpec &module_spec, lldb::addr_t module_addr)
{
- ((ProcessWindows &)*m_process).OnLoadDll(module_spec, module_addr);
+ if (ProcessWindowsSP process = GetProcessPointer())
+ process->OnLoadDll(module_spec, module_addr);
}
void
LocalDebugDelegate::OnUnloadDll(lldb::addr_t module_addr)
{
- ((ProcessWindows &)*m_process).OnUnloadDll(module_addr);
+ if (ProcessWindowsSP process = GetProcessPointer())
+ process->OnUnloadDll(module_addr);
}
void
LocalDebugDelegate::OnDebugString(const std::string &string)
{
- ((ProcessWindows &)*m_process).OnDebugString(string);
+ if (ProcessWindowsSP process = GetProcessPointer())
+ process->OnDebugString(string);
}
void
LocalDebugDelegate::OnDebuggerError(const Error &error, uint32_t type)
{
- ((ProcessWindows &)*m_process).OnDebuggerError(error, type);
+ if (ProcessWindowsSP process = GetProcessPointer())
+ process->OnDebuggerError(error, type);
+}
+
+ProcessWindowsSP
+LocalDebugDelegate::GetProcessPointer()
+{
+ ProcessSP process = m_process.lock();
+ return std::static_pointer_cast<ProcessWindows>(process);
}
diff --git a/lldb/source/Plugins/Process/Windows/Live/LocalDebugDelegate.h b/lldb/source/Plugins/Process/Windows/Live/LocalDebugDelegate.h index 5a1c29eaead..2ce4e47f998 100644 --- a/lldb/source/Plugins/Process/Windows/Live/LocalDebugDelegate.h +++ b/lldb/source/Plugins/Process/Windows/Live/LocalDebugDelegate.h @@ -11,6 +11,8 @@ #define liblldb_Plugins_Process_Windows_LocalDebugDelegate_H_
#include "IDebugDelegate.h"
+#include "ProcessWindowsForward.h"
+
#include "lldb/lldb-forward.h"
class ProcessWindows;
@@ -40,7 +42,7 @@ namespace lldb_private class LocalDebugDelegate : public IDebugDelegate
{
public:
- explicit LocalDebugDelegate(lldb::ProcessSP process);
+ explicit LocalDebugDelegate(lldb::ProcessWP process);
void OnExitProcess(uint32_t exit_code) override;
void OnDebuggerConnected(lldb::addr_t image_base) override;
@@ -53,7 +55,10 @@ class LocalDebugDelegate : public IDebugDelegate void OnDebuggerError(const Error &error, uint32_t type) override;
private:
- lldb::ProcessSP m_process;
+ ProcessWindowsSP
+ GetProcessPointer();
+
+ lldb::ProcessWP m_process;
};
}
diff --git a/lldb/source/Plugins/Process/Windows/Live/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Live/ProcessWindows.cpp index 8e8ab6d3b12..b173645056d 100644 --- a/lldb/source/Plugins/Process/Windows/Live/ProcessWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/Live/ProcessWindows.cpp @@ -39,6 +39,7 @@ #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" +#include "Plugins/Process/Windows/Live/ProcessWindowsForward.h" #include "Plugins/Process/Windows/live/ProcessWindowsLog.h" #include "DebuggerThread.h" diff --git a/lldb/source/Plugins/Process/Windows/Live/ProcessWindowsForward.h b/lldb/source/Plugins/Process/Windows/Live/ProcessWindowsForward.h new file mode 100644 index 00000000000..666012a7a5a --- /dev/null +++ b/lldb/source/Plugins/Process/Windows/Live/ProcessWindowsForward.h @@ -0,0 +1,19 @@ +//===-- ProcessWindows.h ----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_Plugins_Process_Windows_ProcessWindowsForward_H_ +#define liblldb_Plugins_Process_Windows_ProcessWindowsForward_H_ + +#include <memory> + +class ProcessWindows; + +typedef std::shared_ptr<ProcessWindows> ProcessWindowsSP; + +#endif
\ No newline at end of file |