From 0b668f825eb5c19b7dca5561bd78cc13f99159fa Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 4 Dec 2014 10:56:49 -0800 Subject: [PATCH 1/4] bmessage: use regex breakpoint to match category Resolves #57 --- commands/FBDebugCommands.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commands/FBDebugCommands.py b/commands/FBDebugCommands.py index fff110a..7c3ed39 100644 --- a/commands/FBDebugCommands.py +++ b/commands/FBDebugCommands.py @@ -136,6 +136,7 @@ def run(self, arguments, options): breakpointClassName = objc.class_getName(nextClass) breakpointFullName = '{}[{} {}]'.format(methodTypeCharacter, breakpointClassName, selector) + breakpointPattern = '{}\[{}(\(.+\))? {}\]'.format(methodTypeCharacter, breakpointClassName, selector) breakpointCondition = None if targetIsClass: @@ -145,7 +146,7 @@ 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)) + lldb.debugger.HandleCommand('breakpoint set --func-regex "{}" --condition "{}"'.format(breakpointPattern, breakpointCondition)) def classItselfImplementsSelector(klass, selector): thisMethod = objc.class_getInstanceMethod(klass, selector) From ee6c3b29f017316c8734cbddd4ed8b3a9677ae25 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 10 Dec 2014 09:06:06 -0800 Subject: [PATCH 2/4] bmessage: Allow optional category --- commands/FBDebugCommands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/FBDebugCommands.py b/commands/FBDebugCommands.py index 7c3ed39..9b11f79 100644 --- a/commands/FBDebugCommands.py +++ b/commands/FBDebugCommands.py @@ -82,7 +82,7 @@ def args(self): def run(self, arguments, options): expression = arguments[0] - match = re.match(r'([-+])*\[(.*) (.*)\]', expression) + match = re.match(r'([-+])*\[(.*?)(?:\(.+\))? (.*)\]', expression) if not match: print 'Failed to parse expression. Do you even Objective-C?!' From 6e99fbb3b66b4b096022a704ffb1b46058622a44 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 10 Dec 2014 09:29:25 -0800 Subject: [PATCH 3/4] Use verbose regex for bmessage input --- commands/FBDebugCommands.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/commands/FBDebugCommands.py b/commands/FBDebugCommands.py index 9b11f79..e985c49 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.*?) + (?:\(.+\))? # Optional Category + \s+ + (?P.*) + \] +""", re.VERBOSE) + + match = methodPattern.match(expression) if not match: print 'Failed to parse expression. Do you even Objective-C?!' @@ -93,9 +103,9 @@ 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('class') + selector = match.group('selector') methodIsClassMethod = (methodTypeCharacter == '+') From 0fbaa0cdd2b26c3f202d711343b020beb41bbe67 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 10 Dec 2014 09:52:02 -0800 Subject: [PATCH 4/4] Use exact name when category is given --- commands/FBDebugCommands.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/commands/FBDebugCommands.py b/commands/FBDebugCommands.py index e985c49..e0ffaa1 100644 --- a/commands/FBDebugCommands.py +++ b/commands/FBDebugCommands.py @@ -85,8 +85,8 @@ def run(self, arguments, options): methodPattern = re.compile(r""" (?P[-+])? \[ - (?P.*?) - (?:\(.+\))? # Optional Category + (?P.*?) + (?P\(.+\))? \s+ (?P.*) \] @@ -104,7 +104,8 @@ def run(self, arguments, options): return methodTypeCharacter = match.group('scope') - classNameOrExpression = match.group('class') + classNameOrExpression = match.group('target') + category = match.group('category') selector = match.group('selector') methodIsClassMethod = (methodTypeCharacter == '+') @@ -145,8 +146,8 @@ def run(self, arguments, options): return breakpointClassName = objc.class_getName(nextClass) - breakpointFullName = '{}[{} {}]'.format(methodTypeCharacter, breakpointClassName, selector) - breakpointPattern = '{}\[{}(\(.+\))? {}\]'.format(methodTypeCharacter, breakpointClassName, selector) + formattedCategory = category if category else '' + breakpointFullName = '{}[{}{} {}]'.format(methodTypeCharacter, breakpointClassName, formattedCategory, selector) breakpointCondition = None if targetIsClass: @@ -156,7 +157,11 @@ def run(self, arguments, options): print 'Setting a breakpoint at {} with condition {}'.format(breakpointFullName, breakpointCondition) - lldb.debugger.HandleCommand('breakpoint set --func-regex "{}" --condition "{}"'.format(breakpointPattern, 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)