diff options
author | Stephen Hines <srhines@google.com> | 2014-12-01 14:51:49 -0800 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-12-02 16:08:10 -0800 |
commit | 37ed9c199ca639565f6ce88105f9e39e898d82d0 (patch) | |
tree | 8fb36d3910e3ee4c4e1b7422f4f017108efc52f5 /utils/lldbDataFormatters.py | |
parent | d2327b22152ced7bc46dc629fc908959e8a52d03 (diff) | |
download | external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.zip external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.gz external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.bz2 |
Update aosp/master LLVM for rebase to r222494.
Change-Id: Ic787f5e0124df789bd26f3f24680f45e678eef2d
Diffstat (limited to 'utils/lldbDataFormatters.py')
-rw-r--r-- | utils/lldbDataFormatters.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/utils/lldbDataFormatters.py b/utils/lldbDataFormatters.py index 352448d..f570fb4 100644 --- a/utils/lldbDataFormatters.py +++ b/utils/lldbDataFormatters.py @@ -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 |