js/src/gdb/mozilla/autoload.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/gdb/mozilla/autoload.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,27 @@
     1.4 +# mozilla/autoload.py: Autoload SpiderMonkey pretty-printers.
     1.5 +
     1.6 +print "Loading JavaScript value pretty-printers; see js/src/gdb/README."
     1.7 +print "If they cause trouble, type: disable pretty-printer .* SpiderMonkey"
     1.8 +
     1.9 +import gdb.printing
    1.10 +import mozilla.prettyprinters
    1.11 +
    1.12 +# Import the pretty-printer modules. As a side effect, loading these
    1.13 +# modules registers their printers with mozilla.prettyprinters.
    1.14 +import mozilla.jsid
    1.15 +import mozilla.JSObject
    1.16 +import mozilla.JSString
    1.17 +import mozilla.jsval
    1.18 +import mozilla.Root
    1.19 +
    1.20 +# The user may have personal pretty-printers. Get those, too, if they exist.
    1.21 +try:
    1.22 +    import my_mozilla_printers
    1.23 +except ImportError:
    1.24 +    pass
    1.25 +
    1.26 +# Register our pretty-printers with |objfile|.
    1.27 +def register(objfile):
    1.28 +    lookup = mozilla.prettyprinters.lookup_for_objfile(objfile)
    1.29 +    if lookup:
    1.30 +        gdb.printing.register_pretty_printer(objfile, lookup, replace=True)

mercurial