diff options
| -rwxr-xr-x | lldb/scripts/Python/build-swig-Python.sh | 18 | ||||
| -rw-r--r-- | lldb/scripts/lldb.swig | 1 | ||||
| -rw-r--r-- | lldb/test/array_types/TestArrayTypes.py | 58 | ||||
| -rw-r--r-- | lldb/test/lldbtest.py | 29 |
4 files changed, 104 insertions, 2 deletions
diff --git a/lldb/scripts/Python/build-swig-Python.sh b/lldb/scripts/Python/build-swig-Python.sh index d2ed2098a5b..de26eccd80e 100755 --- a/lldb/scripts/Python/build-swig-Python.sh +++ b/lldb/scripts/Python/build-swig-Python.sh @@ -67,7 +67,7 @@ fi NeedToUpdate=0 -if [ ! -f $swig_output_file ] +if [ ! -f ${swig_output_file} ] then NeedToUpdate=1 if [ $Debug == 1 ] @@ -80,7 +80,7 @@ if [ $NeedToUpdate == 0 ] then for hdrfile in ${HEADER_FILES} do - if [ $hdrfile -nt $swig_output_file ] + if [ $hdrfile -nt ${swig_output_file} ] then NeedToUpdate=1 if [ $Debug == 1 ] @@ -88,10 +88,24 @@ then echo "${hdrfile} is newer than ${swig_output_file}" echo "swig file will need to be re-built." fi + break fi done fi +if [ $NeedToUpdate == 0 ] +then + if [ ${swig_input_file} -nt ${swig_output_file} ] + then + NeedToUpdate=1 + if [ $Debug == 1 ] + then + echo "${swig_input_file} is newer than ${swig_output_file}" + echo "swig file will need to be re-built." + fi + fi +fi + os_name=`uname -s` python_version=`/usr/bin/python --version 2>&1 | sed -e 's,Python ,,' -e 's,[.][0-9],,2' -e 's,[a-z][a-z][0-9],,'` diff --git a/lldb/scripts/lldb.swig b/lldb/scripts/lldb.swig index 4178c83a5f7..31dca479704 100644 --- a/lldb/scripts/lldb.swig +++ b/lldb/scripts/lldb.swig @@ -121,6 +121,7 @@ typedef int32_t break_id_t; typedef lldb::SBStringList SBStringList; typedef lldb::RegisterKind RegisterKind; const RegisterKind kNumRegisterKinds = lldb::kNumRegisterKinds ; +typedef int StopReason; %include "lldb/API/SBAddress.h" diff --git a/lldb/test/array_types/TestArrayTypes.py b/lldb/test/array_types/TestArrayTypes.py index 1e3da35b88b..0b5a227a8d8 100644 --- a/lldb/test/array_types/TestArrayTypes.py +++ b/lldb/test/array_types/TestArrayTypes.py @@ -52,6 +52,64 @@ class TestArrayTypes(TestBase): self.expect("variable list long_6", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(long [6])') + def test_array_types_python(self): + """ + Test 'variable list var_name' on some variables with array types. + + Use the Python APIs from lldb.py. + """ + exe = os.path.join(os.getcwd(), "a.out") + + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + breakpoint = target.BreakpointCreateByLocation("main.c", 42) + self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + + self.runCmd("run", RUN_STOPPED) + + # The stop reason of the thread should be breakpoint. + thread = target.GetProcess().GetThreadAtIndex(0) + self.assertTrue(thread.GetStopReason() == Enum("Breakpoint"), + STOPPED_DUE_TO_BREAKPOINT) + + # The breakpoint should have a hit count of 1. + self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) + + # Lookup the "strings" string array variable. + frame = thread.GetFrameAtIndex(0) + variable = frame.LookupVar("strings") + self.assertTrue(variable.GetNumChildren() == 4, + "Variable 'strings' should have 4 children") + + child3 = variable.GetChildAtIndex(3) + self.assertTrue(child3.GetSummary(frame) == '"Guten Tag"', + 'strings[3] == "Guten Tag"') + + # Lookup the "char_16" char array variable. + variable = frame.LookupVar("char_16") + self.assertTrue(variable.GetNumChildren() == 16, + "Variable 'char_16' should have 16 children") + + # Lookup the "ushort_matrix" ushort[] array variable. + variable = frame.LookupVar("ushort_matrix") + self.assertTrue(variable.GetNumChildren() == 2, + "Variable 'ushort_matrix' should have 2 children") + child0 = variable.GetChildAtIndex(0) + self.assertTrue(child0.GetNumChildren() == 3, + "Variable 'ushort_matrix[0]' should have 3 children") + child0_2 = child0.GetChildAtIndex(2) + self.assertTrue(int(child0_2.GetValue(frame), 16) == 3, + "ushort_matrix[0][2] == 3") + + # Lookup the "long_6" char array variable. + variable = frame.LookupVar("long_6") + self.assertTrue(variable.GetNumChildren() == 6, + "Variable 'long_6' should have 6 children") + child5 = variable.GetChildAtIndex(5) + self.assertTrue(long(child5.GetValue(frame)) == 6, + "long_6[5] == 6") + if __name__ == '__main__': import atexit diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index 3d1c2cc6dcc..5da2343d03e 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -133,14 +133,43 @@ STOPPED_DUE_TO_STEP_IN = "Process state is stopped due to step in" DATA_TYPES_DISPLAYED_CORRECTLY = "Data type(s) displayed correctly" +VALID_BREAKPOINT = "Got a valid breakpoint" + +VALID_PROCESS = "Got a valid process" + +VALID_TARGET = "Got a valid target" + VARIABLES_DISPLAYED_CORRECTLY = "Variable(s) displayed correctly" + # # And a generic "Command '%s' returns successfully" message generator. # def CMD_MSG(command): return "Command '%s' returns successfully" % (command) +# +# Returns the enum from the input string stopReason. +# +def Enum(stopReason): + if stopReason == "Invalid": + return 0 + elif stopReason == "None": + return 1 + elif stopReason == "Trace": + return 2 + elif stopReason == "Breakpoint": + return 3 + elif stopReason == "Watchpoint": + return 4 + elif stopReason == "Signal": + return 5 + elif stopReason == "Exception": + return 6 + elif stopReason == "PlanComplete": + return 7 + else: + raise Exception("Unknown stopReason string") class TestBase(unittest2.TestCase): """This LLDB abstract base class is meant to be subclassed.""" |

