Author: zturner Date: Tue Sep 1 15:02:44 2015 New Revision: 246579 URL: http://llvm.org/viewvc/llvm-project?rev=246579&view=rev Log: Make ProcessWindows not create a strong reference to itself.
Added: lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsForward.h Modified: lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.cpp lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.h lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.cpp Modified: lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.cpp?rev=246579&r1=246578&r2=246579&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.cpp (original) +++ lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.cpp Tue Sep 1 15:02:44 2015 @@ -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(P 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); } Modified: lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.h?rev=246579&r1=246578&r2=246579&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.h (original) +++ lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.h Tue Sep 1 15:02:44 2015 @@ -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 IDebug void OnDebuggerError(const Error &error, uint32_t type) override; private: - lldb::ProcessSP m_process; + ProcessWindowsSP + GetProcessPointer(); + + lldb::ProcessWP m_process; }; } Modified: lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.cpp?rev=246579&r1=246578&r2=246579&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.cpp (original) +++ lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindows.cpp Tue Sep 1 15:02:44 2015 @@ -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" Added: lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsForward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsForward.h?rev=246579&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsForward.h (added) +++ lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsForward.h Tue Sep 1 15:02:44 2015 @@ -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 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits