# HG changeset patch # User Dave Townsend # Date 1533741082 0 # Node ID ff3a0784588f2cb5aaa84e8d6a2a3677a5e52930 # Parent 570f3c07aa2c1768e15f04bc469629c31715b655 Bug 1481555: Use lldb's python API to summarise nsAtoms. r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D2894 diff --git a/.lldbinit b/.lldbinit --- a/.lldbinit +++ b/.lldbinit @@ -16,16 +16,13 @@ script topsrcdir = topsrcdir if locals() # See http://lldb.llvm.org/troubleshooting.html for more info. settings set target.inline-breakpoint-strategy always # Show the dynamic type of an object when using "expr". This, for example, # will show a variable declared as "nsIFrame *" that points to an nsBlockFrame # object as being of type "nsBlockFrame *" rather than "nsIFrame *". settings set target.prefer-dynamic-value run-target -# Show the string value in atoms. -type summary add nsIAtom --summary-string "${var.mString}" - # Show the value of text nodes. type summary add nsTextNode --summary-string "${var.mText}" # Dump the current JS stack. command alias js expr DumpJSStack() diff --git a/third_party/python/lldbutils/lldbutils/general.py b/third_party/python/lldbutils/lldbutils/general.py --- a/third_party/python/lldbutils/lldbutils/general.py +++ b/third_party/python/lldbutils/lldbutils/general.py @@ -1,16 +1,22 @@ import lldb from lldbutils import utils def summarize_string(valobj, internal_dict): data = valobj.GetChildMemberWithName("mData") length = valobj.GetChildMemberWithName("mLength").GetValueAsUnsigned(0) return utils.format_string(data, length) +def summarize_atom(valobj, internal_dict): + target = lldb.debugger.GetSelectedTarget() + length = valobj.GetChildMemberWithName("mLength").GetValueAsUnsigned() + string = target.EvaluateExpression("(char16_t*)%s.GetUTF16String()" % valobj.GetName()) + return utils.format_string(string, length) + class TArraySyntheticChildrenProvider: def __init__(self, valobj, internal_dict): self.valobj = valobj self.header = self.valobj.GetChildMemberWithName("mHdr") self.element_type = self.valobj.GetType().GetTemplateArgumentType(0) self.element_size = self.element_type.GetByteSize() header_size = self.header.GetType().GetPointeeType().GetByteSize() self.element_base_addr = self.header.GetValueAsUnsigned(0) + header_size @@ -93,13 +99,14 @@ def callfunc(debugger, command, result, def init(debugger): debugger.HandleCommand("type summary add nsAString -F lldbutils.general.summarize_string") debugger.HandleCommand("type summary add nsACString -F lldbutils.general.summarize_string") debugger.HandleCommand("type summary add nsFixedString -F lldbutils.general.summarize_string") debugger.HandleCommand("type summary add nsFixedCString -F lldbutils.general.summarize_string") debugger.HandleCommand("type summary add nsAutoString -F lldbutils.general.summarize_string") debugger.HandleCommand("type summary add nsAutoCString -F lldbutils.general.summarize_string") + debugger.HandleCommand("type summary add nsIAtom -F lldbutils.general.summarize_atom") debugger.HandleCommand("type synthetic add -x \"nsTArray<\" -l lldbutils.general.TArraySyntheticChildrenProvider") debugger.HandleCommand("type synthetic add -x \"AutoTArray<\" -l lldbutils.general.TArraySyntheticChildrenProvider") debugger.HandleCommand("type synthetic add -x \"FallibleTArray<\" -l lldbutils.general.TArraySyntheticChildrenProvider") debugger.HandleCommand("command script add -f lldbutils.general.prefcnt -f lldbutils.general.prefcnt prefcnt") debugger.HandleCommand("command script add -f lldbutils.general.callfunc -f lldbutils.general.callfunc callfunc")