Skip to content

Commit

Permalink
Bug 959016 - Add lldb Python command handlers for debugging Gecko, st…
Browse files Browse the repository at this point in the history
…arting with frametree and frametreelimited. (DONTBUILD) r=ehsan
  • Loading branch information
heycam committed Jan 13, 2014
1 parent 71a7b66 commit 7a2dc7c
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .lldbinit
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ settings set target.inline-breakpoint-strategy always
# 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()
6 changes: 6 additions & 0 deletions layout/generic/nsFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5374,6 +5374,12 @@ nsIFrame::DumpFrameTree()
RootFrameList(PresContext(), stdout, 0);
}

void
nsIFrame::DumpFrameTreeLimited()
{
List(stdout, 0);
}

void
nsIFrame::RootFrameList(nsPresContext* aPresContext, FILE* out, int32_t aIndent)
{
Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsIFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -3261,6 +3261,7 @@ NS_PTR_TO_INT32(frame->Properties().Get(nsIFrame::ParagraphDepthProperty()))
static void RootFrameList(nsPresContext* aPresContext,
FILE* out, int32_t aIndent);
virtual void DumpFrameTree();
void DumpFrameTreeLimited();

NS_IMETHOD GetFrameName(nsAString& aResult) const = 0;
#endif
Expand Down
12 changes: 12 additions & 0 deletions python/lldbutils/README.txt
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 7 additions & 0 deletions python/lldbutils/lldbutils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import lldb

__all__ = ['layout']

def init():
for name in __all__:
__import__('lldbutils.' + name, globals(), locals(), ['init']).init(lldb.debugger)
15 changes: 15 additions & 0 deletions python/lldbutils/lldbutils/layout.py
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit 7a2dc7c

Please sign in to comment.