Skip to content

Commit

Permalink
Update the way architecture is determined to actually work.
Browse files Browse the repository at this point in the history
  • Loading branch information
kolinkrewinkel committed Jul 9, 2014
1 parent 4a9a403 commit 6cfb42e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
4 changes: 2 additions & 2 deletions commands/FBDisplayCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def options(self):
]

def run(self, args, options):
arch = runtimeHelpers.currentArch()
colorClassName = 'UIColor'
isMac = runtimeHelpers.isMacintoshArch()

if (arch == 'x86_64'):
if isMac:
colorClassName = 'NSColor'

layer = viewHelpers.convertToLayer(args[0])
Expand Down
2 changes: 1 addition & 1 deletion commands/FBFindCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

import lldb
import fblldbbase as fb
import fblldbviewcontrollerhelpers as vcHelpers
import fblldbobjcruntimehelpers as objc
import fblldbviewcontrollerhelpers as vcHelpers

def lldbcommands():
return [
Expand Down
4 changes: 3 additions & 1 deletion commands/FBFlickerCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ def inputCallback(self, input):
self.setCurrentView(v)
elif input == 'p':
recusionName = 'recursiveDescription'
if (runtimeHelpers.currentArch() == 'x86_64'):
isMac = runtimeHelpers.isMacintoshArch()

if isMac:
recursionName = '_subtreeDescription'

lldb.debugger.HandleCommand('po [(id)' + oldView + ' ' + recusionName + ']')
Expand Down
11 changes: 6 additions & 5 deletions commands/FBPrintCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ def args(self):

def run(self, arguments, options):
maxDepth = int(options.depth)
arch = runtimeHelpers.currentArch()
isMac = runtimeHelpers.isMacintoshArch()

if (arguments[0] == '__keyWindow_dynamic__'):
arguments[0] = '(id)[[UIApplication sharedApplication] keyWindow]'
if (arch == 'x86_64'):

if isMac:
arguments[0] = '(id)[[[[NSApplication sharedApplication] windows] objectAtIndex:0] contentView]'

if options.upwards:
Expand All @@ -65,7 +66,7 @@ def run(self, arguments, options):
print 'Failed to walk view hierarchy. Make sure you pass a view, not any other kind of object or expression.'
else:
printingMethod = 'recursiveDescription'
if (arch == 'x86_64'):
if (isMac):
printingMethod = '_subtreeDescription'

description = fb.evaluateExpressionValue('(id)[' + arguments[0] + ' ' + printingMethod + ']').GetObjectDescription()
Expand Down Expand Up @@ -99,11 +100,11 @@ def args(self):
return [ fb.FBCommandArgument(arg='aViewController', type='UIViewController*', help='The view controller to print the description of.', default='__keyWindow_rootVC_dynamic__') ]

def run(self, arguments, options):
arch = runtimeHelpers.currentArch()
isMac = runtimeHelpers.isMacintoshArch()

if (arguments[0] == '__keyWindow_rootVC_dynamic__'):
arguments[0] = '(id)[(id)[[UIApplication sharedApplication] keyWindow] rootViewController]'
if (arch == 'x86_64'):
if (isMac):
arguments[0] = '(id)[[[[NSApplication sharedApplication] windows] objectAtIndex:0] contentViewController]'

print vcHelpers.viewControllerRecursiveDescription(arguments[0])
Expand Down
15 changes: 14 additions & 1 deletion fblldbobjcruntimehelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import lldb
import fblldbbase as fb
import re

def objc_getClass(className):
command = '(void*)objc_getClass("{}")'.format(className)
Expand Down Expand Up @@ -42,6 +41,8 @@ def currentArch():
return arch

def functionPreambleExpressionForSelf():
import re

arch = currentArch()
expressionForSelf = None
if arch == 'i386':
Expand All @@ -55,6 +56,8 @@ def functionPreambleExpressionForSelf():
return expressionForSelf

def functionPreambleExpressionForObjectParameterAtIndex(parameterIndex):
import re

arch = currentArch()
expresssion = None
if arch == 'i386':
Expand All @@ -73,3 +76,13 @@ def functionPreambleExpressionForObjectParameterAtIndex(parameterIndex):
raise Exception("Current implementation can not return object at index greater than 1 for arm32")
expresssion = '(id)$r' + str(parameterIndex + 2)
return expresssion

def isMacintoshArch():
arch = currentArch()
if not arch == 'x86_64':
return False

nsClassName ='NSApplication'
command = '(void*)objc_getClass("{}")'.format(nsClassName)

return (fb.evaluateBooleanExpression(command + '!= nil'))
4 changes: 2 additions & 2 deletions fblldbviewcontrollerhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _viewControllerDescription(viewController):


def _recursiveViewControllerDescriptionWithPrefixAndChildPrefix(vc, string, prefix, childPrefix):
arch = runtimeHelpers.currentArch()
isMac = runtimeHelpers.isMacintoshArch()

s = '%s%s%s\n' % (prefix, '' if prefix == '' else ' ', _viewControllerDescription(vc))

Expand All @@ -42,7 +42,7 @@ def _recursiveViewControllerDescriptionWithPrefixAndChildPrefix(vc, string, pref
viewController = fb.evaluateExpression('(id)[(id)[%s childViewControllers] objectAtIndex:%d]' % (vc, i))
s += _recursiveViewControllerDescriptionWithPrefixAndChildPrefix(viewController, string, nextPrefix, nextPrefix)

if not arch == 'x86_64':
if not isMac:
isModal = fb.evaluateBooleanExpression('%s != nil && ((id)[(id)[(id)%s presentedViewController] presentingViewController]) == %s' % (vc, vc, vc))

if isModal:
Expand Down

0 comments on commit 6cfb42e

Please sign in to comment.