mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-13 14:47:00 +00:00
utils: Teach lldbDataFormatters how to format ArrayRefs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217567 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
463a096177
commit
326018c0b3
@ -12,6 +12,9 @@ def __lldb_init_module(debugger, internal_dict):
|
||||
debugger.HandleCommand('type synthetic add -w llvm '
|
||||
'-l lldbDataFormatters.SmallVectorSynthProvider '
|
||||
'-x "^llvm::SmallVector<.+,.+>$"')
|
||||
debugger.HandleCommand('type synthetic add -w llvm '
|
||||
'-l lldbDataFormatters.ArrayRefSynthProvider '
|
||||
'-x "^llvm::ArrayRef<.+>$"')
|
||||
|
||||
# Pretty printer for llvm::SmallVector/llvm::SmallVectorImpl
|
||||
class SmallVectorSynthProvider:
|
||||
@ -53,3 +56,33 @@ class SmallVectorSynthProvider:
|
||||
self.data_type = the_type.GetTemplateArgumentType(0)
|
||||
self.type_size = self.data_type.GetByteSize()
|
||||
assert self.type_size != 0
|
||||
|
||||
class ArrayRefSynthProvider:
|
||||
""" Provider for llvm::ArrayRef """
|
||||
def __init__(self, valobj, dict):
|
||||
self.valobj = valobj;
|
||||
self.update() # initialize this provider
|
||||
|
||||
def num_children(self):
|
||||
return self.length
|
||||
|
||||
def get_child_index(self, name):
|
||||
try:
|
||||
return int(name.lstrip('[').rstrip(']'))
|
||||
except:
|
||||
return -1;
|
||||
|
||||
def get_child_at_index(self, index):
|
||||
if index < 0 or index >= self.num_children():
|
||||
return None;
|
||||
offset = index * self.type_size
|
||||
return self.data.CreateChildAtOffset('[' + str(index) + ']',
|
||||
offset, self.data_type)
|
||||
|
||||
def update(self):
|
||||
self.data = self.valobj.GetChildMemberWithName('Data')
|
||||
length_obj = self.valobj.GetChildMemberWithName('Length')
|
||||
self.length = length_obj.GetValueAsUnsigned(0)
|
||||
self.data_type = self.data.GetType().GetPointeeType()
|
||||
self.type_size = self.data_type.GetByteSize()
|
||||
assert self.type_size != 0
|
||||
|
Loading…
Reference in New Issue
Block a user