summaryrefslogtreecommitdiffstats
path: root/lldb/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py
diff options
context:
space:
mode:
authorEnrico Granata <granata.enrico@gmail.com>2011-08-04 02:34:29 +0000
committerEnrico Granata <granata.enrico@gmail.com>2011-08-04 02:34:29 +0000
commit5dfd49ccba48bbfcfdfccf01deb0c513d113b180 (patch)
tree163387d8cd6c6f8453621c0e5994e72c789ddf3e /lldb/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py
parent6fd87d5d33c677badffcab70b60e8dcc169de07e (diff)
downloadbcm5719-llvm-5dfd49ccba48bbfcfdfccf01deb0c513d113b180.tar.gz
bcm5719-llvm-5dfd49ccba48bbfcfdfccf01deb0c513d113b180.zip
New formatting symbol %# can be used in summary strings to get the "count of children" of a variable
- accordingly, the test cases for the synthetic providers for the std:: containers have been edited to use ${svar%#} instead of ${svar.len} to print out the count of elements ; the .len synthetic child has been removed from the synthetic providers The synthetic children providers for the std:: containers now return None when asked for children indexes >= num_children() Basic code to support filter names based on regular expressions (WIP) llvm-svn: 136862
Diffstat (limited to 'lldb/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py')
-rw-r--r--lldb/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py91
1 files changed, 44 insertions, 47 deletions
diff --git a/lldb/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py b/lldb/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py
index dc226902d1e..f2b3d442925 100644
--- a/lldb/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py
+++ b/lldb/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py
@@ -1,55 +1,52 @@
class StdVectorSynthProvider:
- def __init__(self, valobj, dict):
- self.valobj = valobj;
- self.update()
+ def __init__(self, valobj, dict):
+ self.valobj = valobj;
+ self.update()
- def num_children(self):
- start_val = self.start.GetValueAsUnsigned(0)
- finish_val = self.finish.GetValueAsUnsigned(0)
- end_val = self.end.GetValueAsUnsigned(0)
- # Before a vector has been constructed, it will contain bad values
- # so we really need to be careful about the length we return since
- # unitialized data can cause us to return a huge number. We need
- # to also check for any of the start, finish or end of storage values
- # being zero (NULL). If any are, then this vector has not been
- # initialized yet and we should return zero
+ def num_children(self):
+ start_val = self.start.GetValueAsUnsigned(0)
+ finish_val = self.finish.GetValueAsUnsigned(0)
+ end_val = self.end.GetValueAsUnsigned(0)
+ # Before a vector has been constructed, it will contain bad values
+ # so we really need to be careful about the length we return since
+ # unitialized data can cause us to return a huge number. We need
+ # to also check for any of the start, finish or end of storage values
+ # being zero (NULL). If any are, then this vector has not been
+ # initialized yet and we should return zero
- # Make sure nothing is NULL
- if start_val == 0 or finish_val == 0 or end_val == 0:
- return 0
- # Make sure start is less than finish
- if start_val >= finish_val:
- return 0
- # Make sure finish is less than or equal to end of storage
- if finish_val > end_val:
- return 0
+ # Make sure nothing is NULL
+ if start_val == 0 or finish_val == 0 or end_val == 0:
+ return 0
+ # Make sure start is less than finish
+ if start_val >= finish_val:
+ return 0
+ # Make sure finish is less than or equal to end of storage
+ if finish_val > end_val:
+ return 0
- # We might still get things wrong, so cap things at 256 items for now
- # TODO: read a target "settings set" variable for this to allow it to
- # be customized
- num_children = (finish_val-start_val)/self.data_size
- if num_children > 256:
- return 256
- return num_children
+ # We might still get things wrong, so cap things at 256 items for now
+ # TODO: read a target "settings set" variable for this to allow it to
+ # be customized
+ num_children = (finish_val-start_val)/self.data_size
+ if num_children > 256:
+ return 256
+ return num_children
- def get_child_index(self,name):
- if name == "len":
- return self.num_children();
- else:
- return int(name.lstrip('[').rstrip(']'))
+ def get_child_index(self,name):
+ return int(name.lstrip('[').rstrip(']'))
- def get_child_at_index(self,index):
- if index == self.num_children():
- return self.valobj.CreateValueFromExpression("len",str(self.num_children()))
- else:
- offset = index * self.data_size
- return self.start.CreateChildAtOffset('['+str(index)+']',offset,self.data_type)
+ def get_child_at_index(self,index):
+ if index >= self.num_children():
+ return None;
+ offset = index * self.data_size
+ return self.start.CreateChildAtOffset('['+str(index)+']',offset,self.data_type)
+
+ def update(self):
+ impl = self.valobj.GetChildMemberWithName('_M_impl')
+ self.start = impl.GetChildMemberWithName('_M_start')
+ self.finish = impl.GetChildMemberWithName('_M_finish')
+ self.end = impl.GetChildMemberWithName('_M_end_of_storage')
+ self.data_type = self.start.GetType().GetPointeeType()
+ self.data_size = self.data_type.GetByteSize()
- def update(self):
- impl = self.valobj.GetChildMemberWithName('_M_impl')
- self.start = impl.GetChildMemberWithName('_M_start')
- self.finish = impl.GetChildMemberWithName('_M_finish')
- self.end = impl.GetChildMemberWithName('_M_end_of_storage')
- self.data_type = self.start.GetType().GetPointeeType()
- self.data_size = self.data_type.GetByteSize()
OpenPOWER on IntegriCloud