From e1fec30415932dda2179ea8602aebee442de43c6 Mon Sep 17 00:00:00 2001 From: Bartosz Janda Date: Wed, 24 Dec 2014 22:05:34 +0100 Subject: [PATCH 01/11] Added 'slow' command. --- commands/FBDisplayCommands.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/commands/FBDisplayCommands.py b/commands/FBDisplayCommands.py index bd2b6ea..6d092b5 100644 --- a/commands/FBDisplayCommands.py +++ b/commands/FBDisplayCommands.py @@ -24,6 +24,7 @@ def lldbcommands(): FBUnmaskViewCommand(), FBShowViewCommand(), FBHideViewCommand(), + FBSlowAnimation() ] @@ -145,3 +146,17 @@ def args(self): def run(self, args, options): viewHelpers.setViewHidden(args[0], True) + + +class FBSlowAnimation(fb.FBCommand): + def name(self): + return 'slow' + + def description(self): + return 'Slows down animations. Works on the iOS Simulator and a device.' + + def args(self): + return [ fb.FBCommandArgument(arg='speed', type='float', default='1', help='Animation speed.') ] + + def run(self, args, option): + lldb.debugger.HandleCommand('expr [(CALayer *)[[[[UIApplication sharedApplication] windows] objectAtIndex:0] layer] setSpeed:(CGFloat)%s]' % (args[0])) From 72145be8a38417145abdc87657d6ebebfbae3057 Mon Sep 17 00:00:00 2001 From: weizhou Date: Wed, 14 Jan 2015 17:40:28 +0800 Subject: [PATCH 02/11] add ppath command Print application's 'Documents' directory path. --- commands/FBPrintCommands.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/commands/FBPrintCommands.py b/commands/FBPrintCommands.py index b9907c9..e483d14 100644 --- a/commands/FBPrintCommands.py +++ b/commands/FBPrintCommands.py @@ -29,6 +29,7 @@ def lldbcommands(): FBPrintInternals(), FBPrintInstanceVariable(), FBPrintKeyPath(), + FBPrintApplicationDocumentsPath(), ] class FBPrintViewHierarchyCommand(fb.FBCommand): @@ -299,3 +300,15 @@ def run(self, arguments, options): object = fb.evaluateObjectExpression(objectToMessage) printCommand = 'po [{} valueForKeyPath:@"{}"]'.format(object, keypath) lldb.debugger.HandleCommand(printCommand) + + +class FBPrintApplicationDocumentsPath(fb.FBCommand): + def name(self): + return 'ppath' + + def description(self): + return "Print application's 'Documents' directory path." + + def run(self, arguments, options): + lldb.debugger.HandleCommand('po [NSSearchPathForDirectoriesInDomains(9, 1, YES) lastObject]') # NSDocumentDirectory == 9 NSUserDomainMask == 1 + From ff0d7631def44d0d7a87d225261242cec0741759 Mon Sep 17 00:00:00 2001 From: weizhou Date: Thu, 15 Jan 2015 10:17:12 +0800 Subject: [PATCH 03/11] change command name --- commands/FBPrintCommands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/FBPrintCommands.py b/commands/FBPrintCommands.py index e483d14..28fc682 100644 --- a/commands/FBPrintCommands.py +++ b/commands/FBPrintCommands.py @@ -304,7 +304,7 @@ def run(self, arguments, options): class FBPrintApplicationDocumentsPath(fb.FBCommand): def name(self): - return 'ppath' + return 'pdocspath' def description(self): return "Print application's 'Documents' directory path." From e6e9f5198274f816b83ecfa4b12bc4e425d1f052 Mon Sep 17 00:00:00 2001 From: weizhou Date: Thu, 29 Jan 2015 01:18:07 +0800 Subject: [PATCH 04/11] option -o "open in finder" not fully tested yet --- commands/FBPrintCommands.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/commands/FBPrintCommands.py b/commands/FBPrintCommands.py index 28fc682..257bb1c 100644 --- a/commands/FBPrintCommands.py +++ b/commands/FBPrintCommands.py @@ -308,7 +308,19 @@ def name(self): def description(self): return "Print application's 'Documents' directory path." + + def options(self): + return [ + fb.FBCommandArgument(short='-o', long='--open', arg='open', boolean=True, default=False, help='open in Finder'), + ] def run(self, arguments, options): - lldb.debugger.HandleCommand('po [NSSearchPathForDirectoriesInDomains(9, 1, YES) lastObject]') # NSDocumentDirectory == 9 NSUserDomainMask == 1 + if options.open: + path = fb.evaluateExpressionValue('(NSString *)[NSSearchPathForDirectoriesInDomains(9, 1, YES) lastObject]') + pathString = '{}'.format(path).split('"')[1] + print pathString + lldb.debugger.HandleCommand('script os.system("open {}")'.format(pathString)) + else: + lldb.debugger.HandleCommand('po [NSSearchPathForDirectoriesInDomains(9, 1, YES) lastObject]') # NSDocumentDirectory == 9 NSUserDomainMask == 1 + From 1d47c554a75af678ff7bc5be57bad7688bc7e471 Mon Sep 17 00:00:00 2001 From: Bartosz Janda Date: Mon, 16 Feb 2015 19:41:26 +0100 Subject: [PATCH 05/11] Added 'slowanim' and 'unslowanim'. --- commands/FBDisplayCommands.py | 22 +++++++++++++++++----- fblldbviewhelpers.py | 3 +++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/commands/FBDisplayCommands.py b/commands/FBDisplayCommands.py index 6d092b5..18c26b6 100644 --- a/commands/FBDisplayCommands.py +++ b/commands/FBDisplayCommands.py @@ -24,7 +24,8 @@ def lldbcommands(): FBUnmaskViewCommand(), FBShowViewCommand(), FBHideViewCommand(), - FBSlowAnimation() + FBSlowAnimationCommand(), + FBUnslowAnimationCommand() ] @@ -148,15 +149,26 @@ def run(self, args, options): viewHelpers.setViewHidden(args[0], True) -class FBSlowAnimation(fb.FBCommand): +class FBSlowAnimationCommand(fb.FBCommand): def name(self): - return 'slow' + return 'slowanim' def description(self): return 'Slows down animations. Works on the iOS Simulator and a device.' def args(self): - return [ fb.FBCommandArgument(arg='speed', type='float', default='1', help='Animation speed.') ] + return [ fb.FBCommandArgument(arg='speed', type='float', help='Animation speed.') ] def run(self, args, option): - lldb.debugger.HandleCommand('expr [(CALayer *)[[[[UIApplication sharedApplication] windows] objectAtIndex:0] layer] setSpeed:(CGFloat)%s]' % (args[0])) + viewHelpers.slowAnimation(args[0]) + + +class FBUnslowAnimationCommand(fb.FBCommand): + def name(self): + return 'unslowanim' + + def description(self): + return 'Turn off slow animations.' + + def run(self, args, option): + viewHelpers.slowAnimation() \ No newline at end of file diff --git a/fblldbviewhelpers.py b/fblldbviewhelpers.py index 6e46aed..28dcf7b 100644 --- a/fblldbviewhelpers.py +++ b/fblldbviewhelpers.py @@ -87,3 +87,6 @@ def upwardsRecursiveDescription(view, maxDepth=0): currentPrefix += " | " return builder + +def slowAnimation(speed=1): + lldb.debugger.HandleCommand('expr -- for (UIWindow *$w in (NSArray *)[[UIApplication sharedApplication] windows]) { [[$w layer] setSpeed:(CGFloat)%s]; }' % (speed)) From cc42cbd1e1a47affe6b7b9511e4f18a82c52f20d Mon Sep 17 00:00:00 2001 From: Bartosz Janda Date: Tue, 17 Feb 2015 20:05:29 +0100 Subject: [PATCH 06/11] Changed default animation speed to 0.1. --- commands/FBDisplayCommands.py | 4 ++-- fblldbviewhelpers.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commands/FBDisplayCommands.py b/commands/FBDisplayCommands.py index 18c26b6..ac86854 100644 --- a/commands/FBDisplayCommands.py +++ b/commands/FBDisplayCommands.py @@ -157,7 +157,7 @@ def description(self): return 'Slows down animations. Works on the iOS Simulator and a device.' def args(self): - return [ fb.FBCommandArgument(arg='speed', type='float', help='Animation speed.') ] + return [ fb.FBCommandArgument(arg='speed', type='float', default=0.1, help='Animation speed (default 0.1).') ] def run(self, args, option): viewHelpers.slowAnimation(args[0]) @@ -171,4 +171,4 @@ def description(self): return 'Turn off slow animations.' def run(self, args, option): - viewHelpers.slowAnimation() \ No newline at end of file + viewHelpers.slowAnimation() diff --git a/fblldbviewhelpers.py b/fblldbviewhelpers.py index 28dcf7b..cf1ef0f 100644 --- a/fblldbviewhelpers.py +++ b/fblldbviewhelpers.py @@ -89,4 +89,4 @@ def upwardsRecursiveDescription(view, maxDepth=0): return builder def slowAnimation(speed=1): - lldb.debugger.HandleCommand('expr -- for (UIWindow *$w in (NSArray *)[[UIApplication sharedApplication] windows]) { [[$w layer] setSpeed:(CGFloat)%s]; }' % (speed)) + lldb.debugger.HandleCommand('expr (void)[[[UIApplication sharedApplication] windows] setValue:@(%s) forKeyPath:@"layer.speed"]' % speed) From f3119a6167e12dfb4612015b26030673c05236bc Mon Sep 17 00:00:00 2001 From: weizhou Date: Wed, 18 Mar 2015 00:06:07 +0800 Subject: [PATCH 07/11] refactor pdocspath --- commands/FBPrintCommands.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/commands/FBPrintCommands.py b/commands/FBPrintCommands.py index 257bb1c..c3e19de 100644 --- a/commands/FBPrintCommands.py +++ b/commands/FBPrintCommands.py @@ -315,12 +315,13 @@ def options(self): ] def run(self, arguments, options): + # in iOS SDK NSDocumentDirectory == 9 NSUserDomainMask == 1 + NSDocumentDirectory = '9' + NSUserDomainMask = '1' + path = fb.evaluateExpressionValue('(NSString*)[NSSearchPathForDirectoriesInDomains(' + NSDocumentDirectory + ', ' + NSUserDomainMask + ', YES) lastObject]') + pathString = '{}'.format(path).split('"')[1] + print pathString if options.open: - path = fb.evaluateExpressionValue('(NSString *)[NSSearchPathForDirectoriesInDomains(9, 1, YES) lastObject]') - pathString = '{}'.format(path).split('"')[1] - print pathString - lldb.debugger.HandleCommand('script os.system("open {}")'.format(pathString)) - else: - lldb.debugger.HandleCommand('po [NSSearchPathForDirectoriesInDomains(9, 1, YES) lastObject]') # NSDocumentDirectory == 9 NSUserDomainMask == 1 + os.system('open '+ pathString) From f833c0f4ce86e21289ced82050a5fe7dcdee6b85 Mon Sep 17 00:00:00 2001 From: Bartosz Janda Date: Mon, 23 Mar 2015 21:12:13 +0100 Subject: [PATCH 08/11] Added 'pdata' command to print content of NSData object. --- commands/FBPrintCommands.py | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/commands/FBPrintCommands.py b/commands/FBPrintCommands.py index b9907c9..bd5be5d 100644 --- a/commands/FBPrintCommands.py +++ b/commands/FBPrintCommands.py @@ -29,6 +29,7 @@ def lldbcommands(): FBPrintInternals(), FBPrintInstanceVariable(), FBPrintKeyPath(), + FBPrintData(), ] class FBPrintViewHierarchyCommand(fb.FBCommand): @@ -299,3 +300,74 @@ def run(self, arguments, options): object = fb.evaluateObjectExpression(objectToMessage) printCommand = 'po [{} valueForKeyPath:@"{}"]'.format(object, keypath) lldb.debugger.HandleCommand(printCommand) + +class FBPrintData(fb.FBCommand): + def name(self): + return 'pdata' + + def description(self): + return 'Print the contents of NSData object as string.\n' \ + 'Supported encodings:\n' \ + '- ascii,\n' \ + '- utf8,\n' \ + '- utf16, unicode,\n' \ + '- utf16l (Little endian),\n' \ + '- utf16b (Big endian),\n' \ + '- utf32,\n' \ + '- utf32l (Little endian),\n' \ + '- utf32b (Big endian),\n' \ + '- latin1, iso88591 (88591),\n' \ + '- latin2, iso88592 (88592),\n' \ + '- cp1251 (1251),\n' \ + '- cp1252 (1252),\n' \ + '- cp1253 (1253),\n' \ + '- cp1254 (1254),\n' \ + '- cp1250 (1250),' \ + + def options(self): + return [ + fb.FBCommandArgument(arg='encoding', short='-e', long='--encoding', type='string', help='Used encoding (default utf-8).', default='utf-8') + ] + + def args(self): + return [ + fb.FBCommandArgument(arg='data', type='NSData *', help='NSData object.') + ] + + def run(self, arguments, option): + # Normalize encoding. + encoding_text = option.encoding.lower().replace(' -', '') + enc = 4 # Default encoding UTF-8. + if encoding_text == 'ascii': + enc = 1 + elif encoding_text == 'utf8': + enc = 4 + elif encoding_text == 'latin1' or encoding_text == '88591' or encoding_text == 'iso88591': + enc = 5 + elif encoding_text == 'latin2' or encoding_text == '88592' or encoding_text == 'iso88592': + enc = 9 + elif encoding_text == 'unicode' or encoding_text == 'utf16': + enc = 10 + elif encoding_text == '1251' or encoding_text == 'cp1251': + enc = 11 + elif encoding_text == '1252' or encoding_text == 'cp1252': + enc = 12 + elif encoding_text == '1253' or encoding_text == 'cp1253': + enc = 13 + elif encoding_text == '1254' or encoding_text == 'cp1254': + enc = 14 + elif encoding_text == '1250' or encoding_text == 'cp1250': + enc = 15 + elif encoding_text == 'utf16b': + enc = 0x90000100 + elif encoding_text == 'utf16l': + enc = 0x94000100 + elif encoding_text == 'utf32': + enc = 0x8c000100 + elif encoding_text == 'utf32b': + enc = 0x98000100 + elif encoding_text == 'utf32l': + enc = 0x9c000100 + + print_command = 'po (NSString *)[[NSString alloc] initWithData:{} encoding:{}]'.format(arguments[0], enc) + lldb.debugger.HandleCommand(print_command) From 3d961fe5a3a434fd51bde41cc44c8c1567d23197 Mon Sep 17 00:00:00 2001 From: Natansh Verma Date: Wed, 25 Mar 2015 11:09:05 -0700 Subject: [PATCH 09/11] Add pcomponents/dcomponents/rcomponents for debugging in ComponentKit --- commands/FBComponentCommands.py | 81 +++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 commands/FBComponentCommands.py diff --git a/commands/FBComponentCommands.py b/commands/FBComponentCommands.py new file mode 100644 index 0000000..1ffb443 --- /dev/null +++ b/commands/FBComponentCommands.py @@ -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 .' + + 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 .' + + 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 + ']') From 84d60b8726d78cd00923c1f2c2525144b0b94821 Mon Sep 17 00:00:00 2001 From: weizhou Date: Fri, 27 Mar 2015 13:58:57 +0800 Subject: [PATCH 10/11] copy to the pasteboard before print --- commands/FBPrintCommands.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commands/FBPrintCommands.py b/commands/FBPrintCommands.py index c3e19de..7220c99 100644 --- a/commands/FBPrintCommands.py +++ b/commands/FBPrintCommands.py @@ -320,6 +320,8 @@ def run(self, arguments, options): NSUserDomainMask = '1' path = fb.evaluateExpressionValue('(NSString*)[NSSearchPathForDirectoriesInDomains(' + NSDocumentDirectory + ', ' + NSUserDomainMask + ', YES) lastObject]') pathString = '{}'.format(path).split('"')[1] + cmd = 'echo {} | tr -d "\n" | pbcopy'.format(pathString) + os.system(cmd) print pathString if options.open: os.system('open '+ pathString) From a935d09a2c3f4829720ec1bd99df83b095c96e8a Mon Sep 17 00:00:00 2001 From: Dustin Barker Date: Fri, 10 Apr 2015 12:15:58 -0700 Subject: [PATCH 11/11] Update Patent Grant http://fb.me/patents2 --- PATENTS | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/PATENTS b/PATENTS index 4090cc0..ccfb843 100644 --- a/PATENTS +++ b/PATENTS @@ -1,24 +1,33 @@ -Additional Grant of Patent Rights +Additional Grant of Patent Rights Version 2 -"Software" means the Chisel software distributed by Facebook, Inc. +"Software" means the chisel software distributed by Facebook, Inc. -Facebook hereby grants you a perpetual, worldwide, royalty-free, non-exclusive, -irrevocable (subject to the termination provision below) license under any -rights in any patent claims owned by Facebook, to make, have made, use, sell, -offer to sell, import, and otherwise transfer the Software. For avoidance of -doubt, no license is granted under Facebook’s rights in any patent claims that -are infringed by (i) modifications to the Software made by you or a third party, -or (ii) the Software in combination with any software or other technology -provided by you or a third party. +Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software +("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable +(subject to the termination provision below) license under any Necessary +Claims, to make, have made, use, sell, offer to sell, import, and otherwise +transfer the Software. For avoidance of doubt, no license is granted under +Facebook’s rights in any patent claims that are infringed by (i) modifications +to the Software made by you or any third party or (ii) the Software in +combination with any software or other technology. The license granted hereunder will terminate, automatically and without notice, -for anyone that makes any claim (including by filing any lawsuit, assertion or -other action) alleging (a) direct, indirect, or contributory infringement or -inducement to infringe any patent: (i) by Facebook or any of its subsidiaries or -affiliates, whether or not such claim is related to the Software, (ii) by any -party if such claim arises in whole or in part from any software, product or -service of Facebook or any of its subsidiaries or affiliates, whether or not -such claim is related to the Software, or (iii) by any party relating to the -Software; or (b) that any right in any patent claim of Facebook is invalid or -unenforceable. +if you (or any of your subsidiaries, corporate affiliates or agents) initiate +directly or indirectly, or take a direct financial interest in, any Patent +Assertion: (i) against Facebook or any of its subsidiaries or corporate +affiliates, (ii) against any party if such Patent Assertion arises in whole or +in part from any software, technology, product or service of Facebook or any of +its subsidiaries or corporate affiliates, or (iii) against any party relating +to the Software. Notwithstanding the foregoing, if Facebook or any of its +subsidiaries or corporate affiliates files a lawsuit alleging patent +infringement against you in the first instance, and you respond by filing a +patent infringement counterclaim in that lawsuit against that party that is +unrelated to the Software, the license granted hereunder will not terminate +under section (i) of this paragraph due to such counterclaim. +A "Necessary Claim" is a claim of a patent owned by Facebook that is +necessarily infringed by the Software standing alone. + +A "Patent Assertion" is any lawsuit or other action alleging direct, indirect, +or contributory infringement or inducement to infringe any patent, including a +cross-claim or counterclaim.