Index: include/lldb/API/SBTarget.h =================================================================== --- include/lldb/API/SBTarget.h +++ include/lldb/API/SBTarget.h @@ -888,7 +888,10 @@ lldb::addr_t GetStackRedZoneSize(); - + + void + AddImageSearchPath (const char* path, const char* replacement); + protected: friend class SBAddress; friend class SBBlock; Index: scripts/Python/interface/SBTarget.i =================================================================== --- scripts/Python/interface/SBTarget.i +++ scripts/Python/interface/SBTarget.i @@ -810,6 +810,9 @@ lldb::addr_t GetStackRedZoneSize(); + void + AddImageSearchPath (const char* path, const char* replacement); + bool operator == (const lldb::SBTarget &rhs) const; Index: source/API/SBTarget.cpp =================================================================== --- source/API/SBTarget.cpp +++ source/API/SBTarget.cpp @@ -2568,3 +2568,15 @@ } return 0; } + +void +SBTarget::AddImageSearchPath (const char* path, const char* replacement) +{ + TargetSP target_sp(GetSP()); + if (target_sp) + { + target_sp->GetImageSearchPathList().Append(ConstString(path), + ConstString(replacement), + true); + } +} Index: test/lldbtest.py =================================================================== --- test/lldbtest.py +++ test/lldbtest.py @@ -1418,6 +1418,31 @@ stdflag = "-std=c++11" return stdflag + def addImageSearchPaths(self, target): + """Adds image search paths to the target.""" + img_search_path = os.environ.get('LLDB_IMAGE_SEARCH_PATH', None) + if img_search_path: + self.addImageSearchPathsInternal(target, img_search_path, '') + + def addImageSearchPathsInternal(self, target, base_dir, rel_dir): + files_found = False + full_dir_path = os.path.join(base_dir, rel_dir) + for p in os.listdir(full_dir_path): + full_path = os.path.join(full_dir_path, p) + if os.path.isfile(full_path): + files_found = True + else: + self.addImageSearchPathsInternal(target, base_dir, os.path.join(rel_dir, p)) + + # Add image search path only a directory that contains files. + if files_found: + from_path = '/' + rel_dir + replacement_path = full_dir_path + + if self.TraceOn(): + print "Add image search path (%s, %s)" % (from_path, replacement_path) + target.AddImageSearchPath(from_path, replacement_path) + def buildDriver(self, sources, exe_name): """ Platform-specific way to build a program that links with LLDB (via the liblldb.so or LLDB.framework). Index: test/python_api/hello_world/TestHelloWorld.py =================================================================== --- test/python_api/hello_world/TestHelloWorld.py +++ test/python_api/hello_world/TestHelloWorld.py @@ -46,7 +46,6 @@ self.setTearDownCleanup(dictionary=self.d) self.hello_world_attach_with_id_api() - @not_remote_testsuite_ready @python_api_test @dwarf_test @expectedFailurei386 # llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly @@ -72,7 +71,6 @@ self.setTearDownCleanup(dictionary=self.d) self.hello_world_attach_with_name_api() - @not_remote_testsuite_ready @python_api_test @dwarf_test @expectedFailurei386 # llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly @@ -140,6 +138,7 @@ """Create target, spawn a process, and attach to it by id.""" target = self.dbg.CreateTarget(self.exe) + self.addImageSearchPaths(target) # Spawn a new process popen = self.spawnSubprocess(self.exe, ["abc", "xyz"]) @@ -165,6 +164,7 @@ """Create target, spawn a process, and attach to it by name.""" target = self.dbg.CreateTarget(self.exe) + self.addImageSearchPaths(target) # Spawn a new process popen = self.spawnSubprocess(self.exe, ["abc", "xyz"])