Commit 1bcea834 authored by Stefan Zager's avatar Stefan Zager Committed by Commit Bot

Add gdb pretty printers for JSON values and cc::PaintOpBuffer

Change-Id: Iaa04227763c118fc285ee1e9bf4cc3bd32329ff8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2092935Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Commit-Queue: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748285}
parent 6b57a75f
...@@ -360,6 +360,23 @@ class BlinkDataRefPrinter: ...@@ -360,6 +360,23 @@ class BlinkDataRefPrinter:
return 'DataRef(%s)' % (str(self.val['data_'])) return 'DataRef(%s)' % (str(self.val['data_']))
class BlinkJSONValuePrinter:
def __init__(self, val):
self.val = val
def to_string(self):
s = str(gdb.parse_and_eval("((blink::JSONValue*) %s)->ToPrettyJSONString().Utf8(0)" % self.val.address))
return s.replace("\\n", "\n").replace('\\"', '"')
class CcPaintOpBufferPrinter:
def __init__(self, val):
self.val = val
def to_string(self):
return gdb.parse_and_eval("blink::RecordAsJSON(*((cc::PaintOpBuffer*) %s))" % self.val.address)
def add_pretty_printers(): def add_pretty_printers():
pretty_printers = ( pretty_printers = (
(re.compile("^WTF::Vector<.*>$"), WTFVectorPrinter), (re.compile("^WTF::Vector<.*>$"), WTFVectorPrinter),
...@@ -374,6 +391,12 @@ def add_pretty_printers(): ...@@ -374,6 +391,12 @@ def add_pretty_printers():
(re.compile("^blink::PixelsAndPercent$"), BlinkPixelsAndPercentPrinter), (re.compile("^blink::PixelsAndPercent$"), BlinkPixelsAndPercentPrinter),
(re.compile("^blink::Length$"), BlinkLengthPrinter), (re.compile("^blink::Length$"), BlinkLengthPrinter),
(re.compile("^blink::DataRef<.*>$"), BlinkDataRefPrinter), (re.compile("^blink::DataRef<.*>$"), BlinkDataRefPrinter),
(re.compile("^blink::JSONValue$"), BlinkJSONValuePrinter),
(re.compile("^blink::JSONBasicValue$"), BlinkJSONValuePrinter),
(re.compile("^blink::JSONString$"), BlinkJSONValuePrinter),
(re.compile("^blink::JSONObject$"), BlinkJSONValuePrinter),
(re.compile("^blink::JSONArray$"), BlinkJSONValuePrinter),
(re.compile("^cc::PaintOpBuffer$"), CcPaintOpBufferPrinter),
) )
def lookup_function(val): def lookup_function(val):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment