Bug 959016 - Add lldb Python command handlers for debugging Gecko, starting with frametree and frametreelimited. (DONTBUILD) r=ehsan
authorCameron McCormack <cam@mcc.id.au>
Tue, 14 Jan 2014 09:24:22 +1100
changeset 179235 481e4766030eefc867a29701d37007c3796e696b
parent 179234 1a1968da61b32a7dee6f1c08c15f7de9e825ec77
child 179236 e2f3827a2f441cd3509b86c6546fd7617b0a5764
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs959016
milestone29.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 959016 - Add lldb Python command handlers for debugging Gecko, starting with frametree and frametreelimited. (DONTBUILD) r=ehsan
.lldbinit
layout/generic/nsFrame.cpp
layout/generic/nsIFrame.h
python/lldbutils/README.txt
python/lldbutils/lldbutils/__init__.py
python/lldbutils/lldbutils/layout.py
--- a/.lldbinit
+++ b/.lldbinit
@@ -4,8 +4,13 @@
 # single compiled file breaks lldb breakpoint setting. This works around that.
 # 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
+
+# Import the module that defines complex Gecko debugging commands.  Rather
+# than do any kind of searching, this assumes that you are running lldb from
+# the top level source directory.
+script sys.path.append('python/lldbutils'); import lldbutils; lldbutils.init()
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -5370,16 +5370,22 @@ nsFrame::MakeFrameName(const nsAString& 
 
 void
 nsIFrame::DumpFrameTree()
 {
   RootFrameList(PresContext(), stdout, 0);
 }
 
 void
+nsIFrame::DumpFrameTreeLimited()
+{
+  List(stdout, 0);
+}
+
+void
 nsIFrame::RootFrameList(nsPresContext* aPresContext, FILE* out, int32_t aIndent)
 {
   if (!aPresContext || !out)
     return;
 
   nsIPresShell *shell = aPresContext->GetPresShell();
   if (shell) {
     nsIFrame* frame = shell->FrameManager()->GetRootFrame();
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -3256,16 +3256,17 @@ public:
   virtual void List(FILE* out, int32_t aIndent, uint32_t aFlags = 0) const;
   /**
    * lists the frames beginning from the root frame
    * - calls root frame's List(...)
    */
   static void RootFrameList(nsPresContext* aPresContext,
                             FILE* out, int32_t aIndent);
   virtual void DumpFrameTree();
+  void DumpFrameTreeLimited();
 
   NS_IMETHOD  GetFrameName(nsAString& aResult) const = 0;
 #endif
 
 #ifdef DEBUG
 public:
   NS_IMETHOD_(nsFrameState)  GetDebugStateBits() const = 0;
   NS_IMETHOD  DumpRegressionData(nsPresContext* aPresContext,
new file mode 100644
--- /dev/null
+++ b/python/lldbutils/README.txt
@@ -0,0 +1,12 @@
+lldb debugging functionality for Gecko
+--------------------------------------
+
+This directory contains a module, lldbutils, which is imported by the
+in-tree .lldbinit file.  The lldbutil modules define some lldb commands
+that are handy for debugging Gecko.
+
+If you want to add a new command or Python-implemented type summary, either add
+it to one of the existing broad area Python files (such as lldbutils/layout.py
+for layout-related commands) or create a new file if none of the existing files
+is appropriate.  If you add a new file, make sure you add it to __all__ in
+lldbutils/__init__.py.
new file mode 100644
--- /dev/null
+++ b/python/lldbutils/lldbutils/__init__.py
@@ -0,0 +1,7 @@
+import lldb
+
+__all__ = ['layout']
+
+def init():
+    for name in __all__:
+        __import__('lldbutils.' + name, globals(), locals(), ['init']).init(lldb.debugger)
new file mode 100644
--- /dev/null
+++ b/python/lldbutils/lldbutils/layout.py
@@ -0,0 +1,15 @@
+import lldb
+
+def frametree(debugger, command, result, dict):
+    """Dumps the frame tree containing the given nsIFrame*."""
+    debugger.HandleCommand('expr (' + command + ')->DumpFrameTree()')
+
+def frametreelimited(debugger, command, result, dict):
+    """Dumps the subtree of a frame tree rooted at the given nsIFrame*."""
+    debugger.HandleCommand('expr (' + command + ')->DumpFrameTreeLimited()')
+
+def init(debugger):
+    debugger.HandleCommand('command script add -f lldbutils.layout.frametree frametree')
+    debugger.HandleCommand('command script add -f lldbutils.layout.frametree frametreelimited')
+    debugger.HandleCommand('command alias ft frametree')
+    debugger.HandleCommand('command alias ftl frametree')