Add BasicFormatter and ChildVisitingFormatter utility classes to the lldbutil.py module

which provide some convenient ways to print an SBValue object.  Use that in TestValueAPI.py
to print the 'days_of_week' char* array variable.

For an example:

cvf = lldbutil.ChildVisitingFormatter(indent=2)
print cvf.format(days_of_week)

produces:

(const char *[7]) days_of_week = 0x00000001026a5060 (location)
  (const char *) [0] = "Sunday"
  (const char *) [1] = "Monday"
  (const char *) [2] = "Tuesday"
  (const char *) [3] = "Wednesday"
  (const char *) [4] = "Thursday"
  (const char *) [5] = "Friday"
  (const char *) [6] = "Saturday"

llvm-svn: 135736
This commit is contained in:
Johnny Chen
2011-07-22 00:47:58 +00:00
parent 1eb27ae580
commit 989b7efd8a
3 changed files with 44 additions and 0 deletions

View File

@@ -66,6 +66,12 @@ class ValueAPITestCase(TestBase):
self.assertTrue(days_of_week.GetNumChildren() == 7, VALID_VARIABLE)
self.DebugSBValue(days_of_week)
fmt = lldbutil.BasicFormatter()
cvf = lldbutil.ChildVisitingFormatter(indent=2)
if self.TraceOn():
print fmt.format(days_of_week)
print cvf.format(days_of_week)
# Get variable 'str_ptr'.
value = frame0.FindVariable('str_ptr')
self.assertTrue(value, VALID_VARIABLE)