1 //===-- DynamicLoader.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 "lldb/lldb-private.h"
11 #include "lldb/Target/DynamicLoader.h"
12 #include "lldb/Core/PluginManager.h"
13 
14 using namespace lldb;
15 using namespace lldb_private;
16 
17 DynamicLoader*
18 DynamicLoader::FindPlugin (Process *process, const char *plugin_name)
19 {
20     DynamicLoaderCreateInstance create_callback = NULL;
21     if (plugin_name)
22     {
23         create_callback  = PluginManager::GetDynamicLoaderCreateCallbackForPluginName (plugin_name);
24         if (create_callback)
25         {
26             std::auto_ptr<DynamicLoader> instance_ap(create_callback(process, true));
27             if (instance_ap.get())
28                 return instance_ap.release();
29         }
30     }
31     else
32     {
33         for (uint32_t idx = 0; (create_callback = PluginManager::GetDynamicLoaderCreateCallbackAtIndex(idx)) != NULL; ++idx)
34         {
35             std::auto_ptr<DynamicLoader> instance_ap(create_callback(process, false));
36             if (instance_ap.get())
37                 return instance_ap.release();
38         }
39     }
40     return NULL;
41 }
42 
43 
44 //----------------------------------------------------------------------
45 // DynamicLoader constructor
46 //----------------------------------------------------------------------
47 DynamicLoader::DynamicLoader(Process *process) :
48     m_process (process),
49     m_stop_when_images_change(false)    // Stop the process by default when a process' images change
50 {
51 }
52 
53 //----------------------------------------------------------------------
54 // Destructor
55 //----------------------------------------------------------------------
56 DynamicLoader::~DynamicLoader()
57 {
58 }
59 
60 //----------------------------------------------------------------------
61 // Accessosors to the global setting as to whether to stop at image
62 // (shared library) loading/unloading.
63 //----------------------------------------------------------------------
64 bool
65 DynamicLoader::GetStopWhenImagesChange () const
66 {
67     return m_stop_when_images_change;
68 }
69 
70 void
71 DynamicLoader::SetStopWhenImagesChange (bool stop)
72 {
73     m_stop_when_images_change = stop;
74 }
75 
76