diff options
author | Enrico Granata <egranata@apple.com> | 2012-02-29 03:28:49 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2012-02-29 03:28:49 +0000 |
commit | 7bc0ec3aad663a2c81fddf9da38dba46bba6be19 (patch) | |
tree | 3c6cb745570d4095b37a18dd0f6cbacf04e79eaf /lldb/examples/summaries/cocoa/CFDictionary.py | |
parent | 3203f6b9daa558443f406686522780d0271d7824 (diff) | |
download | bcm5719-llvm-7bc0ec3aad663a2c81fddf9da38dba46bba6be19.tar.gz bcm5719-llvm-7bc0ec3aad663a2c81fddf9da38dba46bba6be19.zip |
This commit:
a) adds a Python summary provider for NSDate
b) changes the initialization for ScriptInterpreter so that we are not passing a bulk of Python-specific function pointers around
c) provides a new ScriptInterpreterObject class that allows for ref-count safe wrapping of scripting objects on the C++ side
d) contains much needed performance improvements:
1) the pointer to the Python function generating a scripted summary is now cached instead of looked up every time
2) redundant memory reads in the Python ObjC runtime wrapper are eliminated
3) summaries now use the m_summary_str in ValueObject to store their data instead of passing around ( == copying) an std::string object
e) contains other minor fixes, such as adding descriptive error messages for some cases of summary generation failure
llvm-svn: 151703
Diffstat (limited to 'lldb/examples/summaries/cocoa/CFDictionary.py')
-rw-r--r-- | lldb/examples/summaries/cocoa/CFDictionary.py | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/lldb/examples/summaries/cocoa/CFDictionary.py b/lldb/examples/summaries/cocoa/CFDictionary.py index 944e05aca59..5bd9e690b36 100644 --- a/lldb/examples/summaries/cocoa/CFDictionary.py +++ b/lldb/examples/summaries/cocoa/CFDictionary.py @@ -15,7 +15,7 @@ statistics.add_metric('code_notrun') # obey the interface specification for synthetic children providers class NSCFDictionary_SummaryProvider: def adjust_for_architecture(self): - self.lp64 = (self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8) + self.is_64_bit = (self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8) self.is_little = (self.valobj.GetTarget().GetProcess().GetByteOrder() == lldb.eByteOrderLittle) self.pointer_size = self.valobj.GetTarget().GetProcess().GetAddressByteSize() @@ -26,7 +26,7 @@ class NSCFDictionary_SummaryProvider: def update(self): self.adjust_for_architecture(); self.id_type = self.valobj.GetType().GetBasicType(lldb.eBasicTypeObjCID) - if self.lp64: + if self.is_64_bit: self.NSUInteger = self.valobj.GetType().GetBasicType(lldb.eBasicTypeUnsignedLong) else: self.NSUInteger = self.valobj.GetType().GetBasicType(lldb.eBasicTypeUnsignedInt) @@ -36,7 +36,7 @@ class NSCFDictionary_SummaryProvider: # the description of __CFDictionary is not readily available so most # of this is guesswork, plain and simple def offset(self): - if self.lp64: + if self.is_64_bit: return 20 else: return 12 @@ -50,7 +50,7 @@ class NSCFDictionary_SummaryProvider: class NSDictionaryI_SummaryProvider: def adjust_for_architecture(self): - self.lp64 = (self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8) + self.is_64_bit = (self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8) self.is_little = (self.valobj.GetTarget().GetProcess().GetByteOrder() == lldb.eByteOrderLittle) self.pointer_size = self.valobj.GetTarget().GetProcess().GetAddressByteSize() @@ -61,14 +61,14 @@ class NSDictionaryI_SummaryProvider: def update(self): self.adjust_for_architecture(); self.id_type = self.valobj.GetType().GetBasicType(lldb.eBasicTypeObjCID) - if self.lp64: + if self.is_64_bit: self.NSUInteger = self.valobj.GetType().GetBasicType(lldb.eBasicTypeUnsignedLong) else: self.NSUInteger = self.valobj.GetType().GetBasicType(lldb.eBasicTypeUnsignedInt) # we just need to skip the ISA and the count immediately follows def offset(self): - if self.lp64: + if self.is_64_bit: return 8 else: return 4 @@ -79,19 +79,18 @@ class NSDictionaryI_SummaryProvider: self.NSUInteger) value = num_children_vo.GetValueAsUnsigned(0) if value != None: - # the MSB on immutable dictionaries seems to be taken by the LSB of capacity - # not sure if it is a bug or some weird sort of feature, but masking it out - # gets the count right (unless, of course, someone's dictionaries grow - # too large - but I have not tested this) - if self.lp64: - value = value & ~0xFF00000000000000 + # the MS6bits on immutable dictionaries seem to be taken by the LSB of capacity + # not sure if it is a bug or some weird sort of feature, but masking that out + # gets the count right + if self.is_64_bit: + value = value & ~0xFC00000000000000 else: - value = value & ~0xFF000000 + value = value & ~0xFC000000 return value class NSDictionaryM_SummaryProvider: def adjust_for_architecture(self): - self.lp64 = (self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8) + self.is_64_bit = (self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8) self.is_little = (self.valobj.GetTarget().GetProcess().GetByteOrder() == lldb.eByteOrderLittle) self.pointer_size = self.valobj.GetTarget().GetProcess().GetAddressByteSize() @@ -102,14 +101,14 @@ class NSDictionaryM_SummaryProvider: def update(self): self.adjust_for_architecture(); self.id_type = self.valobj.GetType().GetBasicType(lldb.eBasicTypeObjCID) - if self.lp64: + if self.is_64_bit: self.NSUInteger = self.valobj.GetType().GetBasicType(lldb.eBasicTypeUnsignedLong) else: self.NSUInteger = self.valobj.GetType().GetBasicType(lldb.eBasicTypeUnsignedInt) # we just need to skip the ISA and the count immediately follows def offset(self): - if self.lp64: + if self.is_64_bit: return 8 else: return 4 @@ -118,12 +117,21 @@ class NSDictionaryM_SummaryProvider: num_children_vo = self.valobj.CreateChildAtOffset("count", self.offset(), self.NSUInteger) - return num_children_vo.GetValueAsUnsigned(0) + value = num_children_vo.GetValueAsUnsigned(0) + if value != None: + # the MS6bits on mutable dictionaries seem to be taken by flags for + # KVO and probably other features. however, masking it out does get + # the count right + if self.is_64_bit: + value = value & ~0xFC00000000000000 + else: + value = value & ~0xFC000000 + return value class NSDictionaryUnknown_SummaryProvider: def adjust_for_architecture(self): - self.lp64 = (self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8) + self.is_64_bit = (self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8) self.is_little = (self.valobj.GetTarget().GetProcess().GetByteOrder() == lldb.eByteOrderLittle) self.pointer_size = self.valobj.GetTarget().GetProcess().GetAddressByteSize() @@ -198,7 +206,7 @@ def CFDictionary_SummaryProvider2 (valobj,dict): if summary == None: summary = 'no valid dictionary here' # needed on OSX Mountain Lion - elif provider.lp64: + elif provider.is_64_bit: summary = int(summary) & ~0x0f1f000000000000 return str(summary) + " key/value pairs" return '' |