Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | # Pretty-printers for JSID values. |
michael@0 | 2 | |
michael@0 | 3 | import gdb |
michael@0 | 4 | import mozilla.prettyprinters |
michael@0 | 5 | import mozilla.Root |
michael@0 | 6 | |
michael@0 | 7 | from mozilla.prettyprinters import pretty_printer |
michael@0 | 8 | |
michael@0 | 9 | # Forget any printers from previous loads of this module. |
michael@0 | 10 | mozilla.prettyprinters.clear_module_printers(__name__) |
michael@0 | 11 | |
michael@0 | 12 | @pretty_printer('jsid') |
michael@0 | 13 | class jsid(object): |
michael@0 | 14 | # Since people don't always build with macro debugging info, I can't |
michael@0 | 15 | # think of any way to avoid copying these values here, short of using |
michael@0 | 16 | # inferior calls for every operation (which, I hear, is broken from |
michael@0 | 17 | # pretty-printers in some recent GDBs). |
michael@0 | 18 | TYPE_STRING = 0x0 |
michael@0 | 19 | TYPE_INT = 0x1 |
michael@0 | 20 | TYPE_VOID = 0x2 |
michael@0 | 21 | TYPE_OBJECT = 0x4 |
michael@0 | 22 | TYPE_MASK = 0x7 |
michael@0 | 23 | |
michael@0 | 24 | def __init__(self, value, cache): |
michael@0 | 25 | self.value = value |
michael@0 | 26 | self.cache = cache |
michael@0 | 27 | self.concrete_type = self.value.type.strip_typedefs() |
michael@0 | 28 | |
michael@0 | 29 | # SpiderMonkey has two alternative definitions of jsid: a typedef for |
michael@0 | 30 | # ptrdiff_t, and a struct with == and != operators defined on it. |
michael@0 | 31 | # Extract the bits from either one. |
michael@0 | 32 | def as_bits(self): |
michael@0 | 33 | if self.concrete_type.code == gdb.TYPE_CODE_STRUCT: |
michael@0 | 34 | return self.value['asBits'] |
michael@0 | 35 | elif self.concrete_type.code == gdb.TYPE_CODE_INT: |
michael@0 | 36 | return self.value |
michael@0 | 37 | else: |
michael@0 | 38 | raise RuntimeError, ("definition of SpiderMonkey 'jsid' type" |
michael@0 | 39 | "neither struct nor integral type") |
michael@0 | 40 | |
michael@0 | 41 | def to_string(self): |
michael@0 | 42 | bits = self.as_bits() |
michael@0 | 43 | tag = bits & jsid.TYPE_MASK |
michael@0 | 44 | if tag == jsid.TYPE_STRING: |
michael@0 | 45 | body = bits.cast(self.cache.JSString_ptr_t) |
michael@0 | 46 | elif tag & jsid.TYPE_INT: |
michael@0 | 47 | body = bits >> 1 |
michael@0 | 48 | elif tag == jsid.TYPE_VOID: |
michael@0 | 49 | return "JSID_VOID" |
michael@0 | 50 | elif tag == jsid.TYPE_OBJECT: |
michael@0 | 51 | body = ((bits & ~jsid.TYPE_MASK) |
michael@0 | 52 | .cast(self.cache.JSObject_ptr_t)) |
michael@0 | 53 | else: |
michael@0 | 54 | body = "<unrecognized>" |
michael@0 | 55 | return '$jsid(%s)' % (body,) |
michael@0 | 56 | |
michael@0 | 57 | # Hard-code the referent type pretty-printer for jsid roots and handles. |
michael@0 | 58 | # See the comment for mozilla.Root.Common.__init__. |
michael@0 | 59 | @pretty_printer('JS::Rooted<long>') |
michael@0 | 60 | def RootedJSID(value, cache): |
michael@0 | 61 | return mozilla.Root.Rooted(value, cache, jsid) |
michael@0 | 62 | @pretty_printer('JS::Handle<long>') |
michael@0 | 63 | def HandleJSID(value, cache): |
michael@0 | 64 | return mozilla.Root.Handle(value, cache, jsid) |
michael@0 | 65 | @pretty_printer('JS::MutableHandle<long>') |
michael@0 | 66 | def MutableHandleJSID(value, cache): |
michael@0 | 67 | return mozilla.Root.MutableHandle(value, cache, jsid) |