[Lldb-commits] [lldb] r121036 - /lldb/trunk/test/load_unload/TestLoadUnload.py
Johnny Chen
johnny.chen at apple.com
Mon Dec 6 13:08:51 PST 2010
Author: johnny
Date: Mon Dec 6 15:08:51 2010
New Revision: 121036
URL: http://llvm.org/viewvc/llvm-project?rev=121036&view=rev
Log:
Add a test case test_lldb_process_load_and_unload_commands() for using lldb commands
'process load' and 'process unload' to load and unload shared library from lldb command
lines.
Modified:
lldb/trunk/test/load_unload/TestLoadUnload.py
Modified: lldb/trunk/test/load_unload/TestLoadUnload.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/load_unload/TestLoadUnload.py?rev=121036&r1=121035&r2=121036&view=diff
==============================================================================
--- lldb/trunk/test/load_unload/TestLoadUnload.py (original)
+++ lldb/trunk/test/load_unload/TestLoadUnload.py Mon Dec 6 15:08:51 2010
@@ -3,6 +3,7 @@
"""
import os, time
+import re
import unittest2
import lldb
from lldbtest import *
@@ -11,6 +12,63 @@
mydir = "load_unload"
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break for main.cpp.
+ self.line = line_number('main.c',
+ '// Set break point at this line for test_lldb_process_load_and_unload_commands().')
+
+ def test_lldb_process_load_and_unload_commands(self):
+ """Test that lldb process load/unload command work correctly."""
+
+ # Invoke the default build rule.
+ self.buildDefault()
+
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break at main.c before the call to dlopen().
+ # Use lldb's process load command to load the dylib, instead.
+
+ self.expect("breakpoint set -f main.c -l %d" % self.line,
+ BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 1: file ='main.c', line = %d" %
+ self.line)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # Make sure that a_function does not exist at this point.
+ self.expect("image lookup -n a_function", "a_function should not exist yet",
+ error=True, matching=False,
+ patterns = ["1 match found .* %s" % self.mydir])
+
+ # Use lldb 'process load' to load the dylib.
+ self.expect("process load liba.dylib", "liba.dylib loaded correctly",
+ patterns = ['Loading "liba.dylib".*ok',
+ 'Image [0-9]+ loaded'])
+
+ # Search for and match the "Image ([0-9]+) loaded" pattern.
+ output = self.res.GetOutput()
+ pattern = re.compile("Image ([0-9]+) loaded")
+ for l in output.split(os.linesep):
+ #print "l:", l
+ match = pattern.search(l)
+ if match:
+ break
+ index = match.group(1)
+
+ # Now we should have an entry for a_function.
+ self.expect("image lookup -n a_function", "a_function should now exist",
+ patterns = ["1 match found .*%s" % self.mydir])
+
+ # Use lldb 'process unload' to unload the dylib.
+ self.expect("process unload %s" % index, "liba.dylib unloaded correctly",
+ patterns = ["Unloading .* with index %s.*ok" % index])
+
+ self.runCmd("process continue")
+
+
def test_load_unload(self):
"""Test breakpoint by name works correctly with dlopen'ing."""
More information about the lldb-commits
mailing list