]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/llvm/tools/lldb/source/Core/DynamicLoader.cpp
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / contrib / llvm / tools / lldb / source / Core / DynamicLoader.cpp
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/Target/Process.h"
13 #include "lldb/Core/PluginManager.h"
14
15 using namespace lldb;
16 using namespace lldb_private;
17
18 DynamicLoader*
19 DynamicLoader::FindPlugin (Process *process, const char *plugin_name)
20 {
21     DynamicLoaderCreateInstance create_callback = NULL;
22     if (plugin_name)
23     {
24         ConstString const_plugin_name(plugin_name);
25         create_callback  = PluginManager::GetDynamicLoaderCreateCallbackForPluginName (const_plugin_name);
26         if (create_callback)
27         {
28             std::unique_ptr<DynamicLoader> instance_ap(create_callback(process, true));
29             if (instance_ap.get())
30                 return instance_ap.release();
31         }
32     }
33     else
34     {
35         for (uint32_t idx = 0; (create_callback = PluginManager::GetDynamicLoaderCreateCallbackAtIndex(idx)) != NULL; ++idx)
36         {
37             std::unique_ptr<DynamicLoader> instance_ap(create_callback(process, false));
38             if (instance_ap.get())
39                 return instance_ap.release();
40         }
41     }
42     return NULL;
43 }
44
45
46 //----------------------------------------------------------------------
47 // DynamicLoader constructor
48 //----------------------------------------------------------------------
49 DynamicLoader::DynamicLoader(Process *process) :
50     m_process (process)
51 {
52 }
53
54 //----------------------------------------------------------------------
55 // Destructor
56 //----------------------------------------------------------------------
57 DynamicLoader::~DynamicLoader()
58 {
59 }
60
61 //----------------------------------------------------------------------
62 // Accessosors to the global setting as to whether to stop at image
63 // (shared library) loading/unloading.
64 //----------------------------------------------------------------------
65 bool
66 DynamicLoader::GetStopWhenImagesChange () const
67 {
68     return m_process->GetStopOnSharedLibraryEvents();
69 }
70
71 void
72 DynamicLoader::SetStopWhenImagesChange (bool stop)
73 {
74     m_process->SetStopOnSharedLibraryEvents (stop);
75 }
76