The extra burden for the Python API test case to assign its process object to self.process

in order to have its process cleaned up (terminated) upon tearDown is gone for good.
Let's simplify a bunch of Python API test cases.

llvm-svn: 133097
This commit is contained in:
Johnny Chen 2011-06-15 22:14:12 +00:00
parent c20b1393e1
commit 5a0bee7c5f
28 changed files with 149 additions and 174 deletions

View File

@ -110,19 +110,17 @@ class ArrayTypesTestCase(TestBase):
substrs = ["resolved = 1"]) substrs = ["resolved = 1"])
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(process, PROCESS_IS_VALID)
self.process = target.GetProcess()
self.assertTrue(self.process, PROCESS_IS_VALID)
# Sanity check the print representation of process. # Sanity check the print representation of process.
proc = repr(self.process) proc = repr(process)
self.expect(proc, msg="Process looks good", exe=False, self.expect(proc, msg="Process looks good", exe=False,
substrs = ["state = stopped", substrs = ["state = stopped",
"executable = a.out"]) "executable = a.out"])
# The stop reason of the thread should be breakpoint. # The stop reason of the thread should be breakpoint.
thread = self.process.GetThreadAtIndex(0) thread = process.GetThreadAtIndex(0)
if thread.GetStopReason() != lldb.eStopReasonBreakpoint: if thread.GetStopReason() != lldb.eStopReasonBreakpoint:
from lldbutil import stop_reason_to_str from lldbutil import stop_reason_to_str
self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS %

View File

@ -94,8 +94,8 @@ class BitfieldsTestCase(TestBase):
breakpoint = target.BreakpointCreateByLocation("main.c", self.line) breakpoint = target.BreakpointCreateByLocation("main.c", self.line)
self.assertTrue(breakpoint, VALID_BREAKPOINT) self.assertTrue(breakpoint, VALID_BREAKPOINT)
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(self.process, PROCESS_IS_VALID) self.assertTrue(process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint. # The stop reason of the thread should be breakpoint.
thread = target.GetProcess().GetThreadAtIndex(0) thread = target.GetProcess().GetThreadAtIndex(0)

View File

@ -139,14 +139,12 @@ class BreakpointConditionsTestCase(TestBase):
startstr = 'val == 3') startstr = 'val == 3')
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(process, PROCESS_IS_VALID)
self.process = target.GetProcess()
self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line1 and the break condition should hold. # Frame #0 should be on self.line1 and the break condition should hold.
from lldbutil import get_stopped_thread from lldbutil import get_stopped_thread
thread = get_stopped_thread(self.process, lldb.eStopReasonPlanComplete) thread = get_stopped_thread(process, lldb.eStopReasonPlanComplete)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition")
frame0 = thread.GetFrameAtIndex(0) frame0 = thread.GetFrameAtIndex(0)
var = frame0.FindValue('val', lldb.eValueTypeVariableArgument) var = frame0.FindValue('val', lldb.eValueTypeVariableArgument)
@ -156,7 +154,7 @@ class BreakpointConditionsTestCase(TestBase):
# The hit count for the breakpoint should be 3. # The hit count for the breakpoint should be 3.
self.assertTrue(breakpoint.GetHitCount() == 3) self.assertTrue(breakpoint.GetHitCount() == 3)
self.process.Continue() process.Continue()
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -101,16 +101,14 @@ class BreakpointIgnoreCountTestCase(TestBase):
"SetIgnoreCount() works correctly") "SetIgnoreCount() works correctly")
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(process, PROCESS_IS_VALID)
self.process = target.GetProcess()
self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and
# frame#2 should be on main.c:48. # frame#2 should be on main.c:48.
#lldbutil.print_stacktraces(self.process) #lldbutil.print_stacktraces(process)
from lldbutil import get_stopped_thread from lldbutil import get_stopped_thread
thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint")
frame0 = thread.GetFrameAtIndex(0) frame0 = thread.GetFrameAtIndex(0)
frame1 = thread.GetFrameAtIndex(1) frame1 = thread.GetFrameAtIndex(1)
@ -123,7 +121,7 @@ class BreakpointIgnoreCountTestCase(TestBase):
# The hit count for the breakpoint should be 3. # The hit count for the breakpoint should be 3.
self.assertTrue(breakpoint.GetHitCount() == 3) self.assertTrue(breakpoint.GetHitCount() == 3)
self.process.Continue() process.Continue()
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -80,13 +80,11 @@ class StaticVariableTestCase(TestBase):
self.assertTrue(breakpoint, VALID_BREAKPOINT) self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(process, PROCESS_IS_VALID)
self.process = target.GetProcess()
self.assertTrue(self.process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint. # The stop reason of the thread should be breakpoint.
thread = self.process.GetThreadAtIndex(0) thread = process.GetThreadAtIndex(0)
if thread.GetStopReason() != lldb.eStopReasonBreakpoint: if thread.GetStopReason() != lldb.eStopReasonBreakpoint:
from lldbutil import stop_reason_to_str from lldbutil import stop_reason_to_str
self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS %

View File

@ -120,18 +120,18 @@ class ClassTypesTestCase(TestBase):
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
error = lldb.SBError() error = lldb.SBError()
self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error)
if not error.Success() or not self.process: if not error.Success() or not process:
self.fail("SBTarget.Launch() failed") self.fail("SBTarget.Launch() failed")
if self.process.GetState() != lldb.eStateStopped: if process.GetState() != lldb.eStateStopped:
self.fail("Process should be in the 'stopped' state, " self.fail("Process should be in the 'stopped' state, "
"instead the actual state is: '%s'" % "instead the actual state is: '%s'" %
lldbutil.state_type_to_str(self.process.GetState())) lldbutil.state_type_to_str(process.GetState()))
# The stop reason of the thread should be breakpoint. # The stop reason of the thread should be breakpoint.
thread = self.process.GetThreadAtIndex(0) thread = process.GetThreadAtIndex(0)
if thread.GetStopReason() != lldb.eStopReasonBreakpoint: if thread.GetStopReason() != lldb.eStopReasonBreakpoint:
from lldbutil import stop_reason_to_str from lldbutil import stop_reason_to_str
self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS %
@ -149,7 +149,7 @@ class ClassTypesTestCase(TestBase):
# We should be stopped on the breakpoint with a hit count of 1. # We should be stopped on the breakpoint with a hit count of 1.
self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE)
self.process.Continue() process.Continue()
def class_types_expr_parser(self): def class_types_expr_parser(self):
"""Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" """Test 'frame variable this' and 'expr this' when stopped inside a constructor."""

View File

@ -53,12 +53,12 @@ class ConditionalBreakTestCase(TestBase):
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
error = lldb.SBError() error = lldb.SBError()
self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error)
self.assertTrue(error.Success() and self.process, PROCESS_IS_VALID) self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint. # The stop reason of the thread should be breakpoint.
self.assertTrue(self.process.GetState() == lldb.eStateStopped, self.assertTrue(process.GetState() == lldb.eStateStopped,
STOPPED_DUE_TO_BREAKPOINT) STOPPED_DUE_TO_BREAKPOINT)
# Find the line number where a's parent frame function is c. # Find the line number where a's parent frame function is c.
@ -72,7 +72,7 @@ class ConditionalBreakTestCase(TestBase):
# The 10 in range(10) is just an arbitrary number, which means we would # The 10 in range(10) is just an arbitrary number, which means we would
# like to try for at most 10 times. # like to try for at most 10 times.
for j in range(10): for j in range(10):
thread = self.process.GetThreadAtIndex(0) thread = process.GetThreadAtIndex(0)
if thread.GetNumFrames() >= 2: if thread.GetNumFrames() >= 2:
frame0 = thread.GetFrameAtIndex(0) frame0 = thread.GetFrameAtIndex(0)
@ -94,7 +94,7 @@ class ConditionalBreakTestCase(TestBase):
self.assertTrue(val.GetValue(frame1) == "3", "'val' has a value of 3") self.assertTrue(val.GetValue(frame1) == "3", "'val' has a value of 3")
break break
self.process.Continue() process.Continue()
def simulate_conditional_break_by_user(self): def simulate_conditional_break_by_user(self):
"""Simulate a user using lldb commands to break on c() if called from a().""" """Simulate a user using lldb commands to break on c() if called from a()."""

View File

@ -114,12 +114,12 @@ class DynamicValueTestCase(TestBase):
VALID_BREAKPOINT) VALID_BREAKPOINT)
# Now launch the process, and do not stop at the entry point. # Now launch the process, and do not stop at the entry point.
self.process = target.LaunchSimple (None, None, os.getcwd()) process = target.LaunchSimple (None, None, os.getcwd())
self.assertTrue(self.process.GetState() == lldb.eStateStopped, self.assertTrue(process.GetState() == lldb.eStateStopped,
PROCESS_STOPPED) PROCESS_STOPPED)
threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, first_call_bpt) threads = lldbutil.get_threads_stopped_at_breakpoint (process, first_call_bpt)
self.assertTrue (len(threads) == 1) self.assertTrue (len(threads) == 1)
thread = threads[0] thread = threads[0]
@ -141,7 +141,7 @@ class DynamicValueTestCase(TestBase):
# Okay now run to doSomething: # Okay now run to doSomething:
threads = lldbutil.continue_to_breakpoint (self.process, do_something_bpt) threads = lldbutil.continue_to_breakpoint (process, do_something_bpt)
self.assertTrue (len(threads) == 1) self.assertTrue (len(threads) == 1)
thread = threads[0] thread = threads[0]
@ -194,7 +194,7 @@ class DynamicValueTestCase(TestBase):
# Okay, now continue again, and when we hit the second breakpoint in main # Okay, now continue again, and when we hit the second breakpoint in main
threads = lldbutil.continue_to_breakpoint (self.process, second_call_bpt) threads = lldbutil.continue_to_breakpoint (process, second_call_bpt)
self.assertTrue (len(threads) == 1) self.assertTrue (len(threads) == 1)
thread = threads[0] thread = threads[0]
@ -206,7 +206,7 @@ class DynamicValueTestCase(TestBase):
# Finally continue to doSomething again, and make sure we get the right value for anotherA, # Finally continue to doSomething again, and make sure we get the right value for anotherA,
# which this time around is just an "A". # which this time around is just an "A".
threads = lldbutil.continue_to_breakpoint (self.process, do_something_bpt) threads = lldbutil.continue_to_breakpoint (process, do_something_bpt)
self.assertTrue(len(threads) == 1) self.assertTrue(len(threads) == 1)
thread = threads[0] thread = threads[0]

View File

@ -101,18 +101,18 @@ class BasicExprCommandsTestCase(TestBase):
# Launch the process, and do not stop at the entry point. # Launch the process, and do not stop at the entry point.
# Pass 'X Y Z' as the args, which makes argc == 4. # Pass 'X Y Z' as the args, which makes argc == 4.
error = lldb.SBError() error = lldb.SBError()
self.process = target.Launch(self.dbg.GetListener(), ['X', 'Y', 'Z'], None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) process = target.Launch(self.dbg.GetListener(), ['X', 'Y', 'Z'], None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error)
if not error.Success() or not self.process: if not error.Success() or not process:
self.fail("SBTarget.LaunchProcess() failed") self.fail("SBTarget.LaunchProcess() failed")
if self.process.GetState() != lldb.eStateStopped: if process.GetState() != lldb.eStateStopped:
self.fail("Process should be in the 'stopped' state, " self.fail("Process should be in the 'stopped' state, "
"instead the actual state is: '%s'" % "instead the actual state is: '%s'" %
lldbutil.state_type_to_str(self.process.GetState())) lldbutil.state_type_to_str(process.GetState()))
# The stop reason of the thread should be breakpoint. # The stop reason of the thread should be breakpoint.
thread = self.process.GetThreadAtIndex(0) thread = process.GetThreadAtIndex(0)
if thread.GetStopReason() != lldb.eStopReasonBreakpoint: if thread.GetStopReason() != lldb.eStopReasonBreakpoint:
from lldbutil import stop_reason_to_str from lldbutil import stop_reason_to_str
self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS %

View File

@ -213,12 +213,12 @@ class FoundationTestCase(TestBase):
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
error = lldb.SBError() error = lldb.SBError()
self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error)
self.assertTrue(self.process, PROCESS_IS_VALID) self.assertTrue(process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint. # The stop reason of the thread should be breakpoint.
thread = self.process.GetThreadAtIndex(0) thread = process.GetThreadAtIndex(0)
if thread.GetStopReason() != lldb.eStopReasonBreakpoint: if thread.GetStopReason() != lldb.eStopReasonBreakpoint:
from lldbutil import stop_reason_to_str from lldbutil import stop_reason_to_str
self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS %

View File

@ -62,10 +62,10 @@ class HelloWorldTestCase(TestBase):
# On the other hand, the following line of code are more reliable. # On the other hand, the following line of code are more reliable.
self.runCmd("run") self.runCmd("run")
self.process = target.GetProcess() process = target.GetProcess()
self.assertTrue(self.process, PROCESS_IS_VALID) self.assertTrue(process, PROCESS_IS_VALID)
thread = self.process.GetThreadAtIndex(0) thread = process.GetThreadAtIndex(0)
if thread.GetStopReason() != lldb.eStopReasonBreakpoint: if thread.GetStopReason() != lldb.eStopReasonBreakpoint:
from lldbutil import stop_reason_to_str from lldbutil import stop_reason_to_str
self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS %

View File

@ -58,15 +58,15 @@ class CrashingInferiorTestCase(TestBase):
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
# Both argv and envp are null. # Both argv and envp are null.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
import lldbutil import lldbutil
if self.process.GetState() != lldb.eStateStopped: if process.GetState() != lldb.eStateStopped:
self.fail("Process should be in the 'stopped' state, " self.fail("Process should be in the 'stopped' state, "
"instead the actual state is: '%s'" % "instead the actual state is: '%s'" %
lldbutil.state_type_to_str(self.process.GetState())) lldbutil.state_type_to_str(process.GetState()))
thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonException) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonException)
if not thread: if not thread:
self.fail("Fail to stop the thread upon bad access exception") self.fail("Fail to stop the thread upon bad access exception")

View File

@ -230,7 +230,7 @@ def get_stopped_thread(process, reason):
... ...
from lldbutil import get_stopped_thread from lldbutil import get_stopped_thread
thread = get_stopped_thread(self.process, lldb.eStopReasonPlanComplete) thread = get_stopped_thread(process, lldb.eStopReasonPlanComplete)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition")
... ...
@ -238,7 +238,7 @@ def get_stopped_thread(process, reason):
... ...
from lldbutil import get_stopped_thread from lldbutil import get_stopped_thread
thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint")
... ...

View File

@ -67,12 +67,12 @@ class ObjCDynamicValueTestCase(TestBase):
VALID_BREAKPOINT) VALID_BREAKPOINT)
# Now launch the process, and do not stop at the entry point. # Now launch the process, and do not stop at the entry point.
self.process = target.LaunchSimple (None, None, os.getcwd()) process = target.LaunchSimple (None, None, os.getcwd())
self.assertTrue(self.process.GetState() == lldb.eStateStopped, self.assertTrue(process.GetState() == lldb.eStateStopped,
PROCESS_STOPPED) PROCESS_STOPPED)
threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, main_before_setProperty_bkpt) threads = lldbutil.get_threads_stopped_at_breakpoint (process, main_before_setProperty_bkpt)
self.assertTrue (len(threads) == 1) self.assertTrue (len(threads) == 1)
thread = threads[0] thread = threads[0]
@ -99,7 +99,7 @@ class ObjCDynamicValueTestCase(TestBase):
thread.StepInto() thread.StepInto()
threads = lldbutil.get_stopped_threads (self.process, lldb.eStopReasonPlanComplete) threads = lldbutil.get_stopped_threads (process, lldb.eStopReasonPlanComplete)
self.assertTrue (len(threads) == 1) self.assertTrue (len(threads) == 1)
line_entry = threads[0].GetFrameAtIndex(0).GetLineEntry() line_entry = threads[0].GetFrameAtIndex(0).GetLineEntry()
self.assertTrue (line_entry.GetLine() == self.set_property_line) self.assertTrue (line_entry.GetLine() == self.set_property_line)
@ -107,7 +107,7 @@ class ObjCDynamicValueTestCase(TestBase):
# Okay, back to the main business. Continue to the handle_SourceBase and make sure we get the correct dynamic value. # Okay, back to the main business. Continue to the handle_SourceBase and make sure we get the correct dynamic value.
threads = lldbutil.continue_to_breakpoint (self.process, handle_SourceBase_bkpt) threads = lldbutil.continue_to_breakpoint (process, handle_SourceBase_bkpt)
self.assertTrue (len(threads) == 1) self.assertTrue (len(threads) == 1)
thread = threads[0] thread = threads[0]
@ -142,7 +142,7 @@ class ObjCDynamicValueTestCase(TestBase):
# This one looks exactly the same, but in fact this is an "un-KVO'ed" version of SourceBase, so # This one looks exactly the same, but in fact this is an "un-KVO'ed" version of SourceBase, so
# its isa pointer points to SourceBase not NSKVOSourceBase or whatever... # its isa pointer points to SourceBase not NSKVOSourceBase or whatever...
threads = lldbutil.continue_to_breakpoint (self.process, handle_SourceBase_bkpt) threads = lldbutil.continue_to_breakpoint (process, handle_SourceBase_bkpt)
self.assertTrue (len(threads) == 1) self.assertTrue (len(threads) == 1)
thread = threads[0] thread = threads[0]

View File

@ -64,12 +64,12 @@ class TestObjCStepping(TestBase):
self.assertTrue(break_returnStruct_call_super, VALID_BREAKPOINT) self.assertTrue(break_returnStruct_call_super, VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
self.process = target.LaunchSimple (None, None, os.getcwd()) process = target.LaunchSimple (None, None, os.getcwd())
self.assertTrue(self.process, PROCESS_IS_VALID) self.assertTrue(process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint. # The stop reason of the thread should be breakpoint.
thread = self.process.GetThreadAtIndex(0) thread = process.GetThreadAtIndex(0)
if thread.GetStopReason() != lldb.eStopReasonBreakpoint: if thread.GetStopReason() != lldb.eStopReasonBreakpoint:
from lldbutil import stop_reason_to_str from lldbutil import stop_reason_to_str
self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS %
@ -100,7 +100,7 @@ class TestObjCStepping(TestBase):
line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
self.assertTrue (line_number == self.sourceBase_randomMethod_line, "Stepped through super into SourceBase randomMethod.") self.assertTrue (line_number == self.sourceBase_randomMethod_line, "Stepped through super into SourceBase randomMethod.")
self.process.Continue() process.Continue()
line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
self.assertTrue (line_number == self.line2, "Continued to second breakpoint in main.") self.assertTrue (line_number == self.line2, "Continued to second breakpoint in main.")
@ -109,7 +109,7 @@ class TestObjCStepping(TestBase):
line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
self.assertTrue (line_number == self.source_returnsStruct_start_line, "Stepped into Source returnsStruct.") self.assertTrue (line_number == self.source_returnsStruct_start_line, "Stepped into Source returnsStruct.")
self.process.Continue() process.Continue()
line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
self.assertTrue (line_number == self.source_returnsStruct_call_line, "Stepped to the call super line in Source returnsStruct.") self.assertTrue (line_number == self.source_returnsStruct_call_line, "Stepped to the call super line in Source returnsStruct.")
@ -120,7 +120,7 @@ class TestObjCStepping(TestBase):
# Cool now continue to get past the call that intializes the Observer, and then do our steps in again to see that # Cool now continue to get past the call that intializes the Observer, and then do our steps in again to see that
# we can find our way when we're stepping through a KVO swizzled object. # we can find our way when we're stepping through a KVO swizzled object.
self.process.Continue() process.Continue()
frame = thread.GetFrameAtIndex(0) frame = thread.GetFrameAtIndex(0)
line_number = frame.GetLineEntry().GetLine() line_number = frame.GetLineEntry().GetLine()
self.assertTrue (line_number == self.line3, "Continued to third breakpoint in main, our object should now be swizzled.") self.assertTrue (line_number == self.line3, "Continued to third breakpoint in main, our object should now be swizzled.")
@ -140,7 +140,7 @@ class TestObjCStepping(TestBase):
line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
self.assertTrue (line_number == self.sourceBase_randomMethod_line, "Stepped through super into SourceBase randomMethod in swizzled object.") self.assertTrue (line_number == self.sourceBase_randomMethod_line, "Stepped through super into SourceBase randomMethod in swizzled object.")
self.process.Continue() process.Continue()
line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
self.assertTrue (line_number == self.line4, "Continued to fourth breakpoint in main.") self.assertTrue (line_number == self.line4, "Continued to fourth breakpoint in main.")
@ -149,7 +149,7 @@ class TestObjCStepping(TestBase):
line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
self.assertTrue (line_number == self.source_returnsStruct_start_line, "Stepped into Source returnsStruct in swizzled object.") self.assertTrue (line_number == self.source_returnsStruct_start_line, "Stepped into Source returnsStruct in swizzled object.")
self.process.Continue() process.Continue()
line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
self.assertTrue (line_number == self.source_returnsStruct_call_line, "Stepped to the call super line in Source returnsStruct - second time.") self.assertTrue (line_number == self.source_returnsStruct_call_line, "Stepped to the call super line in Source returnsStruct - second time.")

View File

@ -64,13 +64,11 @@ class EventAPITestCase(TestBase):
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
error = lldb.SBError() error = lldb.SBError()
self.process = target.Launch (listener, None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) process = target.Launch (listener, None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error)
self.assertTrue(process, PROCESS_IS_VALID)
self.process = target.GetProcess()
self.assertTrue(self.process, PROCESS_IS_VALID)
# Get a handle on the process's broadcaster. # Get a handle on the process's broadcaster.
broadcaster = self.process.GetBroadcaster() broadcaster = process.GetBroadcaster()
self.assertTrue(broadcaster, "Process with valid broadcaster") self.assertTrue(broadcaster, "Process with valid broadcaster")
# Create an empty event object. # Create an empty event object.
@ -94,7 +92,7 @@ class EventAPITestCase(TestBase):
# Use Python API to kill the process. The listening thread should be # Use Python API to kill the process. The listening thread should be
# able to receive a state changed event. # able to receive a state changed event.
self.process.Kill() process.Kill()
# Let's start the listening thread to retrieve the event. # Let's start the listening thread to retrieve the event.
my_thread = MyListeningThread() my_thread = MyListeningThread()
@ -122,14 +120,12 @@ class EventAPITestCase(TestBase):
VALID_BREAKPOINT) VALID_BREAKPOINT)
# Now launch the process, and do not stop at the entry point. # Now launch the process, and do not stop at the entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(process.GetState() == lldb.eStateStopped,
self.process = target.GetProcess()
self.assertTrue(self.process.GetState() == lldb.eStateStopped,
PROCESS_STOPPED) PROCESS_STOPPED)
# Get a handle on the process's broadcaster. # Get a handle on the process's broadcaster.
broadcaster = self.process.GetBroadcaster() broadcaster = process.GetBroadcaster()
self.assertTrue(broadcaster, "Process with valid broadcaster") self.assertTrue(broadcaster, "Process with valid broadcaster")
# Create an empty event object. # Create an empty event object.
@ -188,7 +184,7 @@ class EventAPITestCase(TestBase):
# Use Python API to continue the process. The listening thread should be # Use Python API to continue the process. The listening thread should be
# able to receive the state changed events. # able to receive the state changed events.
self.process.Continue() process.Continue()
# Start the listening thread to receive the "running" followed by the # Start the listening thread to receive the "running" followed by the
# "stopped" events. # "stopped" events.

View File

@ -41,9 +41,6 @@ class FrameAPITestCase(TestBase):
VALID_BREAKPOINT) VALID_BREAKPOINT)
# Now launch the process, and do not stop at the entry point. # Now launch the process, and do not stop at the entry point.
# Note that we don't assign the process to self.process as in other test
# cases. We want the inferior to run till it exits and there's no need
# for the testing framework to kill the inferior upon tearDown().
process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
process = target.GetProcess() process = target.GetProcess()

View File

@ -53,14 +53,12 @@ class DisasmAPITestCase(TestBase):
VALID_BREAKPOINT) VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(process, PROCESS_IS_VALID)
self.process = target.GetProcess()
self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line1. # Frame #0 should be on self.line1.
self.assertTrue(self.process.GetState() == lldb.eStateStopped) self.assertTrue(process.GetState() == lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition")
frame0 = thread.GetFrameAtIndex(0) frame0 = thread.GetFrameAtIndex(0)
lineEntry = frame0.GetLineEntry() lineEntry = frame0.GetLineEntry()
@ -77,9 +75,9 @@ class DisasmAPITestCase(TestBase):
print "context1:", context1 print "context1:", context1
# Continue the inferior, the breakpoint 2 should be hit. # Continue the inferior, the breakpoint 2 should be hit.
self.process.Continue() process.Continue()
self.assertTrue(self.process.GetState() == lldb.eStateStopped) self.assertTrue(process.GetState() == lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition")
frame0 = thread.GetFrameAtIndex(0) frame0 = thread.GetFrameAtIndex(0)
lineEntry = frame0.GetLineEntry() lineEntry = frame0.GetLineEntry()

View File

@ -53,14 +53,12 @@ class SymbolAPITestCase(TestBase):
VALID_BREAKPOINT) VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(process, PROCESS_IS_VALID)
self.process = target.GetProcess()
self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line1. # Frame #0 should be on self.line1.
self.assertTrue(self.process.GetState() == lldb.eStateStopped) self.assertTrue(process.GetState() == lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition")
frame0 = thread.GetFrameAtIndex(0) frame0 = thread.GetFrameAtIndex(0)
symbol_line1 = frame0.GetSymbol() symbol_line1 = frame0.GetSymbol()
@ -71,9 +69,9 @@ class SymbolAPITestCase(TestBase):
self.assertTrue(addr_line1.GetSectionType() == lldb.eSectionTypeCode) self.assertTrue(addr_line1.GetSectionType() == lldb.eSectionTypeCode)
# Continue the inferior, the breakpoint 2 should be hit. # Continue the inferior, the breakpoint 2 should be hit.
self.process.Continue() process.Continue()
self.assertTrue(self.process.GetState() == lldb.eStateStopped) self.assertTrue(process.GetState() == lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition")
frame0 = thread.GetFrameAtIndex(0) frame0 = thread.GetFrameAtIndex(0)
symbol_line2 = frame0.GetSymbol() symbol_line2 = frame0.GetSymbol()

View File

@ -59,18 +59,17 @@ class CommandInterpreterAPICase(TestBase):
ci.HandleCommand("process launch", res) ci.HandleCommand("process launch", res)
self.assertTrue(res.Succeeded()) self.assertTrue(res.Succeeded())
# Assigning to self.process so it gets cleaned up during test tear down. process = ci.GetProcess()
self.process = ci.GetProcess() self.assertTrue(process)
self.assertTrue(self.process)
import lldbutil import lldbutil
if self.process.GetState() != lldb.eStateStopped: if process.GetState() != lldb.eStateStopped:
self.fail("Process should be in the 'stopped' state, " self.fail("Process should be in the 'stopped' state, "
"instead the actual state is: '%s'" % "instead the actual state is: '%s'" %
lldbutil.state_type_to_str(self.process.GetState())) lldbutil.state_type_to_str(process.GetState()))
if self.TraceOn(): if self.TraceOn():
lldbutil.print_stacktraces(self.process) lldbutil.print_stacktraces(process)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -33,15 +33,15 @@ class FrameUtilsTestCase(TestBase):
self.assertTrue(breakpoint, VALID_BREAKPOINT) self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
if not self.process: if not process:
self.fail("SBTarget.LaunchProcess() failed") self.fail("SBTarget.LaunchProcess() failed")
self.assertTrue(self.process.GetState() == lldb.eStateStopped, self.assertTrue(process.GetState() == lldb.eStateStopped,
PROCESS_STOPPED) PROCESS_STOPPED)
import lldbutil import lldbutil
thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
frame0 = thread.GetFrameAtIndex(0) frame0 = thread.GetFrameAtIndex(0)
frame1 = thread.GetFrameAtIndex(1) frame1 = thread.GetFrameAtIndex(1)
parent = lldbutil.get_parent_frame(frame0) parent = lldbutil.get_parent_frame(frame0)

View File

@ -45,9 +45,9 @@ class LLDBIteratorTestCase(TestBase):
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
rc = lldb.SBError() rc = lldb.SBError()
self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc)
if not rc.Success() or not self.process: if not rc.Success() or not process:
self.fail("SBTarget.LaunchProcess() failed") self.fail("SBTarget.LaunchProcess() failed")
from lldbutil import get_description from lldbutil import get_description
@ -106,14 +106,14 @@ class LLDBIteratorTestCase(TestBase):
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
rc = lldb.SBError() rc = lldb.SBError()
self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc)
if not rc.Success() or not self.process: if not rc.Success() or not process:
self.fail("SBTarget.LaunchProcess() failed") self.fail("SBTarget.LaunchProcess() failed")
from lldbutil import print_stacktrace from lldbutil import print_stacktrace
stopped_due_to_breakpoint = False stopped_due_to_breakpoint = False
for thread in self.process: for thread in process:
if self.TraceOn(): if self.TraceOn():
print_stacktrace(thread) print_stacktrace(thread)
ID = thread.GetThreadID() ID = thread.GetThreadID()

View File

@ -34,13 +34,13 @@ class RegistersIteratorTestCase(TestBase):
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
rc = lldb.SBError() rc = lldb.SBError()
self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc)
if not rc.Success() or not self.process: if not rc.Success() or not process:
self.fail("SBTarget.LaunchProcess() failed") self.fail("SBTarget.LaunchProcess() failed")
import lldbutil import lldbutil
for thread in self.process: for thread in process:
if thread.GetStopReason() == lldb.eStopReasonBreakpoint: if thread.GetStopReason() == lldb.eStopReasonBreakpoint:
for frame in thread: for frame in thread:
# Dump the registers of this frame using lldbutil.get_GPRs() and friends. # Dump the registers of this frame using lldbutil.get_GPRs() and friends.

View File

@ -35,19 +35,19 @@ class ThreadsStackTracesTestCase(TestBase):
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
rc = lldb.SBError() rc = lldb.SBError()
self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc)
if not rc.Success() or not self.process: if not rc.Success() or not process:
self.fail("SBTarget.LaunchProcess() failed") self.fail("SBTarget.LaunchProcess() failed")
import lldbutil import lldbutil
if self.process.GetState() != lldb.eStateStopped: if process.GetState() != lldb.eStateStopped:
self.fail("Process should be in the 'stopped' state, " self.fail("Process should be in the 'stopped' state, "
"instead the actual state is: '%s'" % "instead the actual state is: '%s'" %
lldbutil.state_type_to_str(self.process.GetState())) lldbutil.state_type_to_str(process.GetState()))
if self.TraceOn(): if self.TraceOn():
lldbutil.print_stacktraces(self.process) lldbutil.print_stacktraces(process)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -76,9 +76,9 @@ class ProcessAPITestCase(TestBase):
# Launch the process, and do not stop at the entry point. # Launch the process, and do not stop at the entry point.
error = lldb.SBError() error = lldb.SBError()
self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) 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) thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint")
frame = thread.GetFrameAtIndex(0) frame = thread.GetFrameAtIndex(0)
@ -95,7 +95,7 @@ class ProcessAPITestCase(TestBase):
# Due to the typemap magic (see lldb.swig), we pass in 1 to ReadMemory and # Due to the typemap magic (see lldb.swig), we pass in 1 to ReadMemory and
# expect to get a Python string as the result object! # expect to get a Python string as the result object!
content = self.process.ReadMemory(location, 1, error) content = process.ReadMemory(location, 1, error)
if not error.Success(): if not error.Success():
self.fail("SBProcess.ReadMemory() failed") self.fail("SBProcess.ReadMemory() failed")
if self.TraceOn(): if self.TraceOn():
@ -118,9 +118,9 @@ class ProcessAPITestCase(TestBase):
# Launch the process, and do not stop at the entry point. # Launch the process, and do not stop at the entry point.
error = lldb.SBError() error = lldb.SBError()
self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) 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) thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint")
frame = thread.GetFrameAtIndex(0) frame = thread.GetFrameAtIndex(0)
@ -139,14 +139,14 @@ class ProcessAPITestCase(TestBase):
# But we want to use the WriteMemory() API to assign 'a' to the variable. # But we want to use the WriteMemory() API to assign 'a' to the variable.
# Now use WriteMemory() API to write 'a' into the global variable. # Now use WriteMemory() API to write 'a' into the global variable.
result = self.process.WriteMemory(location, 'a', error) result = process.WriteMemory(location, 'a', error)
if not error.Success() or result != 1: if not error.Success() or result != 1:
self.fail("SBProcess.WriteMemory() failed") self.fail("SBProcess.WriteMemory() failed")
# Read from the memory location. This time it should be 'a'. # Read from the memory location. This time it should be 'a'.
# Due to the typemap magic (see lldb.swig), we pass in 1 to ReadMemory and # Due to the typemap magic (see lldb.swig), we pass in 1 to ReadMemory and
# expect to get a Python string as the result object! # expect to get a Python string as the result object!
content = self.process.ReadMemory(location, 1, error) content = process.ReadMemory(location, 1, error)
if not error.Success(): if not error.Success():
self.fail("SBProcess.ReadMemory() failed") self.fail("SBProcess.ReadMemory() failed")
if self.TraceOn(): if self.TraceOn():
@ -169,9 +169,9 @@ class ProcessAPITestCase(TestBase):
# Launch the process, and do not stop at the entry point. # Launch the process, and do not stop at the entry point.
error = lldb.SBError() error = lldb.SBError()
self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) 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) thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint")
frame = thread.GetFrameAtIndex(0) frame = thread.GetFrameAtIndex(0)
@ -192,7 +192,7 @@ class ProcessAPITestCase(TestBase):
byteSize = val.GetByteSize() byteSize = val.GetByteSize()
bytes = int_to_bytearray(256, byteSize) bytes = int_to_bytearray(256, byteSize)
byteOrder = self.process.GetByteOrder() byteOrder = process.GetByteOrder()
if byteOrder == lldb.eByteOrderBig: if byteOrder == lldb.eByteOrderBig:
bytes.reverse() bytes.reverse()
elif byteOrder == lldb.eByteOrderLittle: elif byteOrder == lldb.eByteOrderLittle:
@ -207,7 +207,7 @@ class ProcessAPITestCase(TestBase):
# Now use WriteMemory() API to write 256 into the global variable. # Now use WriteMemory() API to write 256 into the global variable.
new_value = str(bytes) new_value = str(bytes)
result = self.process.WriteMemory(location, new_value, error) result = process.WriteMemory(location, new_value, error)
if not error.Success() or result != byteSize: if not error.Success() or result != byteSize:
self.fail("SBProcess.WriteMemory() failed") self.fail("SBProcess.WriteMemory() failed")
@ -225,7 +225,7 @@ class ProcessAPITestCase(TestBase):
startstr = '256') startstr = '256')
# Now read the memory content. The bytearray should have (byte)1 as the second element. # Now read the memory content. The bytearray should have (byte)1 as the second element.
content = self.process.ReadMemory(location, byteSize, error) content = process.ReadMemory(location, byteSize, error)
if not error.Success(): if not error.Success():
self.fail("SBProcess.ReadMemory() failed") self.fail("SBProcess.ReadMemory() failed")

View File

@ -47,14 +47,12 @@ class SymbolContextAPITestCase(TestBase):
VALID_BREAKPOINT) VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(process, PROCESS_IS_VALID)
self.process = target.GetProcess()
self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line. # Frame #0 should be on self.line.
from lldbutil import get_stopped_thread from lldbutil import get_stopped_thread
thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint")
frame0 = thread.GetFrameAtIndex(0) frame0 = thread.GetFrameAtIndex(0)
self.assertTrue(frame0.GetLineEntry().GetLine() == self.line) self.assertTrue(frame0.GetLineEntry().GetLine() == self.line)

View File

@ -99,8 +99,7 @@ class TargetAPITestCase(TestBase):
breakpoint = target.BreakpointCreateByLocation('main.c', line) breakpoint = target.BreakpointCreateByLocation('main.c', line)
# Now launch the process, do not stop at entry point, and redirect stdout to "stdout.txt" file. # Now launch the process, do not stop at entry point, and redirect stdout to "stdout.txt" file.
# The inferior should run to completion after "process.Continue()" call, so there's no need # The inferior should run to completion after "process.Continue()" call.
# to assign to self.process to have the inferior kiiled during test teardown.
error = lldb.SBError() error = lldb.SBError()
process = target.Launch (self.dbg.GetListener(), None, None, None, "stdout.txt", None, None, 0, False, error) process = target.Launch (self.dbg.GetListener(), None, None, None, "stdout.txt", None, None, 0, False, error)
process.Continue() process.Continue()
@ -146,14 +145,12 @@ class TargetAPITestCase(TestBase):
VALID_BREAKPOINT) VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point. # Now launch the process, and do not stop at entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(process, PROCESS_IS_VALID)
self.process = target.GetProcess()
self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line1. # Frame #0 should be on self.line1.
self.assertTrue(self.process.GetState() == lldb.eStateStopped) self.assertTrue(process.GetState() == lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition")
#self.runCmd("process status") #self.runCmd("process status")
frame0 = thread.GetFrameAtIndex(0) frame0 = thread.GetFrameAtIndex(0)
@ -163,9 +160,9 @@ class TargetAPITestCase(TestBase):
address1 = lineEntry.GetStartAddress() address1 = lineEntry.GetStartAddress()
# Continue the inferior, the breakpoint 2 should be hit. # Continue the inferior, the breakpoint 2 should be hit.
self.process.Continue() process.Continue()
self.assertTrue(self.process.GetState() == lldb.eStateStopped) self.assertTrue(process.GetState() == lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition")
#self.runCmd("process status") #self.runCmd("process status")
frame0 = thread.GetFrameAtIndex(0) frame0 = thread.GetFrameAtIndex(0)

View File

@ -116,15 +116,15 @@ class ThreadAPITestCase(TestBase):
self.runCmd("breakpoint list") self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point. # Launch the process, and do not stop at the entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint")
self.runCmd("process status") self.runCmd("process status")
proc_of_thread = thread.GetProcess() proc_of_thread = thread.GetProcess()
#print "proc_of_thread:", proc_of_thread #print "proc_of_thread:", proc_of_thread
self.assertTrue(proc_of_thread.GetProcessID() == self.process.GetProcessID()) self.assertTrue(proc_of_thread.GetProcessID() == process.GetProcessID())
def get_stop_description(self): def get_stop_description(self):
"""Test Python SBThread.GetStopDescription() API.""" """Test Python SBThread.GetStopDescription() API."""
@ -138,9 +138,9 @@ class ThreadAPITestCase(TestBase):
#self.runCmd("breakpoint list") #self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point. # Launch the process, and do not stop at the entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint")
#self.runCmd("process status") #self.runCmd("process status")
@ -163,10 +163,10 @@ class ThreadAPITestCase(TestBase):
self.runCmd("breakpoint list") self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point. # Launch the process, and do not stop at the entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
while True: while True:
thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint")
caller_symbol = get_caller_symbol(thread) caller_symbol = get_caller_symbol(thread)
#print "caller symbol of malloc:", caller_symbol #print "caller symbol of malloc:", caller_symbol
@ -176,7 +176,7 @@ class ThreadAPITestCase(TestBase):
break break
#self.runCmd("thread backtrace") #self.runCmd("thread backtrace")
#self.runCmd("process status") #self.runCmd("process status")
self.process.Continue() process.Continue()
thread.StepOut() thread.StepOut()
self.runCmd("thread backtrace") self.runCmd("thread backtrace")
@ -196,13 +196,13 @@ class ThreadAPITestCase(TestBase):
self.runCmd("breakpoint list") self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point. # Launch the process, and do not stop at the entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(self.process, PROCESS_IS_VALID) self.assertTrue(process, PROCESS_IS_VALID)
# Frame #0 should be on self.line2. # Frame #0 should be on self.line2.
self.assertTrue(self.process.GetState() == lldb.eStateStopped) self.assertTrue(process.GetState() == lldb.eStateStopped)
thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition")
self.runCmd("thread backtrace") self.runCmd("thread backtrace")
frame0 = thread.GetFrameAtIndex(0) frame0 = thread.GetFrameAtIndex(0)
@ -237,13 +237,13 @@ class ThreadAPITestCase(TestBase):
self.runCmd("breakpoint list") self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point. # Launch the process, and do not stop at the entry point.
self.process = target.LaunchSimple(None, None, os.getcwd()) process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(self.process, PROCESS_IS_VALID) self.assertTrue(process, PROCESS_IS_VALID)
# Frame #0 should be on self.line2. # Frame #0 should be on self.line2.
self.assertTrue(self.process.GetState() == lldb.eStateStopped) self.assertTrue(process.GetState() == lldb.eStateStopped)
thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition")
self.runCmd("thread backtrace") self.runCmd("thread backtrace")
frame0 = thread.GetFrameAtIndex(0) frame0 = thread.GetFrameAtIndex(0)