 Chromium Code Reviews
 Chromium Code Reviews Issue 978123002:
  More useful prettyprinting for RefPtr/OwnPtr/DataRef.  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk
    
  
    Issue 978123002:
  More useful prettyprinting for RefPtr/OwnPtr/DataRef.  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk| Index: Tools/gdb/webkit.py | 
| diff --git a/Tools/gdb/webkit.py b/Tools/gdb/webkit.py | 
| index 77d411abd7ec98ba0e925286cf7cbddae505a63f..2ef488c0f727d330f218ef227586912d24a7a9b3 100644 | 
| --- a/Tools/gdb/webkit.py | 
| +++ b/Tools/gdb/webkit.py | 
| @@ -345,6 +345,36 @@ class WTFVectorPrinter: | 
| def display_hint(self): | 
| return 'array' | 
| + | 
| +# Copied from //tools/gdb/gdb_chrome.py | 
| +def typed_ptr(ptr): | 
| + """Prints a pointer along with its exact type. | 
| + | 
| + By default, gdb would print just the address, which takes more | 
| + steps to interpret. | 
| + """ | 
| + # Returning this as a cast expression surrounded by parentheses | 
| + # makes it easier to cut+paste inside of gdb. | 
| + return '((%s)%s)' % (ptr.dynamic_type, ptr) | 
| + | 
| + | 
| +class WTFRefOrOwnPtrPrinter: | 
| + def __init__(self, val): | 
| + self.val = val | 
| + | 
| + def to_string(self): | 
| + type_without_param = re.sub(r'<.*>', '', self.val.type.name) | 
| + return '%s%s' % (type_without_param, typed_ptr(self.val['m_ptr'])) | 
| + | 
| + | 
| +class BlinkDataRefPrinter: | 
| + def __init__(self, val): | 
| + self.val = val | 
| + | 
| + def to_string(self): | 
| + return 'DataRef(%s)' % WTFRefOrOwnPtrPrinter(self.val['m_data']).to_string() | 
| 
tony
2015/03/05 01:54:10
nit: 80 cols
 
cbiesinger
2015/03/05 02:05:06
Done.
 | 
| + | 
| + | 
| def add_pretty_printers(): | 
| pretty_printers = ( | 
| (re.compile("^WTF::Vector<.*>$"), WTFVectorPrinter), | 
| @@ -359,6 +389,8 @@ def add_pretty_printers(): | 
| (re.compile("^blink::QualifiedName$"), blinkQualifiedNamePrinter), | 
| (re.compile("^blink::PixelsAndPercent$"), BlinkPixelsAndPercentPrinter), | 
| (re.compile("^blink::Length$"), BlinkLengthPrinter), | 
| + (re.compile("^WTF::(Ref|Own)Ptr<.*>$"), WTFRefOrOwnPtrPrinter), | 
| + (re.compile("^blink::DataRef<.*>$"), BlinkDataRefPrinter), | 
| ) | 
| def lookup_function(val): |