From 915ae38496e7323994f842d7b1b512d4f89171d0 Mon Sep 17 00:00:00 2001 From: Dmitry Purtov Date: Sun, 2 Oct 2016 04:23:04 +0300 Subject: [PATCH 1/2] [pinternals] -a option added --- commands/FBPrintCommands.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/commands/FBPrintCommands.py b/commands/FBPrintCommands.py index 58ae418..e87d27c 100755 --- a/commands/FBPrintCommands.py +++ b/commands/FBPrintCommands.py @@ -259,12 +259,19 @@ def description(self): def args(self): return [ fb.FBCommandArgument(arg='object', type='id', help='Object expression to be evaluated.') ] + + def options(self): + return [ + fb.FBCommandArgument(arg='appleWay', short='-a', long='--apple', boolean=True, default=False, help='Print ivars the apple way') + ] def run(self, arguments, options): object = fb.evaluateObjectExpression(arguments[0]) - objectClass = fb.evaluateExpressionValue('(id)[(id)(' + object + ') class]').GetObjectDescription() - - command = 'p *(({} *)((id){}))'.format(objectClass, object) + if options.appleWay: + command = 'po [{} _ivarDescription]'.format(object) + else: + objectClass = fb.evaluateExpressionValue('(id)[(id)(' + object + ') class]').GetObjectDescription() + command = 'p *(({} *)((id){}))'.format(objectClass, object) lldb.debugger.HandleCommand(command) From cf36274f4baa89fbb0e8bc5573b9a123338fe7c2 Mon Sep 17 00:00:00 2001 From: Dmitry Purtov Date: Thu, 24 Nov 2016 22:26:55 +0300 Subject: [PATCH 2/2] [pinternals] added -respondsToSelector: check on private method. --- commands/FBPrintCommands.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/commands/FBPrintCommands.py b/commands/FBPrintCommands.py index e87d27c..b1ff081 100755 --- a/commands/FBPrintCommands.py +++ b/commands/FBPrintCommands.py @@ -268,7 +268,11 @@ def options(self): def run(self, arguments, options): object = fb.evaluateObjectExpression(arguments[0]) if options.appleWay: - command = 'po [{} _ivarDescription]'.format(object) + if fb.evaluateBooleanExpression('[{} respondsToSelector:@selector(_ivarDescription)]'.format(object)): + command = 'po [{} _ivarDescription]'.format(object) + else: + print 'Sorry, but it seems Apple dumped the _ivarDescription method' + return else: objectClass = fb.evaluateExpressionValue('(id)[(id)(' + object + ') class]').GetObjectDescription() command = 'p *(({} *)((id){}))'.format(objectClass, object)