llvm.org GIT mirror llvm / 7994959
Simplify the SmallVector pretty printer for LLDB a bit and make it work with reference types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167674 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 8 years ago
1 changed file(s) with 9 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
11 Load into LLDB with:
22 script import lldbDataFormatters
33 type synthetic add -x "^llvm::SmallVectorImpl<.+>$" -l lldbDataFormatters.SmallVectorSynthProvider
4 type synthetic add -x "^llvm::SmallVector<.+,.+>$" -l lldbDataFormatters.SmallVectorSynthProvider
45 """
56
67 # Pretty printer for llvm::SmallVector/llvm::SmallVectorImpl
3132 return self.begin.CreateChildAtOffset('['+str(index)+']',
3233 offset, self.data_type)
3334
34 def get_type_from_name(self):
35 import re
36 name = self.valobj.GetType().GetName()
37 # This class works with both SmallVectors and SmallVectorImpls.
38 res = re.match("^(llvm::)?SmallVectorImpl<(.+)>$", name)
39 if res:
40 return res.group(2)
41 res = re.match("^(llvm::)?SmallVector<(.+), \d+>$", name)
42 if res:
43 return res.group(2)
44 return None
45
4635 def update(self):
4736 self.begin = self.valobj.GetChildMemberWithName('BeginX')
4837 self.end = self.valobj.GetChildMemberWithName('EndX')
49 data_type = self.get_type_from_name()
50 # FIXME: this sometimes returns an invalid type.
51 self.data_type = self.valobj.GetTarget().FindFirstType(data_type)
38 the_type = self.valobj.GetType()
39 # If this is a reference type we have to dereference it to get to the
40 # template parameter.
41 if the_type.IsReferenceType():
42 the_type = the_type.GetDereferencedType()
43
44 self.data_type = the_type.GetTemplateArgumentType(0)
5245 self.type_size = self.data_type.GetByteSize()
46 assert self.type_size != 0