Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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 | { |
Greg Clayton | 75c703d | 2011-02-16 04:46:07 +0000 | [diff] [blame] | 26 | std::auto_ptr<DynamicLoader> instance_ap(create_callback(process, true)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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 | { |
Greg Clayton | 75c703d | 2011-02-16 04:46:07 +0000 | [diff] [blame] | 35 | std::auto_ptr<DynamicLoader> instance_ap(create_callback(process, false)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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 | //---------------------------------------------------------------------- |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 61 | // Accessosors to the global setting as to whether to stop at image |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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 | |