Exemplo n.º 1
0
def prefcnt(debugger, command, result, dict):
    """Displays the refcount of an object."""
    # We handled regular nsISupports-like refcounted objects and cycle collected
    # objects.
    target = debugger.GetSelectedTarget()
    process = target.GetProcess()
    thread = process.GetSelectedThread()
    frame = thread.GetSelectedFrame()
    obj = frame.EvaluateExpression(command)
    if obj.GetError().Fail():
        print "could not evaluate expression"
        return
    obj = utils.dereference(obj)
    field = obj.GetChildMemberWithName("mRefCnt")
    if field.GetError().Fail():
        field = obj.GetChildMemberWithName("refCnt")
    if field.GetError().Fail():
        print "not a refcounted object"
        return
    refcnt_type = field.GetType().GetCanonicalType().GetName()
    if refcnt_type == "nsAutoRefCnt":
        print field.GetChildMemberWithName("mValue").GetValueAsUnsigned(0)
    elif refcnt_type == "nsCycleCollectingAutoRefCnt":
        print field.GetChildMemberWithName(
            "mRefCntAndFlags").GetValueAsUnsigned(0) >> 2
    elif refcnt_type == "mozilla::ThreadSafeAutoRefCnt":
        print field.GetChildMemberWithName("mValue").GetChildMemberWithName(
            "mValue").GetValueAsUnsigned(0)
    elif refcnt_type == "int":  # non-atomic mozilla::RefCounted object
        print field.GetValueAsUnsigned(0)
    elif refcnt_type == "mozilla::Atomic<int>":  # atomic mozilla::RefCounted object
        print field.GetChildMemberWithName("mValue").GetValueAsUnsigned(0)
    else:
        print "unknown mRefCnt type " + refcnt_type
Exemplo n.º 2
0
def prefcnt(debugger, command, result, dict):
    """Displays the refcount of an object."""
    # We handled regular nsISupports-like refcounted objects and cycle collected
    # objects.
    target = debugger.GetSelectedTarget()
    process = target.GetProcess()
    thread = process.GetSelectedThread()
    frame = thread.GetSelectedFrame()
    obj = frame.EvaluateExpression(command)
    if obj.GetError().Fail():
        print "could not evaluate expression"
        return
    obj = utils.dereference(obj)
    field = obj.GetChildMemberWithName("mRefCnt")
    if field.GetError().Fail():
        field = obj.GetChildMemberWithName("refCnt")
    if field.GetError().Fail():
        print "not a refcounted object"
        return
    refcnt_type = field.GetType().GetCanonicalType().GetName()
    if refcnt_type == "nsAutoRefCnt":
        print field.GetChildMemberWithName("mValue").GetValueAsUnsigned(0)
    elif refcnt_type == "nsCycleCollectingAutoRefCnt":
        print field.GetChildMemberWithName("mRefCntAndFlags").GetValueAsUnsigned(0) >> 2
    elif refcnt_type == "mozilla::ThreadSafeAutoRefCnt":
        print field.GetChildMemberWithName("mValue").GetChildMemberWithName("mValue").GetValueAsUnsigned(0)
    elif refcnt_type == "int":  # non-atomic mozilla::RefCounted object
        print field.GetValueAsUnsigned(0)
    elif refcnt_type == "mozilla::Atomic<int>":  # atomic mozilla::RefCounted object
        print field.GetChildMemberWithName("mValue").GetValueAsUnsigned(0)
    else:
        print "unknown mRefCnt type " + refcnt_type