Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(914)

Unified Diff: Tools/gdb/webkit.py

Issue 978123002: More useful prettyprinting for RefPtr/OwnPtr/DataRef. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: line length Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Tools/gdb/webkit.py
diff --git a/Tools/gdb/webkit.py b/Tools/gdb/webkit.py
index 77d411abd7ec98ba0e925286cf7cbddae505a63f..f3d6efbb5d02094053daf37838076babcdd4fbdf 100644
--- a/Tools/gdb/webkit.py
+++ b/Tools/gdb/webkit.py
@@ -345,6 +345,37 @@ 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())
+
+
def add_pretty_printers():
pretty_printers = (
(re.compile("^WTF::Vector<.*>$"), WTFVectorPrinter),
@@ -359,6 +390,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):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698