Introduce a mechanism for reusing Python modules out of tree.

Right now our Python code does not all share a common root.  Tests and
scripts both contain python code that cannot take advantage of reusability
since they are unrelated siblings of each other.

In particular, this presents a problem for wanting to use third party
packages from both sides, since it does not make sense to copy the module
into both places.

This patch solves this by introducing a script lldb_shared.py which is a
very lightweight script that just searches up the tree until it finds a
root, and then imports a module from there.  That module knows how to
find all of the shared code that LLDB uses, and adjusts sys.path
accordingly to make them all visible.

llvm-svn: 250858
diff --git a/lldb/test/lldb_shared.py b/lldb/test/lldb_shared.py
new file mode 100644
index 0000000..4d7a92d
--- /dev/null
+++ b/lldb/test/lldb_shared.py
@@ -0,0 +1,22 @@
+import inspect
+import os
+import sys
+
+def find_lldb_root():
+    lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
+    while True:
+        lldb_root = os.path.dirname(lldb_root)
+        if lldb_root is None:
+            return None
+
+        test_path = os.path.join(lldb_root, "lldb.root")
+        if os.path.isfile(test_path):
+            return lldb_root
+    return None
+
+lldb_root = find_lldb_root()
+if lldb_root is not None:
+    import imp
+    module = imp.find_module("lldb_shared_base", [lldb_root])
+    if module is not None:
+        imp.load_module("lldb_shared_base", *module)
\ No newline at end of file