diff --git a/commands/FBDebugCommands.py b/commands/FBDebugCommands.py index fff110a..e0ffaa1 100644 --- a/commands/FBDebugCommands.py +++ b/commands/FBDebugCommands.py @@ -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[-+])? + \[ + (?P.*?) + (?P\(.+\))? + \s+ + (?P.*) + \] +""", re.VERBOSE) + + match = methodPattern.match(expression) if not match: print 'Failed to parse expression. Do you even Objective-C?!' @@ -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 == '+') @@ -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: @@ -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)