From 6b92f8c14a58b87191de0055942b935c061834cc Mon Sep 17 00:00:00 2001 From: Wei-Cheng Pan Date: Mon, 29 Aug 2016 18:27:42 +0800 Subject: [PATCH] Bug 1298775 - Support mozilla::StyleSheetHandle::RefPtr in gdb pretty printer. r=tbsaunde MozReview-Commit-ID: 77jCHNGbFZ4 --HG-- extra : rebase_source : 2c5b907c9bdd319a64df217825b105a077abe547 --- python/gdbpp/gdbpp/smartptr.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/python/gdbpp/gdbpp/smartptr.py b/python/gdbpp/gdbpp/smartptr.py index 7ec1cd365f3d..958b31eb9bea 100644 --- a/python/gdbpp/gdbpp/smartptr.py +++ b/python/gdbpp/gdbpp/smartptr.py @@ -40,3 +40,24 @@ class smartptr_printer(object): type_name = str(self.value.dereference().dynamic_type.pointer()) return '[(%s) %s]' % (type_name, str(self.value)) + +@GeckoPrettyPrinter('mozilla::StyleSheetHandle::RefPtr', '^mozilla::HandleRefPtr$') +class sheetptr_printer(object): + def __init__(self, value): + self.value = value['mHandle'] + if self.value and self.value['mPtr'] and self.value['mPtr']['mValue']: + self.value = self.value['mPtr']['mValue'] + + def to_string(self): + if not self.value: + type_name = str(self.value.type) + value = 0 + else: + value = int(self.value) + if value & 0x1: + value = value & ~0x1 + type_name = 'mozilla::ServoStyleSheet *' + else: + type_name = 'mozilla::CSSStyleSheet *' + + return '[(%s) %s]' % (type_name, hex(value))