Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions commands/FBDebugCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,17 @@ def args(self):
def run(self, arguments, options):
expression = arguments[0]

match = re.match(r'([-+])*\[(.*) (.*)\]', expression)
methodPattern = re.compile(r"""
(?P<scope>[-+])?
\[
(?P<target>.*?)
(?P<category>\(.+\))?
\s+
(?P<selector>.*)
\]
""", re.VERBOSE)

match = methodPattern.match(expression)

if not match:
print 'Failed to parse expression. Do you even Objective-C?!'
Expand All @@ -93,9 +103,10 @@ def run(self, arguments, options):
print 'Your architecture, {}, is truly fantastic. However, I don\'t currently support it.'.format(arch)
return

methodTypeCharacter = match.group(1)
classNameOrExpression = match.group(2)
selector = match.group(3)
methodTypeCharacter = match.group('scope')
classNameOrExpression = match.group('target')
category = match.group('category')
selector = match.group('selector')

methodIsClassMethod = (methodTypeCharacter == '+')

Expand Down Expand Up @@ -135,7 +146,8 @@ def run(self, arguments, options):
return

breakpointClassName = objc.class_getName(nextClass)
breakpointFullName = '{}[{} {}]'.format(methodTypeCharacter, breakpointClassName, selector)
formattedCategory = category if category else ''
breakpointFullName = '{}[{}{} {}]'.format(methodTypeCharacter, breakpointClassName, formattedCategory, selector)

breakpointCondition = None
if targetIsClass:
Expand All @@ -145,7 +157,11 @@ def run(self, arguments, options):

print 'Setting a breakpoint at {} with condition {}'.format(breakpointFullName, breakpointCondition)

lldb.debugger.HandleCommand('breakpoint set --fullname "{}" --condition "{}"'.format(breakpointFullName, breakpointCondition))
if category:
lldb.debugger.HandleCommand('breakpoint set --fullname "{}" --condition "{}"'.format(breakpointFullName, breakpointCondition))
else:
breakpointPattern = '{}\[{}(\(.+\))? {}\]'.format(methodTypeCharacter, breakpointClassName, selector)
lldb.debugger.HandleCommand('breakpoint set --func-regex "{}" --condition "{}"'.format(breakpointPattern, breakpointCondition))

def classItselfImplementsSelector(klass, selector):
thisMethod = objc.class_getInstanceMethod(klass, selector)
Expand Down