[Lldb-commits] [lldb] r124762 - in /lldb/trunk: source/Commands/CommandObjectTarget.cpp test/load_unload/TestLoadUnload.py
Johnny Chen
johnny.chen at apple.com
Wed Feb 2 16:30:19 PST 2011
Author: johnny
Date: Wed Feb 2 18:30:19 2011
New Revision: 124762
URL: http://llvm.org/viewvc/llvm-project?rev=124762&view=rev
Log:
Add a test case test_image_search_paths() to test lldb's ability to do image search paths
substitutions in order to achieve file mappings.
Modify CommandObjectTarget.cpp to properly set the status of the return object to make
scripting like this:
self.runCmd("target image-search-paths add %s %s" % (os.getcwd(), new_dir))
works.
Modified:
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/test/load_unload/TestLoadUnload.py
Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=124762&r1=124761&r2=124762&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Wed Feb 2 18:30:19 2011
@@ -92,6 +92,7 @@
target->GetImageSearchPathList().Append (ConstString(from),
ConstString(to),
last_pair); // Notify if this is the last pair
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
else
{
@@ -138,6 +139,7 @@
{
bool notify = true;
target->GetImageSearchPathList().Clear(notify);
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
else
{
@@ -233,6 +235,7 @@
ConstString(to),
insert_idx,
last_pair);
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
else
{
@@ -293,6 +296,7 @@
}
target->GetImageSearchPathList().Dump(&result.GetOutputStream());
+ result.SetStatus (eReturnStatusSuccessFinishResult);
}
else
{
@@ -351,6 +355,8 @@
result.GetOutputStream().Printf("%s\n", transformed.GetCString());
else
result.GetOutputStream().Printf("%s\n", orig.GetCString());
+
+ result.SetStatus (eReturnStatusSuccessFinishResult);
}
else
{
Modified: lldb/trunk/test/load_unload/TestLoadUnload.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/load_unload/TestLoadUnload.py?rev=124762&r1=124761&r2=124762&view=diff
==============================================================================
--- lldb/trunk/test/load_unload/TestLoadUnload.py (original)
+++ lldb/trunk/test/load_unload/TestLoadUnload.py Wed Feb 2 18:30:19 2011
@@ -21,6 +21,41 @@
self.line_d_function = line_number('d.c',
'// Find this line number within d_dunction().')
+ def test_image_search_paths(self):
+ """Test image list after moving libd.dylib, and verifies that it works with 'target image-search-paths add'."""
+
+ # Invoke the default build rule.
+ self.buildDefault()
+
+ if sys.platform.startswith("darwin"):
+ dylibName = 'libd.dylib'
+
+ # Now let's move the dynamic library to a different directory than $CWD.
+
+ # The directory to relocate the dynamic library to.
+ new_dir = os.path.join(os.getcwd(), "dyld_path")
+
+ # This is the function to remove the dyld_path directory after the test.
+ def remove_dyld_dir():
+ import shutil
+ shutil.rmtree(new_dir)
+
+ old_dylib = os.path.join(os.getcwd(), dylibName)
+ new_dylib = os.path.join(new_dir, dylibName)
+
+ os.mkdir(new_dir)
+ os.rename(old_dylib, new_dylib)
+ self.addTearDownHook(remove_dyld_dir)
+
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+ self.expect("image list",
+ substrs = [old_dylib])
+ self.runCmd("target image-search-paths add %s %s" % (os.getcwd(), new_dir))
+ self.expect("image list", "LLDB successfully locates the relocated dynamic library",
+ substrs = [new_dylib])
+
+
def test_dyld_library_path(self):
"""Test DYLD_LIBRARY_PATH after moving libd.dylib, which defines d_function, somewhere else."""
More information about the lldb-commits
mailing list