Skip to content

Commit

Permalink
Fix taplog
Browse files Browse the repository at this point in the history
Summary:
Taplog broke at some point and was failing with this error:
```
(lldb) taplog
error: could not get num args: can't find callable: sys.modules['FBFindCommands'].FBTapLoggerCommand.taplog_callback
```

It looks like `SetScriptCallbackFunction()` is the canonical API for providing a callback. I hoisted the function to the module so we can independently import it for visibility in LLDB.

Reviewed By: adamjernst

Differential Revision: D25681511

fbshipit-source-id: c95378c877f77e6faf201c55a4bfa8573ba84a13
  • Loading branch information
jballer authored and facebook-github-bot committed Dec 22, 2020
1 parent ff44d31 commit d759f8f
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions commands/FBFindCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,33 +147,31 @@ def run(self, arguments, options):
+ " allTouches] anyObject] phase] == 0"
)
breakpoint.SetOneShot(True)

callback_name = taplog_callback.__qualname__
# Import the callback so LLDB can see it
lldb.debugger.HandleCommand(
"breakpoint command add -s python -F \"sys.modules['"
+ __name__
+ "']."
+ self.__class__.__name__
+ '.taplog_callback" '
+ str(breakpoint.id)
"script from %s import %s" % (__name__, callback_name)
)
breakpoint.SetScriptCallbackFunction(callback_name)

lldb.debugger.SetAsync(True)
lldb.debugger.HandleCommand("continue")

@staticmethod
def taplog_callback(frame, bp_loc, internal_dict):
parameterExpr = objc.functionPreambleExpressionForObjectParameterAtIndex(0)
print(
"Gesture Recognizers:\n{}".format(
fb.describeObject(
"[[[%s allTouches] anyObject] gestureRecognizers]" % (parameterExpr)
)

def taplog_callback(frame, bp_loc, internal_dict):
parameterExpr = objc.functionPreambleExpressionForObjectParameterAtIndex(0)
print(
"Gesture Recognizers:\n{}".format(
fb.describeObject(
"[[[%s allTouches] anyObject] gestureRecognizers]" % (parameterExpr)
)
)
print(
"View:\n{}".format(
fb.describeObject(
"[[[%s allTouches] anyObject] view]" % (parameterExpr)
)
)
)
print(
"View:\n{}".format(
fb.describeObject("[[[%s allTouches] anyObject] view]" % (parameterExpr))
)
# We don't want to proceed event (click on button for example), so we just skip it
lldb.debugger.HandleCommand("thread return")
)
# We don't want to proceed event (click on button for example), so we just skip it
lldb.debugger.HandleCommand("thread return")

0 comments on commit d759f8f

Please sign in to comment.