Bug 1481555: Use lldb's python API to summarise nsAtoms. r=froydnj
authorDave Townsend <dtownsend@oxymoronical.com>
Wed, 08 Aug 2018 15:11:22 +0000
changeset 430547 ff3a0784588f2cb5aaa84e8d6a2a3677a5e52930
parent 430546 a86f1df2608ce18a5381a3d49d988feda78de6af
child 430548 0064f1c26b4bda2db2ee811249475e84294a4413
push id34409
push usertoros@mozilla.com
push dateThu, 09 Aug 2018 10:00:05 +0000
treeherdermozilla-central@eb9ff7de69ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1481555
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1481555: Use lldb's python API to summarise nsAtoms. r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D2894
.lldbinit
third_party/python/lldbutils/lldbutils/general.py
--- 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 nsAtom --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()
--- 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 nsAtom -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")