[Lldb-commits] [lldb] r127444 - /lldb/trunk/test/python_api/thread/TestThreadAPI.py
Johnny Chen
johnny.chen at apple.com
Thu Mar 10 17:16:03 PST 2011
Author: johnny
Date: Thu Mar 10 19:16:03 2011
New Revision: 127444
URL: http://llvm.org/viewvc/llvm-project?rev=127444&view=rev
Log:
Add test cases to exercise the SBThread.GetProcess() API. We launch the process using the
SBTarget.Launch() API, stop at a breakpoint, get the stopped thread, and verify that the
pid of the stopped thread's process is equal to the pid of the process returned by
SBTarget.Launch().
Modified:
lldb/trunk/test/python_api/thread/TestThreadAPI.py
Modified: lldb/trunk/test/python_api/thread/TestThreadAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/thread/TestThreadAPI.py?rev=127444&r1=127443&r2=127444&view=diff
==============================================================================
--- lldb/trunk/test/python_api/thread/TestThreadAPI.py (original)
+++ lldb/trunk/test/python_api/thread/TestThreadAPI.py Thu Mar 10 19:16:03 2011
@@ -14,6 +14,19 @@
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@python_api_test
+ def test_get_process_with_dsym(self):
+ """Test Python SBThread.GetProcess() API."""
+ self.buildDsym()
+ self.get_process()
+
+ @python_api_test
+ def test_get_process_with_dwarf(self):
+ """Test Python SBThread.GetProcess() API."""
+ self.buildDwarf()
+ self.get_process()
+
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ @python_api_test
def test_get_stop_description_with_dsym(self):
"""Test Python SBThread.GetStopDescription() API."""
self.buildDsym()
@@ -27,6 +40,25 @@
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@python_api_test
+ def test_run_to_address_with_dsym(self):
+ """Test Python SBThread.RunToAddress() API."""
+ # We build a different executable than the default buildDwarf() does.
+ d = {'CXX_SOURCES': 'main2.cpp'}
+ self.buildDsym(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+ self.run_to_address()
+
+ @python_api_test
+ def test_run_to_address_with_dwarf(self):
+ """Test Python SBThread.RunToAddress() API."""
+ # We build a different executable than the default buildDwarf() does.
+ d = {'CXX_SOURCES': 'main2.cpp'}
+ self.buildDwarf(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+ self.run_to_address()
+
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ @python_api_test
def test_step_out_of_malloc_into_function_b_with_dsym(self):
"""Test Python SBThread.StepOut() API to step out of a malloc call where the call site is at function b()."""
# We build a different executable than the default buildDsym() does.
@@ -72,8 +104,32 @@
self.line2 = line_number("main2.cpp", "// thread step-out of malloc into function b.")
self.line3 = line_number("main2.cpp", "// we should reach here after 3 step-over's.")
+ def get_process(self):
+ """Test Python SBThread.GetProcess() API."""
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target.IsValid(), VALID_TARGET)
+
+ breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
+ self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
+ self.runCmd("breakpoint list")
+
+ # Launch the process, and do not stop at the entry point.
+ error = lldb.SBError()
+ self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error)
+
+ thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint")
+ self.runCmd("process status")
+
+ proc_of_thread = thread.GetProcess()
+ #print "proc_of_thread:", proc_of_thread
+ self.assertTrue(proc_of_thread.GetProcessID() == self.process.GetProcessID())
+
def get_stop_description(self):
- """Test Python SBProcess.ReadMemory() API."""
+ """Test Python SBThread.GetStopDescription() API."""
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
@@ -172,7 +228,7 @@
self.assertTrue(thread.GetStopReason() == lldb.eStopReasonPlanComplete)
self.assertTrue(lineEntry.GetLine() == self.line3)
- def test_run_to_address(self):
+ def run_to_address(self):
"""Test Python SBThread.RunToAddress() API."""
# We build a different executable than the default buildDwarf() does.
d = {'CXX_SOURCES': 'main2.cpp'}
More information about the lldb-commits
mailing list