o Added a test case for array_types which uses the Python APIs from lldb.py,

with the only exception of launching the process from SBTarget which is under
  investigation.

o build-swig-Python.sh should also checks the timestamp of ${swig_input_file}
  for update eligibility.  Also, once an update is in order, there's no need
  to check the remaining header files for timestamps.

o Coaches swig to treat StopReason as an int type, instead of a C++ class.

llvm-svn: 112210
This commit is contained in:
Johnny Chen
2010-08-26 20:04:17 +00:00
parent 4fcc97f2f9
commit 5fca8ca8cd
4 changed files with 104 additions and 2 deletions

View File

@@ -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],,'`

View File

@@ -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"

View File

@@ -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

View File

@@ -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."""