Now that we have added a post-processing step for adding truth value testing to

those lldb objects which implement the IsValid() method, let's change the rest of
the test suite to use the more compact truth value testing pattern (the Python way).

llvm-svn: 131970
This commit is contained in:
Johnny Chen 2011-05-24 18:22:45 +00:00
parent 97019c709d
commit 4ebd019b97
27 changed files with 137 additions and 137 deletions

View File

@ -95,10 +95,10 @@ class ArrayTypesTestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.c", self.line)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Sanity check the print representation of breakpoint.
bp = repr(breakpoint)
@ -113,7 +113,7 @@ class ArrayTypesTestCase(TestBase):
self.process = target.LaunchSimple(None, None, os.getcwd())
self.process = target.GetProcess()
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
self.assertTrue(self.process, PROCESS_IS_VALID)
# Sanity check the print representation of process.
proc = repr(self.process)

View File

@ -89,13 +89,13 @@ class BitfieldsTestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.c", self.line)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
self.process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
self.assertTrue(self.process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint.
thread = target.GetProcess().GetThreadAtIndex(0)

View File

@ -104,12 +104,12 @@ class BreakpointConditionsTestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Now create a breakpoint on main.c by name 'c'.
breakpoint = target.BreakpointCreateByName('c', 'a.out')
#print "breakpoint:", breakpoint
self.assertTrue(breakpoint.IsValid() and
self.assertTrue(breakpoint and
breakpoint.GetNumLocations() == 1,
VALID_BREAKPOINT)
@ -129,7 +129,7 @@ class BreakpointConditionsTestCase(TestBase):
# Get the breakpoint location from breakpoint after we verified that,
# indeed, it has one location.
location = breakpoint.GetLocationAtIndex(0)
self.assertTrue(location.IsValid() and
self.assertTrue(location and
location.IsEnabled(),
VALID_BREAKPOINT_LOCATION)
@ -142,7 +142,7 @@ class BreakpointConditionsTestCase(TestBase):
self.process = target.LaunchSimple(None, None, os.getcwd())
self.process = target.GetProcess()
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line1 and the break condition should hold.
from lldbutil import get_stopped_thread

View File

@ -80,18 +80,18 @@ class BreakpointIgnoreCountTestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Now create a breakpoint on main.c by name 'c'.
breakpoint = target.BreakpointCreateByName('c', 'a.out')
self.assertTrue(breakpoint.IsValid() and
self.assertTrue(breakpoint and
breakpoint.GetNumLocations() == 1,
VALID_BREAKPOINT)
# Get the breakpoint location from breakpoint after we verified that,
# indeed, it has one location.
location = breakpoint.GetLocationAtIndex(0)
self.assertTrue(location.IsValid() and
self.assertTrue(location and
location.IsEnabled(),
VALID_BREAKPOINT_LOCATION)
@ -104,7 +104,7 @@ class BreakpointIgnoreCountTestCase(TestBase):
self.process = target.LaunchSimple(None, None, os.getcwd())
self.process = target.GetProcess()
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
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#2 should be on main.c:48.

View File

@ -74,16 +74,16 @@ class StaticVariableTestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point.
self.process = target.LaunchSimple(None, None, os.getcwd())
self.process = target.GetProcess()
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
self.assertTrue(self.process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint.
thread = self.process.GetThreadAtIndex(0)

View File

@ -97,10 +97,10 @@ class ClassTypesTestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
filespec = target.GetExecutable()
self.assertTrue(filespec.IsValid(), VALID_FILESPEC)
self.assertTrue(filespec, VALID_FILESPEC)
fsDir = filespec.GetDirectory()
fsFile = filespec.GetFilename()
@ -111,7 +111,7 @@ class ClassTypesTestCase(TestBase):
bpfilespec = lldb.SBFileSpec("main.cpp", False)
breakpoint = target.BreakpointCreateByLocation(bpfilespec, self.line)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Verify the breakpoint just created.
self.expect(repr(breakpoint), BREAKPOINT_CREATED, exe=False,
@ -123,7 +123,7 @@ class ClassTypesTestCase(TestBase):
self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error)
#self.breakAfterLaunch(self.process, "C::C(int, int, int)")
if not error.Success() or not self.process.IsValid():
if not error.Success() or not self.process:
self.fail("SBTarget.Launch() failed")
if self.process.GetState() != lldb.eStateStopped:

View File

@ -100,7 +100,7 @@ class IterateFrameAndDisassembleTestCase(TestBase):
if self.TraceOn():
print
print function
if function.IsValid():
if function:
# Get all instructions for this function and print them out.
insts = function.GetInstructions(target)
for inst in insts:

View File

@ -46,16 +46,16 @@ class ConditionalBreakTestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByName("c", exe)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point.
error = lldb.SBError()
self.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.IsValid(), PROCESS_IS_VALID)
self.assertTrue(error.Success() and self.process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint.
self.assertTrue(self.process.GetState() == lldb.eStateStopped,

View File

@ -41,12 +41,12 @@ class DynamicValueTestCase(TestBase):
# Get "this" as its static value
self.assertTrue (this_static.IsValid())
self.assertTrue (this_static)
this_static_loc = int (this_static.GetValue(), 16)
# Get "this" as its dynamic value
self.assertTrue (this_dynamic.IsValid())
self.assertTrue (this_dynamic)
this_dynamic_typename = this_dynamic.GetTypeName()
self.assertTrue (this_dynamic_typename.find('B') != -1)
this_dynamic_loc = int (this_dynamic.GetValue(), 16)
@ -65,7 +65,7 @@ class DynamicValueTestCase(TestBase):
no_dynamic = lldb.eNoDynamicValues
this_dynamic_m_b_value = this_dynamic.GetChildMemberWithName('m_b_value', use_dynamic)
self.assertTrue (this_dynamic_m_b_value.IsValid())
self.assertTrue (this_dynamic_m_b_value)
m_b_value = int (this_dynamic_m_b_value.GetValue(), 0)
self.assertTrue (m_b_value == 10)
@ -73,17 +73,17 @@ class DynamicValueTestCase(TestBase):
# Make sure it is not in the static version
this_static_m_b_value = this_static.GetChildMemberWithName('m_b_value', no_dynamic)
self.assertTrue (this_static_m_b_value.IsValid() == False)
self.assertFalse (this_static_m_b_value)
# Okay, now let's make sure that we can get the dynamic type of a child element:
contained_auto_ptr = this_dynamic.GetChildMemberWithName ('m_client_A', use_dynamic)
self.assertTrue (contained_auto_ptr.IsValid())
self.assertTrue (contained_auto_ptr)
contained_b = contained_auto_ptr.GetChildMemberWithName ('_M_ptr', use_dynamic)
self.assertTrue (contained_b.IsValid())
self.assertTrue (contained_b)
contained_b_static = contained_auto_ptr.GetChildMemberWithName ('_M_ptr', no_dynamic)
self.assertTrue (contained_b_static.IsValid())
self.assertTrue (contained_b_static)
contained_b_addr = int (contained_b.GetValue(), 16)
contained_b_static_addr = int (contained_b_static.GetValue(), 16)
@ -97,20 +97,20 @@ class DynamicValueTestCase(TestBase):
# Create a target from the debugger.
target = self.dbg.CreateTarget (exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Set up our breakpoints:
do_something_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.do_something_line)
self.assertTrue(do_something_bpt.IsValid(),
self.assertTrue(do_something_bpt,
VALID_BREAKPOINT)
first_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_first_call_line)
self.assertTrue(first_call_bpt.IsValid(),
self.assertTrue(first_call_bpt,
VALID_BREAKPOINT)
second_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_second_call_line)
self.assertTrue(second_call_bpt.IsValid(),
self.assertTrue(second_call_bpt,
VALID_BREAKPOINT)
# Now launch the process, and do not stop at the entry point.
@ -132,11 +132,11 @@ class DynamicValueTestCase(TestBase):
no_dynamic = lldb.eNoDynamicValues
myB = frame.FindVariable ('myB', no_dynamic);
self.assertTrue (myB.IsValid())
self.assertTrue (myB)
myB_loc = int (myB.GetLocation(), 16)
otherB = frame.FindVariable('otherB', no_dynamic)
self.assertTrue (otherB.IsValid())
self.assertTrue (otherB)
otherB_loc = int (otherB.GetLocation(), 16)
# Okay now run to doSomething:
@ -173,11 +173,11 @@ class DynamicValueTestCase(TestBase):
# Now make sure we also get it right for a reference as well:
anotherA_static = frame.FindVariable ('anotherA', False)
self.assertTrue (anotherA_static.IsValid())
self.assertTrue (anotherA_static)
anotherA_static_addr = int (anotherA_static.GetValue(), 16)
anotherA_dynamic = frame.FindVariable ('anotherA', True)
self.assertTrue (anotherA_dynamic.IsValid())
self.assertTrue (anotherA_dynamic)
anotherA_dynamic_addr = int (anotherA_dynamic.GetValue(), 16)
anotherA_dynamic_typename = anotherA_dynamic.GetTypeName()
self.assertTrue (anotherA_dynamic_typename.find('B') != -1)
@ -185,12 +185,12 @@ class DynamicValueTestCase(TestBase):
self.assertTrue(anotherA_dynamic_addr < anotherA_static_addr)
anotherA_m_b_value_dynamic = anotherA_dynamic.GetChildMemberWithName('m_b_value', True)
self.assertTrue (anotherA_m_b_value_dynamic.IsValid())
self.assertTrue (anotherA_m_b_value_dynamic)
anotherA_m_b_val = int (anotherA_m_b_value_dynamic.GetValue(), 10)
self.assertTrue (anotherA_m_b_val == 300)
anotherA_m_b_value_static = anotherA_static.GetChildMemberWithName('m_b_value', True)
self.assertTrue (anotherA_m_b_value_static.IsValid() == False)
self.assertFalse (anotherA_m_b_value_static)
# Okay, now continue again, and when we hit the second breakpoint in main
@ -200,7 +200,7 @@ class DynamicValueTestCase(TestBase):
frame = thread.GetFrameAtIndex(0)
reallyA_value = frame.FindVariable ('reallyA', False)
self.assertTrue(reallyA_value.IsValid())
self.assertTrue(reallyA_value)
reallyA_loc = int (reallyA_value.GetLocation(), 16)
# Finally continue to doSomething again, and make sure we get the right value for anotherA,
@ -212,7 +212,7 @@ class DynamicValueTestCase(TestBase):
frame = thread.GetFrameAtIndex(0)
anotherA_value = frame.FindVariable ('anotherA', True)
self.assertTrue(anotherA_value.IsValid())
self.assertTrue(anotherA_value)
anotherA_loc = int (anotherA_value.GetValue(), 16)
self.assertTrue (anotherA_loc == reallyA_loc)
self.assertTrue (anotherA_value.GetTypeName().find ('B') == -1)

View File

@ -86,12 +86,12 @@ class BasicExprCommandsTestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Create the breakpoint.
filespec = lldb.SBFileSpec("main.cpp", False)
breakpoint = target.BreakpointCreateByLocation(filespec, self.line)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Verify the breakpoint just created.
self.expect(repr(breakpoint), BREAKPOINT_CREATED, exe=False,
@ -103,7 +103,7 @@ class BasicExprCommandsTestCase(TestBase):
error = lldb.SBError()
self.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.IsValid():
if not error.Success() or not self.process:
self.fail("SBTarget.LaunchProcess() failed")
if self.process.GetState() != lldb.eStateStopped:

View File

@ -206,16 +206,16 @@ class FoundationTestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
break1 = target.BreakpointCreateByLocation(self.main_source, self.line)
self.assertTrue(break1.IsValid(), VALID_BREAKPOINT)
self.assertTrue(break1, VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point.
error = lldb.SBError()
self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error)
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
self.assertTrue(self.process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint.
thread = self.process.GetThreadAtIndex(0)
@ -232,15 +232,15 @@ class FoundationTestCase(TestBase):
self.assertTrue (line_number == self.line, "Hit the first breakpoint.")
my_var = cur_frame.FindVariable("my")
self.assertTrue(my_var.IsValid(), "Made a variable object for my")
self.assertTrue(my_var, "Made a variable object for my")
str_var = cur_frame.FindVariable("str")
self.assertTrue(str_var.IsValid(), "Made a variable object for str")
self.assertTrue(str_var, "Made a variable object for str")
# Now make sure that the my->str == str:
my_str_var = my_var.GetChildMemberWithName("str")
self.assertTrue(my_str_var.IsValid(), "Found a str ivar in my")
self.assertTrue(my_str_var, "Found a str ivar in my")
str_value = int(str_var.GetValue(cur_frame), 0)

View File

@ -42,7 +42,7 @@ class FoundationSymtabTestCase(TestBase):
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Launch the process, and do not stop at the entry point.
process = target.LaunchSimple(None, None, os.getcwd())
@ -55,13 +55,13 @@ class FoundationSymtabTestCase(TestBase):
filespec = lldb.SBFileSpec(exe, False)
module = target.FindModule(filespec)
self.assertTrue(module.IsValid(), VALID_MODULE)
self.assertTrue(module, VALID_MODULE)
# Create the set of known symbols. As we iterate through the symbol
# table, remove the symbol from the set if it is a known symbol.
expected_symbols = set(self.symbols_list)
for symbol in module:
self.assertTrue(symbol.IsValid(), VALID_SYMBOL)
self.assertTrue(symbol, VALID_SYMBOL)
#print "symbol:", symbol
name = symbol.GetName()
if name in expected_symbols:

View File

@ -67,7 +67,7 @@ class HelloWorldTestCase(TestBase):
#self.runCmd("thread list")
self.process = target.GetProcess()
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
self.assertTrue(self.process, PROCESS_IS_VALID)
thread = self.process.GetThreadAtIndex(0)
if thread.GetStopReason() != lldb.eStopReasonBreakpoint:

View File

@ -54,7 +54,7 @@ class CrashingInferiorTestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Now launch the process, and do not stop at entry point.
# Both argv and envp are null.

View File

@ -45,7 +45,7 @@ class UniversalTestCase(TestBase):
# Check whether we have a 64-bit process launched.
target = self.dbg.GetSelectedTarget()
process = target.GetProcess()
self.assertTrue(target.IsValid() and process.IsValid() and
self.assertTrue(target and process and
self.invoke(process, 'GetAddressByteSize') == 8,
"64-bit process launched")
@ -73,7 +73,7 @@ class UniversalTestCase(TestBase):
# Check whether we have a 32-bit process launched.
target = self.dbg.GetSelectedTarget()
process = target.GetProcess()
self.assertTrue(target.IsValid() and process.IsValid(),
self.assertTrue(target and process,
"32-bit process launched")
pointerSize = self.invoke(process, 'GetAddressByteSize')

View File

@ -39,10 +39,10 @@ class ObjCDynamicValueTestCase(TestBase):
'// Break here to see if we can step into real method.')
def examine_SourceDerived_ptr (self, object):
self.assertTrue (object.IsValid())
self.assertTrue (object)
self.assertTrue (object.GetTypeName().find ('SourceDerived') != -1)
derivedValue = object.GetChildMemberWithName ('_derivedValue')
self.assertTrue (derivedValue.IsValid())
self.assertTrue (derivedValue)
self.assertTrue (int (derivedValue.GetValue(), 0) == 30)
def do_get_dynamic_vals(self):
@ -52,17 +52,17 @@ class ObjCDynamicValueTestCase(TestBase):
# Create a target from the debugger.
target = self.dbg.CreateTarget (exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Set up our breakpoints:
handle_SourceBase_bkpt = target.BreakpointCreateByLocation(self.source_name, self.handle_SourceBase)
self.assertTrue(handle_SourceBase_bkpt.IsValid() and
self.assertTrue(handle_SourceBase_bkpt and
handle_SourceBase_bkpt.GetNumLocations() == 1,
VALID_BREAKPOINT)
main_before_setProperty_bkpt = target.BreakpointCreateByLocation(self.source_name, self.main_before_setProperty_line)
self.assertTrue(main_before_setProperty_bkpt.IsValid() and
self.assertTrue(main_before_setProperty_bkpt and
main_before_setProperty_bkpt.GetNumLocations() == 1,
VALID_BREAKPOINT)
@ -82,7 +82,7 @@ class ObjCDynamicValueTestCase(TestBase):
frame = thread.GetFrameAtIndex(0)
myObserver = frame.FindVariable('myObserver', lldb.eDynamicCanRunTarget)
self.assertTrue (myObserver.IsValid())
self.assertTrue (myObserver)
myObserver_source = myObserver.GetChildMemberWithName ('_source', lldb.eDynamicCanRunTarget)
self.examine_SourceDerived_ptr (myObserver_source)

View File

@ -43,30 +43,30 @@ class TestObjCStepping(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
break1 = target.BreakpointCreateByLocation(self.main_source, self.line1)
self.assertTrue(break1.IsValid(), VALID_BREAKPOINT)
self.assertTrue(break1, VALID_BREAKPOINT)
break2 = target.BreakpointCreateByLocation(self.main_source, self.line2)
self.assertTrue(break2.IsValid(), VALID_BREAKPOINT)
self.assertTrue(break2, VALID_BREAKPOINT)
break3 = target.BreakpointCreateByLocation(self.main_source, self.line3)
self.assertTrue(break3.IsValid(), VALID_BREAKPOINT)
self.assertTrue(break3, VALID_BREAKPOINT)
break4 = target.BreakpointCreateByLocation(self.main_source, self.line4)
self.assertTrue(break4.IsValid(), VALID_BREAKPOINT)
self.assertTrue(break4, VALID_BREAKPOINT)
break5 = target.BreakpointCreateByLocation(self.main_source, self.line5)
self.assertTrue(break5.IsValid(), VALID_BREAKPOINT)
self.assertTrue(break5, VALID_BREAKPOINT)
break_returnStruct_call_super = target.BreakpointCreateByLocation(self.main_source, self.source_returnsStruct_call_line)
self.assertTrue(break_returnStruct_call_super.IsValid(), VALID_BREAKPOINT)
self.assertTrue(break_returnStruct_call_super, VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point.
self.process = target.LaunchSimple (None, None, os.getcwd())
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
self.assertTrue(self.process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint.
thread = self.process.GetThreadAtIndex(0)
@ -81,9 +81,9 @@ class TestObjCStepping(TestBase):
self.assertTrue (line_number == self.line1, "Hit the first breakpoint.")
mySource = thread.GetFrameAtIndex(0).FindVariable("mySource")
self.assertTrue(mySource.IsValid(), "Found mySource local variable.")
self.assertTrue(mySource, "Found mySource local variable.")
mySource_isa = mySource.GetChildMemberWithName ("isa")
self.assertTrue(mySource_isa.IsValid(), "Found mySource->isa local variable.")
self.assertTrue(mySource_isa, "Found mySource->isa local variable.")
mySource_isa.GetValue (thread.GetFrameAtIndex(0))
# Lets delete mySource so we can check that after stepping a child variable

View File

@ -50,12 +50,12 @@ class EventAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Now create a breakpoint on main.c by name 'c'.
breakpoint = target.BreakpointCreateByName('c', 'a.out')
#print "breakpoint:", breakpoint
self.assertTrue(breakpoint.IsValid() and
self.assertTrue(breakpoint and
breakpoint.GetNumLocations() == 1,
VALID_BREAKPOINT)
@ -67,15 +67,15 @@ class EventAPITestCase(TestBase):
self.process = target.Launch (listener, None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error)
self.process = target.GetProcess()
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
self.assertTrue(self.process, PROCESS_IS_VALID)
# Get a handle on the process's broadcaster.
broadcaster = self.process.GetBroadcaster()
self.assertTrue(broadcaster.IsValid(), "Process with valid broadcaster")
self.assertTrue(broadcaster, "Process with valid broadcaster")
# Create an empty event object.
event = lldb.SBEvent()
self.assertFalse(event.IsValid(), "Event should not be valid initially")
self.assertFalse(event, "Event should not be valid initially")
# Create MyListeningThread to wait for any kind of event.
import threading
@ -103,7 +103,7 @@ class EventAPITestCase(TestBase):
# Wait until the 'MyListeningThread' terminates.
my_thread.join()
self.assertTrue(event.IsValid(),
self.assertTrue(event,
"My listening thread successfully received an event")
def do_add_listener_to_broadcaster(self):
@ -112,12 +112,12 @@ class EventAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Now create a breakpoint on main.c by name 'c'.
breakpoint = target.BreakpointCreateByName('c', 'a.out')
#print "breakpoint:", breakpoint
self.assertTrue(breakpoint.IsValid() and
self.assertTrue(breakpoint and
breakpoint.GetNumLocations() == 1,
VALID_BREAKPOINT)
@ -130,11 +130,11 @@ class EventAPITestCase(TestBase):
# Get a handle on the process's broadcaster.
broadcaster = self.process.GetBroadcaster()
self.assertTrue(broadcaster.IsValid(), "Process with valid broadcaster")
self.assertTrue(broadcaster, "Process with valid broadcaster")
# Create an empty event object.
event = lldb.SBEvent()
self.assertFalse(event.IsValid(), "Event should not be valid initially")
self.assertFalse(event, "Event should not be valid initially")
# Create a listener object and register with the broadcaster.
listener = lldb.SBListener("TestEvents.listener")

View File

@ -31,12 +31,12 @@ class FrameAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Now create a breakpoint on main.c by name 'c'.
breakpoint = target.BreakpointCreateByName('c', 'a.out')
#print "breakpoint:", breakpoint
self.assertTrue(breakpoint.IsValid() and
self.assertTrue(breakpoint and
breakpoint.GetNumLocations() == 1,
VALID_BREAKPOINT)
@ -87,10 +87,10 @@ class FrameAPITestCase(TestBase):
# but they should be valid. Uses get_GPRs() from the lldbutil module.
gpr_reg_set = lldbutil.get_GPRs(frame)
pc_value = gpr_reg_set.GetChildMemberWithName("pc")
self.assertTrue (pc_value.IsValid(), "We should have a valid PC.")
self.assertTrue (pc_value, "We should have a valid PC.")
self.assertTrue (int(pc_value.GetValue(frame), 0) == frame.GetPC(), "PC gotten as a value should equal frame's GetPC")
sp_value = gpr_reg_set.GetChildMemberWithName("sp")
self.assertTrue (sp_value.IsValid(), "We should have a valid Stack Pointer.")
self.assertTrue (sp_value, "We should have a valid Stack Pointer.")
self.assertTrue (int(sp_value.GetValue(frame), 0) == frame.GetSP(), "SP gotten as a value should equal frame's GetSP")
print >> session, "---"

View File

@ -38,17 +38,17 @@ class DisasmAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Now create the two breakpoints inside function 'a'.
breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1)
breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2)
#print "breakpoint1:", breakpoint1
#print "breakpoint2:", breakpoint2
self.assertTrue(breakpoint1.IsValid() and
self.assertTrue(breakpoint1 and
breakpoint1.GetNumLocations() == 1,
VALID_BREAKPOINT)
self.assertTrue(breakpoint2.IsValid() and
self.assertTrue(breakpoint2 and
breakpoint2.GetNumLocations() == 1,
VALID_BREAKPOINT)
@ -56,7 +56,7 @@ class DisasmAPITestCase(TestBase):
self.process = target.LaunchSimple(None, None, os.getcwd())
self.process = target.GetProcess()
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line1.
self.assertTrue(self.process.GetState() == lldb.eStateStopped)
@ -72,7 +72,7 @@ class DisasmAPITestCase(TestBase):
# Now call SBTarget.ResolveSymbolContextForAddress() with address1.
context1 = target.ResolveSymbolContextForAddress(address1, lldb.eSymbolContextEverything)
self.assertTrue(context1.IsValid())
self.assertTrue(context1)
if self.TraceOn():
print "context1:", context1
@ -88,7 +88,7 @@ class DisasmAPITestCase(TestBase):
# Verify that the symbol and the function has the same address range per function 'a'.
symbol = context1.GetSymbol()
function = frame0.GetFunction()
self.assertTrue(symbol.IsValid() and function.IsValid())
self.assertTrue(symbol and function)
disasm_output = lldbutil.disassemble(target, symbol)
if self.TraceOn():

View File

@ -38,17 +38,17 @@ class SymbolAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Now create the two breakpoints inside function 'a'.
breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1)
breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2)
#print "breakpoint1:", breakpoint1
#print "breakpoint2:", breakpoint2
self.assertTrue(breakpoint1.IsValid() and
self.assertTrue(breakpoint1 and
breakpoint1.GetNumLocations() == 1,
VALID_BREAKPOINT)
self.assertTrue(breakpoint2.IsValid() and
self.assertTrue(breakpoint2 and
breakpoint2.GetNumLocations() == 1,
VALID_BREAKPOINT)
@ -56,7 +56,7 @@ class SymbolAPITestCase(TestBase):
self.process = target.LaunchSimple(None, None, os.getcwd())
self.process = target.GetProcess()
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line1.
self.assertTrue(self.process.GetState() == lldb.eStateStopped)

View File

@ -35,11 +35,11 @@ class CommandInterpreterAPICase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Retrieve the associated command interpreter from our debugger.
ci = self.dbg.GetCommandInterpreter()
self.assertTrue(ci.IsValid(), VALID_COMMAND_INTERPRETER)
self.assertTrue(ci, VALID_COMMAND_INTERPRETER)
# Exercise some APIs....
@ -61,7 +61,7 @@ class CommandInterpreterAPICase(TestBase):
# Assigning to self.process so it gets cleaned up during test tear down.
self.process = ci.GetProcess()
self.assertTrue(self.process.IsValid())
self.assertTrue(self.process)
import lldbutil
if self.process.GetState() != lldb.eStateStopped:

View File

@ -69,10 +69,10 @@ class ProcessAPITestCase(TestBase):
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Launch the process, and do not stop at the entry point.
error = lldb.SBError()
@ -111,10 +111,10 @@ class ProcessAPITestCase(TestBase):
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Launch the process, and do not stop at the entry point.
error = lldb.SBError()
@ -162,10 +162,10 @@ class ProcessAPITestCase(TestBase):
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Launch the process, and do not stop at the entry point.
error = lldb.SBError()
@ -251,7 +251,7 @@ class ProcessAPITestCase(TestBase):
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Launch the process, and do not stop at the entry point.
error = lldb.SBError()

View File

@ -37,12 +37,12 @@ class SymbolContextAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Now create a breakpoint on main.c by name 'c'.
breakpoint = target.BreakpointCreateByName('c', 'a.out')
#print "breakpoint:", breakpoint
self.assertTrue(breakpoint.IsValid() and
self.assertTrue(breakpoint and
breakpoint.GetNumLocations() == 1,
VALID_BREAKPOINT)
@ -50,7 +50,7 @@ class SymbolContextAPITestCase(TestBase):
self.process = target.LaunchSimple(None, None, os.getcwd())
self.process = target.GetProcess()
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line.
from lldbutil import get_stopped_thread
@ -61,7 +61,7 @@ class SymbolContextAPITestCase(TestBase):
# Now get the SBSymbolContext from this frame. We want everything. :-)
context = frame0.GetSymbolContext(lldb.eSymbolContextEverything)
self.assertTrue(context.IsValid())
self.assertTrue(context)
# Get the description of this module.
module = context.GetModule()
@ -74,11 +74,11 @@ class SymbolContextAPITestCase(TestBase):
substrs = [os.path.join(self.mydir, 'main.c')])
function = context.GetFunction()
self.assertTrue(function.IsValid())
self.assertTrue(function)
#print "function:", function
block = context.GetBlock()
self.assertTrue(block.IsValid())
self.assertTrue(block)
#print "block:", block
lineEntry = context.GetLineEntry()

View File

@ -64,7 +64,7 @@ class TargetAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
from lldbutil import get_description
@ -91,7 +91,7 @@ class TargetAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Add an extra twist of stopping the inferior in a breakpoint, and then continue till it's done.
# We should still see the entire stdout redirected once the process is finished.
@ -131,17 +131,17 @@ class TargetAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Now create the two breakpoints inside function 'a'.
breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1)
breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2)
#print "breakpoint1:", breakpoint1
#print "breakpoint2:", breakpoint2
self.assertTrue(breakpoint1.IsValid() and
self.assertTrue(breakpoint1 and
breakpoint1.GetNumLocations() == 1,
VALID_BREAKPOINT)
self.assertTrue(breakpoint2.IsValid() and
self.assertTrue(breakpoint2 and
breakpoint2.GetNumLocations() == 1,
VALID_BREAKPOINT)
@ -149,7 +149,7 @@ class TargetAPITestCase(TestBase):
self.process = target.LaunchSimple(None, None, os.getcwd())
self.process = target.GetProcess()
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line1.
self.assertTrue(self.process.GetState() == lldb.eStateStopped)
@ -181,14 +181,14 @@ class TargetAPITestCase(TestBase):
context1 = target.ResolveSymbolContextForAddress(address1, lldb.eSymbolContextEverything)
context2 = target.ResolveSymbolContextForAddress(address2, lldb.eSymbolContextEverything)
self.assertTrue(context1.IsValid() and context2.IsValid())
self.assertTrue(context1 and context2)
#print "context1:", context1
#print "context2:", context2
# Verify that the context point to the same function 'a'.
symbol1 = context1.GetSymbol()
symbol2 = context2.GetSymbol()
self.assertTrue(symbol1.IsValid() and symbol2.IsValid())
self.assertTrue(symbol1 and symbol2)
#print "symbol1:", symbol1
#print "symbol2:", symbol2

View File

@ -109,10 +109,10 @@ class ThreadAPITestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point.
@ -131,10 +131,10 @@ class ThreadAPITestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
#self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point.
@ -156,10 +156,10 @@ class ThreadAPITestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByName('malloc')
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point.
@ -189,16 +189,16 @@ class ThreadAPITestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation('main2.cpp', self.line2)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point.
self.process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line2.
self.assertTrue(self.process.GetState() == lldb.eStateStopped)
@ -230,16 +230,16 @@ class ThreadAPITestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation('main2.cpp', self.line2)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point.
self.process = target.LaunchSimple(None, None, os.getcwd())
self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line2.
self.assertTrue(self.process.GetState() == lldb.eStateStopped)

View File

@ -40,7 +40,7 @@ class SourceManagerTestCase(TestBase):
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
self.assertTrue(target, VALID_TARGET)
# Launch the process, and do not stop at the entry point.
error = lldb.SBError()