1061da546Spatrickimport inspect 2061da546Spatrickimport os 3061da546Spatrickimport sys 4061da546Spatrick 5061da546Spatrick 6061da546Spatrickdef find_lldb_root(): 7061da546Spatrick lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe())) 8061da546Spatrick while True: 9061da546Spatrick parent = os.path.dirname(lldb_root) 10061da546Spatrick if parent == lldb_root: # dirname('/') == '/' 11*be691f3bSpatrick raise Exception("use_lldb_suite_root.py not found") 12061da546Spatrick lldb_root = parent 13061da546Spatrick 14061da546Spatrick test_path = os.path.join(lldb_root, "use_lldb_suite_root.py") 15061da546Spatrick if os.path.isfile(test_path): 16061da546Spatrick return lldb_root 17061da546Spatrick 18061da546Spatricklldb_root = find_lldb_root() 19061da546Spatrickimport imp 20061da546Spatrickfp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root]) 21061da546Spatricktry: 22061da546Spatrick imp.load_module("use_lldb_suite_root", fp, pathname, desc) 23061da546Spatrickfinally: 24061da546Spatrick if fp: 25061da546Spatrick fp.close() 26