llvm-capstone/lldb/source/Core/DynamicLoader.cpp
Greg Clayton 93d3c8339c The DynamicLoader plug-in instance now lives up in lldb_private::Process where
it should live and the lldb_private::Process takes care of managing the 
auto pointer to the dynamic loader instance.

Also, now that the ArchSpec contains the target triple, we are able to 
correctly set the Target architecture in DidLaunch/DidAttach in the subclasses,
and then the lldb_private::Process will find the dynamic loader plug-in 
by letting the dynamic loader plug-ins inspect the arch/triple in the target.

So now the ProcessGDBRemote plug-in is another step closer to be purely 
process/platform agnostic.

I updated the ProcessMacOSX and the ProcessLinux plug-ins accordingly.

llvm-svn: 125650
2011-02-16 04:46:07 +00:00

76 lines
2.3 KiB
C++

//===-- DynamicLoader.cpp ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/lldb-private.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Core/PluginManager.h"
using namespace lldb;
using namespace lldb_private;
DynamicLoader*
DynamicLoader::FindPlugin (Process *process, const char *plugin_name)
{
DynamicLoaderCreateInstance create_callback = NULL;
if (plugin_name)
{
create_callback = PluginManager::GetDynamicLoaderCreateCallbackForPluginName (plugin_name);
if (create_callback)
{
std::auto_ptr<DynamicLoader> instance_ap(create_callback(process, true));
if (instance_ap.get())
return instance_ap.release();
}
}
else
{
for (uint32_t idx = 0; (create_callback = PluginManager::GetDynamicLoaderCreateCallbackAtIndex(idx)) != NULL; ++idx)
{
std::auto_ptr<DynamicLoader> instance_ap(create_callback(process, false));
if (instance_ap.get())
return instance_ap.release();
}
}
return NULL;
}
//----------------------------------------------------------------------
// DynamicLoader constructor
//----------------------------------------------------------------------
DynamicLoader::DynamicLoader(Process *process) :
m_process (process),
m_stop_when_images_change(false) // Stop the process by default when a process' images change
{
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
DynamicLoader::~DynamicLoader()
{
}
//----------------------------------------------------------------------
// Accessosors to the global setting as to whether to stop at image
// (shared library) loading/unloading.
//----------------------------------------------------------------------
bool
DynamicLoader::GetStopWhenImagesChange () const
{
return m_stop_when_images_change;
}
void
DynamicLoader::SetStopWhenImagesChange (bool stop)
{
m_stop_when_images_change = stop;
}