-
Notifications
You must be signed in to change notification settings - Fork 803
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from facebook/componentkit
Add pcomponents/dcomponents/rcomponents for debugging in ComponentKit
- Loading branch information
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/usr/bin/python | ||
|
||
import os | ||
|
||
import lldb | ||
import fblldbbase as fb | ||
|
||
def lldbinit(): | ||
# Tell LLDB to print CKComponentAction as a c-string | ||
lldb.debugger.HandleCommand('type summary add --summary-string "${var%c-string}" CKComponentAction') | ||
|
||
def lldbcommands(): | ||
return [ | ||
FBComponentsDebugCommand(), | ||
FBComponentsPrintCommand(), | ||
FBComponentsReflowCommand(), | ||
] | ||
|
||
|
||
class FBComponentsDebugCommand(fb.FBCommand): | ||
def name(self): | ||
return 'dcomponents' | ||
|
||
def description(self): | ||
return 'Set debugging options for components.' | ||
|
||
def options(self): | ||
return [ | ||
fb.FBCommandArgument(short='-s', long='--set', arg='set', help='Set debug mode for components', boolean=True), | ||
fb.FBCommandArgument(short='-u', long='--unset', arg='unset', help='Unset debug mode for components', boolean=True), | ||
] | ||
|
||
def run(self, arguments, options): | ||
if options.set: | ||
lldb.debugger.HandleCommand('expr (void)[CKComponentDebugController setDebugMode:YES]') | ||
print 'Debug mode for ComponentKit has been set.' | ||
elif options.unset: | ||
lldb.debugger.HandleCommand('expr (void)[CKComponentDebugController setDebugMode:NO]') | ||
print 'Debug mode for ComponentKit has been unset.' | ||
else: | ||
print 'No option for ComponentKit Debug mode specified.' | ||
|
||
class FBComponentsPrintCommand(fb.FBCommand): | ||
def name(self): | ||
return 'pcomponents' | ||
|
||
def description(self): | ||
return 'Print a recursive description of components found starting from <aView>.' | ||
|
||
def options(self): | ||
return [ fb.FBCommandArgument(short='-u', long='--up', arg='upwards', boolean=True, default=False, help='Print only the component hierarchy found on the first superview that has them, carrying the search up to its window.') ] | ||
|
||
def args(self): | ||
return [ fb.FBCommandArgument(arg='aView', type='UIView*', help='The view to from which the search for components begins.', default='(id)[[UIApplication sharedApplication] keyWindow]') ] | ||
|
||
def run(self, arguments, options): | ||
upwards = 'NO' | ||
if options.upwards: | ||
upwards = 'YES' | ||
|
||
lldb.debugger.HandleCommand('po (id)[CKComponentHierarchyDebugHelper componentHierarchyDescriptionForView:(UIView *)' + arguments[0] + ' searchUpwards:' + upwards + ']') | ||
|
||
class FBComponentsReflowCommand(fb.FBCommand): | ||
def name(self): | ||
return 'rcomponents' | ||
|
||
def description(self): | ||
return 'Synchronously reflow and update root components found starting from <aView>.' | ||
|
||
def options(self): | ||
return [ fb.FBCommandArgument(short='-u', long='--up', arg='upwards', boolean=True, default=False, help='Reflow only the root components found on the first superview that has them, carrying the search up to its window.') ] | ||
|
||
def args(self): | ||
return [ fb.FBCommandArgument(arg='aView', type='UIView*', help='The view to from which the search for the root components begins.', default='(id)[[UIApplication sharedApplication] keyWindow]') ] | ||
|
||
def run(self, arguments, options): | ||
upwards = 'NO' | ||
if options.upwards: | ||
upwards = 'YES' | ||
|
||
lldb.debugger.HandleCommand('e (void)[CKComponentDebugController reflowComponentsForView:(UIView *)' + arguments[0] + ' searchUpwards:' + upwards + ']') |