python/lldbutils/lldbutils/content.py
author Cameron McCormack <cam@mcc.id.au>
Thu, 16 Jan 2014 17:51:54 +1100
changeset 163659 fbb977ca1d5fa5d1450ccec580085523644d8f56
parent 163411 bb7af8904cac445e8d044d2e5b49748c64ec24a9
permissions -rw-r--r--
Bug 959921 - Add lldb command to print an Element's tag name. (DONTBUILD) r=ehsan

import lldb
from lldbutils import utils

def summarize_text_fragment(valobj, internal_dict):
    content_union = valobj.GetChildAtIndex(0)
    state_union = valobj.GetChildAtIndex(1).GetChildMemberWithName("mState")
    length = state_union.GetChildMemberWithName("mLength").GetValueAsUnsigned(0)
    if state_union.GetChildMemberWithName("mIs2b").GetValueAsUnsigned(0):
        field = "m2b"
    else:
        field = "m1b"
    ptr = content_union.GetChildMemberWithName(field)
    return utils.format_string(ptr, length)

def ptag(debugger, command, result, dict):
    """Displays the tag name of a content node."""
    debugger.HandleCommand("expr (" + command + ")->mNodeInfo.mRawPtr->mInner.mName")

def init(debugger):
    debugger.HandleCommand("type summary add nsTextFragment -F lldbutils.content.summarize_text_fragment")
    debugger.HandleCommand("command script add -f lldbutils.content.ptag ptag")