Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are 
prepared for plug-ins. Plug-ins will attempt to be loaded from the 
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins" 
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:

extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);

If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:

    bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
    bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);

This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.

To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:

    static void *
    Host::DynamicLibraryOpen (const FileSpec &file_spec, 
                              Error &error);

    static Error
    Host::DynamicLibraryClose (void *dynamic_library_handle);

    static void *
    Host::DynamicLibraryGetSymbol (void *dynamic_library_handle, 
                                  const char *symbol_name, 
                                  Error &error);

lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:


    typedef enum EnumerateDirectoryResult
    {
        eEnumerateDirectoryResultNext,  // Enumerate next entry in the current directory
        eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
        eEnumerateDirectoryResultExit,  // Exit from the current directory at the current level.
        eEnumerateDirectoryResultQuit   // Stop directory enumerations at any level
    };

    typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
                                                                                  FileSpec::FileType file_type,
                                                                                  const FileSpec &spec);

    static FileSpec::EnumerateDirectoryResult
    FileSpec::EnumerateDirectory (const char *dir_path,
                                  bool find_directories,
                                  bool find_files,
                                  bool find_other,
                                  EnumerateDirectoryCallbackType callback,
                                  void *callback_baton);

This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to 
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at 
all levels.

Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based 
declaration information. Columns support can be re-enabled with the
additions of a #define.

Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.

Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.





git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@124716 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/lldb.cpp b/source/lldb.cpp
index ac281a2..83acbd0 100644
--- a/source/lldb.cpp
+++ b/source/lldb.cpp
@@ -11,6 +11,7 @@
 #include "lldb/lldb-private-log.h"
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/Log.h"
+#include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Timer.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/Mutex.h"
@@ -97,6 +98,8 @@
         ProcessLinux::Initialize();
         DynamicLoaderLinuxDYLD::Initialize();
 #endif
+        // Scan for any system or user LLDB plug-ins
+        PluginManager::Initialize();
     }
 }
 
@@ -110,6 +113,10 @@
 lldb_private::Terminate ()
 {
     Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
+    
+    // Terminate and unload and loaded system or user LLDB plug-ins
+    PluginManager::Terminate();
+
     DisassemblerLLVM::Terminate();
     ObjectContainerBSDArchive::Terminate();
     ObjectFileELF::Terminate();